Day-3 Basic Linux Commands
Deepak Patil
DevOps engineer with 3+yrs DevOps/ DevSecOps/ Cloud Experience in AWS?? | DevOps ?? Technologies ?????? Linux ??? | Git ?? | Terraform?? | Docker ?? | Kubernetes | EKS | HELM | ? | Jenkins ???.
1. cat 'fileName' -To view what's written in a file.
2. chmod 777 folderName/fileName -To change the access permissions of files.
3. history -To check which commands you have run till now.
4. head -3 'fileName' -To Show only top three fruits from the file.
5. tail -3 'fileName' To Show only bottom three fruits from the file.
6. diff 'file1' 'file2' -To find the difference between two files.
7. Sudo -This command executes only that command with superuser privileges.
8. Grep -This command searches for a particular string/ word in a text file. This is similar to “Ctrl+F†but executed via a CLI.
9. Sort -This command is used to sort the results of search either alphabetically or numerically. It also sorts files and directories.
sort -r -the flag returns the results in reverse order.
sort -f - the flag does case-insensitive sorting.
sort -n -the flag returns the results as per numerical order.
10. Chown -This command is used to change the file Owner or group.
Here, below the ownership of the “Chetan.txt†file got changed to root.
11. Ping – This command will ping a host and check if it is responding.
12. Find -This is used to find files and directories and perform subsequent operations on them.
In the below command, It will search in the present working directory and its subdirectories, and print the name of the file that have “.txt†file extension.
13. ssh user@host – Connect to the host as a user.
14. Ssh-keygen - This command is used to generate a public/private authentication key pair.
This process of authentication allows the user to connect remote server without providing a password.
(This authentication method we will use to authenticate the server with Jenkins while deploying CI/CD pipelines).
15. Apt-get - This command is used to install, update, and remove packages, as well as to manage the package repository sources.
Here are some common apt-get commands:
- apt-get update: This updates the package index files from the package repositories listed in the /etc/apt/sources.list file. This is usually the first command you should run after adding a new repository or package to your system.
- apt-get upgrade: This installs newer versions of packages that are already installed on the system. It will also remove any packages that are no longer required.
- apt-get install: This installs one or more packages. For example, to install the nano text editor, you would run apt-get install nano.
- apt-get remove: This removes one or more packages, but it does not remove the configuration files for the package.
- apt-get purge: This removes one or more packages and their configuration files.
- apt-get autoremove: This removes packages that were installed as
16. apt-get -May be considered as lower-level and "back-end", and support other APT-based tools.
17. apt -Is designed for end-users (humans) and its output may be changed between versions.
18. cp 'source' 'destination' -This command used to copy contents/files from one to another
19. SCP 'source' 'destination' -This command is used to share the files between the local system and to server and vice versa
Thank you! for reading this article.
Happy Learning!