100 Essential Linux Commands with Examples
Command Example Description
cd cd /var/log Change directory to /var/log
ls ls -l List files in long format
pwd pwd Print current working directory
mkdir mkdir test Create a new directory named test
rm rm file.txt Remove a file
rmdir rmdir olddir Remove an empty directory
cp cp file1.txt file2.txt Copy file1.txt to file2.txt
mv mv file.txt /tmp/ Move file.txt to /tmp directory
touch touch newfile.txt Create a new empty file
echo echo 'Hello World' Print Hello World
cat cat file.txt Display content of file.txt
more more file.txt View content one screen at a time
less less file.txt Scroll through file content
head head file.txt Show first 10 lines of file.txt
tail tail file.txt Show last 10 lines of file.txt
grep grep 'root' /etc/passwd Search for 'root' in /etc/passwd
find find / -name file.txt Find file.txt from root
chmod chmod 755 script.sh Set permissions to rwxr-xr-x
chown chown user:user file.txt Change ownership of file.txt
df df -h Show disk space usage in human-readable format
du du -sh * Show size of each file/folder in current dir
free free -m Show memory usage in MB
top top Show real-time process usage
htop htop Interactive process viewer
ps ps aux Show all running processes
kill kill -9 1234 Force kill process with PID 1234
killall killall firefox Kill all processes named firefox
service service httpd restart Restart httpd service
systemctl systemctl status sshd Check status of sshd
yum yum install nano Install nano editor using yum
Page 1
100 Essential Linux Commands with Examples
rpm rpm -ivh pkg.rpm Install RPM package
history history Show command history
alias alias cls='clear' Create alias for clear command
unalias unalias cls Remove alias named cls
man man ls Show manual for ls
info info cp Show info page for cp
whoami whoami Show current username
id id Show user ID and group ID
date date Show current date and time
cal cal Display calendar
uptime uptime Show system uptime
uname uname -a Show system information
hostname hostname Display system hostname
ifconfig ifconfig Show network interfaces (deprecated)
ip ip a Show IP addresses and interfaces
ping ping google.com Ping google to test connectivity
netstat netstat -tuln Show listening ports
ss ss -tuln Alternative to netstat
scp scp file.txt user@remote:/tmp/ Copy file to remote server
rsync rsync -av file.txt /backup/ Sync file to backup directory
wget wget http://example.com/file.txt Download file using wget
curl curl http://example.com Fetch webpage using curl
tar tar -xvzf archive.tar.gz Extract .tar.gz archive
zip zip file.zip file.txt Compress file into a zip
unzip unzip file.zip Extract a zip file
locate locate bashrc Find file using database
updatedb updatedb Update locate database
mount mount /dev/sdb1 /mnt Mount partition to /mnt
umount umount /mnt Unmount /mnt
df df -Th Show type and space of filesystems
who who Show who is logged in
w w Show who is logged in and what they are doing
Page 2
100 Essential Linux Commands with Examples
users users Show logged in users
passwd passwd Change user password
adduser adduser john Add a new user named john
userdel userdel john Delete user john
groupadd groupadd dev Create a new group named dev
groupdel groupdel dev Delete group dev
usermod usermod -aG dev john Add john to group dev
crontab crontab -e Edit current user's cron jobs
at at now + 1 minute Schedule job at specific time
shutdown shutdown -h now Shutdown the system immediately
reboot reboot Reboot the system
logger logger 'Test log entry' Write message to system log
dmesg dmesg | less Kernel ring buffer output
lsblk lsblk List block devices
blkid blkid Display block device UUIDs
fdisk fdisk -l List partitions
parted parted /dev/sda Partition a disk
mkfs mkfs.ext4 /dev/sdb1 Format partition with ext4
fsck fsck /dev/sda1 Check filesystem
tune2fs tune2fs -l /dev/sda1 Adjust ext2/ext3/ext4 filesystem
journalctl journalctl -xe View logs in systemd journal
systemctl systemctl list-units List systemd units
hostnamectl hostnamectl set-hostname myhost Set system hostname
timedatectl timedatectl Show or set system time
nmcli nmcli device status NetworkManager CLI
firewall-cmd firewall-cmd --list-all List active firewall zones
semanage semanage port -l Manage SELinux ports
getenforce getenforce Show SELinux status
setenforce setenforce 0 Set SELinux to permissive
sestatus sestatus Display SELinux status
last last Show login history
uptime uptime Show how long system has been up
Page 3
100 Essential Linux Commands with Examples
vmstat vmstat 1 Show memory and CPU stats
iostat iostat Show I/O stats
Page 4