Linux commands are text-based instructions used to interact with your operating system. This guide covers the most essential commands that every Linux user should know, from basic navigation to advanced system administration.
File Navigation
Command
Description
Example
pwd
Print Working Directory – shows current directory
pwd
ls
List files and directories
ls -la (shows all files including hidden ones with details)
cd
Change Directory
cd /home/user/Documents
cd ..
Move up one directory
cd ..
cd ~
Go to home directory
cd ~
find
Search for files
find /home -name "*.txt"
locate
Find files by name (requires updatedb)
locate filename
which
Show the full path of shell commands
which python
File Operations
Command
Description
Example
cp
Copy files or directories
cp file.txt /home/user/Documents
mv
Move or rename files or directories
mv file.txt newname.txt
rm
Remove files or directories
rm file.txt or rm -r directory
mkdir
Create a new directory
mkdir new_directory
rmdir
Remove an empty directory
rmdir empty_directory
touch
Create an empty file or update timestamp
touch newfile.txt
du
Disk usage – show file/directory size
du -h file.txt (human-readable format)
df
Display free disk space
df -h (human-readable format)
tar
Archive files
tar -cvf archive.tar files/
zip/unzip
Compress/decompress files
zip archive.zip files/
System Information
Command
Description
Example
uname
Display system information
uname -a (all information)
cat /etc/os-release
Show OS information
cat /etc/os-release
lsb_release
Display distribution-specific information
lsb_release -a
uptime
Show how long the system has been running
uptime
free
Display memory usage
free -h (human-readable)
lscpu
Display CPU information
lscpu
lsblk
List block devices
lsblk
dmesg
Print kernel messages
dmesg | less
lshw
List hardware
sudo lshw
User Management
Command
Description
Example
whoami
Display current user
whoami
id
Display user identity
id
useradd
Create a new user
sudo useradd username
usermod
Modify user account
sudo usermod -aG group username
userdel
Delete a user
sudo userdel username
passwd
Change password
passwd or sudo passwd username
su
Switch user
su - username
sudo
Execute command as another user (typically root)
sudo command
who
Show who is logged on
who
File Permissions
Command
Description
Example
chmod
Change file permissions
chmod 755 file.txt or chmod u+x file.sh
chown
Change file owner
sudo chown user:group file.txt
chgrp
Change group ownership
sudo chgrp group file.txt
umask
Set default permissions
umask 022
Permission values:
4: read (r)
2: write (w)
1: execute (x)
Common permission combinations:
755: rwxr-xr-x (owner can read/write/execute, others can read/execute)
644: rw-r–r– (owner can read/write, others can read)
700: rwx—— (owner can read/write/execute, others have no permissions)
Process Management
Command
Description
Example
ps
Display running processes
ps aux
top
Dynamic real-time view of processes
top
htop
Interactive process viewer (may need installation)
htop
kill
Terminate a process
kill PID or kill -9 PID (force kill)
pkill
Kill processes by name
pkill process_name
killall
Kill all processes by name
killall process_name
nice
Run a command with modified priority
nice -n 10 command
renice
Alter priority of running process
renice +10 -p PID
bg
Resume suspended jobs in background
bg
fg
Bring background process to foreground
fg
jobs
List background jobs
jobs
nohup
Run command immune to hangups
nohup command &
Network Commands
Command
Description
Example
ifconfig
Configure network interface (deprecated in some distributions)
ifconfig
ip
Show/manipulate routing, devices, tunnels
ip addr show
ping
Test network connectivity
ping google.com
traceroute
Display route packets to network host
traceroute google.com
netstat
Network statistics
netstat -tuln
ss
Socket statistics (similar to netstat)
ss -tuln
dig
DNS lookup
dig google.com
nslookup
Query DNS records
nslookup google.com
wget
Download files from the web
wget https://example.com/file.zip
curl
Transfer data from/to a server
curl https://example.com
ssh
Secure shell remote login
ssh user@hostname
scp
Securely copy files between hosts
scp file.txt user@host:/path
rsync
Remote file synchronization
rsync -av source/ destination/
Package Management
Debian/Ubuntu (APT)
Command
Description
Example
apt update
Update package lists
sudo apt update
apt upgrade
Upgrade installed packages
sudo apt upgrade
apt install
Install a package
sudo apt install package_name
apt remove
Remove a package
sudo apt remove package_name
apt search
Search for a package
apt search keyword
apt list
List packages
apt list --installed
Red Hat/Fedora (DNF/YUM)
Command
Description
Example
dnf check-update
Check for updates
sudo dnf check-update
dnf upgrade
Upgrade installed packages
sudo dnf upgrade
dnf install
Install a package
sudo dnf install package_name
dnf remove
Remove a package
sudo dnf remove package_name
dnf search
Search for a package
dnf search keyword
dnf list
List packages
dnf list installed
Arch Linux (Pacman)
Command
Description
Example
pacman -Sy
Synchronize package databases
sudo pacman -Sy
pacman -Syu
Update system
sudo pacman -Syu
pacman -S
Install package
sudo pacman -S package_name
pacman -R
Remove package
sudo pacman -R package_name
pacman -Ss
Search for package
pacman -Ss keyword
pacman -Q
List installed packages
pacman -Q
Text Processing
Command
Description
Example
cat
Display file contents
cat file.txt
less
View file contents with pagination
less file.txt
more
View file contents page by page
more file.txt
head
Display first lines of a file
head -n 10 file.txt
tail
Display last lines of a file
tail -n 10 file.txt or tail -f logfile (follow)
grep
Search text using patterns
grep "pattern" file.txt
sed
Stream editor for filtering and transforming text
sed 's/old/new/g' file.txt
awk
Pattern scanning and processing language
awk '{print $1}' file.txt
sort
Sort lines of text files
sort file.txt
uniq
Report or omit repeated lines
uniq file.txt
wc
Count lines, words, and characters
wc -l file.txt (line count)
cut
Remove sections from each line
cut -d ',' -f 1 file.csv (get first column)
diff
Compare files line by line
diff file1.txt file2.txt
Advanced Commands
Command
Description
Example
cron
Schedule periodic tasks
crontab -e (edit current user’s crontab)
at
Schedule one-time tasks
at 10:00 AM
systemctl
Control the systemd system and service manager
systemctl status service_name
journalctl
Query the systemd journal
journalctl -u service_name
dd
Convert and copy a file
dd if=/dev/zero of=file bs=1M count=10
lsof
List open files
lsof -i :80 (show processes using port 80)
strace
Trace system calls and signals
strace command
alias
Create command shortcuts
alias ll='ls -la'
history
Show command history
history
screen
Terminal multiplexer
screen
tmux
Terminal multiplexer (alternative to screen)
tmux
xargs
Build and execute commands from standard input
find . -name "*.txt" | xargs grep "pattern"
tee
Read from stdin and write to stdout and files
command | tee output.txt
Useful Shortcuts
Shortcut
Description
Ctrl+C
Interrupt (kill) current process
Ctrl+Z
Suspend current process
Ctrl+D
Exit shell or current session
Ctrl+L
Clear screen
Ctrl+A
Go to beginning of line
Ctrl+E
Go to end of line
Ctrl+U
Clear line before cursor
Ctrl+K
Clear line after cursor
Ctrl+W
Delete word before cursor
Ctrl+R
Search command history
Tab
Auto-complete commands or filenames
↑/↓
Navigate through command history
Conclusion
This guide covers the most essential Linux commands for everyday use. Remember that most commands have numerous options that can be discovered by reading their man pages (man command_name). Linux commands can be combined using pipes (|) and redirects (>, >>, <) to create powerful command chains.
For more detailed information about any command, use:
man command_name
or
command_name --help
As you become more familiar with these commands, your productivity and ability to manage Linux systems will greatly improve.