Essential Linux Command-Line Reference

Core System Navigation & Utilities

Administrative tasks often require elevating privileges or inspecting system states. Transition to the root account using su, or switch to a specific user session with su - username. To list available environment variables and filter them, pipe through standard text processors:

# Switch to root, create a marker file, and remove it
su
touch config.sample.txt
rm config.sample.txt

# Filter environment variables for CUDA paths
env | grep -E 'CUDA|LD_LIBRARY'

# Inspect active sessions and system load
who
uptime

Archival operations rely heavily on tar. Modern invocations prefer long-form flags for readability:

tar --create --gzip --verbose --file project_backup.tar.gz ./source_folder/
tar --list --gzip --verbose --file project_backup.tar.gz
tar --extract --gzip --verbose --file project_backup.tar.gz

When package installations fail due to missing dependencies, force resolution before proceeding:

sudo apt --fix-broken install

Log files reside in distribution-specific locations. Authentication trails are typically stored at /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL/CentOS). Identify your distribution version by reading /etc/os-release.

Command Line Interface Shortcuts

  • History & Search: Ctrl+R for incremental reverse search; Ctrl+P/N for previous/next history entries.
  • Cursor Movement: Ctrl+B/F moves backward/forward by character; Ctrl+A/E jumps to beginning/end of line; Alt+F/B navigates word boundaries.
  • Line Editing: Ctrl+U clears text before cursor; Ctrl+K clears text after cursor; Ctrl+W deletes the preceding word; Alt+D deletes the following word. Revert accidental deletions with Ctrl+Y.
  • Viewport: Ctrl+L refreshes the terminal screen.

Vim Modal Editor Essentials

Vim operates in distinct modes. Navigate buffers efficiently using standard mappings:

h j k l          # Down / Up / Left / Right
W E B            # Jump forward/backward words
0 ^ $            # Absolute line start / Indented start / Line end
gg G             # First line / Last line
fx ; ,           # Find character / Repeat find direction
* #              # Search forward/backward for word under cursor

Text manipulation and mode transitions:

i I a A o O      # Insert before/after/above/below cursor
dd dw d$         # Delete line / word / to end of line
yy yw Y$         # Copy line / word / to end of line
p P              # Paste below / above current line
u                # Undo changes
/ ?              # Forward / backward search
:%s/old_pattern/new_pattern/gc   # Global substitution with confirmation
:.!command       # Pipe current line through external command output

Account Lifecycle & Permission Controls

User metadata is managed through system files. View account and group registries with cat /etc/passwd and cat /etc/group. Create and manage accounts:

sudo adduser --ingroup engineering dev_jane
sudo userdel -r dev_jane
sudo id dev_jane
sudo groups dev_jane
sudo usermod -aG engineering dev_john      # Append to supplementary group
sudo usermod -l developer_john dev_john     # Rename account
sudo usermod -d /home/developer_john -m dev_john # Relocate home directory

File permissions utilize octal notation (r=4, w=2, x=1). Adjust access levels symbolically or numerically:

sudo chmod 755 deploy_script.sh
sudo chmod u+x,g-w,o-r config.yml
sudo chown -R developer:team_project /opt/app_data

The default file mask umask subtracts from maximum permissions (777 for dirs, 666 for files). Set umask 0022 to create standard readable/executable resources.

Audit authentication attempts by parsing log outputs:

journalctl /var/log/auth.log | grep -i "failed password" \
| awk '{print $(NF-4)}' \
| sort \
| uniq -c \
| sort -nr \
| head -n 10

Secure Remote Access & Session Persistence

Establish encrypted tunnels using ssh. Enable X11 forwarding or verbose debugging as needed:

ssh -X admin@192.168.10.50
ssh -vvv admin@192.168.10.50

Eliminate repetitive password prompts by deploying public keys:

ssh-keygen -t ed25519 -C "workstation_identity"
ssh-copy-id admin@192.168.10.50

Configure host aliases and jump hosts in ~/.ssh/config:

Host prod-server
    HostName 203.0.113.45
    Port 2222
    User admin
    IdentityFile ~/.ssh/prod_key

Host internal-db
    HostName 10.0.0.15
    User dba
    ProxyJump prod-server

Manage shell initialization order: /etc/profile executes globally on login, ~/.bash_profile runs once per session, and ~/.bashrc handles interactive non-login shells (like GUI terminals). Place persistent exports in ~/.bashrc.

File Discovery & Metadata Queries

Transfer files securely between hosts using scp or establish symbolic links:

scp -r ./reports/ remote_user@backup.example.com:/archive/reports/
ln -s /data/raw_dataset.csv /current_work/input_link.csv

Stream large files with out loading entire contents into memory using less with line numbering and auto-scroll capabilities:

less +N +100 application.log
# Inside less: G (end), gg (start), N (line), n/N (repeat search)

Extract and rank specific columns from tabular outputs:

awk '{print $9}' network_traffic.csv \
| sort \
| uniq -c \
| sort -nr \
| tail -n 15

cut -d',' -f1,4 report_export.tsv \
| sort -k2 \
| uniq

Calculate resource consumption and locate executables:

du -sh ./build_artifacts/*
wc -l < access_log.txt
which systemctl
locate .conf --regex '\.yaml$'
find /mnt/storage -name '*.log' -mmin -30 -user analyst

Process Tracking & Service Orchestration

Monitor active workloads and resource contention:

ps aux --sort=-%mem | head -n 20
top -o %CPU -d 2 > performance_snapshot.log
iotop -b -n 5
sar -n DEV 1 10

Control background jobs and detach processes from terminal sessions:

./train_model.py &
[Press Ctrl+Z to suspend]
bg                  # Resume in background
fg %1               # Bring to foreground
kill -15 %1         # Graceful termination
nohup ./batch_job.sh > job_output.log 2>&1 &

Manage systemd units consistently:

sudo systemctl start nginx.service
sudo systemctl enable monitor-agent.service
sudo systemctl list-units --type=service --state=running
journalctl -u nginx --since "1 hour ago"

Block Device Mounting & Persistent Storage

Inspect partitions and attach filesystems:

lsblk -f
sudo mount /dev/sdb1 /mnt/archive
df -Th

To persist mounts across reboots, edit /etc/fstab:

UUID=a1b2-c3d4-e5f6  /mnt/data  ext4  defaults,noatime  0  2

Validate configuration with sudo mount -a before rebooting.

Graphics Processing Unit Diagnostics

Query NVIDIA hardware status and identify hidden consumers:

nvidia-smi
watch -n 2 nvidia-smi
sudo fuser -v /dev/nvidia0

Terminate specific user processes consuming GPU resources safely:

fuser -k -TERM /dev/nvidia1
fuser -k -SIGKILL /dev/nvidia2

Package Managers & Dynamic Environments

RHEL-family systems use dnf/yum; Debian-family uses apt/dpkg. Refresh repositories and upgrade packages:

sudo apt update && sudo apt upgrade -y

Manipulate environment strings dynamically using Bash parameter expansion:

ORIGINAL_PATH="/opt/libs/runtime/bin:/usr/local/bin:/opt/libs/tools"
MODIFIED_PATH="${ORIGINAL_PATH//runtime/runtime-new}"
echo "$MODIFIED_PATH"

Network Diagnostics & Traffic Fitlering

Interact with HTTP endpoints and establish secure tunnels:

curl -X POST -H "Content-Type: application/json" -d '{"status":"active"}' https://api.internal/v1/update
ssh -L 5432:db.internal.local:5432 gateway@vpn.example.com
ssh -R 8090:localhost:3000 gateway@vpn.example.com

Verify connectivity, resolve addresses, and capture packets:

nc -zv mail.example.com 993
nslookup api.gateway.net
ss -tulnp | grep LISTEN
tcpdump -i eth0 host 192.168.5.10 and port 443

Manage IPv4 packet filtering rules cautiously:

iptables -A OUTPUT -d 10.10.0.0/16 -j ACCEPT
iptables -A INPUT -s 172.16.0.0/12 -p tcp --dport 8443 -j DROP
iptables -L INPUT --line-numbers -v
iptables -D INPUT 3

Display Server & Resolution Configuration

Adjust virtual desktop dimensions for remote framebuffer servers:

vncserver :1 -geometry 2560x1440 -depth 24 -localhost no

Regisetr custom resolutions when presets are unavailable:

cvt 1920 1080 60
# Copy Modeline output
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VNC-0 1920x1080_60.00
xrandr -s "1920x1080_60.00"

JVM Tuning & Execution Flags

Instrument Java applications with heap and stack constraints, plus garbage collection tracing:

java -Xms1g -Xmx2g \
     -XX:+PrintGCDetails -XX:+PrintGCDateStamps \
     -Xloggc:/var/log/app_gc.log \
     HeapAnalyzerApp

jcmd <pid> VM.flags
jstack <pid> > thread_dump.txt
</pid></pid>

Version Control Workflows

Initialize repositories, configure credentials, and set upstream remotes:

git config --global user.name "DevOps Bot"
git config --global user.email "automation@example.net"
git init
git add .
git commit -m "Initial architecture scaffolding"
git branch -M stable
git remote add origin git@github.com:org/core-engine.git
git push -u origin stable

Synchronize branches and apply targeted commits:

git fetch origin
git merge origin/main --no-ff
git rebase -i stable~2
git cherry-pick a1b2c3 d4e5f6
git reset HEAD unsafe_file.cfg

Route Git traffic through SOCKS proxies:

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
# For SSH transports, configure ~/.ssh/config:
Host github.com
    ProxyCommand nc -x 127.0.0.1:1080 %h %p

Cross-Platform Terminal Automation

Manage disk encryption and enumerate executable paths on Windows:

powershell Disable-BitLocker -MountPoint "C:"
powershell manage-bde -status C:
wmic process where name="app.exe" get processid,executablepath,name

Set transient environment variables in PowerShell and CMD:

$env:HTTPS_PROXY="http://proxy.local:8080"
set HTTP_PROXY=http://proxy.local:8080

MacOS Terminal shortcuts accelerate workflow navigation:

  • Cmd+T / Cmd+W: Open / Close tabs
  • Cmd+Option+Arrows: Cycle spaces/displays
  • Ctrl+U / Ctrl+L: Clear buffer / Refresh view
  • Select text automatically copies; middle-click pastes.

Tags: linux-shell vim-editor system-administration network-diagnostics process-monitoring

Posted on Thu, 02 Jul 2026 16:49:35 +0000 by bsfischer