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.
Sections6
File Management
5 snippetsFundamental 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
Quando usar: When you need to view all files with detailed information, including hidden files (starting with .)
ls -lahCopy Files Recursively
Copies directories and their content recursively, preserving attributes
Quando usar: For backing up entire directories or duplicating folder structures
cp -r /origem /destinoMove or Rename Files
Moves files/directories or renames if destination is in the same directory
Quando usar: To organize files or rename them directly via the terminal
mv arquivo.txt /novo/caminho/
mv arquivo_antigo.txt arquivo_novo.txtFind Files by Name
Locates files in the system recursively using glob patterns
Quando usar: When you need to locate specific files in large directory structures
find /caminho -name "*.log"
find . -type f -name "config*"Create nested directories
Creates multiple levels of directories at once
Quando usar: To quickly create complex folder structures without needing to create each level manually
mkdir -p /projeto/src/components/uiPermissions and Ownership
4 snippetsFile and directory access control using chmod, chown, and umask.
Change Permissions Numerically
Sets permissions using octal notation (rwx = 7, rw- = 6, r-x = 5)
Quando usar: 755 for executables (rwxr-xr-x), 644 for data files (rw-r--r--)
chmod 755 script.sh
chmod 644 arquivo.txtChange Permissions Symbolically
Modifies permissions using symbolic notation (u=user, g=group, o=others)
Quando usar: When you want to modify specific permissions without changing others
chmod u+x script.sh
chmod go-w arquivo.txtChange Owner Recursively
Changes the owner and group of files/directories recursively
Quando usar: To correct permissions after deployment or web server configuration
chown -R usuario:grupo /var/www/htmlView Octal Permissions
Displays file permissions in numeric format
Quando usar: To quickly check the numeric value of current permissions
stat -c '%a %n' arquivo.txtProcess Management
5 snippetsMonitoring, controlling, and manipulating running processes on the system.
List User Processes
Displays all processes of the current user with CPU and memory details
Quando usar: To identify PIDs of specific processes or diagnose resource usage
ps aux | grep usuario
ps -ef | grep nginxMonitor Processes in Real-time
Interactive interface with real-time process updates
Quando usar: For continuous monitoring of CPU, memory, and identifying problematic processes
top
htopKill Process by PID
Terminates process using different signal levels
Quando usar: kill for graceful termination, kill -9 to force immediate termination
kill 1234
kill -9 1234
kill -SIGTERM 1234Kill Process by Name
Terminates all processes matching the name
Quando usar: When you know the process name but not the PID
pkill nginx
killall nodeRun process in background
Starts process in the background, freeing up the terminal
Quando usar: To run long scripts without blocking the terminal (nohup keeps it running after logout)
npm run dev &
nohup python3 script.py &Network and Connectivity
5 snippetsTools for network diagnostics, file transfer, and connectivity testing.
Test Connectivity
Sends ICMP packets to check if the host is reachable
Quando usar: To check network connectivity and latency (-c limits the number of packets)
ping -c 4 google.com
ping 192.168.1.1Download Files
Downloads files from the web via HTTP/HTTPS
Quando usar: wget for simple downloads, curl for APIs and more complex requests
wget https://example.com/file.zip
curl -O https://example.com/file.tar.gzView Ports in Use
Lists all open TCP/UDP ports and associated processes
Quando usar: To identify port conflicts or check if a service is listening
netstat -tulpn
ss -tulpnSecure Transfer (SCP)
Copies files between machines via SSH
Quando usar: To securely transfer files between servers (use -r for directories)
scp arquivo.txt user@servidor:/path/
scp -r /pasta user@servidor:/destinoCheck External IP
Discovers the machine's public IP address
Quando usar: To know your public IP when working remotely or configuring firewalls
curl ifconfig.me
wget -qO- ifconfig.mePackage Management
5 snippetsInstalling, updating, and removing software using package managers (APT/YUM).
Update Package List (Debian/Ubuntu)
Synchronizes the list of available packages with repositories
Quando usar: Always before installing new packages to ensure updated versions
sudo apt updateInstall Package (Debian/Ubuntu)
Downloads and installs package with all dependencies
Quando usar: To install software via official repositories (-y automatically confirms)
sudo apt install nginx -yUpdate System (Debian/Ubuntu)
Updates all installed packages to newer versions
Quando usar: Regular system maintenance for security patches and improvements
sudo apt update && sudo apt upgrade -yRemove Package (Debian/Ubuntu)
Uninstalls package, keeping configuration files
Quando usar: remove keeps configs, purge removes everything (useful for clean reinstallation)
sudo apt remove pacote
sudo apt purge pacoteSearch packages (Debian/Ubuntu)
Searches for available packages in repositories
Quando usar: To find the exact package name before installing
apt search python3
apt-cache search nodejsSystem Information
6 snippetsCommands for getting hardware, OS, and resource usage information.
Disk Usage
Displays used and available space on all mounted partitions
Quando usar: To check for sufficient disk space (-h displays in human-readable format)
df -hDirectory Size
Calculates total size of directories and files
Quando usar: To identify which directories are consuming the most space
du -sh /var/log
du -h --max-depth=1 /homeMemory Usage
Shows RAM and swap usage in human-readable format
Quando usar: To diagnose memory issues or check if swap is being used
free -hCPU Information
Displays processor details (model, cores, frequency)
Quando usar: To check hardware specifications before optimizations
lscpu
cat /proc/cpuinfoSystem uptime
Shows how long the system has been running and average load
Quando usar: To check server stability and load average
uptimeSystem version
Identifies Linux distribution and kernel version
Quando usar: To document environment or check software compatibility
uname -a
cat /etc/os-releaseRelated cheatsheets
Get-LocationPowerShell: Automate the Boring Stuff
GUIs are for amateurs. Master the One-Liners and Pipelines that manage 100 servers simultaneously. Stop clicking windows and start treating your infrastructure as code.
git status -sGit: The Emergency Kit
Messed up the code? Save this guide. Essential commands to undo mistakes, revert commits and save your job.
docker --versionDocker: Production Commands
Forget manual configuration. Copy and paste commands to spin up containers, clean volumes and deploy in record time.