Linux

Boost Workflow Efficiency With 50 Essential Linux Commands

Tech Setup5 min read
TS

Tech Setup

Published September 17, 2026 · Editorial policy

Boost Workflow Efficiency With 50 Essential Linux Commands

You are three hours deep into debugging a CI/CD pipeline failure on a remote Ubuntu 22.04 server, and your terminal history search is failing you. Instead of swiftly navigating directories, filtering logs, and checking process states, you are wasting mental energy trying to remember the exact syntax for awk, find, or tar. This reference manual cuts through the noise, delivering 50 essential Linux commands grouped by real-world developer workflows so you can stop Googling basic syntax and stay in the flow.

Getting around the filesystem and manipulating files is the bedrock of any daily development workflow.

Moving and Inspecting

# Print your current working directory
pwd
# Output: /home/developer/projects/backend-api

# List all files, including hidden dotfiles, with long formatting and human-readable sizes
ls -la
# Output:
# drwxr-xr-x  6 developer developer 4096 Oct 24 10:15 .
# drwxr-xr-x 12 developer developer 4096 Oct 24 09:00 ..
# -rw-r--r--  1 developer developer  220 Oct 24 09:00 .env.example
# drwxr-xr-x  8 developer developer 4096 Oct 24 11:30 src

# Change directory to your home folder
cd ~

# Move up one directory level
cd ..
  • pwd: Outputs the absolute path of your current directory.
  • ls -la: -l provides permissions, owner, size, and timestamp; -a reveals hidden configuration files like .env or .gitignore.
  • cd: Navigates directories. cd - returns you to your previous directory instantly.

Creating, Copying, and Deleting

# Create a nested directory structure in one go
mkdir -p src/components/auth

# Create an empty file or update its timestamp
touch app.js

# Copy a file and preserve its modification timestamps
cp -p .env.example .env

# Move or rename a file
mv app.js server.js

# Forcefully remove a directory and its contents recursively
rm -rf dist/
  • mkdir -p: The -p flag prevents errors if the parent directories already exist and builds the full tree silently.
  • cp -p: Crucial for deployment scripts where file timestamps matter for build tools like Make or Webpack.
  • rm -rf: Use with extreme caution. Omitting -r on a directory will throw an error; omitting it on a file is fine.

Searching and Filtering

When log files span gigabytes, manual inspection fails. These utilities parse text streams and locate files instantly.

Locating Files and Text

# Find all TypeScript files modified in the last 7 days
find src/ -name "*.ts" -mtime -7

# Search for the string "database_url" case-insensitively across the codebase
grep -rnwi "database_url" src/

# Search using ripgrep (faster alternative respecting .gitignore)
rg "database_url" src/
  • find src/ -name "*.ts" -mtime -7: Traverses src/, filters by extension, and restricts results to files modified within 7 days.
  • grep -rnwi: -r is recursive, -n prints line numbers, -w matches whole words, and -i ignores case.
  • rg: Ripgrep ignores files specified in .gitignore by default, making it dramatically faster for large codebases.

Processing Streams with Awk and Sed

# Print only the first and third columns of a space-delimited log file
awk '{print $1, $3}' access.log

# Replace all instances of "localhost:3000" with "api.internal" in a config file
sed -i 's/localhost:3000/api.internal/g' config.json
  • awk '{print $1, $3}': Treats whitespace as a delimiter and extracts specific columns. Essential for parsing Nginx access logs.
  • sed -i: The -i flag edits the file in place. Always back up the file or test without -i first.

System Monitoring and Process Management

A runaway Node.js process or an exhausted memory pool will grind your development server to a halt.

Inspecting Resources and Processes

# Display real-time CPU and memory utilization (press 'q' to exit)
htop

# Find the Process ID (PID) listening on port 8080
lsof -i :8080
# Output:
# COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
# node    41292 developer   21u  IPv6 981243      0t0  TCP *:http-alt (LISTEN)

# Gracefully terminate a process by its PID
kill 15 41292

# Forcefully kill a stuck process
kill -9 41292
  • htop: An interactive process viewer. If not installed on Ubuntu/Debian, run sudo apt install htop.
  • lsof -i :8080: Essential when you get an EADDRINUSE error trying to spin up a local development server.
  • kill -9: Sends the SIGKILL signal, bypassing cleanup routines. Use only when kill 15 (SIGTERM) fails.

Disk Usage

# Check available disk space in human-readable format
df -h
# Output:
# Filesystem      Size  Used Avail Use% Mounted on
# /dev/sda1        50G   42G   5.6G  89% /

# Estimate space consumed by the current directory and its subdirectories
du -sh node_modules/
  • df -h: Look here first when Docker builds fail due to "No space left on device".
  • du -sh: Summarize (-s) in human-readable units (-h) to find which directory is bloating your disk.

Networking and Remote Access

Developers live in remote environments, containers, and cloud VMs. These commands diagnose network bottlenecks and manage secure connections.

Connectivity and Diagnostics

# Test if a remote host is reachable and responding to ICMP
ping -c 4 8.8.8.8

# Inspect network interfaces and IP addresses
ip a

# Check which processes are listening on TCP/UDP ports
ss -tulpn
  • ping -c 4: The -c 4 flag stops the ping after 4 packets, preventing an infinite loop.
  • ip a: Replaces the legacy ifconfig. Displays network interfaces and assigned IPs.
  • ss -tulpn: Replaces netstat. Lists listening sockets with associated PIDs (-p) and numerical ports (-n).

Secure Shell and File Transfer

# Connect to a remote server using a specific private key on a custom port
ssh -i ~/.ssh/id_ed25519 -p 2222 developer@192.168.1.50

# Securely copy a local build artifact to a remote server
scp -P 2222 dist.tar.gz developer@192.168.1.50:/var/www/html/

# Synchronize directories efficiently over SSH (local to remote)
rsync -avz --progress -e 'ssh -p 2222' ./build/ developer@192.168.1.50:/var/www/html/
  • ssh -i: Always prefer Ed25519 or RSA keys over password authentication.
  • rsync: The gold standard for deployments. -a preserves file permissions and timestamps, -v is verbose, -z compresses data during transfer, and --progress shows a live transfer bar.

Package Management and Environment

Managing system dependencies cleanly prevents dependency hell across different Linux distributions.

Package Managers (Debian/Ubuntu vs. RHEL/CentOS)

# Update local package index and upgrade installed packages (Debian/Ubuntu)
sudo apt update && sudo apt upgrade -y

# Install a utility package without prompt
sudo apt install -y curl git build-essential

# Remove unused packages and clear local cache
sudo apt autoremove -y && sudo apt clean

# Install a package on RedHat/CentOS/Fedora systems
sudo dnf install -y nginx
  • apt update && apt upgrade -y: Always update your package lists before installing new software to avoid missing dependency versions.
  • sudo apt autoremove: Removes orphaned packages left behind when dependencies are uninstalled.

Environment Variables and Path

# Print the value of a specific environment variable
echo $PATH

# Temporarily set an environment variable for the current session
export NODE_ENV=production

# Persistently set an environment variable for future sessions
echo 'export DATABASE_URL="postgres://user:pass@localhost:5432/db"' >> ~/.bashrc
source ~/.bashrc
  • export: Changes apply only to the current terminal session unless written to shell configuration files (.bashrc or .zshrc).
  • source ~/.bashrc: Reloads your shell profile instantly without opening a new terminal window.

Archiving and Compression

Bundling logs, backups, or project folders for transfer requires reliable archiving tools.

Tarballs and Zipping

# Create a compressed gzip archive of a project directory
tar -czvf project-backup.tar.gz src/ package.json

# Extract a tarball into a specific destination directory
tar -xzvf project-backup.tar.gz -C /var/www/

# Create a zip archive (useful for sharing with non-Linux users)
zip -r archive.zip src/ .env

# Extract a zip archive
unzip archive.zip -d extracted_files/
  • tar -czvf: -c creates, -z compresses with gzip, -v lists files verbosely, and -f specifies the output filename. Always put -f last, immediately followed by the filename.
  • tar -xzvf: The -x flag extracts the archive. Use -C to direct output to a specific path without changing directories first.

Text Manipulation and Inspection

Viewing file contents without opening a full editor keeps your workflow moving.

Reading and Slicing Files

# Output the entire file to the terminal
cat package.json

# View a large log file interactively (use spacebar to scroll, 'q' to quit)
less /var/log/syslog

# Print only the first 20 lines of a file
head -n 20 error.log

# Stream new lines appended to a log file in real time
tail -f /var/log/nginx/access.log
  • less: Much safer and faster than cat or text editors when inspecting multi-gigabyte log files.
  • tail -f: Essential for monitoring live application behavior during debugging or load testing.

Permissions and Ownership

Permission denied errors stall deployments instantly. Correcting them requires precise ownership and mode adjustments.

Changing Modes and Owners

# Grant read, write, and execute permissions to the file owner only
chmod 700 deploy.sh

# Recursively grant read and execute permissions for directories, read for files
chmod -R 755 /var/www/html

# Recursively change file ownership to the current user and web group
sudo chown -R developer:www-data /var/www/html
  • chmod 700: Numeric permissions break down as Owner (7 = rwx), Group (0 = none), and Others (0 = none).
  • chown -R: The colon separates user and group. Running this via sudo is required when modifying system-owned directories like /var/www or /etc.

Command Line Productivity Shortcuts

Speeding up your terminal usage reduces friction during high-pressure debugging sessions.

History, Aliases, and Multiplexing

# Search through your command history interactively
# Press Ctrl+R and start typing part of a previous command

# Execute the last run command with sudo privileges
sudo !!

# Create a permanent alias in ~/.bashrc for quick directory jumping
alias ll='ls -alF'

# Start a terminal multiplexer session to prevent dropped SSH connections from killing processes
tmux new -s debug-session

# Detach from a tmux session (press Ctrl+B, then d)
# Reattach to a running tmux session later
tmux attach -t debug-session
  • Ctrl+R: The single most effective shortcut for retrieving long commands you ran hours or days ago.
  • sudo !!: Saves re-typing a long command when you realize halfway through that it requires root privileges.
  • tmux: Non-negotiable for remote development. If your internet drops, your long-running build or script keeps executing safely inside the detached session.

If This Doesn't Work

Even with the right commands, environment quirks can cause failures.

  • Command not found: If standard utilities like wget, dig, or jq throw a "command not found" error, your PATH variable may be misconfigured, or the package is simply missing. Run sudo apt install <package-name> (or your distribution's equivalent) to install it.
  • Permission denied on scripts: If executing a custom bash script throws Permission denied, you forgot to make it executable. Run chmod +x script.sh before running ./script.sh.
  • Port already in use: If a service fails to bind to a port, find the rogue process using sudo lsof -i :<port> and terminate it with sudo kill -9 <PID>.

Keep this reference bookmarked in your terminal workflow, and use shell aliases to build muscle memory around these exact flags.