If you run your own Linux server, most day-to-day work happens at the command line: checking disk space, installing updates, restarting a service, reading a log. This guide covers the essential commands for a server you manage yourself, such as a VPS, using AlmaLinux and Rocky Linux as the main examples with Ubuntu and Debian equivalents, and it points out which older commands have been replaced.
The commands for users, packages, services and firewalls need root access, which you have on a VPS but not on shared hosting. On Domain India shared hosting you get a jailed (restricted) shell instead; see how to log in using SSH and essential commands for shared hosting.
Log in with an SSH key as a normal user and use sudo for admin tasks. Use dnf (AlmaLinux, Rocky) or apt (Ubuntu, Debian) for packages, systemctl and journalctl for services and logs, ip and ss for networking, and firewall-cmd or ufw for the firewall. Look before you change: df -h, du -sh, top and journalctl tell you what is wrong before you touch anything.
1. Old commands and their modern replacements
Many older tutorials, including the earlier version of this article, use commands that are deprecated or missing on current distributions. CentOS Linux itself has reached end of life; AlmaLinux and Rocky Linux are its maintained successors.
| Old command | Use instead | Notes |
|---|---|---|
| ifconfig | ip addr, ip link | ifconfig is in the old net-tools package, often not installed |
| netstat -tuln | ss -tulpn | ss is faster and installed by default |
| service name start | systemctl start name | systemd manages services on all current distributions |
| chkconfig name on | systemctl enable name | Starts the service at boot |
| yum install | dnf install | On AlmaLinux and Rocky, yum is only an alias for dnf |
| iptables rules by hand | firewall-cmd or ufw | Both manage nftables underneath |
2. Log in and find your way around
Connect with an SSH key, as a normal user, from Terminal on macOS or Linux, or PowerShell on Windows:
ssh -i ~/.ssh/id_ed25519 youruser@your-server-ipThen look around:
pwd # where am I?
ls -lah # list files, including hidden ones, with sizes
cd /var/www # change folder
cd ~ # back to your home folder
less /etc/os-release # read a file page by page (q to quit)
tail -n 50 file.log # last 50 lines of a fileFor setting up keys and a first login, see how to access your Domain India VPS using SSH and how to generate SSH keys.
3. Files, permissions and ownership
mkdir -p /srv/app/logs # create a folder, with parents
cp -a site site.bak # copy, keeping permissions and dates
mv old.conf new.conf # rename or move
rm file.txt # delete a file
chmod 644 index.php # owner read/write, everyone else read
chmod 755 /srv/app # folders: owner full, others read and enter
chown -R nginx:nginx /srv/app # change owner and group, recursivelyFor websites, files are usually 644 and folders 755. Never use 777: it lets any process on the server change the file.
rm -rf deletes permanently, dd overwrites whatever you point it at, and mkfs erases a whole partition. Run pwd, ls and lsblk first, double-check device names such as /dev/sdb1, and take a backup or snapshot before any disk operation.
4. Users, groups and sudo
sudo useradd -m -s /bin/bash deploy # create a user with a home folder
sudo passwd deploy # set a password
sudo usermod -aG wheel deploy # AlmaLinux/Rocky: allow sudo
sudo usermod -aG sudo deploy # Ubuntu/Debian: allow sudo
sudo groupadd webteam # create a group
sudo userdel -r olduser # remove a user and their home folder
id deploy # check a user's groupsDo daily work as a normal user and use sudo for admin commands. Turn off direct root login over SSH once your sudo user works; the SSH security hardening checklist shows how.
5. Packages and updates
| Task | AlmaLinux / Rocky Linux | Ubuntu / Debian |
|---|---|---|
| Refresh and apply all updates | sudo dnf upgrade | sudo apt update && sudo apt upgrade |
| Install a package | sudo dnf install htop | sudo apt install htop |
| Remove a package | sudo dnf remove htop | sudo apt remove htop |
| Search for a package | dnf search nginx | apt search nginx |
| List installed packages | rpm -qa | dpkg -l |
On AlmaLinux and Rocky Linux, many extra tools such as htop come from the EPEL repository: install it first with sudo dnf install epel-release. Apply security updates regularly, and reboot after kernel updates.
6. Services and logs
sudo systemctl status nginx # is it running? recent log lines
sudo systemctl restart nginx # restart
sudo systemctl enable --now nginx # start now and at every boot
systemctl list-units --failed # anything that failed to start
sudo journalctl -u nginx --since "1 hour ago" # a service's log
sudo journalctl -p err -b # errors since the last boot
sudo dmesg -T | tail -n 50 # kernel messages, with readable timesMost services also write their own logs under /var/log, for example /var/log/nginx/error.log. Use sudo tail -f on a log to watch new lines arrive while you test.
7. Processes, memory and disk
top # live CPU and memory use (q to quit); htop is friendlier
ps aux --sort=-%mem | head # the processes using the most memory
kill 12345 # ask process 12345 to stop; kill -9 only as a last resort
free -h # memory and swap
uptime # load averages for 1, 5 and 15 minutes
df -h # free space on each file system
du -sh /var/* | sort -h # which folders are largest
lsblk # disks and partitions
sudo lsof -i :80 # which process is using port 80vmstat 1 5 and iostat -x 1 (from the sysstat package) show whether the server is short of CPU, memory or disk speed. To run a heavy job gently, start it with nice -n 10 command.
8. Networking and the firewall
ip addr # IP addresses on each interface
ip route # the default gateway
ss -tulpn # listening ports and the programs behind them
ping -c 4 example.com # basic reachability
tracepath example.com # the route to a host (or traceroute, if installed)
curl -I https://example.com # HTTP status and headers
dig example.com A +short # DNS lookup (bind-utils or dnsutils package)Open only the ports you need. On AlmaLinux and Rocky Linux, firewalld is the default:
sudo firewall-cmd --list-all
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reloadOn Ubuntu, ufw is simpler: sudo ufw allow OpenSSH, sudo ufw allow 443/tcp, then sudo ufw enable. Always allow SSH before you enable a firewall, or you lock yourself out. For rule-level control, see modern firewall management with nftables.
9. Text, scheduling and backups
grep -ri "error" /var/log/nginx/ # search files for a word
sed -i.bak 's/old/new/g' app.conf # replace text, keeping app.conf.bak
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head # top visitor IPs
crontab -e # edit scheduled jobs for your user
tar -czf site-$(date +%F).tar.gz /srv/app # pack a folder
rsync -a /srv/app/ backup@other-host:/backups/app/ # copy to another serverKeep backups off the server itself, test a restore now and then, and be careful with rsync --delete, which removes files at the destination that are not in the source. More on scheduling in cron job commands and on searching in the grep guide.
10. Where Domain India fits
A Domain India VPS is self-managed by default, with full root SSH access and a choice of Linux distributions, including AlmaLinux, Rocky Linux, Ubuntu and Debian. Everything in this guide applies there: you install packages, run services and manage the firewall yourself. cPanel is not offered on a VPS.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
The plan card shows the Domain India list price, excluding 18% GST. If you only need to manage a website and do not want to look after a server, shared hosting with a control panel is simpler: jailed SSH is available on every shared plan on request, but root commands are not.
Frequently asked questions
What are the most important Linux commands for managing a server?
For daily work: ls, cd and less to look around; df -h and du -sh for disk space; top and free -h for load and memory; systemctl and journalctl for services and logs; dnf or apt for updates; ss -tulpn for open ports; and firewall-cmd or ufw for the firewall.
Should I use yum or dnf on AlmaLinux and Rocky Linux?
Use dnf. On current AlmaLinux and Rocky Linux releases, yum is only an alias for dnf, so both work, but new guides and scripts should use dnf.
Why is ifconfig or netstat not found on my server?
They belong to the old net-tools package, which current distributions do not install by default. Use ip addr instead of ifconfig and ss -tulpn instead of netstat.
Can I run these commands on shared hosting?
Only the basic file commands. Shared hosting gives a jailed shell limited to your own account, with no sudo, package installs, service control or firewall changes. Those need a VPS with root access.
How do I restart a service on Linux?
Run sudo systemctl restart followed by the service name, for example sudo systemctl restart nginx. Check the result with sudo systemctl status nginx and read its log with sudo journalctl -u nginx.
Is CentOS still a good choice for a server?
No. CentOS Linux has reached end of life and no longer receives updates. Choose AlmaLinux or Rocky Linux for a RHEL-compatible server, or Ubuntu LTS or Debian if you prefer that family.
Ready to run your own server? Compare VPS plans, set up SSH key login first, and work through the SSH hardening checklist before you put anything live.
Self-managed KVM VPS with root SSH access and your choice of Linux distribution.
See VPS plans