{"id":171,"date":"2026-07-17T07:22:27","date_gmt":"2026-07-17T07:22:27","guid":{"rendered":"https:\/\/alexawebservers.com\/blog\/100-essential-linux-commands-every-sysadmin-should-know\/"},"modified":"2026-07-19T08:08:25","modified_gmt":"2026-07-19T08:08:25","slug":"100-essential-linux-commands-every-sysadmin-should-know","status":"publish","type":"post","link":"https:\/\/alexawebservers.com\/blog\/100-essential-linux-commands-every-sysadmin-should-know\/","title":{"rendered":"100 Essential Linux Commands Every Sysadmin Should Know"},"content":{"rendered":"<p>For anyone managing a Linux server \u2014 whether it is a cloud VPS, a dedicated box, or a Raspberry Pi at home \u2014 knowing the right commands can save hours of frustration. This guide covers the 100 essential Linux commands every sysadmin should know, grouped by category. Bookmark it, print it, or grab our <a href=\"https:\/\/ovidia1.gumroad.com\/l\/os-ubuntu\" target=\"_blank\" rel=\"noopener noreferrer\">Ubuntu Server Commands Cheat Sheet<\/a> for quick offline reference.<\/p>\n<h2>1. File and Directory Operations<\/h2>\n<p><code>ls -la<\/code> \u2014 List all files with details (permissions, size, date). Always start here.<br \/>\n<code>cd \/path<\/code> \u2014 Change directory.<br \/>\n<code>pwd<\/code> \u2014 Print working directory. Where am I?<br \/>\n<code>mkdir -p a\/b\/c<\/code> \u2014 Create nested directories in one command.<br \/>\n<code>rm -rf dir\/<\/code> \u2014 Remove directory and all contents. Use with care.<br \/>\n<code>cp -r source dest<\/code> \u2014 Copy recursively.<br \/>\n<code>mv source dest<\/code> \u2014 Move or rename.<br \/>\n<code>touch file<\/code> \u2014 Create empty file or update timestamp.<br \/>\n<code>find \/ -name \"*.log\"<\/code> \u2014 Find files matching a pattern.<br \/>\n<code>locate filename<\/code> \u2014 Faster than find, uses a prebuilt index.<br \/>\n<code>tree -L 2<\/code> \u2014 Show directory tree, 2 levels deep.<\/p>\n<h2>2. Viewing and Editing Files<\/h2>\n<p><code>cat file<\/code> \u2014 Dump file contents to terminal.<br \/>\n<code>less file<\/code> \u2014 Scroll through files page by page (press q to quit).<br \/>\n<code>head -n 20 file<\/code> \u2014 Show first 20 lines.<br \/>\n<code>tail -n 20 file<\/code> \u2014 Show last 20 lines.<br \/>\n<code>tail -f \/var\/log\/syslog<\/code> \u2014 Follow logs in real time.<br \/>\n<code>grep \"error\" \/var\/log\/syslog<\/code> \u2014 Search inside files. Combine with -i for case-insensitive, -r for recursive.<br \/>\n<code>wc -l file<\/code> \u2014 Count lines in a file.<br \/>\n<code>diff file1 file2<\/code> \u2014 Show differences between two files.<br \/>\n<code>sort file<\/code> \u2014 Sort lines alphabetically.<br \/>\n<code>uniq<\/code> \u2014 Remove duplicate adjacent lines. Often paired with sort | uniq.<\/p>\n<h2>3. File Permissions and Ownership<\/h2>\n<p><code>chmod 755 script.sh<\/code> \u2014 Set permissions (rwx r-x r-x).<br \/>\n<code>chmod +x script.sh<\/code> \u2014 Make executable.<br \/>\n<code>chown user:group file<\/code> \u2014 Change owner and group.<br \/>\n<code>umask 022<\/code> \u2014 Set default permission mask for new files.<br \/>\n<code>ls -l<\/code> \u2014 Check current permissions.<br \/>\n<code>stat file<\/code> \u2014 Detailed file information including permissions, ownership, timestamps.<\/p>\n<h2>4. Disk and Storage<\/h2>\n<p><code>df -h<\/code> \u2014 Show disk usage in human-readable format.<br \/>\n<code>du -sh \/var<\/code> \u2014 Show total size of a directory.<br \/>\n<code>du -h --max-depth=1<\/code> \u2014 Size of each subdirectory, one level deep.<br \/>\n<code>lsblk<\/code> \u2014 List block devices (disks, partitions).<br \/>\n<code>fdisk -l<\/code> \u2014 List partition tables.<br \/>\n<code>mount \/dev\/sdb1 \/mnt<\/code> \u2014 Mount a partition.<br \/>\n<code>umount \/mnt<\/code> \u2014 Unmount.<br \/>\n<code>blkid<\/code> \u2014 Show UUIDs of all block devices.<br \/>\n<code>fallocate -l 1G testfile<\/code> \u2014 Create a 1GB file instantly (for swap or testing).<br \/>\n<code>smartctl -a \/dev\/sda<\/code> \u2014 Check disk health (requires smartmontools).<\/p>\n<h2>5. Package Management (APT)<\/h2>\n<p><code>apt update<\/code> \u2014 Refresh package index.<br \/>\n<code>apt upgrade<\/code> \u2014 Upgrade all packages.<br \/>\n<code>apt install nginx<\/code> \u2014 Install a package.<br \/>\n<code>apt remove nginx<\/code> \u2014 Remove a package.<br \/>\n<code>apt purge nginx<\/code> \u2014 Remove package and config files.<br \/>\n<code>apt autoremove<\/code> \u2014 Remove unused dependencies.<br \/>\n<code>dpkg -i package.deb<\/code> \u2014 Install a .deb file directly.<br \/>\n<code>dpkg -l | grep nginx<\/code> \u2014 Check if a package is installed.<br \/>\n<code>apt list --upgradable<\/code> \u2014 Show packages that can be upgraded.<br \/>\n<code>add-apt-repository ppa:name<\/code> \u2014 Add a PPA repository.<\/p>\n<h2>6. System Information and Monitoring<\/h2>\n<p><code>top<\/code> \u2014 Real-time process viewer. Press q to quit.<br \/>\n<code>htop<\/code> \u2014 Better top with color and scrolling (install separately).<br \/>\n<code>ps aux<\/code> \u2014 List all running processes.<br \/>\n<code>ps aux | grep nginx<\/code> \u2014 Find a specific process.<br \/>\n<code>kill -9 PID<\/code> \u2014 Force kill a process.<br \/>\n<code>killall nginx<\/code> \u2014 Kill all processes by name.<br \/>\n<code>systemctl status nginx<\/code> \u2014 Check service status.<br \/>\n<code>systemctl start\/stop\/restart nginx<\/code> \u2014 Control services.<br \/>\n<code>systemctl enable nginx<\/code> \u2014 Start service on boot.<br \/>\n<code>journalctl -u nginx -n 50<\/code> \u2014 Show last 50 log lines for a service.<br \/>\n<code>uptime<\/code> \u2014 How long has the server been running?<br \/>\n<code>who<\/code> \u2014 Who is logged in?<br \/>\n<code>last<\/code> \u2014 Login history.<br \/>\n<code>free -h<\/code> \u2014 Memory usage (RAM + swap).<br \/>\n<code>uname -a<\/code> \u2014 Kernel version and system info.<br \/>\n<code>lscpu<\/code> \u2014 CPU details.<br \/>\n<code>nproc<\/code> \u2014 Number of CPU cores.<\/p>\n<h2>7. Networking<\/h2>\n<p><code>ip a<\/code> \u2014 Show all network interfaces and IP addresses.<br \/>\n<code>ip r<\/code> \u2014 Show routing table.<br \/>\n<code>ss -tulpn<\/code> \u2014 Show listening ports and the processes using them.<br \/>\n<code>ping -c 4 google.com<\/code> \u2014 Check network connectivity.<br \/>\n<code>curl ifconfig.me<\/code> \u2014 Show your public IP.<br \/>\n<code>curl -I https:\/\/example.com<\/code> \u2014 Fetch HTTP headers only.<br \/>\n<code>wget https:\/\/example.com\/file<\/code> \u2014 Download a file.<br \/>\n<code>scp file user@host:\/path<\/code> \u2014 Copy files over SSH.<br \/>\n<code>rsync -avz source\/ user@host:\/dest\/<\/code> \u2014 Sync directories over SSH.<br \/>\n<code>ssh user@host<\/code> \u2014 Connect to a remote server.<br \/>\n<code>ssh-keygen -t ed25519<\/code> \u2014 Generate SSH key pair.<br \/>\n<code>ssh-copy-id user@host<\/code> \u2014 Copy public key to remote server.<br \/>\n<code>dig example.com<\/code> \u2014 Detailed DNS query.<br \/>\n<code>nslookup example.com<\/code> \u2014 DNS lookup.<br \/>\n<code>traceroute example.com<\/code> \u2014 Trace network path.<br \/>\n<code>mtr example.com<\/code> \u2014 Combine traceroute + ping continuous.<br \/>\n<code>tcpdump -i eth0 port 80<\/code> \u2014 Capture network packets (use with care).<br \/>\n<code>nmap -sV localhost<\/code> \u2014 Scan open ports on local machine.<\/p>\n<h2>8. Compression and Archiving<\/h2>\n<p><code>tar -czvf archive.tar.gz \/path<\/code> \u2014 Create a .tar.gz archive.<br \/>\n<code>tar -xzvf archive.tar.gz<\/code> \u2014 Extract a .tar.gz archive.<br \/>\n<code>tar -cjvf archive.tar.bz2 \/path<\/code> \u2014 Create a .tar.bz2 archive.<br \/>\n<code>zip -r archive.zip \/path<\/code> \u2014 Create a zip archive.<br \/>\n<code>unzip archive.zip<\/code> \u2014 Extract a zip archive.<br \/>\n<code>gzip file<\/code> \u2014 Compress a file.<br \/>\n<code>gunzip file.gz<\/code> \u2014 Decompress.<br \/>\n<code>zcat file.gz<\/code> \u2014 View compressed file contents without extracting.<\/p>\n<h2>9. User Management<\/h2>\n<p><code>useradd -m -s \/bin\/bash username<\/code> \u2014 Create a new user with home directory.<br \/>\n<code>passwd username<\/code> \u2014 Set or change password.<br \/>\n<code>usermod -aG sudo username<\/code> \u2014 Add user to sudo group.<br \/>\n<code>deluser username<\/code> \u2014 Remove a user.<br \/>\n<code>groups username<\/code> \u2014 Show groups a user belongs to.<br \/>\n<code>id username<\/code> \u2014 Show user ID, group ID, and groups.<br \/>\n<code>sudo -l<\/code> \u2014 List sudo privileges for current user.<br \/>\n<code>visudo<\/code> \u2014 Edit sudoers file safely.<\/p>\n<h2>10. Process Management and Scheduling<\/h2>\n<p><code>nohup command &<\/code> \u2014 Run command immune to hangups, in background.<br \/>\n<code>screen<\/code> \u2014 Terminal multiplexer (reattachable sessions).<br \/>\n<code>tmux<\/code> \u2014 Modern alternative to screen.<br \/>\n<code>at 09:00 -f script.sh<\/code> \u2014 Schedule a one-time job.<br \/>\n<code>crontab -e<\/code> \u2014 Edit cron jobs.<br \/>\n<code>crontab -l<\/code> \u2014 List cron jobs.<br \/>\n<code>nice -n 10 command<\/code> \u2014 Run with lower priority.<\/p>\n<h2>11. Text Processing with Pipes<\/h2>\n<p><code>command | grep pattern<\/code> \u2014 Filter output.<br \/>\n<code>command | awk '{print $2}'<\/code> \u2014 Print second column.<br \/>\n<code>command | sed 's\/old\/new\/g'<\/code> \u2014 Find and replace in stream.<br \/>\n<code>command | cut -d: -f1<\/code> \u2014 Cut by delimiter, first field.<br \/>\n<code>command | sort | uniq -c<\/code> \u2014 Count unique occurrences.<br \/>\n<code>command | tee file.txt<\/code> \u2014 Show output and save to file simultaneously.<\/p>\n<h2>12. Security Essentials<\/h2>\n<p><code>ufw status verbose<\/code> \u2014 Firewall status (Uncomplicated Firewall).<br \/>\n<code>ufw allow 22\/tcp<\/code> \u2014 Allow SSH through firewall.<br \/>\n<code>ufw enable<\/code> \u2014 Enable firewall.<br \/>\n<code>fail2ban-client status<\/code> \u2014 Check fail2ban status.<br \/>\n<code>lastb<\/code> \u2014 Show failed login attempts.<br \/>\n<code>openssl s_client -connect example.com:443<\/code> \u2014 Check SSL certificate details.<\/p>\n<p><strong>Also see:<\/strong> Our <a href=\"https:\/\/alexawebservers.com\/blog\/100-essential-kubernetes-commands-every-devops-engineer-should-know\/\">100+ Essential Kubernetes Commands<\/a> guide for container orchestration.<\/p>\n<hr \/>\n<p><strong>Master these commands and you can handle 95% of daily sysadmin tasks.<\/strong> Keep this guide handy \u2014 or better yet, download our <a href=\"https:\/\/ovidia1.gumroad.com\/l\/os-ubuntu\" target=\"_blank\" rel=\"noopener noreferrer\">Ubuntu Server Commands Cheat Sheet ($2.99)<\/a> with all 100+ commands in a printable format. No fluff, no ads, just commands.<\/p>\n<p>We release new cheat sheets regularly \u2014 check our <a href=\"https:\/\/alexawebservers.com\/blog\/products\/\" target=\"_blank\" rel=\"noopener noreferrer\">full product catalog<\/a> for references on Docker, Linux security, Kubernetes, Python, and more.<\/p>\n<p><strong>Also see:<\/strong> Our <a href=\"https:\/\/alexawebservers.com\/blog\/80-essential-docker-commands-every-developer-should-know\/\" target=\"_blank\" rel=\"noopener noreferrer\">80+ Essential Docker Commands guide<\/a> for container and deployment commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Complete reference of 100 essential Linux commands every sysadmin needs. Covers file operations, networking, disk management, security, and more. With downloadable cheat sheet.<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-linux-devops"],"_links":{"self":[{"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/comments?post=171"}],"version-history":[{"count":3,"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions\/223"}],"wp:attachment":[{"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexawebservers.com\/blog\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}