Linux commands everyone should know

Last updated on July 21st, 2024

If you’ve just switched to Linux, or find yourself needing to do work in Linux shell, then this list of core Linux commands along with a brief description of their functionality is for you.

Linux shell is similar to Command Prompt/PowerShell in Windows, it uses text-based commands to conduct both basic and powerful actions.

It’s a good idea to refer to the manual pages (‘man command‘ e.g. ‘man cp‘) for detailed information on a command you’re not familiar with to understand its usage and options.

  1. man: Display the manual for a command.
    Example: man command (e.g. man ls)
  2. ls: List files and directories in the current directory.
    Example: ls
  3. pwd: Print the current working directory.
    Example: pwd
  4. cd: Change directory.
    Example: cd /path/to/directory
  5. cp: Copy files or directories. (See scp (#37) for copying files between hosts).
    Example: cp file.txt destination_directory/
  6. mv: Move or rename files or directories.
    Example: mv file.txt new_location/ or mv old_file.txt new_file.txt
  7. rm: Remove files or directories.
    Example: rm file.txt (Note: Be careful with this command, as it deletes files permanently. There is no undo/recycle bin)
  8. mkdir: Create a new directory.
    Example: mkdir new_directory
  9. rmdir: Remove an empty directory.
    Example: rmdir empty_directory
  10. touch: Update the access and modification times of a file. This creates an empty file if the file doesn’t exist.
    Example: touch new_file.txt
  11. cat: Display the contents of a file.
    Example: cat file.txt
  12. grep: Search for a pattern in a file or stream of text.
    Example: grep "pattern" file.txt
  13. chmod: Change file permissions.
    Example: chmod +x script.sh (Grants execute permission to a script.)
  14. chown: Change file ownership.
    Example: chown user:group file.txt
  15. ps: Display information about currently running processes.
    Example: ps aux
  16. kill: Terminate a process.
    Example: kill process_id
  17. df: Display information about disk space usage.
    Example: df -h
  18. du: Estimate file space usage.
    Example: du -sh directory/
  19. zip: Package and compress files.
    Example: zip archive.zip file1.txt file2.txt
  20. unzip: Unzip compressed files.
    Example: unzip archive.zip
  21. tar: Archive files.
    Example: tar -cvf archive.tar.gz directory/
  22. tar (extract): Extract files from an archive.
    Example: tar -xvf archive.tar.gz
  23. wget: Download files from the internet.
    Example: wget https://example.com/file.txt
  24. echo: Display a message or a variable value.
    Example: echo "Hello, World!"
  25. nano: A simple text file editor.
    Example: nano filename
  26. vi or vim: A more advanced text file editor.
    Example: vim filename
  27. head: Display the first few lines of a file.
    Example: head filename
  28. tail: Display the last few lines of a file. This is really useful when reading the last entries in a log file.
    Example: tail filename
  29. find: Search for files in a directory hierarchy.
    Example: find /path/to/search -name "*.txt"
  30. locate: Quickly find the location of files.
    Example: locate filename
  31. awk: A powerful programming language for pattern scanning and text processing.
    Example: awk '{print $1}' filename (Prints the first column of a file.)
  32. sed: Stream editor for filtering and transforming text.
    Example: sed 's/old/new/' filename (Replaces ‘old’ with ‘new’ in a file.)
  33. ping: Test the reachability of a host on an Internet Protocol (IP) network.
    Example: ping google.com
  34. traceroute: Display the route that packets take to reach a network host.
    Example: traceroute google.com
  35. ifconfig: Display or configure network interfaces.
    Example: ifconfig
  36. netstat: Display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
    Example: netstat -a
  37. scp: Securely copy files between hosts.
    Example: scp file.txt user@remote:/path/to/destination/
  38. ssh: OpenSSH client (remote login program).
    Example: ssh user@hostname
  39. history: Display the command history.
    Example: history
  40. psql: Command-line interface for PostgreSQL database.
    Example: psql -U username -d database_name

These are just 40 examples to get you started on the most common areas of use for shell commands. Don’t forget that each command has various options and flags that you can explore by checking their manual pages (man command e.g. ‘man cp‘). I strongly recommend checking the manual pages careful for destructive commands. As with PowerShell in Windows, Linux shell commands can be extremely powerful.

Best of wishes for your journey into Linux shell commands!