Linux Commands Cheat Sheet

in

Here’s a list of common commands along with their descriptions and usage examples:

  1. ls – List Directory Contents
    • Usage: ls [options] [directory]
    • Example: ls -l /home (lists all files in /home with detailed information)
  2. cd – Change Directory
    • Usage: cd [directory]
    • Example: cd /home/user/Documents (changes the current directory to /home/user/Documents)
  3. pwd – Print Working Directory
    • Usage: pwd
    • Example: pwd (displays the path of the current directory)
  4. cat – Concatenate and Display Files
    • Usage: cat [options] [file]
    • Example: cat file.txt (displays the content of file.txt)
  5. cp – Copy Files and Directories
    • Usage: cp [options] source destination
    • Example: cp file1.txt file2.txt (copies file1.txt to file2.txt)
  6. mv – Move or Rename Files and Directories
    • Usage: mv [options] source destination
    • Example: mv file1.txt /home/user/Documents (moves file1.txt to /home/user/Documents)
  7. rm – Remove Files or Directories
    • Usage: rm [options] file
    • Example: rm file.txt (removes file.txt)
  8. mkdir – Create a New Directory
    • Usage: mkdir [options] directory
    • Example: mkdir new_folder (creates a new directory named new_folder)
  9. rmdir – Remove Empty Directories
    • Usage: rmdir [options] directory
    • Example: rmdir old_folder (removes the directory old_folder if it’s empty)
  10. grep – Search Text Using Patterns
    • Usage: grep [options] pattern [file]
    • Example: grep "hello" file.txt (searches for the word “hello” in file.txt)
  11. find – Search for Files in a Directory Hierarchy
    • Usage: find [path] [options] [expression]
    • Example: find /home -name "file.txt" (finds all files named “file.txt” in /home)
  12. chmod – Change File Modes or Access Control Lists
    • Usage: chmod [options] mode file
    • Example: chmod 755 script.sh (sets the permission of script.sh to 755)
  13. chown – Change File Owner and Group
    • Usage: chown [options] owner[:group] file
    • Example: chown user:group file.txt (changes the owner of file.txt to ‘user’ and the group to ‘group’)
  14. tail – Output the Last Part of Files
    • Usage: tail [options] [file]
    • Example: tail -n 5 file.txt (displays the last 5 lines of file.txt)
  15. head – Output the First Part of Files
    • Usage: head [options] [file]
    • Example: head -n 5 file.txt (displays the first 5 lines of file.txt)
  16. man – Interface to the System Reference Manuals
    • Usage: man [command]
    • Example: man ls (displays the manual page for the ls command)

This is just a basic set of commands, and there are many more commands and options in Linux. For detailed information and more commands, you can always use the man command followed by the command name to read the manual pages.

Discover more from Jorge Saldívar

Subscribe now to keep reading and get access to the full archive.

Continue reading