Introduction
The Linux terminal is your gateway to the operating system. Here's a breakdown of essential commands that every beginner should master.
ls — List Directory Contents
Lists files and folders in the current directory.
ls # basic listing
ls -l # long format (permissions, size, date)
ls -a # show hidden files (those starting with .)
ls -la # long format + hidden files
ls -lh # long format with human-readable sizes
The output of ls -l shows: file type + permissions, link count, owner, group, size, modification date, and name.
cd — Change Directory
Moves you between directories.
cd /home/user # go to an absolute path
cd Documents # go into a subdirectory (relative path)
cd .. # go up one directory
cd ~ # go to your home directory
cd - # go to the previous directory
cd / — Root Directory
/ is the root of the entire Linux filesystem — the topmost directory. Everything on your system lives under /.
cd / # jump to the root of the filesystem
ls / # see top-level directories like /bin, /etc, /home, /var, /usr
Key directories under /:
/bin&/usr/bin— essential user binaries (commands)/etc— system configuration files/home— user home directories/var— variable data (logs, databases)/tmp— temporary files
mkdir — Make Directory
Creates new directories.
mkdir myfolder # create a single directory
mkdir -p a/b/c # create nested directories (parent chain)
mkdir dir1 dir2 dir3 # create multiple directories at once
The -p flag is especially useful in scripts — it creates parent directories as needed and won't error if they already exist.
touch — Create Empty Files / Update Timestamps
Creates an empty file or updates the timestamp of an existing one.
touch file.txt # create a new empty file
touch existing.txt # update its last-modified time to now
touch a.txt b.txt c.txt # create multiple files
Useful for creating placeholder files, log files, or forcing file timestamp updates.
rm — Remove Files and Directories
Permanently deletes files. There is no Trash bin — use with care.
rm file.txt # delete a file
rm -i file.txt # prompt before each deletion (safe mode)
rm -r myfolder # recursively delete a directory and its contents
rm -f file.txt # force delete (no prompt, even if write-protected)
rm -rf myfolder # 🔥 recursive + force — extremely powerful, be very careful
Warning:
rm -rf /would attempt to delete your entire system. Never run this unless you know exactly what you're doing (and even then, don't).
mv — Move or Rename Files
Moves a file to a new location, or renames it within the same directory.
mv file.txt /tmp/ # move file.txt into /tmp
mv oldname.txt newname.txt # rename a file
mv file1.txt dir/ # move file1.txt into dir/
mv -i file.txt dir/ # prompt before overwriting any existing file
mv is also the standard way to rename files and directories in Linux.
vim — Terminal Text Editor
A powerful modal text editor that runs in the terminal.
vim file.txt # open or create a file in vim
Vim Modes (essential)
| Mode | What it does |
|------|-------------|
| Normal | default — navigate, copy, paste, delete (press Esc to return here) |
| Insert | type text (press i to enter) |
| Visual | select text (v for character, V for line) |
| Command | run commands like save/quit (: to enter) |
Vim Survival Guide
i # enter Insert mode (start typing)
Esc # return to Normal mode
:w # save the file (write)
:q # quit vim
:wq # save and quit
:q! # quit without saving (force)
dd # delete the current line
yy # copy (yank) the current line
p # paste below the cursor
/searchterm # search for "searchterm" in the file
n # go to next search match
u # undo
Ctrl + r # redo
ifconfig — Network Interface Configuration
Shows and configures network interfaces. On modern Linux, ip is the replacement, but ifconfig is still widely used.
ifconfig # show all active network interfaces
ifconfig -a # show all interfaces (including inactive)
ifconfig eth0 # show details for a specific interface
sudo ifconfig eth0 down # take an interface offline
sudo ifconfig eth0 up # bring an interface online
Typical output includes: IP address (inet), netmask, broadcast address, MAC address (ether), and packet stats (RX/TX).
Note: You may need to install
net-toolsto getifconfig:sudo apt install net-tools
nslookup — DNS Lookup
Queries DNS servers to resolve domain names to IP addresses (and vice versa).
nslookup google.com # get the IP address of google.com
nslookup 8.8.8.8 # reverse lookup — find the domain for an IP
nslookup google.com 1.1.1.1 # query a specific DNS server (Cloudflare)
``\)
Output shows the DNS server used, the resolved IP address (A record), and sometimes alias names (CNAME).
Useful for debugging DNS issues like "why can't my browser reach this website?"
---
## Summary Cheatsheet
| Command | What it does |
|---------|-------------|
| `ls` | List files |
| `cd` | Change directory |
| `mkdir` | Create a directory |
| `touch` | Create/update a file |
| `rm` | Delete files (permanent!) |
| `mv` | Move or rename files |
| `vim` | Edit files in terminal |
| `ifconfig` | Show network interfaces |
| `nslookup` | Query DNS records |
Practice these in your terminal daily and they'll become second nature in no time.