List of Essential Ubuntu Terminal Commands with Examples
The Ubuntu terminal (Bash shell) is a powerful tool for managing files, installing software, and controlling system processes. Below is a comprehensive list of commonly used commands with practical examples.
1. File & Directory Operations
| Command | Description | Example |
|---|
ls | List directory contents | ls -l (detailed list) |
cd | Change directory | cd /home/user/Documents |
pwd | Print working directory | pwd → /home/user |
mkdir | Create a directory | mkdir new_folder |
rmdir | Remove empty directory | rmdir empty_folder |
rm | Remove files/directories | rm file.txt (file)
rm -r folder (recursive) |
cp | Copy files/directories | cp file.txt /backup/ |
mv | Move/rename files | mv old.txt new.txt (rename)
mv file.txt /target/ (move) |
touch | Create empty file | touch newfile.txt |
cat | Display file content | cat notes.txt |
nano | Text editor | nano file.txt |
chmod | Change file permissions | chmod +x script.sh (make executable) |
chown | Change file owner | sudo chown user:group file.txt |
2. System Information & Monitoring
| Command | Description | Example |
|---|
uname -a | Show system info | uname -a (kernel details) |
df -h | Disk space usage | df -h (human-readable) |
free -h | Memory usage | free -h (RAM info) |
top | Real-time process monitor | top (press q to quit) |
htop | Interactive process viewer | sudo apt install htop then htop |
neofetch | Display system specs | sudo apt install neofetch then neofetch |
uptime | System uptime | uptime |
3. Package Management (APT)
| Command | Description | Example |
|---|
sudo apt update | Update package list | sudo apt update |
sudo apt upgrade | Upgrade installed packages | sudo apt upgrade |
sudo apt install | Install a package | sudo apt install git |
sudo apt remove | Remove a package | sudo apt remove vim |
sudo apt autoremove | Remove unused packages | sudo apt autoremove |
apt search | Search for packages | apt search python |
apt show | Show package details | apt show firefox |
4. User & Permission Management
| Command | Description | Example |
|---|
sudo | Run as superuser | sudo nano /etc/hosts |
su | Switch user | su root |
passwd | Change password | passwd (current user)
sudo passwd username (another user) |
whoami | Show current user | whoami |
adduser | Add a new user | sudo adduser bob |
deluser | Delete a user | sudo deluser bob |
usermod | Modify user (e.g., add to group) | sudo usermod -aG sudo bob |
5. Network & Connectivity
| Command | Description | Example |
|---|
ping | Test network connection | ping google.com |
ifconfig | Network interfaces (deprecated, use ip) | ifconfig |
ip a | Show IP addresses | ip a |
wget | Download files | wget https://example.com/file.zip |
curl | Fetch web content | curl -O https://example.com/file.zip |
ssh | Remote login | ssh user@192.168.1.100 |
scp | Secure file copy | scp file.txt user@192.168.1.100:/home/user/ |
netstat | Network statistics | netstat -tuln (open ports) |
6. Process Management
| Command | Description | Example |
|---|
ps | List running processes | ps aux (all processes) |
kill | Terminate a process | kill 1234 (PID)
kill -9 1234 (force kill) |
pkill | Kill by process name | pkill firefox |
bg / fg | Background/Foreground process | bg %1 (resume job #1 in background) |
jobs | List background jobs | jobs |
7. File Compression & Archiving
| Command | Description | Example |
|---|
tar | Archive files | tar -cvf archive.tar /folder (create)
tar -xvf archive.tar (extract) |
gzip | Compress files | gzip file.txt → file.txt.gz |
gunzip | Decompress .gz files | gunzip file.txt.gz |
zip / unzip | ZIP compression | zip archive.zip file.txt
unzip archive.zip |
8. Miscellaneous Useful Commands
| Command | Description | Example |
|---|
history | Show command history | history |
grep | Search text in files | grep "error" log.txt |
find | Search for files | find /home -name "*.txt" |
alias | Create command shortcuts | alias ll='ls -la' |
shutdown | Power off/restart | sudo shutdown now (power off)
sudo reboot (restart) |
Conclusion
These commands cover file management, system monitoring, networking, package control, and more.
Pro Tips:
Use man for help (e.g., man ls).
Press Tab for auto-completion.
Ctrl+C cancels a running command.
No comments:
Post a Comment