Linux Commands End to End
Linux Commands End to End
1. Basic Commands:
Command Description Example
ls List contents in the directory ls -l
cd Change the current working directory cd /home/user
pwd Prints current working directory pwd
cp Copy files or directories cp file.txt backup.txt
mv Move or rename files or directories mv oldname.txt newname.txt
rm Remove files or directories rm file.txt
mkdir Create a new directory mkdir new_folder
rmdir Remove empty directories rmdir empty_folder
rm -rf Force removes a directory rm -rf directory_name
touch Create an empty file or update timestamp touch newfile.txt
clear Clear the terminal screen clear
2. User Management:
Command Description Example (sudo for elevated
priviliges)
useradd Add a new user sudo useradd testusr
groupadd Create a new user group sudo groupadd testgrp
adduser Interactive script to add a new user sudo adduser testusr
passwd Change a user's password passwd testusr
usermod Modify a user account sudo usermod -aG sudo
testusr
deluser Delete a user sudo deluser testusr
userdel Delete a user, home directory and mail spool sudo userdel -r testusr
groupdel Delete an existing user group sudo groupdel testgrp
groups Show groups of a user groups testusrgrp
usermod -aG Add user to a group sudo usermod -aG sudo
testusrgrp
whoami Show current logged-in user whoami
chage Change user account aging information sudo chage -l testusr
who Show who is logged on who
w Show who is logged in and what they’re w
doing
id Show user ID (UID), group ID (GID), and id testusr
groups
6. Package Management:
Command Description Example
apt Debian package manager tool apt update
apt-get APT package handling utility apt-get install package_name
apt-get update
apt-get upgrade
apt-get remove
yum Red Hat package manager tool yum install package_name
yum update
yum upgrade
yum remove
7. Network Commands:
Command Description Example
ping Test connectivity to a host ping google.com
ifconfig Configure network interfaces ifconfig eth0
(deprecated)
ip Show/manipulate routing, devices, ip a
interfaces
netstat Display network connections netstat -tuln
(deprecated)
traceroute Trace the route packets take to a traceroute google.com
network host
nslookup Query Internet name servers nslookup example.com
interactively
dig DNS lookup utility dig example.com
ss Display socket statistics ss -tuln
curl Transfer data from or to a server curl http://example.com
wget Download files from the internet wget http://example.com/file.zip
scp Securely copy files between hosts scp file.txt testusr@host:/tmp/
ssh Secure shell access to remote machines ssh [email protected]
ftp File Transfer Protocol client ftp ftp.example.com
nc Network utility for reading and writing nc -l -p 844
from network connections
8. Disk Management:
Command Description Example
df Show disk space usage df -h
du Show directory space usage du -sh /home/testusr
fdisk Partition table manipulator sudo fdisk /dev/sda
mount Mount a filesystem mount /dev/sdb1 /mnt
umount Unmount a filesystem umount /mnt
fstab File system table (configuration file for /etc/fstab
mounting file systems)
lsblk List block devices lsblk
blkid Display block device attributes blkid
parted Manipulate disk partitions sudo parted /dev/sda
mkfs Create a file system on a device or sudo mkfs.ext4 /dev/sdb1
partition
fsck Check and repair a Linux file system sudo fsck /dev/sdb1
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
cut Remove sections from each line of a file cut -d ':' -f1 /etc/passwd
sort Sort lines of text sort names.txt
uniq Filter duplicate lines uniq sorted.txt
tr Translate or delete characters tr 'a-z' 'A-Z' < file.txt
wc By default, wc prints the number of lines, words wc file.txt
and bytes in each file.
13. Compression & Archiving
Command Description Example
tar Used to create or extract archive files, tar -cvzf archive.tar file.txt
Common flags include -c (create), -x tar -xvzf archive.tar.gz
(extract), -v (verbose), -z (gzip
compression), and -f (specify archive
file).
gzip Compress files gzip file.txt
gunzip Decompress .gz files gunzip file.txt.gz
bzip2 Compress files using bzip2 bzip2 file.txt
zip Compress files into a zip archive zip archive.zip file.txt
unzip Extract files from a zip archive unzip archive.zip