Linux Command Line¶
🧠 Overview¶
This wiki provides a quick reference for essential Linux terminal commands. It covers basic navigation, file system operations, search with grep, system monitoring tools (top, htop, btop), CPU and GPU usage (lscpu, nvidia-smi), device detection (lsusb, xrandr), and network diagnostics. The goal is to offer a simple, accessible guide for day-to-day command line tasks and system checks.
🖥️ Linux Command Line Quick Reference¶
📁 Basic Navigation¶
-
pwd– Print current working directory -
ls– List files in the current directory -
ls -l– Long listing (permissions, size, etc.) -
ls -a– Include hidden files -
cd <dir>– Change directory -
cd ..– Go up one directory -
cd ~– Go to home directory
🔍 Search with grep¶
-
grep "text" file.txt– Search for "text" in file.txt -
grep -r "text" /path/– Recursively search in a directory -
grep -i "text"– Case-insensitive search -
grep -n "text"– Show line numbers -
Combine with
ps,dmesg,journalctlfor filtering logs
📂 File System and Disk¶
-
df -h– Disk space usage (human-readable) -
du -sh *– Show size of folders/files in current directory -
mount– List mounted filesystems -
lsblk– List block devices and partitions -
find . -name "*.log"– Find files by name -
fdisk -l– Show disk partitions
⚙️ System Status¶
-
top– Real-time process monitor -
htop– Improvedtop(may needsudo apt install htop) -
ps aux– List all running processes -
uptime– Show system uptime and load average -
free -h– Show memory usage -
vmstat– System performance overview -
dmesg | less– View kernel/system logs
💻 CPU and GPU Usage¶
-
lscpu– Show CPU architecture info -
nproc– Number of available CPU cores -
watch -n 1 "grep 'cpu' /proc/stat"– Live CPU stats
GPU (NVIDIA only):
nvidia-smi– Show GPU usage, temperature, memory, running processes (requires NVIDIA drivers)
🔌 Device Detection¶
-
lsusb– List USB devices -
lspci– List PCI devices (e.g., GPUs, network cards) -
xrandr– Show connected monitors and resolutions -
inxi -F– Full system summary (install withsudo apt install inxi)
📊 Modern System Monitor: btop¶
btop– A colorful, interactive resource monitor for CPU, memory, disk, network, and processes
(Install withsudo apt install btoporsnap install btop)
Shortcut-friendly and great for quick diagnostics
🌐 Network¶
-
ip aorifconfig– Show IP addresses -
ping <host>– Test network connectivity -
netstat -tuln– Show open ports -
ss -tuln– Modern alternative tonetstat -
curl ifconfig.me– Show your public IP
📦 Package Management (Debian/Ubuntu)¶
-
sudo apt update– Refresh package list -
sudo apt upgrade– Upgrade packages -
sudo apt install <pkg>– Install a package -
dpkg -l– List installed packages
✨ Cool Tools¶
-
tmux – Terminal multiplexer to manage multiple terminal sessions in one window (
sudo apt install tmux) -
yazi– Fast and friendly Markdown viewer for the terminal (install from source or via package manager) -
fzf– Command-line fuzzy finder for quick file and command searching -
exa– Modern replacement forlswith colors and Git integration -
ripgrep(rg) – Fast recursive search tool, alternative togrep -
bat– Acatclone with syntax highlighting and Git integration -
lazygit – A simple, fast, and intuitive terminal UI for Git. It helps you visualize your repository, stage changes, resolve conflicts, and manage branches without leaving the terminal.
-
lazydocker – A terminal UI for Docker and Docker Compose. It allows you to manage containers, images, volumes, and networks interactively from your terminal with ease.
-
zoxide – a smarter cd command, inspired by z and autojump. It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.