Basic Linux Server Commands for New Hosting Managers — A Hands-On Guide from A to Z
- Published on

Introduction
You just rented a VPS or a dedicated server, successfully connected via SSH, and now you're staring at a black screen with a blinking cursor — feeling a bit overwhelmed? Don't worry. That's exactly how most people feel the first time they face a Linux server.
Managing a hosting server doesn't have to be complicated. In fact, with just about 15–20 essential Linux commands, you can handle 90% of daily administration tasks: checking server resources, managing files, installing software, restarting services, and reading error logs.
This guide is designed for absolute beginners — people who are comfortable with cPanel or other visual hosting control panels and want to transition to command-line server management. Every command includes a short explanation, a real-world hosting example, and important safety notes.
If you don't know how to connect via SSH yet, read our guide on What is PuTTY? How to Download and Use SSH Client. If you don't have a server yet, check out What is VPS? VPS vs Shared Hosting Comparison and What is Hosting? to pick the right solution.
1. System Information Commands — Know What Your Server Is Running
Before doing anything else, you need to know what operating system your server runs, how long it has been up, and what resources are available.
Check operating system information
uname -a
This command displays full kernel information — Linux version, CPU architecture (x86_64 or aarch64), and build date. It's the first command you should run after SSH-ing into a new server to confirm you received the right configuration.
Check server uptime
uptime
The output shows: how long the server has been running, how many users are logged in, and the load average over 1/5/15 minutes. Load average is a critical metric — if it exceeds your CPU core count, the server is overloaded.
Check disk usage
df -h
The -h flag (human-readable) displays sizes in GB/MB instead of bytes. This tells you how much space each partition has used and how much is free. In hosting management, this is the command you'll run daily to ensure disks aren't full.
du -sh /var/www
The du command calculates directory sizes. The -s flag (summary) shows only the total, and -h makes it readable. Very useful for identifying which website directory is eating up the most space.
Check RAM
free -h
Shows total RAM, used RAM, free RAM, and swap. If swap is heavily used, your server is running out of RAM — consider an upgrade or optimization.
Pro tip: Running
df -handfree -hshould be the first two things you do whenever you suspect a server performance issue.
2. File and Directory Management Commands — The Backbone of Server Administration
Every website on your server is a collection of files stored in directories like /var/www/ or /home/user/. You need to master the following commands to navigate, create, copy, and delete files.
List files and directories
ls -la
ls: list — shows directory contents.-l: long format — displays details (permissions, owner, size, date).-a: all — shows hidden files (starting with.).
In hosting, you'll use ls -la to check .htaccess, wp-config.php, or the wp-content/ directory.
Navigate between directories
cd /var/www/example.com/public_html
cd (change directory) is the command you'll use most often. Useful shortcuts:
cd ~— go to the current user's home directory.cd ..— move up one level.cd -— return to the previous directory.
Print working directory
pwd
Prints the absolute path of your current directory. Very handy when you've wandered deep into the file system.
Create directories
mkdir -p /var/www/example.com/public_html
The -p flag (parents) automatically creates parent directories if they don't exist. Without -p, you must create each level manually.
Copy files and directories
cp -r /var/www/old-site /var/www/new-site
cp: copy.-r: recursive — required for copying directories and their contents.
Move or rename
mv /var/www/old-name /var/www/new-name
mv handles both moving files to another directory and renaming. It's safer than cp because it doesn't duplicate data.
Delete files and directories
rm -rf /var/www/cache/
⚠️ WARNING: rm -rf is one of the most dangerous commands. -r (recursive) deletes subdirectories, -f (force) skips confirmation. Always double-check the path before running. A common mistake is rm -rf / var/www/ (extra space after the slash) — this will wipe your entire system.
Find files
find /var/www -name "wp-config.php"
The find command is powerful when you need to locate files. Combine it with -type d (directories), -size +100M (files larger than 100MB), or -mtime -7 (files modified in the last 7 days).
Learn more: What is .htaccess? Configuration Guide — a critical configuration file you'll frequently work with in hosting management.
3. Permission Commands — Security First
File permissions are the number one cause of "Permission Denied" and "500 Internal Server Error" on websites. Understanding chmod and chown is non-negotiable.
Change file owner
chown -R www-data:www-data /var/www/example.com
chown: change owner.www-data: the user that runs the web server (Nginx/Apache).www-data: the group for that user.-R: recursive — applies to all files and subdirectories.
In hosting, after uploading new site files, you need to run this command so the web server can read and write to them.
Change file permissions
chmod -R 755 /var/www/example.com/public_html
chmod 644 /var/www/example.com/public_html/index.php
Linux permission system:
755= owner (7: read+write+execute), group (5: read+execute), others (5: read+execute) — for directories.644= owner (6: read+write), group (4: read), others (4: read) — for files.
| Value | Permission | Meaning |
|---|---|---|
| 7 | rwx | Read + Write + Execute |
| 6 | rw- | Read + Write |
| 5 | r-x | Read + Execute |
| 4 | r-- | Read only |
| 0 | --- | No permissions |
Golden rules for hosting
- Directories:
755(owner has full access, others can read and enter). - Files:
644(owner can edit, others can only read). - Sensitive files like
wp-config.php:600or640. - Upload directories: Sometimes need
775if the web server must write files (e.g., WordPress image uploads).
find /var/www -type d -exec chmod 755 {} \;
find /var/www -type f -exec chmod 644 {} \;
These two commands batch-set permissions: directories = 755, files = 644. Very useful after extracting a fresh source code archive.
Security tip: Harden your server with our Server Security Guide, Website Security, and What is SSL?.
4. Process and Service Management — Keep Your Website Running
When a website becomes unreachable, the cause is often the web server (Nginx/Apache) or PHP-FPM having stopped. These commands let you check and restart services.
Manage services with systemctl
sudo systemctl status nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl enable nginx
sudo systemctl disable nginx
status: check whether the service is running, stopped, or has errors.restart: stop and start again.reload: reload configuration without dropping connections (preferred over restart).enable: auto-start on boot.disable: prevent auto-start on boot.
Learn more: What is Nginx? Installation Guide and How to Install Nginx on a VPS A-Z — if you're using Nginx, these two articles are essential reading.
List running processes
ps aux
Lists all running processes with user, PID, %CPU, %RAM, and the corresponding command. Pipe to grep to filter:
ps aux | grep nginx
ps aux | grep php
The output shows how many Nginx worker processes or PHP-FPM instances are running — helping you determine if the server has enough resources.
Monitor resources in real-time
top
The top command shows a real-time table of processes using the most CPU and RAM. Press q to quit. If your server has htop (more visual and user-friendly), install it:
sudo apt install htop
htop
Stop a process
kill 1234
kill -9 1234
kill PID: sends a termination signal (SIGTERM).kill -9 PID: force-kills immediately (SIGKILL) — only use when the normal signal fails.
View service logs
journalctl -u nginx --no-pager -n 50
The journalctl command reads systemd service logs. The -n 50 flag shows the last 50 lines, --no-pager outputs directly to the terminal (without using less).
5. Network Commands — Connectivity and Debugging
Network commands help you check connectivity, download files, and debug network-related issues.
Check network connectivity
ping -c 4 google.com
Sends 4 ICMP packets to Google to verify your server has internet access. The response time (ms) also indicates network latency.
Download files from the internet
curl -O https://wordpress.org/latest.tar.gz
wget https://wordpress.org/latest.tar.gz
Both download files to your server. curl is more flexible (supports APIs, headers, POST requests), while wget is simpler (recursive downloads, resume support).
curl -I https://example.com
This fetches only the HTTP headers — very useful for quickly checking response codes (200, 301, 404, 500).
Check open ports
ss -tlnp
The ss command replaces netstat (now deprecated). Flags: -t (TCP), -l (listening), -n (show port numbers, no name resolution), -p (show process). The output tells you whether ports 80 (HTTP), 443 (HTTPS), 22 (SSH) are listening and which process owns each port.
ip addr
Shows all IP addresses and network interface status. Replaces the older ifconfig command.
Explore: What is a Web Server? and HTTP Status Codes — Quick Reference.
6. Package Management Commands — Installing and Updating Software
On Ubuntu/Debian (the most popular distros for hosting), you manage software through APT (Advanced Package Tool).
Update package lists
sudo apt update
This syncs the package list from repositories. Always run this before installing any software.
Upgrade all packages
sudo apt upgrade -y
Updates all packages to their latest versions. The -y flag auto-answers Yes. On production servers, consider upgrading in batches to avoid conflicts.
Install new packages
sudo apt install nginx -y
sudo apt install php-fpm mysql-server -y
Installing Nginx, PHP, and MySQL — the three foundational components for web hosting.
Remove packages
sudo apt remove nginx
sudo apt purge nginx
sudo apt autoremove
remove: deletes the package but keeps configuration files.purge: wipes both the package and its configuration files.autoremove: cleans up orphaned packages that are no longer needed.
Search for packages
apt search php
Finds all packages related to PHP — useful when you don't remember the exact package name.
Learn more: What is Apache? Installation and Configuration — if you choose Apache over Nginx.
7. Log Reading and Text Processing Commands — Debug Made Easy
Logs are the first place to look when a website breaks. These commands help you read logs efficiently.
Display full file content
cat /var/log/nginx/error.log
cat prints the entire file to the terminal — fine for small files. For large logs (potentially hundreds of MB), use the commands below.
View the last lines of a log (real-time)
tail -n 100 /var/log/nginx/error.log
tail -f /var/log/nginx/access.log
tail -n 100: show the last 100 lines.tail -f: follow mode — displays log entries in real-time as new requests come in. PressCtrl+Cto exit.
View the first lines of a file
head -n 50 /var/log/nginx/error.log
head displays the first lines. Often used to check a log file's header.
Search within logs
grep "PHP Fatal" /var/log/php-error.log
grep -i "error" /var/log/nginx/error.log
grep is your most powerful weapon for searching within files. The -i flag makes it case-insensitive. Combine with tail -f for live monitoring:
tail -f /var/log/nginx/access.log | grep "500"
View files with pagination
less /var/log/nginx/error.log
less lets you scroll up/down, search (type /keyword), and doesn't load the entire file into RAM — very resource-friendly for large logs. Press q to exit.
Edit configuration files
nano /etc/nginx/sites-available/example.com
Nano is the simplest editor for beginners — use arrow keys to navigate, Ctrl+X to exit, Ctrl+O to save. If you need a more powerful editor:
vim /etc/nginx/sites-available/example.com
Vim has two modes: INSERT (press i to enter insert mode) and NORMAL (press Esc to return). Save with :wq (write and quit), exit without saving with :q!.
Learn more: How to Check Website Speed and Optimize Website Speed — after reading logs, measure performance and optimize.
8. Compression and Archival Commands — Backup and Transfer Data
In hosting management, you frequently need to compress website source code, databases, or logs for backup or migration.
Tar (most common on Linux)
tar -czvf backup.tar.gz /var/www/example.com
tar -xzvf backup.tar.gz
-c: create an archive.-x: extract an archive.-z: gzip compression.-v: verbose (show details).-f: file (target archive name).
Gzip
gzip error.log
gunzip error.log.gz
Compresses individual files. gzip old log files to save disk space.
Zip (Windows-compatible)
zip -r backup.zip /var/www/example.com
unzip backup.zip
zip is useful when you need to send files to Windows users.
Learn more: Website Backup Best Practices to build an automated backup pipeline for your server.
9. User Management Commands — Control Access
On a server with multiple users, you need to manage who can do what.
Execute commands with root privileges
sudo apt update
sudo (superuser do) allows a regular user to run commands with root privileges. The first user on Ubuntu (typically the one created when you buy a VPS) has sudo rights.
Switch to another user
su - www-data
Switches the current user. Use su - (with the dash) to load the target user's environment.
See who is logged in
who
w
who lists logged-in users with login time and IP address. w provides more detail (load, idle time, running command).
Create a new user
sudo useradd -m -s /bin/bash deploy
sudo passwd deploy
sudo usermod -aG sudo deploy
useradd -m: creates the user and home directory.-s /bin/bash: sets the default shell.passwd: sets the password.usermod -aG sudo: adds the user to the sudo group.
Quick Command Reference Table
| Command | Function | When to use |
|---|---|---|
| df -h | Check disk usage | Daily — full disk is the #1 cause of website errors |
| free -h | Check RAM | When the website is slow or unresponsive |
| ls -la | List files with details | Check website directory contents |
| chown -R www-data:www-data | Set web server ownership | After uploading fresh source code |
| chmod 755 / 644 | Set directory / file permissions | When you get a Permission Denied error |
| sudo systemctl status nginx | Check web server status | When the website returns 502 or 503 errors |
| sudo apt update && sudo apt upgrade | Update the system | Weekly — keep the system secure |
| tail -f /var/log/nginx/error.log | View logs in real-time | When debugging a website error |
| ps aux | grep php | Filter PHP processes | Check if PHP-FPM is running |
| tar -czvf backup.tar.gz | Compress a backup | Before updating source code |
| grep "error" /var/log/nginx/error.log | Search within logs | When the log is too long and you need to find a specific error |
| ss -tlnp | Check open ports | When there's a port conflict or a service isn't listening |
Frequently Asked Questions
Do I need to know all of these commands?
No. Start with 10 commands: df -h, free -h, ls -la, cd, chmod, chown, systemctl, apt, tail -f, grep. Learn the rest as you encounter new situations.
How do I remember all these commands?
Practice is the best teacher. Create a Linux virtual machine with VirtualBox or rent a cheap VPS to experiment. Learn 2–3 commands per day and use them in real tasks.
I typed a wrong command. Is there an undo?
There is no undo in Linux. This is why you should always double-check before running rm -rf, chmod, or dd. Always have a backup before performing dangerous operations. Check out WordPress Data Backup Guide if you run WordPress.
Should I use Ubuntu or CentOS for hosting?
Ubuntu (LTS version) is the most popular choice for web hosting today, thanks to its large community, extensive documentation, and easy-to-use APT package manager. CentOS was once popular but has transitioned to CentOS Stream — many users have moved to Ubuntu or Rocky Linux.
How do I know if my server is under attack?
Run top or htop to spot processes consuming excessive CPU. Use ss -tlnp to check for suspicious connections. Monitor tail -f /var/log/auth.log for failed SSH attempts. Read more about What is DDoS? and Website Security.
Want to dig deeper into content optimization? Read our guide on What is Search Intent? How to Optimize for Intent — foundational knowledge for understanding user needs before creating content.
Summary
You now have the essential Linux server commands to begin your hosting management journey:
- System checks:
df -h,free -h,uname -a,uptime - File management:
ls,cd,cp,mv,rm,find - Permissions:
chmod,chown— safety first - Services:
systemctl,journalctl - Network:
ping,curl,wget,ss - Packages:
apt,dpkg - Logs:
tail -f,grep,cat,less - Compression:
tar,gzip,zip
Learning these commands isn't about becoming a professional system administrator — it's about being self-sufficient in running your website without always relying on support tickets. Once you're comfortable, explore What is Docker? A Beginner's Guide, What is Kubernetes?, and other advanced topics in the Hosting Knowledge section.
If you need professional website design or hosting optimization, contact RiverLee for detailed consultation.
Related tags:
LinuxLinux CommandsServer ManagementHostingSSHUbuntuVPSTerminalTechnical GuideHosting SetupComments
0 Comment(s)
Loading...
Latest Posts

Why Choose NextJS Over WordPress for Complex Projects (2026)
An in-depth analysis of why NextJS outperforms WordPress for complex projects — covering performance, SEO, security, and scalability. Practical guidance from web design professionals.

Real Estate Website Design in Dak Lak: Growth Solutions for 2026
Professional real estate website design solutions for Dak Lak — covering local SEO, 7 essential features, real pricing, and client testimonials. Built for agents and investors looking to grow online in 2026.

Website Design in Buon Ma Thuot: Cost, Process & Key Considerations (2026)
A comprehensive guide to website design in Buon Ma Thuot — real pricing for 2026, a step-by-step process, common mistakes to avoid, and a 10-point checklist for choosing a reliable web design agency in Dak Lak.

What is Content Pillar? SEO Content Strategy Guide 2026
Discover what a Content Pillar is and how to build an effective SEO content strategy. A detailed guide covering pillar characteristics, structure, the creation process, and KPI tracking for your website in 2026.
Related Posts

Server Security Guide – Essential Hardening Measures for Linux 2026
A comprehensive Linux server security guide covering 10 essential hardening measures — SSH hardening, firewall configuration, fail2ban, automatic security updates, user management, service security, kernel hardening, intrusion detection, and log monitoring.

What is Cloud Hosting? Benefits, How It Works, and When to Use It — 2026 Guide
Cloud hosting uses a cluster of virtualized servers to host websites and applications. Learn about its benefits, how it works, how it compares to VPS, and when to make the switch.

Hosting Price Comparison 2026 – Detailed Pricing of 15+ Local & International Providers
The most comprehensive hosting price comparison for 2026 — compare 15+ Vietnamese and international hosting providers including Hostinger, Bluehost, SiteGround, MatBao, PA Vietnam, VinaHost and more. Find the right hosting plan for your budget.

How to Install Nginx on a VPS – A Complete A-Z Guide (Ubuntu 22.04/24.04)
An A-Z guide to installing Nginx on a Ubuntu VPS — from SSH connection, firewall configuration, virtual host setup, PHP-FPM integration, server security, to troubleshooting and monitoring.

