Post

Ubuntu Command Line Basics - A Quick Guide for Beginners

A quick guide to basic Ubuntu commands for beginners โ€” navigate, manage files, and control your system with ease.

Ubuntu Command Line Basics - A Quick Guide for Beginners

๐Ÿง Ubuntu Basic Commands Cheat Sheet

A practical list of essential Ubuntu Linux commands for developers, sysadmins, and beginners. Includes navigation, package management, and system control.


๐Ÿ“‚ Navigation

Command Description
pwd Print current working directory
ls List files and directories
ls -l Detailed list (permissions, size, owner)
ls -a Show hidden files
cd <directory> Change directory
cd .. Go up one level
cd ~ Go to home directory
cd / Go to root directory

๐Ÿ“ File & Directory Management

Command Description
mkdir <dir> Create a directory
rmdir <dir> Remove an empty directory
rm -r <dir> Remove a directory and contents
touch <file> Create an empty file
cp <src> <dest> Copy files or directories
mv <src> <dest> Move or rename files
rm <file> Remove a file

๐Ÿ“„ Viewing & Editing Files

Command Description
cat <file> Display file contents
less <file> View file page by page
head <file> Show first 10 lines
tail <file> Show last 10 lines
tail -f <file> Follow file changes (useful for logs)
nano <file> Edit a file using Nano
vim <file> Edit a file using Vim

๐Ÿ” Searching & Finding Files

Command Description
find <path> -name <filename> Find files by name
grep <pattern> <file> Search text inside files
grep -r <pattern> <dir> Search recursively in directory
locate <file> Quickly find files (after sudo updatedb)

โš™๏ธ System Information

Command Description
uname -a Show system info
lsb_release -a Display Ubuntu version
hostnamectl Show hostname and OS info
df -h Display disk space usage
du -h Show directory size
top View active processes
htop Interactive process viewer (install with sudo apt install htop)
free -h Show memory usage
uptime Show system uptime
who Show logged-in users

๐Ÿ‘ฅ User & Permission Management

Command Description
whoami Show current username
id Display user and group info
sudo <command> Run command as superuser
adduser <username> Create a new user
deluser <username> Delete a user
usermod -aG <group> <user> Add user to a group
chmod <perm> <file> Change file permissions
chown <user>:<group> <file> Change file owner/group

๐ŸŒ Networking Commands

Command Description
ip a Show IP addresses
ping <host> Test connectivity
curl <url> Fetch content from a URL
wget <url> Download files from the internet
ssh <user>@<host> Connect to remote server via SSH
scp <file> <user>@<host>:<path> Copy file to remote host
netstat -tuln Show listening ports (install with sudo apt install net-tools)
ss -tuln Show listening ports (modern alternative)

๐Ÿ“ฆ Package Management (APT)

Command Description
sudo apt update Refresh package list
sudo apt upgrade Upgrade installed packages
sudo apt install <package> Install a package
sudo apt remove <package> Uninstall a package
sudo apt autoremove Remove unused dependencies
sudo apt purge <package> Remove package and config files
sudo apt list --installed List installed packages
sudo dpkg -i <package.deb> Install a local .deb package

๐Ÿงฐ System Control

Command Description
sudo systemctl status <service> Check service status
sudo systemctl start <service> Start a service
sudo systemctl stop <service> Stop a service
sudo systemctl restart <service> Restart a service
sudo systemctl enable <service> Enable service at boot
sudo systemctl disable <service> Disable service at boot
sudo reboot Restart the system
sudo shutdown now Shut down immediately

๐Ÿ™ Git & Docker (Common Dev Commands)

Command Description
git clone <repo> Clone a Git repository
git status Show repo status
git commit -m "message" Commit changes
docker ps List running containers
docker images List Docker images
docker build -t <name> . Build Docker image
docker run -d -p 8000:8000 <image> Run container in background

๐Ÿงน Miscellaneous

Command Description
history Show command history
clear Clear terminal screen
man <command> Show manual for command
alias ll='ls -la' Create a shortcut command
exit Close terminal session

๐Ÿ“˜ Pro Tip: Use --help after most commands (e.g., sudo apt --help) to view usage details.


Author: Your Name
Tested on: Ubuntu 22.04 LTS
License: MIT

This post is licensed under CC BY 4.0 by the author.