Basic VPS Server Management Commands
This guide covers the essential Linux commands you need for day-to-day management of your {{COMPANY_NAME}} VPS. Whether you are managing files, services, users, or packages, these commands will help you operate your server efficiently.
File and Directory Management
Navigating the Filesystem
bash
# Print current directory
pwd
# List files and directories
ls -la
# Change directory
cd /var/www
# Go to home directory
cd ~
# Go up one level
cd ..Creating, Copying, Moving, and Deleting
bash
# Create a directory
mkdir /var/www/mysite
mkdir -p /var/www/mysite/public/assets # create nested directories
# Create an empty file
touch filename.txt
# Copy files
cp source.txt destination.txt
cp -r /source/directory /destination/ # copy directory recursively
# Move or rename files
mv oldname.txt newname.txt
mv file.txt /new/location/
# Delete files
rm filename.txt
rm -r directory/ # delete directory and contents
rm -rf directory/ # force delete (use with caution)Tip: Always double-check
rm -rfcommands before executing. There is no recycle bin on Linux.
File Permissions
bash
# View permissions
ls -la
# Change ownership
chown user:group filename
chown -R www-data:www-data /var/www/ # recursive ownership
# Change permissions
chmod 755 directory/
chmod 644 file.txt
chmod +x script.sh # make executablePermission numbers explained:
7= read + write + execute6= read + write5= read + execute4= read only
Service Management (systemd)
Most modern Linux distributions use systemd for managing services.
bash
# Start a service
sudo systemctl start nginx
# Stop a service
sudo systemctl stop nginx
# Restart a service
sudo systemctl restart nginx
# Reload configuration without restart
sudo systemctl reload nginx
# Check service status
sudo systemctl status nginx
# Enable service to start on boot
sudo systemctl enable nginx
# Disable auto-start
sudo systemctl disable nginx
# List all running services
systemctl list-units --type=service --state=runningPackage Management
Ubuntu/Debian (apt)
bash
# Update package lists
sudo apt update
# Upgrade installed packages
sudo apt upgrade -y
# Install a package
sudo apt install nginx -y
# Remove a package
sudo apt remove nginx
# Remove package and configuration
sudo apt purge nginx
# Search for packages
apt search keyword
# Clean up unused packages
sudo apt autoremoveCentOS/RHEL (yum/dnf)
bash
# Update packages
sudo yum update -y
# Install a package
sudo yum install nginx -y
# Remove a package
sudo yum remove nginx
# Search for packages
yum search keywordUser Management
bash
# Add a new user
sudo adduser username
# Delete a user
sudo deluser username
sudo deluser --remove-home username # also remove home directory
# Add user to a group
sudo usermod -aG groupname username
# Grant sudo privileges
sudo usermod -aG sudo username
# Switch to another user
su - username
# List all users
cat /etc/passwd
# Change password
passwd # current user
sudo passwd username # another userDisk Management
bash
# Check disk space usage
df -h
# Check directory size
du -sh /var/www
du -sh /* # size of each top-level directory
# Find large files (over 100MB)
find / -type f -size +100M -exec ls -lh {} ;
# Check inode usage
df -iNetwork Commands
bash
# Check IP address
ip addr show
# Test connectivity
ping google.com -c 4
# Check open ports
ss -tulnp
# Check active connections
ss -tan
# DNS lookup
dig example.com
nslookup example.com
# Download a file
wget https://example.com/file.tar.gz
curl -O https://example.com/file.tar.gz
# Check which process uses a port
sudo lsof -i :80Process Management
bash
# List running processes
ps aux
# Find a specific process
ps aux | grep nginx
# Interactive process viewer
top
htop # more user-friendly (install: sudo apt install htop)
# Kill a process by PID
kill PID
kill -9 PID # force kill
# Kill by name
killall processname
pkill processnameText File Operations
bash
# View file contents
cat filename.txt
# View with pagination
less filename.txt
# View first/last lines
head -n 20 filename.txt
tail -n 20 filename.txt
# Follow a log file in real time
tail -f /var/log/syslog
# Search within files
grep "search term" filename.txt
grep -r "search term" /directory/ # recursive search
# Edit files
nano filename.txt # beginner-friendly
vim filename.txt # powerful but steeper learning curveSystem Information
bash
# OS information
lsb_release -a
cat /etc/os-release
# Kernel version
uname -r
# System uptime
uptime
# Memory usage
free -h
# CPU info
lscpu
nproc # number of CPUs
# System hostname
hostname
hostnamectlCron Jobs (Scheduled Tasks)
bash
# Edit crontab
crontab -e
# List cron jobs
crontab -l
# Cron format: minute hour day month weekday command
# Run daily at 2:30 AM
30 2 * * * /path/to/script.sh
# Run every 5 minutes
*/5 * * * * /path/to/script.sh
# Run every Monday at 9 AM
0 9 * * 1 /path/to/script.shRelated Articles
- How to Connect to Your VPS via SSH
- Monitoring VPS Resources (CPU, RAM, Disk)
- Setting Up a Firewall on Your VPS (UFW/iptables)
Need help managing your VPS? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.