Why Linux for Hosting?
Almost all web hosting runs on Linux because:
- Free and open source ā no licensing costs
- Stable ā servers run for years without restart
- Secure ā robust permission system
- Efficient ā low resource overhead
- Flexible ā runs everything from blogs to enterprise apps
Essential Linux Concepts
The File System
/ Root directory
āāā home/ User home directories
āāā var/ Variable data (logs, websites)
ā āāā www/ Web files (some distros)
ā āāā log/ System logs
āāā etc/ Configuration files
āāā usr/ User programs
āāā tmp/ Temporary filesFile Permissions
Every file has three permission sets: owner, group, others.
-rwxr-xr-x = 755 (directory standard)
-rw-r--r-- = 644 (file standard)Common Commands
bash
# System info
uname -a # Kernel version
cat /etc/os-release # OS details
uptime # Server uptime
# Process management
ps aux # List all processes
kill -9 PID # Force kill process
systemctl status nginx # Service status
# Networking
curl -I domain.com # Check HTTP headers
dig domain.com # DNS lookup
netstat -tlnp # Open portsWeb Server Management
Apache Commands
bash
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl reload apache2 # Graceful reload
sudo apachectl configtest # Test configNginx Commands
bash
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo nginx -t # Test config
sudo nginx -s reload # Graceful reloadLog Files
Logs are your best debugging tool:
bash
# Apache
/var/log/apache2/access.log
/var/log/apache2/error.log
# Nginx
/var/log/nginx/access.log
/var/log/nginx/error.log
# PHP
/var/log/php-fpm.log
# System
/var/log/syslog
/var/log/auth.logReading Logs
bash
# Last 50 lines
tail -50 /var/log/apache2/error.log
# Follow in real-time
tail -f /var/log/nginx/access.log
# Search for errors
grep "error" /var/log/apache2/error.logPackage Management
Ubuntu/Debian (apt)
bash
sudo apt update # Update package list
sudo apt upgrade # Upgrade packages
sudo apt install nginx # Install package
sudo apt remove nginx # Remove packageCentOS/RHEL (yum/dnf)
bash
sudo dnf update
sudo dnf install nginx
sudo dnf remove nginxConclusion
You do not need to be a Linux expert to manage your hosting, but knowing these basics makes you self-sufficient for most tasks. Start with file navigation and log reading ā these two skills solve 80% of hosting issues.