Comprehensive Unix Command Reference
1 File and Directory Commands
ls -l # Long listing format
ls -a # Show hidden files
ls - lh # Human - readable file sizes
ls - lrt # Sort files by modification time , newest last
cd / path / to / directory # Navigate to specified directory
cd .. # Move up one directory level
cd ~ # Move to home directory
pwd # Show current directory path
touch file . txt # Create an empty file
rm - rf directory / # Remove a directory recursively
cp -r source / destination / # Copy a directory recursively
mv oldname newname # Rename or move a file
2 User Management
whoami # Show currently logged - in user
id # Show user ID , group ID , and groups
groups username # Show groups the user belongs to
passwd # Change password of current user
useradd username # Create a new user
usermod - aG groupname username # Add user to a group
deluser username # Delete a user
groupadd groupname # Create a new group
1
3 Package Management
apt update # Update package lists
apt install package_name # Install a package
yum install package_name # Install a package
4 Environment Variables
export VAR_NAME = value # Set an environment variable
env # Show all environment variables
5 Archiving and Compression
tar - cvf archive . tar file . txt # Create tar archive
zip archive . zip file . txt # Create zip archive
6 Text Processing
awk ’{ print $1 } ’ file . txt # Print first column of file
sed ’s / old / new /g ’ file . txt # Replace ’old ’ with ’new ’
cut -d ’: ’ - f1 / etc / passwd # Extract first column
sort file . txt # Sort file contents
uniq file . txt # Remove duplicate lines
diff file1 file2 # Compare two files
2
7 Process Management
ps aux # List all running processes
top # Display real - time process info
kill PID # Kill process with given PID
nohup command & # Run command in background
jobs # Show background jobs
fg %1 # Resume job in foreground
bg %1 # Resume job in background
8 Networking Commands
ping google . com # Send ICMP requests
netstat - tulnp # Show listening ports
ifconfig eth0 # Show details for eth0 interface
curl -I https :// example . com # Get headers
wget https :// example . com / file . zip # Download file
traceroute google . com # Show packet route
9 Permissions and Ownership
chmod 755 file . txt # Set file permissions
chown user : group file . txt # Change ownership
chmod 600 file . txt # Only owner can read and write
chattr + i file . txt # Prevent modifications
10 Searching and Sorting
3
find / path - name " file . txt " # Locate a file
grep " pattern " file . txt # Find pattern in file
11 Logging and System Monitoring
dmesg | tail # Show recent log messages
uptime # Display uptime and load average
free -m # Display memory usage in MB
vmstat 2 # Display system stats every 2 seconds
iostat # Show CPU and disk statistics
12 Disk and Storage Management
df -h # Display disk usage in human - readable format
du - sh folder / # Show directory size
mount / dev / sdb1 / mnt # Mount a device
umount / mnt # Unmount the device
13 Security
Firewall
ufw enable # Enable firewall ( for Ubuntu )
iptables -L # Display firewall rules