Ubuntu & Shell Script Commands Cheat Sheet
1. Basic File & Directory Operations
pwd # Print working directory
ls # List directory contents
ls -l / -a # Long list / show hidden
cd /path/to/dir # Change directory
mkdir new_dir # Create new directory
touch [Link] # Create new file
cp src dest # Copy file/folder
mv old new # Rename/move
rm [Link] # Delete file
rm -r dir # Delete directory recursively
cat [Link] # Print file contents
nano [Link] # Open file in nano editor
2. Search & Locate Files
find / -name [Link] # Find file
find . -type f -size +10M # Files larger than 10MB
grep "text" [Link] # Search in file
grep -r "text" /path # Recursive grep
locate filename # Quickly locate files
which python3 # Path of executable
whereis ls # Binary and man page location
3. Package Management (APT)
sudo apt update # Update package list
sudo apt upgrade # Upgrade packages
sudo apt install pkgname # Install package
sudo apt remove pkgname # Remove package
sudo apt autoremove # Remove unused packages
dpkg -i [Link] # Install .deb file
dpkg -l # List installed packages
4. User & Permissions
whoami # Current user
sudo su # Become root
adduser newuser # Add user
Ubuntu & Shell Script Commands Cheat Sheet
passwd newuser # Set password
chmod 755 [Link] # Set execute permissions
chown user:group file # Change ownership
5. Process Management
ps aux # List all processes
top # Realtime process view
kill PID # Kill by PID
killall process_name # Kill by name
bg / fg # Background / foreground
jobs # Show jobs
6. Networking
ifconfig / ip a # Show IP config
ping [Link] # Ping host
netstat -tulnp # Listening ports
curl [Link] # Fetch web content
wget [Link] # Download file
scp file user@host:/dest # Secure copy
7. Shell Script Essentials
#!/bin/bash
name="Alice"
echo "Hello $name"
read -p "Enter name: " user
echo "Welcome $user"
if [ $age -ge 18 ]; then
echo "Adult"
else
echo "Minor"
fi
for i in {1..5}; do
echo "Item $i"
done
Ubuntu & Shell Script Commands Cheat Sheet
greet() {
echo "Hi $1"
}
greet "Bob"
x=5; y=3
echo $((x + y)) # 8