Linux essentials for DevOps
Linux essentials for DevOps
1. ls: (List Segment) Lists all files and directories in the current directory.
2. ls -a: Shows hidden files (hidden files in linux are starting with a dot).
3. ls -l: Lists files and directories along with permissions, size, owner, group, date and time of last
modification.
5. cd .. : Moves one level up to the parent directory (Suppose you are currently in the directory
/home/user/documents. If you run the command (cd ..)You will be moved up one level to /home/user, as
this is the parent directory of /home/user/documents. If you run cd .. again from /home/user, you will
move up another level, and the directory will change to /home, which is the parent of /home/user. If you
run cd .. when you're at the root directory /, nothing will happen because / is the top-level directory and
does not have a parent.)
6. pwd: (Print Working Directory) Displays the full path to the current directory.
7. mkdir <directoryname>: (Make Directory) Creates a new directory in the current working directory.
8. cat <filename>: (Concatenate) Displays the content of a file or creates a new file.
Ex: cat > aws (to create file using cat command we use > followed by file nam)
touch test1 test2 test3 test4 (to make multiple empty file at same time )
Ex: rm test1
12. cp <source> <destination>: (Copy) Copies a file or folder from the source to the destination.
13. mv <source> <destination>: (Move) Moves a file or folder from the source to the destination or
renames it.
Ex: mv file1 file2 (mv deletes the source file or directory after moving it.)
15. find / -name <filename>: Searches for a file or directory by its name, starting from the root directory.
16. less <filename>: Views the content of a file page by page (great for large files).
Ex: head /etc/passwd (to see any number of line use –n <number of line> for example to see
only 2 lines from top command will be: head –n 2 file name)
21. kill <pid>: (Process ID) Kills the process with the given PID (Process ID).
23. chmod <octal> <filename>: (Change Mode) Changes the permissions of a file (Octal values between 0
and 7).
24. chown <ownername> <filename>: (Change Owner) Changes the owner of a file.
Ex: chown prity test1 (prity user will become owner of file test1)
25. chgrp <groupname> <filename>: (Change Group) Changes the group owner of a file.
26. grep <pattern> <files>: (Global Regular Expression Print) Searches for a pattern in files.
29. diff <file1> <file2> : (Difference) Compares two files and shows the differences.
30. wc <filename>: (Word Count) Counts lines, words, and characters in a file.
Ex: wc test1
31. df: (Disk Filesystem) Shows disk usage for file systems.
33. du –sh <file/folder>: (Disk Usage) See the size of file and folder.
Shortcuts :
Command Description