
September 11, 2026
11 min read
By Kokil Thapa | Last reviewed: September 2026
The best Linux commands for Ubuntu users are not a random cheat sheet. They are the tools you reach for when a Laravel app works locally but fails after deploy, when disk space vanishes overnight, or when PHP-FPM stops answering Nginx. I run Ubuntu 22.04 and 24.04 on production servers daily. This guide ranks commands by what actually saves time on real web stacks. If you are new to the shell, pair this with our Ubuntu server setup guide first.
cd, ls, find), package control (apt, dpkg), process tools (systemctl, journalctl, htop), networking (ss, ufw), and log inspection (tail, grep) on Ubuntu 24.04 LTS servers.What are the best Linux commands for Ubuntu users on production web servers?
Production Ubuntu boxes for PHP and Laravel rarely need exotic utilities. You need fast answers to five questions: where am I, what changed, who owns it, what is running, and what broke. The commands below map directly to those questions.
On sister sites I maintain with Deployer 7 and GitLab CI, the same command set appears in every incident. A stale cron path, wrong PHP binary, or full /var/log partition surfaces through disk, process, and log commands—not through GUI tools.
Ranked by daily impact
- Navigation and inspection:
pwd,cd,ls -lah,tree(install if missing),less,head,tail - Search and edit:
find,grep -R,rg(ripgrep),nanoorvim - Ownership and permissions:
chown,chmod,stat,id,groups - Processes and resources:
ps,top,htop,free -h,df -h,du -sh - Services:
systemctl,journalctl— see our systemd service management guide - Networking:
ip,ss,curl,dig,ufw - Packages:
apt,dpkg,snapwhere relevant
This order reflects incident frequency, not alphabetical neatness. Disk and permission issues beat package bugs on most Laravel hosts I touch.
Which file and directory commands should every Ubuntu user memorize?
File commands are the foundation. A wrong chmod on storage/ breaks uploads. A misplaced chown leaves Nginx unable to read a release symlink. Learn these until they are muscle memory.
Navigation and listing
# Where am I? What is here?
pwd
cd /var/www/current
ls -lah
# Human-readable sizes, newest first
ls -lhtr storage/logs/
# Follow a Laravel log in real time
tail -f storage/logs/laravel.log
ls -lah shows hidden dotfiles, sizes, and permissions in one view. That matters when debugging .env visibility or stale .htaccess files on Apache setups.
Find and search
# Find large log files older than 14 days
find /var/log -type f -name "*.log" -mtime +14 -ls
# Find world-writable files under a web root (security audit)
find /var/www -type f -perm -002 2>/dev/null
# Search config for a directive
grep -R "upload_max_filesize" /etc/php/8.4/fpm/
find is slower than locate but always current. After package upgrades, I use find to confirm which PHP-FPM pool files exist under /etc/php/. Our Ubuntu file permissions guide explains the numeric modes behind chmod.
Copy, move, and archive
# Safe copy with preserve attributes
cp -a source/ destination/
# Move release artifacts
mv release-20260910 /var/www/releases/
# Tar backup before schema change
tar -czf ~/backup-$(date +%F).tar.gz /var/www/current/storage
cp -a preserves timestamps and symlinks. That matters when rsync or Deployer expects intact symlinked current releases. For scheduled dumps, see Ubuntu server backup strategies.
Permissions in practice
# Fix Laravel writable dirs after deploy
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
# Inspect numeric mode and owner
stat -c "%a %U:%G %n" storage/logs/laravel.log
Never run chmod 777 on production. It is a shortcut that creates audit and security debt. Fix the owner and group instead.
How do you monitor processes, disk, and memory on Ubuntu?
“The site is slow” usually means CPU, RAM, disk I/O, or a runaway queue worker. These commands tell you which one within seconds.
Process inspection
# Snapshot of top CPU consumers
ps aux --sort=-%cpu | head -15
# Interactive view (install: sudo apt install htop)
htop
# Find PHP-FPM workers
ps aux | grep php-fpm | grep -v grep
# Kill stuck queue worker by PID
kill -15 12847
Prefer kill -15 (SIGTERM) before kill -9. Laravel queue workers should drain gracefully when possible.
Disk and memory
# Filesystem usage — watch for 100% /var
df -h
# Find what eats /var/log
sudo du -xh /var/log | sort -h | tail -20
# RAM and swap summary
free -h
# Inode exhaustion (common on mail/log servers)
df -i
A full disk stops MySQL, logging, and sessions at once. I check df -h before any deploy on shared EC2 hosts. If logs balloon, rotate or truncate after fixing the root cause—not before you have evidence.
Ports and listeners
# What listens on 443 and 3306?
sudo ss -tulpn | grep -E ':443|:3306'
# Alternative legacy syntax
sudo netstat -tulpn
ss ships with modern Ubuntu and replaces most netstat use cases. When Nginx shows “address already in use”, ss finds the conflicting PID fast.
Which networking and firewall commands matter most on Ubuntu?
Web developers touch networking more than they expect. SSL renewals, upstream timeouts, and blocked admin ports all start at the shell.
IP, DNS, and HTTP checks
# Addresses and routes
ip addr show
ip route show
# DNS resolution test
dig +short app.example.com A
# HTTP headers from localhost
curl -I http://127.0.0.1
curl -I https://app.example.com
curl -I verifies virtual host routing without loading full page bodies. I use it after installing Nginx on Ubuntu to confirm the correct server block answers.
UFW firewall
sudo ufw status verbose
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
Always allow SSH before enabling UFW. Locking yourself out costs real time. Our UFW firewall guide walks through safe ordering. For deeper hardening, read server hardening for Ubuntu web servers.
What package and service commands does Ubuntu rely on every day?
Ubuntu 24.04 LTS still centres on apt for PHP 8.3, 8.4, and 8.5 side-by-side setups. Service control goes through systemd. Mixing Snap and apt for the same role causes confusion—pick one path per tool.
APT and dpkg essentials
# Refresh index and upgrade packages
sudo apt update
sudo apt upgrade -y
# Install PHP 8.4 FPM on Ubuntu 24.04
sudo apt install php8.4-fpm php8.4-cli php8.4-mysql
# See which package owns a binary
dpkg -S $(which php)
# List installed PHP packages
dpkg -l 'php8.4-*'
Run apt update before apt install. The index stale error wastes minutes on fresh VPS builds. See apt update explained on Ubuntu for the distinction between update and upgrade.
systemctl and journalctl
# Service state
sudo systemctl status nginx
sudo systemctl status php8.4-fpm
# Reload after config edit (no drop connections)
sudo systemctl reload nginx
# Restart after pool change
sudo systemctl restart php8.4-fpm
# Last 100 lines of Nginx errors
sudo journalctl -u nginx -n 100 --no-pager
# Follow live logs
sudo journalctl -u php8.4-fpm -f
After Deployer symlink swaps, reload PHP-FPM to clear opcache. A restart kicks active requests—use reload when the unit supports it. Official reference: systemd systemctl documentation.
| Command | Best for | Caution |
|---|---|---|
systemctl reload | Nginx config change, graceful refresh | Unit must support reload |
systemctl restart | PHP-FPM pool edits, extension changes | Brief request interruption |
journalctl -u | Service-specific errors since boot | Use -f sparingly on busy boxes |
apt upgrade | Security patches | Test PHP extensions after kernel/lib upgrades |
ss -tulpn | Port conflicts | Requires sudo for process names |
Cron and scheduled tasks
# Edit root crontab
sudo crontab -e
# List Laravel scheduler entry (typical)
* * * * * cd /var/www/current && php artisan schedule:run >> /dev/null 2>&1
# Verify cron service
sudo systemctl status cron
Stale paths in cron are a classic post-deploy bug. The symlink moves but cron still points at an old release directory. After each deploy pattern change, verify with sudo crontab -l. Details sit in our Ubuntu cron jobs guide.
How do you combine commands for real Ubuntu troubleshooting?
Individual commands matter less than sequences. Below are workflows I use on production Laravel and WordPress hosts.
502 Bad Gateway on PHP-FPM
sudo systemctl status php8.4-fpm— is the unit active?sudo journalctl -u php8.4-fpm -n 50— pool crash or socket mismatch?sudo ss -tulpn | grep php— is the socket listening?grep listen /etc/php/8.4/fpm/pool.d/www.conf— match Nginxfastcgi_passsudo systemctl restart php8.4-fpm && sudo systemctl reload nginx
Socket versus TCP mismatches survive many edits because Nginx and pool configs live in different files. Always compare both sides.
Disk full on /var
df -h /varsudo du -xh /var | sort -h | tail -30sudo journalctl --disk-usage- Rotate or vacuum logs; expand volume if needed
journalctl --vacuum-time=7d reclaims space when systemd journals dominate. Do not delete random files under /var/lib/mysql.
Permission denied on upload
namei -l /var/www/current/storage/app/public— trace path permissionsstat storage/app/publicsudo chown -R www-data:www-data storage- Confirm SELinux/AppArmor only if enabled (uncommon on default Ubuntu)
namei -l is underrated. It shows which directory in the chain blocks access.
Useful one-liners worth saving
history | grep apt— what did I install last week?wc -l storage/logs/laravel.log— log growth sanity checkwatch -n 2 df -h— live disk during import jobslsof -i :80— which process holds port 80sudo nginx -t— test config before reloadphp -v && php -m— confirm CLI version and modules
For JSON log fragments pasted from terminals, clean payloads with our JSON formatter tool before sharing in tickets.
Commands to treat carefully
Some commands delete or overwrite without confirmation prompts.
rm -rf— double-check paths; never run as root on/chmod -R 777— fix ownership insteaddd— disk imaging only when you mean it> /var/log/...truncation — capture evidence first
The GNU coreutils manual remains the authoritative reference for flags and behaviour: GNU Coreutils documentation. Ubuntu-specific packaging docs live at Ubuntu Server Guide — APT.
Key Takeaways
- Learn
ls -lah,find,grep,chmod, andchownfirst—they solve most deploy and upload failures. - Run
df -h,free -h, andhtopbefore restarting services; guesswork wastes minutes. - Use
systemctlplusjournalctl -ufor Nginx, PHP-FPM, MySQL, and cron—not scattered log files alone. - Prefer
ssover legacy netstat, andcurl -Ifor quick HTTP checks after config edits. - Always
apt updatebefore installs, and reload PHP-FPM after Deployer releases to refresh opcache. - Build muscle memory with troubleshooting sequences, not isolated command lists.
People Also Ask
What are the most essential Linux commands for Ubuntu beginners?
Start with pwd, cd, ls -lah, cp, mv, mkdir, rm, cat, less, and sudo. Add apt update and apt install on day two. Our essential Ubuntu terminal commands article expands this list with copy-paste examples for desktop and server.
How do I check which Linux commands are installed on Ubuntu?
Use command -v nginx or which php to locate binaries. Run dpkg -l | grep nginx to see package status. For shell builtins, try type cd. Install missing tools with sudo apt install package-name.
What is the difference between apt and apt-get on Ubuntu?
Both use the same underlying APT libraries. The apt command adds progress bars and cleaner output for interactive use. Scripts often keep apt-get for stable, scriptable behaviour. Either works on Ubuntu 24.04 LTS for installs and upgrades.
Which Linux commands help secure an Ubuntu web server?
Combine ufw status, fail2ban-client status, ss -tulpn, and apt list --upgradable. Review last and lastb for SSH attempts. Hardening is a process—see Ubuntu security hardening and professional Linux system administration when production uptime matters.
Put the best Linux commands for Ubuntu users into daily practice
You do not need hundreds of obscure utilities. The best Linux commands for Ubuntu users are the ones tied to real workflows: deploy, debug, secure, and recover. Practice the sequences in this guide on a staging VPS before you need them at 2 a.m.
I use this exact toolkit across Laravel booking apps, legal-tech portals like Adventure Third Pole Trek, and WooCommerce stores on shared infrastructure. When commands are not enough—monitoring, hardening, or migration—support and maintenance or web development services close the gap.
Want help auditing a production Ubuntu stack or fixing recurring deploy failures? Contact us with your server OS version, web stack, and the last error you saw. Bring journalctl output—we can start from facts, not guesses.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

