DevOps

Linux Terminal: Vital Commands

Lose the fear of the black screen. Navigate folders, manage files and control the server without touching the mouse. Survival basics.

6 sections30 snippetsIntermediate12 Apr 2026

File Management

Fundamental commands for navigating and manipulating files and directories on Linux.

List Detailed Files

Lists all files including hidden ones with permission, size, and date details

bash
ls -lah

When to useWhen you need to view all files with detailed information, including hidden files (starting with .)

Copy Files Recursively

Copies directories and their content recursively, preserving attributes

bash
cp -r /origem /destino

When to useFor backing up entire directories or duplicating folder structures

Move or Rename Files

Moves files/directories or renames if destination is in the same directory

bash
mv arquivo.txt /novo/caminho/
mv arquivo_antigo.txt arquivo_novo.txt

When to useTo organize files or rename them directly via the terminal

Find Files by Name

Locates files in the system recursively using glob patterns

bash
find /caminho -name "*.log"
find . -type f -name "config*"

When to useWhen you need to locate specific files in large directory structures

Create nested directories

Creates multiple levels of directories at once

bash
mkdir -p /projeto/src/components/ui

When to useTo quickly create complex folder structures without needing to create each level manually

Permissions and Ownership

File and directory access control using chmod, chown, and umask.

Change Permissions Numerically

Sets permissions using octal notation (rwx = 7, rw- = 6, r-x = 5)

bash
chmod 755 script.sh
chmod 644 arquivo.txt

When to use755 for executables (rwxr-xr-x), 644 for data files (rw-r--r--)

Change Permissions Symbolically

Modifies permissions using symbolic notation (u=user, g=group, o=others)

bash
chmod u+x script.sh
chmod go-w arquivo.txt

When to useWhen you want to modify specific permissions without changing others

Change Owner Recursively

Changes the owner and group of files/directories recursively

bash
chown -R usuario:grupo /var/www/html

When to useTo correct permissions after deployment or web server configuration

View Octal Permissions

Displays file permissions in numeric format

bash
stat -c '%a %n' arquivo.txt

When to useTo quickly check the numeric value of current permissions

Process Management

Monitoring, controlling, and manipulating running processes on the system.

List User Processes

Displays all processes of the current user with CPU and memory details

bash
ps aux | grep usuario
ps -ef | grep nginx

When to useTo identify PIDs of specific processes or diagnose resource usage

Monitor Processes in Real-time

Interactive interface with real-time process updates

bash
top
htop

When to useFor continuous monitoring of CPU, memory, and identifying problematic processes

Kill Process by PID

Terminates process using different signal levels

bash
kill 1234
kill -9 1234
kill -SIGTERM 1234

When to usekill for graceful termination, kill -9 to force immediate termination

Kill Process by Name

Terminates all processes matching the name

bash
pkill nginx
killall node

When to useWhen you know the process name but not the PID

Run process in background

Starts process in the background, freeing up the terminal

bash
npm run dev &
nohup python3 script.py &

When to useTo run long scripts without blocking the terminal (nohup keeps it running after logout)

Network and Connectivity

Tools for network diagnostics, file transfer, and connectivity testing.

Test Connectivity

Sends ICMP packets to check if the host is reachable

bash
ping -c 4 google.com
ping 192.168.1.1

When to useTo check network connectivity and latency (-c limits the number of packets)

Download Files

Downloads files from the web via HTTP/HTTPS

bash
wget https://example.com/file.zip
curl -O https://example.com/file.tar.gz

When to usewget for simple downloads, curl for APIs and more complex requests

View Ports in Use

Lists all open TCP/UDP ports and associated processes

bash
netstat -tulpn
ss -tulpn

When to useTo identify port conflicts or check if a service is listening

Secure Transfer (SCP)

Copies files between machines via SSH

bash
scp arquivo.txt user@servidor:/path/
scp -r /pasta user@servidor:/destino

When to useTo securely transfer files between servers (use -r for directories)

Check External IP

Discovers the machine's public IP address

bash
curl ifconfig.me
wget -qO- ifconfig.me

When to useTo know your public IP when working remotely or configuring firewalls

Package Management

Installing, updating, and removing software using package managers (APT/YUM).

Update Package List (Debian/Ubuntu)

Synchronizes the list of available packages with repositories

bash
sudo apt update

When to useAlways before installing new packages to ensure updated versions

Install Package (Debian/Ubuntu)

Downloads and installs package with all dependencies

bash
sudo apt install nginx -y

When to useTo install software via official repositories (-y automatically confirms)

Update System (Debian/Ubuntu)

Updates all installed packages to newer versions

bash
sudo apt update && sudo apt upgrade -y

When to useRegular system maintenance for security patches and improvements

Remove Package (Debian/Ubuntu)

Uninstalls package, keeping configuration files

bash
sudo apt remove pacote
sudo apt purge pacote

When to useremove keeps configs, purge removes everything (useful for clean reinstallation)

Search packages (Debian/Ubuntu)

Searches for available packages in repositories

bash
apt search python3
apt-cache search nodejs

When to useTo find the exact package name before installing

System Information

Commands for getting hardware, OS, and resource usage information.

Disk Usage

Displays used and available space on all mounted partitions

bash
df -h

When to useTo check for sufficient disk space (-h displays in human-readable format)

Directory Size

Calculates total size of directories and files

bash
du -sh /var/log
du -h --max-depth=1 /home

When to useTo identify which directories are consuming the most space

Memory Usage

Shows RAM and swap usage in human-readable format

bash
free -h

When to useTo diagnose memory issues or check if swap is being used

CPU Information

Displays processor details (model, cores, frequency)

bash
lscpu
cat /proc/cpuinfo

When to useTo check hardware specifications before optimizations

System uptime

Shows how long the system has been running and average load

bash
uptime

When to useTo check server stability and load average

System version

Identifies Linux distribution and kernel version

bash
uname -a
cat /etc/os-release

When to useTo document environment or check software compatibility

  • #linux
  • #bash
  • #shell
  • #cli
  • #terminal
  • #devops
← All cheatsheets