A reference for common terminal commands used when managing a Ubuntu VPS — files, permissions, networking, users, and system utilities.
Navigate and manage directories and files on the filesystem.
cd /var/www/html cd .. cd ~
Flags:
..
~
ls ls -la ls -lh /var/www/
-l
-a
-h
mkdir /path/to/my/website mkdir /var/www/newsite mdir -p /var/www/a/b/c
-p
cp file.txt /tmp/file.txt mv oldname.txt newname.txt
Create, view and edit files directly in the terminal.
nano /etc/nginx/nginx.conf
Save with CTRL+X → Y → Enter. Discard with CTRL+X → N → Enter.
CTRL+X
Y
N
cat /var/www/file.txt
Dumps an entire file to the terminal. Always ends with an empty terminal line for a next command. Use less for long files.
less
less /var/www/file.txt
Creates an overlay to show a full file in the terminal. Looks like nano, but you cannot edit the file. Press q to leave the overlay.
q
touch /var/www/index.php
Also updates the last-modified timestamp on existing files.
tail -f /var/log/nginx/error.log tail -50 /var/log/syslog
-f
rm -rf
rm file.txt rm -r my-folder/
-i
-r
rmdir emptyfolder
Only works on completely empty directories. Safer than rm -r.
rm -r
Control who can read, write, and execute files.
chmod 755 file.sh chmod -R 775 /var/www/site/
755 → Owner: rwx · Group: r-x · Others: r-x
755
chown ubuntu:ubuntu file.txt chown -R www-data:ubuntu /var/www/site/
Format is user:group. Use -R to apply recursively.
user:group
-R
sudo nano /etc/nginx/nginx.conf sudo systemctl restart nginx
Elevates a single command to root. Safer than switching to the root user.
su root su - ubuntu
su - also loads the target user's environment variables.
su -
7 → rwx Read + Write + Execute 6 → rw- Read + Write 5 → r-x Read + Execute 4 → r-- Read only 0 → --- No access
Three digits = Owner · Group · Others. e.g. 755, 644, 600.
644
600
Create and manage system users. Useful for setting up deploy users or isolating services.
adduser john
Walks you through setting a password and home directory interactively.
usermod -aG sudo john
Adds john to the sudo group. Takes effect on next login.
john
sudo
passwd john sudo passwd root
Run without arguments to change your own password.
deluser john deluser --remove-home john
--remove-home also deletes their home directory and files.
--remove-home
Diagnose connectivity and inspect network configuration.
ping casper-rs.dev ping -c 4 8.8.8.8
-c 4 stops after 4 packets instead of running forever.
-c 4
curl https://example.com curl -I https://example.com curl ifconfig.me
-I shows headers only. ifconfig.me returns your public IP.
-I
ifconfig.me
hostname hostname -I
-I lists all IP addresses assigned to the server.
ss -tlnp
Shows all listening TCP ports and which process owns them. Replaces netstat.
netstat
Monitor system health and read service logs.
systemctl status nginx systemctl restart nginx systemctl enable php8.3-fpm
enable makes a service start automatically on boot.
enable
journalctl -xeu nginx journalctl -f -u php8.3-fpm
-f follows live, -u filters by service name.
-u
tail -f /var/log/nginx/error.log tail -f /var/log/nginx/access.log
Error log is the first place to check when a site isn't loading.
df -h free -h
df -h shows disk usage per partition. free -h shows RAM usage.
df -h
free -h
htop
Interactive CPU/RAM/process viewer. Install with apt install htop if missing.
apt install htop
uptime uname -r
uptime shows how long the server has been running. uname -r shows the kernel version.
uptime
uname -r