Cheat Sheet - Commonly used Linux commands - Part 1

Cheat Sheet - Commonly used Linux commands - Part 1

Certainly! Here are 20 commonly used Linux commands with brief explanations:

  1. ls: Lists the contents of a directory. Example: ls -l displays the contents in a detailed list format.

  2. cd: Changes the current working directory. Example: cd /home/user changes the directory to /home/user.

  3. pwd: Prints the current working directory.

  4. mkdir: Creates a new directory. Example: mkdir new_directory creates a directory named new_directory.

  5. rm: Removes files or directories. Example: rm file.txt removes the file named file.txt.

  6. cp: Copies files and directories. Example: cp file1 file2 copies file1 to file2.

  7. mv: Moves or renames files and directories. Example: mv file1 file2 moves file1 to file2.

  8. cat: Displays the contents of a file. Example: cat file.txt displays the contents of file.txt.

  9. grep: Searches for a specific pattern in files. Example: grep pattern file.txt searches for the pattern in file.txt.

  10. chmod: Changes the permissions of files and directories. Example: chmod 755 file.txt changes the permissions of file.txt.

  11. chown: Changes the owner of files and directories. Example: chown user:group file.txt changes the owner and group of file.txt.

  12. tar: Archives files into a tarball. Example: tar -cvf archive.tar file1 file2 creates an archive named archive.tar containing file1 and file2.

  13. gzip: Compresses files. Example: gzip file.txt compresses file.txt into file.txt.gz.

  14. gunzip: Decompresses files. Example: gunzip file.txt.gz decompresses file.txt.gz into file.txt.

  15. ps: Displays information about running processes. Example: ps aux shows a detailed list of all processes.

  16. kill: Terminates processes. Example: kill PID terminates the process with the specified PID.

  17. top: Displays real-time system information. Example: top shows a dynamic view of system processes and resource usage.

  18. df: Shows disk space usage. Example: df -h displays disk space usage in a human-readable format.

  19. du: Displays disk usage of files and directories. Example: du -sh directory shows the total disk usage of the directory in a human-readable format.

  20. free: Shows system memory usage. Example: free -m displays memory usage in megabytes.

  1. ssh: Allows secure remote access to a server. Example: ssh user@hostname connects to the server with the specified username and hostname.

  2. scp: Securely copies files between different hosts. Example: scp file.txt user@remotehost:/path copies file.txt to the specified path on the remote host.

  3. wget: Downloads files from the internet. Example: wget http://example.com/file.txt downloads file.txt from the specified URL.

  4. curl: Transfers data from or to a server. Example: curl -O http://example.com/file.txt downloads file.txt from the specified URL.

  5. tail: Displays the last part of a file. Example: tail -n 10 file.txt shows the last 10 lines of file.txt.

  6. head: Displays the first part of a file. Example: head -n 10 file.txt shows the first 10 lines of file.txt.

  7. find: Searches for files in a directory hierarchy. Example: find /path -name "file.txt" searches for file.txt in the specified path.

  8. locate: Finds files by name. Example: locate file.txt locates file.txt on the system.

  9. date: Displays the current date and time. Example: date shows the current date and time.

  10. cal: Displays a calendar. Example: cal 2023 shows the calendar for the year 2023.

  11. echo: Displays a line of text. Example: echo "Hello, World!" prints Hello, World! to the terminal.

  12. history: Shows a list of previously executed commands. Example: history displays the command history.

  13. man: Displays the manual page for a command. Example: man ls shows the manual page for the ls command.

  14. alias: Creates an alias for a command. Example: alias ll='ls -l' creates an alias ll for the ls -l command.

  15. df: Displays disk space usage. Example: df -h shows disk space usage in a human-readable format.

  16. du: Shows disk usage of files and directories. Example: du -sh directory shows the total disk usage of the directory in a human-readable format.

  17. free: Shows system memory usage. Example: free -m displays memory usage in megabytes.

  18. uptime: Displays how long the system has been running. Example: uptime shows the system uptime.

  19. ifconfig: Displays network interface configuration. Example: ifconfig shows the network interface configuration.

  20. netstat: Shows network connections, routing tables, interface statistics, and more. Example: netstat -tuln displays active network connections.

Did you find this article valuable?

Support CloudOpsAcademy - Prashanth Katkam by becoming a sponsor. Any amount is appreciated!