Below is a quick reference for commonly used Linux commands. Use it as a handy guide for your day-to-day tasks.
| Command | Description |
|---|---|
ls | List files and directories. |
cd | Change directory. |
pwd | Print the current working directory. |
mkdir | Create a directory. |
rmdir | Remove an empty directory. |
rm | Remove files or directories. |
cp | Copy files or directories. |
mv | Move or rename files or directories. |
touch | Create an empty file or update timestamps. |
cat | Display file contents. |
less | View file contents page by page. |
head | Display the first few lines of a file. |
tail | Display the last few lines of a file. |
find | Search for files and directories. |
grep | Search text using patterns. |
| Command | Description |
|---|---|
uname -a | Display system information. |
df -h | Show disk usage in human-readable format. |
du -sh | Show directory size in human-readable format. |
free -h | Display memory usage. |
top | Display real-time system statistics. |
htop | Interactive system monitor. |
ps | Display running processes. |
kill | Terminate a process by PID. |
| Command | Description |
|---|---|
ping | Test network connectivity. |
ifconfig | Configure and display network interfaces. |
ip addr show | Display IP addresses. |
netstat | Display network connections and statistics. |
ss | Display socket statistics. |
curl | Transfer data from URLs. |
wget | Download files from the web. |
ssh | Securely connect to a remote system. |
scp | Securely copy files between systems. |
rsync | Synchronize files and directories. |
| Command | Description |
|---|---|
apt update | Update package lists (Debian/Ubuntu). |
apt upgrade | Upgrade installed packages (Debian/Ubuntu). |
apt install | Install a package (Debian/Ubuntu). |
apt remove | Remove a package (Debian/Ubuntu). |
dnf update | Update packages (Red Hat/Fedora). |
dnf install | Install a package (Red Hat/Fedora). |
dnf remove | Remove a package (Red Hat/Fedora). |
| Command | Description |
|---|---|
cut | Extract columns from text. |
sort | Sort lines of text. |
uniq | Remove duplicate lines. |
wc | Count lines, words, and characters. |
sed | Stream editor for text manipulation. |
awk | Pattern scanning and processing language. |
| Command | Description |
|---|---|
chmod | Change file permissions. |
chown | Change file ownership. |
chgrp | Change file group ownership. |
| Command | Description |
|---|---|
tar | Archive files. |
gzip | Compress files. |
gunzip | Decompress files. |
zip | Create a ZIP archive. |
unzip | Extract files from a ZIP archive. |
| Command | Description |
|---|---|
shutdown | Shut down the system. |
reboot | Reboot the system. |
systemctl | Manage system services. |
journalctl | View system logs. |
| Command | Description |
|---|---|
useradd | Add a new user. |
userdel | Delete a user. |
passwd | Change a user’s password. |
su | Switch user. |
sudo | Execute commands as another user. |
| Command | Description |
|---|---|
scp | Securely copy files between systems. |
rsync | Synchronize files and directories. |
lftp | Advanced FTP client. |
ncftp | User-friendly FTP client. |
date: Displays the current date and time. date For formatting, you can use flags like:
$ date +”%Y-%m-%d %H:%M:%S”
cal: Shows a calendar of the current month. cal To see a year: $ cal 2025
man: Manual pages for commands. Very useful for detailed information. man [command] Example: $ man ls
history: Lists previously executed commands. history To rerun a command from history, use ! followed by the command number: $ !5
clear: Clears the terminal screen. $ clear
pwd: Prints the current working directory. $ pwd
cd: Change directory.
cd ~cd /path/to/directoryTo go back one directory: $ cd ..
ls: List directory contents.
$ ls-l for long listing format: $ ls -l-a to show hidden files: $ ls -a-h for human-readable sizes: $ ls -lhmkdir: Make directories. $ mkdir new_directory
To create nested directories: $ mkdir -p new_directory/sub_directory
cp: Copy files or directories. $ cp source_file destination_file
To copy directories recursively: $ cp -r source_directory destination_directory
mv: Move or rename files/directories. $ mv old_file new_file
Or to move: $ mv file /new/location/
rm: Remove files or directories. $ rm file.txt
To remove directories and their contents: $ rm -r directory_name
Be cautious as this command is permanent; use -ifor interactive deletion: $ rm -i file.txt
find: Search for files in a directory hierarchy. $ find /path/to/search -name “pattern”
Example to find all .txt files: $ find . -name “*.txt”
locate: Quickly find files by name, using a database (needs to be updated with updatedb). locate pattern
Wildcards: Use in commands like ls, cp, mv, etc., for pattern matching.
* for any number of characters: ls *.txt? for a single character: ls file?.txtcat: Concatenate and display files. $ cat file.txt
To display multiple files: $ cat file1.txt file2.txt
head: Output the first part of files. $ head file.txt
To see the first 10 lines: $ head -n 10 file.txt
tail: Output the last part of files. $ tail file.txt
To follow the file for updates: $ tail -f file.txt
less: View file contents with scroll capabilities. $ less file.txt
Use arrow keys to navigate, q to quit.
touch: Create a new empty file or update the timestamp of an existing file. $ touch new_file.txt
nano: Simple text editor for the command line. $ nano file.txt
Common commands: ^O to save, ^X to exit.
grep: Search text using patterns. $ grep ‘pattern’ file.txt
To search recursively: $ grep -r ‘pattern’ /directory/
top: Interactive process viewer. top Use q to quit.
ps: Report a snapshot of current processes. $ ps aux
To find processes by name: $ ps aux | grep process_name
kill: Send signal to a process. $ kill [PID] To force terminate: $ kill -9 [PID]
ifconfig: Configure network interfaces $ ifconfig Or better use: ip addr show
(note: modern Debian uses ip command more commonly).
ping: Check if a network host is reachable. $ ping google.com
To limit to 4 pings: $ ping -c 4 google.com
wget: Retrieve files from the web. $ wget http://example.com/file.zip
To download in background: $ wget -b http://example.com/file.zip