{"id":254,"date":"2016-02-25T15:36:54","date_gmt":"2016-02-25T20:36:54","guid":{"rendered":"http:\/\/underhost.com\/blog\/?p=254"},"modified":"2026-07-20T14:34:13","modified_gmt":"2026-07-20T18:34:13","slug":"common-ssh-commands-or-linux-shell-commands","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/common-ssh-commands-or-linux-shell-commands\/","title":{"rendered":"Common SSH Commands or Linux Shell Commands"},"content":{"rendered":"<p><!-- UnderHost Blog Hero --><\/p>\n<div class=\"uh-blog-hero\" style=\"margin-bottom: 40px; text-align: center; padding: 48px 24px; border-radius: 22px; background: linear-gradient(135deg,#0A1220 0%,#0D1B30 42%,#0F2040 72%,#071428 100%); color: #ffffff; box-shadow: 0 20px 50px rgba(0,0,0,0.18); position: relative; overflow: hidden;\">\n<div style=\"display: inline-block; padding: 6px 14px; margin-bottom: 16px; border: 1px solid rgba(0,212,255,0.28); border-radius: 999px; color: #00d4ff; font-size: 0.86em; letter-spacing: 0.06em; text-transform: uppercase; background: rgba(0,212,255,0.08);\">Linux Server Administration<\/div>\n<h1 style=\"color: #ffffff; font-size: 2.5em; line-height: 1.15; margin: 0 0 14px; font-weight: 800;\">Common SSH Commands and Linux Shell Commands<\/h1>\n<h2 style=\"color: #b8c7d9; font-size: 1.32em; line-height: 1.45; margin: 0 0 18px; font-weight: 500;\">A practical command-line reference for VPS, dedicated server, and Linux hosting administration<\/h2>\n<p style=\"font-size: 1.1em; color: #f8fafc; max-width: 820px; margin: 0 auto; line-height: 1.75;\">Learn how to connect securely, manage files, inspect services, troubleshoot network problems, review logs, monitor resources, maintain packages, and protect your Linux server.<\/p>\n<\/div>\n<p><!-- Lead Summary --><\/p>\n<div class=\"uh-blog-excerpt\" style=\"border-left: 4px solid #00D4FF; padding: 20px 22px; margin: 0 0 32px; background: #F8F9FA; color: #334155; border-radius: 0 14px 14px 0; box-shadow: 0 10px 20px rgba(0,145,214,0.08); line-height: 1.75;\"><strong style=\"color: #0a1220;\">SSH gives administrators direct and encrypted access to a Linux server.<\/strong><br \/>\nWith the commands in this guide, you can manage a<br \/>\n<a style=\"color: #0091d6; font-weight: 600; text-decoration: none;\" href=\"https:\/\/underhost.com\/cloud-vps.php\">Cloud VPS<\/a>,<br \/>\n<a style=\"color: #0091d6; font-weight: 600; text-decoration: none;\" href=\"https:\/\/underhost.com\/offshore-vps.php\">Offshore VPS<\/a>,<br \/>\nor<br \/>\n<a style=\"color: #0091d6; font-weight: 600; text-decoration: none;\" href=\"https:\/\/underhost.com\/dedicated-servers-offshore.php\">dedicated server<\/a><br \/>\nwithout relying entirely on a graphical control panel.<\/div>\n<p><!-- Important Warning --><\/p>\n<div style=\"padding: 22px; margin: 0 0 34px; border: 1px solid #F59E0B; border-radius: 16px; background: #FFFBEB; color: #78350f; line-height: 1.7;\"><strong style=\"display: block; margin-bottom: 6px; color: #92400e;\">Important command-line safety notice<\/strong><br \/>\nCommands executed as <code>root<\/code> or through <code>sudo<\/code> can modify the entire server. Confirm the command, path, filename, and backup status before deleting files, changing permissions recursively, modifying firewall rules, or restarting production services.<\/div>\n<p><!-- Table of Contents --><\/p>\n<div style=\"padding: 24px; margin: 0 0 38px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 18px; box-shadow: 0 12px 30px rgba(10,18,32,0.07);\">\n<h2 style=\"margin: 0 0 16px; color: #0a1220; font-size: 1.55em;\">Command categories covered<\/h2>\n<div style=\"display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 10px 24px; line-height: 1.65;\"><a style=\"color: #0091d6; text-decoration: none;\" href=\"#ssh-connections\">SSH connections and keys<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#server-information\">Server and OS information<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#navigation\">Directory navigation<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#files-directories\">Files and directories<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#view-edit-files\">Viewing and editing files<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#searching\">Searching files and text<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#permissions\">Permissions and ownership<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#users\">Users and groups<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#packages\">Package management<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#services\">Services and systemd<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#processes\">Processes and resources<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#disk-storage\">Disk and storage<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#networking\">Networking and DNS<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#firewall\">Firewall commands<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#logs\">Logs and troubleshooting<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#transfers-backups\">Transfers and backups<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#archives\">Archives and compression<\/a><br \/>\n<a style=\"color: #0091d6; text-decoration: none;\" href=\"#cron\">Cron jobs<\/a><\/div>\n<\/div>\n<div class=\"uh-post-content\" style=\"color: #334155; font-size: 1.02em; line-height: 1.75;\">\n<h2 id=\"ssh-connections\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 38px; line-height: 1.25;\">1. SSH connection commands<\/h2>\n<p>SSH, or Secure Shell, creates an encrypted connection between your computer and a remote Linux server. Most Linux VPS and dedicated server administration begins with the <code>ssh<\/code> command.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Connect using the default SSH port<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh username@server_ip<\/code><\/pre>\n<p>Example:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh root@203.0.113.10<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Connect using a custom SSH port<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh -p 2222 username@server_ip<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Connect using a private key<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh -i ~\/.ssh\/server_key username@server_ip<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a modern SSH key pair<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh-keygen -t ed25519 -a 100<\/code><\/pre>\n<p>Store the private key securely and protect it with a strong passphrase. Never send a private SSH key through email, chat, or a support ticket.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Copy your public key to the server<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh-copy-id username@server_ip<\/code><\/pre>\n<p>For a custom SSH port:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh-copy-id -p 2222 username@server_ip<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Test the SSH connection with detailed output<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh -vvv username@server_ip<\/code><\/pre>\n<p>Verbose output helps diagnose authentication failures, key problems, connection timeouts, and SSH negotiation errors.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Keep an idle SSH connection alive<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh -o ServerAliveInterval=60 username@server_ip<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run one command remotely<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ssh username@server_ip \"uptime\"<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Close the SSH session<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>exit<\/code><\/pre>\n<div style=\"margin: 26px 0; padding: 18px 20px; border-left: 4px solid #00D4FF; background: #F8FAFC; border-radius: 0 12px 12px 0;\"><strong style=\"color: #0a1220;\">SSH hardening tip:<\/strong><br \/>\nBefore disabling password authentication or direct root access, confirm that key-based authentication works in a second terminal window. Incorrect SSH changes can lock you out of the server.<\/div>\n<h2 id=\"server-information\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">2. Check server, operating system, and kernel information<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the hostname<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>hostname<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show detailed hostname information<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>hostnamectl<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change the server hostname<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo hostnamectl set-hostname server.example.com<\/code><\/pre>\n<p>Also review <code>\/etc\/hosts<\/code> after changing a hostname so local hostname resolution remains correct.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the Linux distribution and version<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cat \/etc\/os-release<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show kernel and architecture information<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>uname -a<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>uname -r<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>uname -m<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show CPU information<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>lscpu<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show memory information<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>free -h<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show server uptime and load averages<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>uptime<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the current date and timezone<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>date<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>timedatectl<\/code><\/pre>\n<h2 id=\"navigation\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">3. Navigate the Linux filesystem<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Display the current directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>pwd<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List files and directories<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ls<\/code><\/pre>\n<p>Detailed list with hidden files and readable sizes:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ls -lah<\/code><\/pre>\n<p>Sort by modification time:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ls -lath<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cd \/path\/to\/directory<\/code><\/pre>\n<p>Go to your home directory:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cd ~<\/code><\/pre>\n<p>Go up one directory:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cd ..<\/code><\/pre>\n<p>Return to the previous directory:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cd -<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Display a directory tree<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tree -L 2 \/var\/www<\/code><\/pre>\n<p>The <code>tree<\/code> package may need to be installed first.<\/p>\n<h2 id=\"files-directories\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">4. Create, copy, move, and delete files<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create an empty file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>touch filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mkdir directory_name<\/code><\/pre>\n<p>Create nested directories:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mkdir -p \/var\/www\/example.com\/public<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Copy a file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cp source.txt destination.txt<\/code><\/pre>\n<p>Copy a directory recursively while preserving attributes:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cp -a source_directory\/ destination_directory\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Move or rename a file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mv old_name.txt new_name.txt<\/code><\/pre>\n<p>Move a file into another directory:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mv file.txt \/path\/to\/destination\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Delete a file interactively<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rm -i filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Remove an empty directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rmdir directory_name<\/code><\/pre>\n<div style=\"margin: 26px 0; padding: 20px; border: 1px solid #FCA5A5; background: #FEF2F2; border-radius: 14px; color: #7f1d1d;\"><strong style=\"display: block; margin-bottom: 7px;\">Be careful with recursive deletion<\/strong><br \/>\nCommands such as <code>rm -rf<\/code> can permanently remove entire directories without confirmation. Verify the full path with <code>pwd<\/code> and <code>ls<\/code>, and confirm that a usable backup or snapshot exists before deleting production data.<\/div>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a symbolic link<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ln -s \/actual\/path \/path\/to\/link<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect a file type<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>file filename<\/code><\/pre>\n<h2 id=\"view-edit-files\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">5. View and edit text files<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Display the complete file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>cat filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Read a long file one screen at a time<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>less filename.txt<\/code><\/pre>\n<p>Inside <code>less<\/code>, press <code>\/<\/code> to search, <code>n<\/code> for the next match, and <code>q<\/code> to quit.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the first lines<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>head -n 20 filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the last lines<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tail -n 50 filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Follow a file as new lines are added<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tail -f \/var\/log\/application.log<\/code><\/pre>\n<p>Start with the latest 100 lines and continue following:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tail -n 100 -f \/var\/log\/application.log<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Edit with Nano<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>nano filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Edit with Vim<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>vim filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Write output to a file as root<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>echo \"configuration=value\" | sudo tee \/etc\/example.conf<\/code><\/pre>\n<p>Append instead of overwriting:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>echo \"new line\" | sudo tee -a \/etc\/example.conf<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Compare two files<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>diff -u old.conf new.conf<\/code><\/pre>\n<h2 id=\"searching\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">6. Search for files, directories, and text<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Find a file by name<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>find \/path\/to\/search -type f -name \"filename.conf\"<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Find files case-insensitively<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>find \/var\/www -type f -iname \"*.php\"<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Find large files<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>find \/var -type f -size +500M -printf '%s %p\\n' 2&gt;\/dev\/null | sort -nr | head<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Find files modified within one day<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>find \/var\/www -type f -mtime -1<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search for text inside a file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>grep \"search text\" filename.txt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search recursively and include line numbers<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>grep -Rni \"search text\" \/path\/to\/directory<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search using an extended regular expression<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>grep -E \"error|failed|critical\" application.log<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Exclude comments and blank lines<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>grep -Ev '^[[:space:]]*(#|$)' \/etc\/ssh\/sshd_config<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Locate a command<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command -v nginx<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>which php<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search command history<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>history | grep systemctl<\/code><\/pre>\n<p>You can also press <code>Ctrl+R<\/code> in Bash and begin typing part of a previous command.<\/p>\n<h2 id=\"permissions\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">7. Linux permissions and ownership<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">View permissions and ownership<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ls -l filename<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change file permissions<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>chmod 644 filename<\/code><\/pre>\n<p>Typical permissions:<\/p>\n<ul style=\"padding-left: 22px;\">\n<li><code>644<\/code> for normal public files<\/li>\n<li><code>755<\/code> for directories<\/li>\n<li><code>600<\/code> for sensitive private files<\/li>\n<li><code>700<\/code> for private directories or scripts accessible only by the owner<\/li>\n<\/ul>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Make a script executable<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>chmod +x script.sh<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change owner and group<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo chown user:group filename<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change ownership recursively<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo chown -R user:group \/specific\/directory<\/code><\/pre>\n<div style=\"margin: 26px 0; padding: 20px; border: 1px solid #FCA5A5; background: #FEF2F2; border-radius: 14px; color: #7f1d1d;\"><strong style=\"display: block; margin-bottom: 7px;\">Avoid blind recursive permission changes<\/strong><br \/>\nDo not run recursive <code>chmod<\/code> or <code>chown<\/code> commands against <code>\/<\/code>, <code>\/etc<\/code>, <code>\/usr<\/code>, or an entire hosting account unless you fully understand the required ownership model. Incorrect ownership can break websites, services, SSH access, and control panels.<\/div>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect permissions on every part of a path<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>namei -l \/var\/www\/example.com\/public\/index.php<\/code><\/pre>\n<h2 id=\"users\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">8. Manage Linux users and groups<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the current user<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>whoami<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show user and group IDs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>id username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show logged-in users<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>w<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>who<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a user on Debian or Ubuntu<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo adduser username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a user on AlmaLinux, Rocky Linux, or RHEL<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo useradd -m username\r\nsudo passwd username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Give sudo access on Debian or Ubuntu<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo usermod -aG sudo username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Give administrative access on AlmaLinux or Rocky Linux<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo usermod -aG wheel username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Change a password<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo passwd username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Lock and unlock a user account<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo passwd -l username\r\nsudo passwd -u username<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Safely edit sudo rules<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo visudo<\/code><\/pre>\n<h2 id=\"packages\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">9. Install and update Linux packages<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Debian and Ubuntu package commands<\/h3>\n<p>Refresh package metadata:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo apt update<\/code><\/pre>\n<p>Install available upgrades:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo apt upgrade<\/code><\/pre>\n<p>Install a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo apt install package_name<\/code><\/pre>\n<p>Remove a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo apt remove package_name<\/code><\/pre>\n<p>Search for a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>apt search package_name<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">AlmaLinux, Rocky Linux, and RHEL package commands<\/h3>\n<p>Check for updates:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo dnf check-update<\/code><\/pre>\n<p>Install updates:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo dnf upgrade<\/code><\/pre>\n<p>Install a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo dnf install package_name<\/code><\/pre>\n<p>Remove a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo dnf remove package_name<\/code><\/pre>\n<p>Search for a package:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dnf search package_name<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Determine which package installed a file<\/h3>\n<p>Debian or Ubuntu:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dpkg -S \/path\/to\/file<\/code><\/pre>\n<p>AlmaLinux, Rocky Linux, or RHEL:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rpm -qf \/path\/to\/file<\/code><\/pre>\n<div style=\"margin: 26px 0; padding: 18px 20px; border-left: 4px solid #00D4FF; background: #F8FAFC; border-radius: 0 12px 12px 0;\"><strong style=\"color: #0a1220;\">Production update advice:<\/strong><br \/>\nReview pending updates, confirm backups, and schedule a maintenance window before performing major package or kernel upgrades on an active production server.<\/div>\n<h2 id=\"services\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">10. Manage services with systemd<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check service status<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl status nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Start, stop, or restart a service<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl start nginx\r\nsudo systemctl stop nginx\r\nsudo systemctl restart nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Reload configuration without a complete restart<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl reload nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Enable a service at boot<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl enable nginx<\/code><\/pre>\n<p>Enable and start immediately:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl enable --now nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Disable a service at boot<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl disable nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check whether a service is active or enabled<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>systemctl is-active nginx\r\nsystemctl is-enabled nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List failed services<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>systemctl --failed<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Validate configuration before restarting<\/h3>\n<p>Nginx:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo nginx -t<\/code><\/pre>\n<p>Apache on Debian or Ubuntu:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo apache2ctl configtest<\/code><\/pre>\n<p>Apache on AlmaLinux or Rocky Linux:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo httpd -t<\/code><\/pre>\n<p>OpenSSH:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo sshd -t<\/code><\/pre>\n<p>Always test configuration syntax before restarting a web server, SSH daemon, database service, or firewall.<\/p>\n<h2 id=\"processes\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">11. Monitor processes, CPU, and memory<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Interactive process monitoring<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>top<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>htop<\/code><\/pre>\n<p><code>htop<\/code> may need to be installed separately.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List all processes<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ps aux<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search for a specific process<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ps aux | grep nginx<\/code><\/pre>\n<p>A cleaner alternative:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>pgrep -a nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the highest CPU-consuming processes<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ps aux --sort=-%cpu | head<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the highest memory-consuming processes<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ps aux --sort=-%mem | head<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Send a normal termination signal<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>kill PID<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Forcefully terminate a process only when necessary<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>kill -9 PID<\/code><\/pre>\n<p>Use a normal <code>kill<\/code> first. Signal 9 prevents the application from completing cleanup or writing pending data.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect memory and system activity<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>vmstat 1 10<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect disk I\/O activity<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>iostat -xz 1 5<\/code><\/pre>\n<p>The <code>iostat<\/code> command is commonly provided by the <code>sysstat<\/code> package.<\/p>\n<h2 id=\"disk-storage\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">12. Check disk space, inodes, and storage devices<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show filesystem disk usage<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>df -hT<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show inode usage<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>df -ih<\/code><\/pre>\n<p>A filesystem can report \u201cNo space left on device\u201d even with free storage if all available inodes have been consumed by many small files.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check the size of one directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>du -sh \/path\/to\/directory<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the largest items in a directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>du -xh --max-depth=1 \/var | sort -h<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Display block devices and filesystems<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>lsblk -f<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List mounted filesystems<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>findmnt<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check current mounts<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mount | column -t<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check swap usage<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>swapon --show<\/code><\/pre>\n<h2 id=\"networking\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">13. Linux networking and DNS commands<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show IP addresses and interfaces<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ip address show<\/code><\/pre>\n<p>Short form:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ip a<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the routing table<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ip route<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show the route used to reach an IP<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ip route get 1.1.1.1<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Test basic connectivity<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ping -c 4 1.1.1.1<\/code><\/pre>\n<p>A failed ping does not always mean the host is offline because ICMP traffic may be filtered.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Trace the network path<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>traceroute example.com<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run an interactive route quality test<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mtr example.com<\/code><\/pre>\n<p>Generate a report suitable for troubleshooting:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>mtr -rwzc 100 example.com<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show listening ports and services<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ss -lntup<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Find the process using a port<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo lsof -i :80<\/code><\/pre>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ss -lntp 'sport = :443'<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Test whether a remote TCP port is reachable<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>nc -vz example.com 443<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Query DNS records<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig example.com A<\/code><\/pre>\n<p>Return only the resolved value:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig example.com A +short<\/code><\/pre>\n<p>Check nameservers:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig example.com NS +short<\/code><\/pre>\n<p>Check mail exchangers:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig example.com MX +short<\/code><\/pre>\n<p>Check reverse DNS:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig -x 203.0.113.10 +short<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect HTTP response headers<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>curl -I https:\/\/example.com<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Follow redirects and show the final response<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>curl -IL https:\/\/example.com<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Test a website against a specific server IP<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>curl -I --resolve example.com:443:203.0.113.10 https:\/\/example.com\/<\/code><\/pre>\n<p>This is useful before DNS changes or while troubleshooting a reverse proxy, migration, or virtual host.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Display the server&#8217;s public IP<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>curl -4 https:\/\/icanhazip.com<\/code><\/pre>\n<h2 id=\"firewall\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">14. Firewall commands<\/h2>\n<div style=\"margin: 20px 0 26px; padding: 20px; border: 1px solid #F59E0B; border-radius: 14px; background: #FFFBEB; color: #78350f;\"><strong style=\"display: block; margin-bottom: 7px; color: #92400e;\">Prevent an SSH lockout<\/strong><br \/>\nConfirm which SSH port is active and allow that port before enabling or reloading a firewall. Keep your existing SSH session open while testing a second connection.<\/div>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">UFW on Ubuntu or Debian<\/h3>\n<p>Show firewall status:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ufw status verbose<\/code><\/pre>\n<p>Allow standard SSH:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ufw allow OpenSSH<\/code><\/pre>\n<p>Allow a custom SSH port:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ufw allow 2222\/tcp<\/code><\/pre>\n<p>Allow HTTP and HTTPS:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ufw allow 80\/tcp\r\nsudo ufw allow 443\/tcp<\/code><\/pre>\n<p>Enable the firewall only after confirming the rules:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo ufw enable<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">firewalld on AlmaLinux or Rocky Linux<\/h3>\n<p>Show active rules:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo firewall-cmd --list-all<\/code><\/pre>\n<p>Allow HTTP and HTTPS permanently:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo firewall-cmd --permanent --add-service=http\r\nsudo firewall-cmd --permanent --add-service=https<\/code><\/pre>\n<p>Allow a custom SSH port:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo firewall-cmd --permanent --add-port=2222\/tcp<\/code><\/pre>\n<p>Reload after confirming all required rules:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo firewall-cmd --reload<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">View the active nftables ruleset<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo nft list ruleset<\/code><\/pre>\n<p>Avoid flushing an active firewall remotely unless you have console or out-of-band access and understand how the firewall is managed.<\/p>\n<h2 id=\"logs\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">15. Read logs and troubleshoot failed services<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show recent system errors<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo journalctl -p err -b<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show logs for one service<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo journalctl -u nginx<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show recent service logs and follow new entries<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo journalctl -u nginx -n 100 -f<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show logs from the current boot<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo journalctl -b<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Show logs from a specific period<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo journalctl --since \"2026-07-20 14:00\" --until \"2026-07-20 15:00\"<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Inspect kernel messages<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo dmesg -T | tail -n 100<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Authentication logs<\/h3>\n<p>Debian or Ubuntu:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo tail -n 100 \/var\/log\/auth.log<\/code><\/pre>\n<p>AlmaLinux or Rocky Linux:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo tail -n 100 \/var\/log\/secure<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Nginx logs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo tail -f \/var\/log\/nginx\/access.log\r\nsudo tail -f \/var\/log\/nginx\/error.log<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Apache logs on Debian or Ubuntu<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo tail -f \/var\/log\/apache2\/access.log\r\nsudo tail -f \/var\/log\/apache2\/error.log<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Apache logs on AlmaLinux or Rocky Linux<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo tail -f \/var\/log\/httpd\/access_log\r\nsudo tail -f \/var\/log\/httpd\/error_log<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Search compressed and active logs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>zgrep -i \"error\" \/var\/log\/application.log*<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check recent login history<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>last -a | head -n 30<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Check failed login attempts<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo lastb | head -n 30<\/code><\/pre>\n<h2 id=\"transfers-backups\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">16. Transfer and synchronize files<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Copy a local file to a remote server with SCP<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>scp file.tar.gz username@server_ip:\/remote\/path\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Download a remote file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>scp username@server_ip:\/remote\/path\/file.tar.gz .\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Use SCP with a custom SSH port<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>scp -P 2222 file.tar.gz username@server_ip:\/remote\/path\/<\/code><\/pre>\n<p>Notice that SCP uses uppercase <code>-P<\/code>, while SSH uses lowercase <code>-p<\/code>.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Synchronize a directory with rsync<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rsync -avh --progress source_directory\/ username@server_ip:\/remote\/path\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Use rsync through a custom SSH port<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rsync -avh --progress -e \"ssh -p 2222\" source_directory\/ username@server_ip:\/remote\/path\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Preview an rsync operation<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>rsync -avhn source_directory\/ destination_directory\/<\/code><\/pre>\n<p>The <code>-n<\/code> option performs a dry run without changing files. Use it before synchronization commands involving deletion or production directories.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Download a file with curl<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>curl -fLO https:\/\/example.com\/file.tar.gz<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Download a file with wget<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>wget https:\/\/example.com\/file.tar.gz<\/code><\/pre>\n<p>Only download installation scripts or software from trusted sources. Review scripts before running them with elevated privileges.<\/p>\n<h2 id=\"archives\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">17. Create and extract compressed archives<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a gzip-compressed tar archive<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tar -czf backup.tar.gz directory_name\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List archive contents before extracting<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tar -tzf backup.tar.gz<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Extract a tar.gz archive<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tar -xzf backup.tar.gz<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Extract into a specific directory<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tar -xzf backup.tar.gz -C \/destination\/path\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Create a ZIP archive<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>zip -r backup.zip directory_name\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Extract a ZIP archive<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>unzip backup.zip -d \/destination\/path\/<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Calculate a SHA-256 checksum<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sha256sum backup.tar.gz<\/code><\/pre>\n<p>Compare checksums before and after a transfer to verify file integrity.<\/p>\n<h2 id=\"cron\" style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">18. Schedule commands with cron<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Edit the current user&#8217;s cron jobs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>crontab -e<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List the current user&#8217;s cron jobs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>crontab -l<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Edit root&#8217;s cron jobs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo crontab -e<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run a script every day at 2:30 AM<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>30 2 * * * \/usr\/local\/bin\/backup.sh &gt;&gt; \/var\/log\/backup.log 2&gt;&amp;1<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run a command every five minutes<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>*\/5 * * * * \/usr\/local\/bin\/task.sh &gt;&gt; \/var\/log\/task.log 2&gt;&amp;1<\/code><\/pre>\n<p>Use full executable paths inside cron jobs because cron usually runs with a limited environment. Redirect standard output and errors to a log so failed jobs can be diagnosed.<\/p>\n<h2 style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">19. Shell shortcuts and command combinations<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run a second command only if the first succeeds<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command_one &amp;&amp; command_two<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run a second command only if the first fails<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command_one || command_two<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Send one command&#8217;s output into another<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>ps aux | grep php<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Redirect output into a file<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command &gt; output.txt<\/code><\/pre>\n<p>Append output:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command &gt;&gt; output.txt<\/code><\/pre>\n<p>Redirect both standard output and errors:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>command &gt; output.log 2&gt;&amp;1<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Run a command in the background<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>long_running_command &amp;<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">List and manage shell jobs<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>jobs\r\nfg %1\r\nbg %1<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Keep a command running after logout<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>nohup command &gt; command.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n<p>For long interactive maintenance sessions, consider using <code>tmux<\/code> or <code>screen<\/code> instead.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Start a tmux session<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tmux new -s maintenance<\/code><\/pre>\n<p>Reattach later:<\/p>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>tmux attach -t maintenance<\/code><\/pre>\n<h2 style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">20. Common server troubleshooting workflows<\/h2>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Website is not responding<\/h3>\n<ol style=\"padding-left: 22px;\">\n<li>Check whether the web service is active.<\/li>\n<li>Validate the web server configuration.<\/li>\n<li>Review listening ports.<\/li>\n<li>Inspect error logs.<\/li>\n<li>Test the website locally and externally.<\/li>\n<\/ol>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl status nginx\r\nsudo nginx -t\r\nsudo ss -lntp | grep -E ':80|:443'\r\nsudo tail -n 100 \/var\/log\/nginx\/error.log\r\ncurl -I http:\/\/127.0.0.1\r\ncurl -IL https:\/\/example.com<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Server is slow<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>uptime\r\nfree -h\r\ntop\r\nps aux --sort=-%cpu | head\r\nps aux --sort=-%mem | head\r\ndf -hT\r\ndf -ih\r\nvmstat 1 10\r\niostat -xz 1 5<\/code><\/pre>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">Disk is full<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>df -hT\r\ndf -ih\r\nsudo du -xhd1 \/ | sort -h\r\nsudo du -xhd1 \/var | sort -h\r\nsudo find \/var -type f -size +500M -printf '%s %p\\n' 2&gt;\/dev\/null | sort -nr | head -n 20<\/code><\/pre>\n<p>Investigate before deleting anything. Common causes include oversized logs, old backups, application caches, database files, temporary files, and abandoned website archives.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">SSH connection is refused<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>sudo systemctl status ssh\r\nsudo systemctl status sshd\r\nsudo sshd -t\r\nsudo ss -lntp | grep ssh\r\nsudo journalctl -u ssh -n 100\r\nsudo journalctl -u sshd -n 100<\/code><\/pre>\n<p>The service is normally named <code>ssh<\/code> on Debian or Ubuntu and <code>sshd<\/code> on AlmaLinux, Rocky Linux, and RHEL.<\/p>\n<h3 style=\"color: #0f2040; font-size: 1.3em;\">DNS points to the wrong server<\/h3>\n<pre style=\"background: #0A1220; color: #e2e8f0; padding: 18px; border-radius: 12px; overflow: auto;\"><code>dig example.com A +short\r\ndig example.com AAAA +short\r\ndig example.com NS +short\r\ndig @1.1.1.1 example.com A +short\r\ndig @8.8.8.8 example.com A +short<\/code><\/pre>\n<h2 style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">21. Commands that require extra caution<\/h2>\n<div style=\"display: grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap: 18px; margin: 22px 0 34px;\">\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Recursive deletion<\/strong><br \/>\nConfirm the path and backup before using recursive deletion. Shell deletion does not normally provide a recycle bin.<\/div>\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Recursive chmod or chown<\/strong><br \/>\nIncorrect permissions can break websites, SSH, control panels, mail services, and system packages.<\/div>\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Firewall changes<\/strong><br \/>\nAlways permit the active SSH port before enabling, reloading, or replacing firewall rules.<\/div>\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Database deletion<\/strong><br \/>\nBack up the database and verify the selected database before running destructive SQL statements.<\/div>\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Filesystem or disk commands<\/strong><br \/>\nFormatting, repartitioning, and filesystem repair commands can cause permanent data loss when applied to the wrong device.<\/div>\n<div style=\"padding: 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 16px; box-shadow: 0 8px 20px rgba(10,18,32,0.06);\"><strong style=\"display: block; color: #0a1220; margin-bottom: 8px;\">Service restarts<\/strong><br \/>\nValidate configuration first and schedule disruptive changes during a maintenance window.<\/div>\n<\/div>\n<p><!-- Branded Divider --><\/p>\n<div class=\"uh-section-divider\" style=\"width: min(100% - 32px,1200px); margin: 46px auto; display: grid; grid-template-columns: 1fr 32px 1fr; align-items: center; gap: 18px; pointer-events: none;\" aria-hidden=\"true\">\n<img loading=\"lazy\" decoding=\"async\" style=\"width: 32px; height: 32px; display: block; border-radius: 8px; filter: drop-shadow(0 0 14px rgba(0,212,255,0.30));\" src=\"https:\/\/cdn.underhost.com\/android-chrome-192x192.webp\" alt=\"\" width=\"32\" height=\"32\" \/><\/div>\n<h2 style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">Choose the right server management approach<\/h2>\n<p>SSH access provides complete control, but it also makes you responsible for operating system updates, firewall policies, service configuration, backups, security monitoring, and incident response.<\/p>\n<p>An unmanaged VPS is suitable when you are comfortable administering Linux yourself. A managed service is better when you need experienced administrators to handle server configuration, hardening, updates, monitoring, or troubleshooting.<\/p>\n<div style=\"display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 18px; margin: 24px 0 38px;\">\n<div style=\"padding: 22px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 17px; box-shadow: 0 10px 24px rgba(10,18,32,0.07);\"><strong style=\"display: block; color: #0a1220; font-size: 1.15em; margin-bottom: 8px;\">Cloud VPS<\/strong><br \/>\nFlexible virtual servers for websites, applications, development environments, and scalable Linux workloads.<\/p>\n<div style=\"margin-top: 14px;\"><a style=\"color: #0091d6; font-weight: bold; text-decoration: none;\" href=\"https:\/\/underhost.com\/cloud-vps.php\">Explore Cloud VPS hosting<\/a><\/div>\n<\/div>\n<div style=\"padding: 22px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 17px; box-shadow: 0 10px 24px rgba(10,18,32,0.07);\"><strong style=\"display: block; color: #0a1220; font-size: 1.15em; margin-bottom: 8px;\">Offshore VPS<\/strong><br \/>\nRoot-access virtual infrastructure in privacy-friendly locations for legitimate projects requiring jurisdictional flexibility.<\/p>\n<div style=\"margin-top: 14px;\"><a style=\"color: #0091d6; font-weight: bold; text-decoration: none;\" href=\"https:\/\/underhost.com\/offshore-vps.php\">Explore Offshore VPS hosting<\/a><\/div>\n<\/div>\n<div style=\"padding: 22px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 17px; box-shadow: 0 10px 24px rgba(10,18,32,0.07);\"><strong style=\"display: block; color: #0a1220; font-size: 1.15em; margin-bottom: 8px;\">Dedicated servers<\/strong><br \/>\nSingle-tenant hardware for high traffic, larger databases, sustained workloads, custom networking, and greater isolation.<\/p>\n<div style=\"margin-top: 14px;\"><a style=\"color: #0091d6; font-weight: bold; text-decoration: none;\" href=\"https:\/\/underhost.com\/servers.php\">View server locations<\/a><\/div>\n<\/div>\n<div style=\"padding: 22px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 17px; box-shadow: 0 10px 24px rgba(10,18,32,0.07);\"><strong style=\"display: block; color: #0a1220; font-size: 1.15em; margin-bottom: 8px;\">Server management<\/strong><br \/>\nProfessional assistance with updates, hardening, monitoring, configuration, optimization, and technical incidents.<\/p>\n<div style=\"margin-top: 14px;\"><a style=\"color: #0091d6; font-weight: bold; text-decoration: none;\" href=\"https:\/\/customerpanel.ca\/client\/store\/server-management\">View management options<\/a><\/div>\n<\/div>\n<\/div>\n<h2 style=\"color: #0a1220; font-size: 1.85em; margin-top: 42px; line-height: 1.25;\">Frequently asked questions<\/h2>\n<div style=\"margin: 22px 0 38px;\">\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">What is the difference between SSH and the Linux shell?<\/summary>\n<p style=\"margin: 14px 0 0;\">SSH is the encrypted network protocol used to connect to a remote system. The shell, such as Bash, is the command interpreter that runs after you connect. SSH transports the session, while the shell processes your commands.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">Should I log in directly as root?<\/summary>\n<p style=\"margin: 14px 0 0;\">For routine administration, using a normal user with controlled sudo access provides better accountability and reduces the risk of accidental system-wide changes. Keep a tested recovery method or console available before changing root or SSH authentication settings.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">Are SSH keys safer than passwords?<\/summary>\n<p style=\"margin: 14px 0 0;\">Properly protected SSH keys are generally more resistant to password guessing and credential reuse. Protect the private key with a passphrase, restrict its file permissions, and never share it.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">Why does a command work on Ubuntu but not AlmaLinux?<\/summary>\n<p style=\"margin: 14px 0 0;\">Linux distributions may use different package managers, service names, configuration paths, firewall systems, and default packages. Ubuntu and Debian normally use APT, while AlmaLinux and Rocky Linux use DNF. Apache is commonly called <code>apache2<\/code> on Ubuntu and <code>httpd<\/code> on AlmaLinux.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">How can I tell which process is using a port?<\/summary>\n<p style=\"margin: 14px 0 0;\">Run <code>sudo ss -lntup<\/code> to view listening ports and associated processes. You can also use <code>sudo lsof -i :PORT<\/code> for one specific port.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">What should I check before restarting a service?<\/summary>\n<p style=\"margin: 14px 0 0;\">Validate the service configuration, inspect its current status and recent logs, confirm dependencies, and consider whether the restart will interrupt production traffic. For web servers and SSH, always run the available syntax test first.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">How do I recover after blocking myself with the firewall?<\/summary>\n<p style=\"margin: 14px 0 0;\">Use the server&#8217;s remote console, KVM, IPMI, or management console to correct the firewall rule. When no console access is available, the hosting provider may need to restore access. This is why SSH access should be tested in a second session before closing the original connection.<\/p>\n<\/details>\n<details style=\"margin-bottom: 12px; padding: 18px 20px; background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 14px;\">\n<summary style=\"cursor: pointer; color: #0a1220; font-weight: bold;\">Do these commands work on cPanel servers?<\/summary>\n<p style=\"margin: 14px 0 0;\">Most standard Linux commands work, but cPanel manages many services, configuration files, permissions, and package components itself. Avoid replacing cPanel-managed configurations manually unless you understand how cPanel rebuilds and maintains them.<\/p>\n<\/details>\n<\/div>\n<\/div>\n<p><!-- Final CTA --><\/p>\n<div style=\"margin-top: 44px; padding: 36px 26px; text-align: center; border-radius: 20px; background: linear-gradient(135deg,#0A1220 0%,#0D1B30 45%,#0F2040 100%); color: #ffffff; box-shadow: 0 20px 45px rgba(10,18,32,0.20);\">\n<p><img decoding=\"async\" style=\"height: 40px; width: auto; max-width: 180px; display: block; margin: 0 auto 18px;\" src=\"https:\/\/cdn.underhost.com\/brands\/logo\/logodark.webp\" alt=\"UnderHost\" height=\"40\" \/><\/p>\n<h2 style=\"margin: 0 0 12px; color: #ffffff; font-size: 1.9em;\">Deploy a Linux server with full administrative control<\/h2>\n<p style=\"max-width: 760px; margin: 0 auto 22px; color: #d7e2ef; line-height: 1.7;\">UnderHost provides Cloud VPS, Offshore VPS, dedicated servers, backup solutions, and professional server management for projects that need reliable infrastructure and experienced technical support.<\/p>\n<div style=\"display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;\"><a style=\"display: inline-block; padding: 13px 21px; border-radius: 10px; background: linear-gradient(90deg,#00D4FF,#0091D6); color: #071428; font-weight: 800; text-decoration: none;\" href=\"https:\/\/underhost.com\/cloud-vps.php\"><br \/>\nExplore Cloud VPS<br \/>\n<\/a><a style=\"display: inline-block; padding: 13px 21px; border-radius: 10px; border: 1px solid rgba(0,212,255,0.55); background: rgba(0,212,255,0.08); color: #ffffff; font-weight: bold; text-decoration: none;\" href=\"https:\/\/underhost.com\/dedicated-servers-offshore.php\"><br \/>\nView Dedicated Servers<br \/>\n<\/a><\/p>\n<p><a style=\"display: inline-block; padding: 13px 21px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.24); background: rgba(255,255,255,0.06); color: #ffffff; font-weight: bold; text-decoration: none;\" href=\"https:\/\/customerpanel.ca\/client\/submitticket.php\"><br \/>\nContact Technical Support<br \/>\n<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Master critical SSH and Linux shell commands with UnderHost.com. Discover how efficient server management starts with powerful terminal skills. Learn the commands that keep your offshore servers, cloud hosting, and dedicated servers running smoothly.<\/p>\n","protected":false},"author":1,"featured_media":4540,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,20],"tags":[115],"class_list":["post-254","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ssh","tag-tag-linux-server"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=254"}],"version-history":[{"count":7,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/254\/revisions"}],"predecessor-version":[{"id":256,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/254\/revisions\/256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/4540"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}