The shell does not reward memorizing a hundred commands. It rewards knowing a small set well enough to combine them—and knowing which ones can quietly delete, overwrite, or stop something important. These forty commands cover the everyday ground, with the warnings that short cheat sheets tend to leave out.
1. ls – List Directory Contents
The ls command lists the contents of a directory. By default, it shows files and subdirectories of the current directory.
- Usage:
ls - Options:
ls -l: Long listing format (permissions, size, owner)ls -a: Show hidden filesls -lh: Long listing with human-readable sizes
2. cd – Change Directory
The cd command changes the current working directory.
- Usage:
cd /path/to/directory - Shortcuts:
cd ~: Navigate to home directorycd ..: Move up one level in directory structure
3. pwd – Print Working Directory
This command prints the full path of the current directory.
- Usage:
pwd
4. cp – Copy Files and Directories
The cp command copies files or directories from one location to another.
- Usage:
cp source destination - Options:
cp -r: Copy directories recursivelycp -i: Prompt before overwriting
5. mv – Move or Rename Files
The mv command is used to move or rename files and directories.
- Usage:
mv source destination
6. rm – Remove Files and Directories
The rm command deletes files or directories.
- Usage:
rm file - Options:
rm -r: Remove directories and their contents recursivelyrm -f: Force removal without prompting
rm does not provide a general undo feature. Check the target carefully, quote paths containing spaces, and avoid combining recursive and forced removal until you understand exactly what will be deleted.
7. touch – Create Empty Files
The touch command creates an empty file or updates the timestamp of an existing file.
- Usage:
touch filename
8. cat – Concatenate and Display File Content
The cat command displays the contents of a file on the terminal.
- Usage:
cat filename - Option:
cat -n: Number the lines
9. mkdir – Make Directories
The mkdir command creates a new directory.
- Usage:
mkdir directory_name - Option:
mkdir -p /path/to/dir: Create parent directories if needed
10. rmdir – Remove Empty Directories
The rmdir command removes empty directories.
- Usage:
rmdir directory_name
11. echo – Display a Line of Text
The echo command prints a line of text to the terminal.
- Usage:
echo "Hello World"
12. df – Disk Space Usage
The df command shows disk space usage of file systems.
- Usage:
df - Option:
df -h: Human-readable format
13. du – Directory Disk Usage
The du command estimates the file space usage of a directory.
- Usage:
du directory_name - Options:
du -h: Human-readable formatdu -sh: Summary for a directory
14. find – Search for Files
The find command searches for files in a directory hierarchy.
- Usage:
find /path -name filename - Option:
find / -type d: Search for directories
15. grep – Search Inside Files
The grep command searches for patterns within files.
- Usage:
grep "pattern" file - Option:
grep -i: Case-insensitive search
16. chmod – Change File Permissions
The chmod command changes the permissions of files or directories.
- Usage:
chmod 755 file - Common permissions:
755: Owner can read, write, and execute; group and others can read and execute644: Owner can read/write, others can only read
For directories, the execute bit controls traversal rather than “running” the directory. Changing ownership or permissions outside files you own may require elevated privileges.
17. chown – Change File Ownership
The chown command changes the ownership of a file or directory.
- Usage:
chown user:group file
18. ps – Process Status
The ps command displays information about running processes.
- Usage:
ps - Option:
ps aux: Detailed process view
19. kill – Send a Signal to a Process
The kill command sends a signal to a PID. With no signal specified it sends SIGTERM, a request that the process may handle or ignore.
- Usage:
kill PID - Option:
kill -KILL PID: Force termination only when a normalTERMrequest has failed
20. top – Real-Time Process Monitoring
The top command provides a real-time view of running processes and system resource usage.
- Usage:
top
21. tar – Archive Files
The tar command creates or extracts archives. A plain .tar groups files but does not compress them; options such as -z, -j, or -J add gzip, bzip2, or xz compression.
- Usage:
- To create an archive:
tar -cvf archive.tar file - To extract:
tar -xvf archive.tar - To create a gzip-compressed archive:
tar -czvf archive.tar.gz directory
- To create an archive:
22. zip – Compress Files
The zip command compresses files into a .zip archive.
- Usage:
zip archive.zip file
23. unzip – Extract Zip Archives
The unzip command extracts files from a .zip archive.
- Usage:
unzip archive.zip
24. wget – Download Files from the Web
The wget command downloads files from the web using HTTP, HTTPS, or FTP protocols.
- Usage:
wget http://example.com/file
25. curl – Transfer Data from a URL
The curl command retrieves content from a URL, supporting various protocols.
- Usage:
curl http://example.com
26. apt – Package Management (Debian-based)
The apt command manages software packages in Debian-based distributions (like Ubuntu).
- Usage:
- To refresh package metadata:
sudo apt update - To install:
sudo apt install package - To upgrade installed packages:
sudo apt upgrade
- To refresh package metadata:
27. dnf – Package Management (Fedora and RHEL-family)
The dnf command manages packages on current Fedora and Red Hat Enterprise Linux-family distributions. Some systems retain yum as a compatibility command.
- Usage:
- To install:
sudo dnf install package - To upgrade:
sudo dnf upgrade
- To install:
28. head – Show the Beginning of a File
The head command prints the first ten lines by default.
- Usage:
head filename - Option:
head -n 20 filenameprints the first twenty lines.
29. nano – Text Editor
The nano command opens a basic text editor in the terminal.
- Usage:
nano filename
30. vim – Advanced Text Editor
The vim command opens a more advanced, but highly efficient text editor.
- Usage:
vim filename
31. history – Show Command History
The history command displays the list of previously executed commands.
- Usage:
history
32. alias – Create Shortcuts for Commands
The alias command creates shortcuts for longer commands.
- Usage:
alias shortname='command' - Example:
alias ll='ls -la'
33. ping – Test Network Connectivity
The ping command sends ICMP echo requests and reports replies and round-trip time. No reply does not prove the host is offline because ICMP may be filtered.
- Usage:
ping google.com
34. netstat – Legacy Network Statistics
The netstat command shows connections and listening sockets on systems where the older net-tools package is installed. New scripts should normally use ss and ip.
- Usage:
netstat -tuln
35. ss – View Network Sockets
The ss command is the maintained socket-inspection tool in the iproute2 suite and is normally preferred over netstat on current Linux systems.
- Usage:
ss -tuln
36. uptime – System Uptime and Load
The uptime command shows how long the system has been running and the system load.
- Usage:
uptime
37. whoami – Display Current User
The whoami command prints the effective user ID’s name. This may differ from the original login identity after sudo, su, or another credential change.
- Usage:
whoami
38. hostname – Display System’s Hostname
The hostname command displays or sets the system’s hostname.
- Usage:
hostname
39. man – Manual Pages
The man command displays an installed manual page. Not every command or package ships one, and shell built-ins may also be documented through the shell’s help command.
- Usage:
man command - Example:
man ls
40. reboot and shutdown – Restart or Power Off the System
- To reboot:
sudo systemctl reboot - To power off:
sudo systemctl poweroff
These affect every user and service on the machine. Save work, notify other users, and confirm that you are connected to the intended host before running them.
Conclusion
Treat this list as a set of starting points, not a memory test. man, --help, and the shell’s help command fill in the details that a one-line example cannot. Before using a command with elevated privileges—or one that deletes, overwrites, kills, or reboots—pause long enough to confirm the host and the target.