Day 3 of #90daysofdevops
In the previous article, we learned about what is Linux and what are some of the basic commands of the Linux Operating System.
In this article, we are going to see what are some of the commands of Linux that DevOps engineers use in day-to-day life.
1. ls Command
ls
command is used to list the contents of a directory.
ls
- if you use
ls -l
it will show the permissions, owner, size, and last modified date for each file in the directory.
2. sudo Command
sudo
command executes commands that run only with superuser privilege.
sudo apt update
- if you use just
apt update
to update your system it won't work but when you usesudo apt update
will update your entire system.
3. pwd Command
pwd
command will show you the current working directory in which you are working.
pwd
- if you use the
pwd
command in the shell will show you which directory you are currently in.
4. cat Command
cat
command is used to concatenate and display files and contents on the terminal but it can also be used to modify existing contents.
cat dipen.txt
- if you use
cat
command with a filename.txt it will show you the contents of filename.txt
cat -b
: This adds line numbers to non-blank lines
cat -n
: This adds line numbers to all lines
cat -s
: This squeezes blank lines into one line
cat –E
: This shows $ at the end of the line
5. Vim Command
vim
is the text editor used in the Linux Operating System.Vim
stands for Vi Improved. It uses different modes to operate on files.
vim dipen.txt
Normal mode: This is the default mode in which Vim starts. In normal mode, you can use various commands to navigate and edit the text.
Insert mode: In insert mode, you can type text into the file. To enter insert mode, press the "i" key. To exit insert mode and return to normal mode, press the "Esc" key.
Command mode: In command mode, you can enter commands to perform various actions, such as saving the file or quitting vim. To enter command mode, press the ":" key.
6. grep Command
grep
command is used to find the particular strings/word in a txt file. This is very similar toCtrl + F
button but this command is executed via CLI.
vim this dipen.txt
- This would print all of the lines in “dipen.txt” that contain the word “hashnode".
7. sort Command
sort
command is used tosort
the results of the search either alphabetically or numerically.sort
can also sort files and directories.
sort dipen.txt
there are 3 modes in sort command.
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.
8. tail Command
tail
command prints the last N number of data of the given output.
- By default,
tail
command prints 10 lines but with commands, you can change it to any number.
tail dipen.txt
9. chmod Command
chmod
command is used to change the access permissions of files and directories.
chmod
can change the permission to read-write.
chmod u+wrx dipen.txt
10. chown Command
chown
command is used to change the file owner or group.
chown
command can permit to read write and execute a file.
sudo chown root dipen.txt
11. ping Command
ping
command is used to ping a host and check if it is responding
- It is used to check
ping
response of the system
12. lsof Command
losf
command is used to display all open files on the Linux system
- if you use this command it will show you all the open files/services in Linux system.
sudo lsof -u root
13. diff Command
diff
command is used to show the difference between two files
These are some of the commands that DevOps engineers use in their day-to-day life while working.
Happy learning💡
~Dipen : )