Server Management (Unmanaged)

Linux Server Mastery: Essential Shell Commands for Beginners

By the Domain India teamPublished 9 min read
Knowledge base article
Contents (11 sections)

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.

This guide is for your own VPS or server

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.

Key takeaways

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 commandUse insteadNotes
ifconfigip addr, ip linkifconfig is in the old net-tools package, often not installed
netstat -tulnss -tulpnss is faster and installed by default
service name startsystemctl start namesystemd manages services on all current distributions
chkconfig name onsystemctl enable nameStarts the service at boot
yum installdnf installOn AlmaLinux and Rocky, yum is only an alias for dnf
iptables rules by handfirewall-cmd or ufwBoth 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:

bash
ssh -i ~/.ssh/id_ed25519 youruser@your-server-ip

Then look around:

bash
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 file

For 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

bash
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, recursively

For websites, files are usually 644 and folders 755. Never use 777: it lets any process on the server change the file.

rm, dd and mkfs do not ask twice

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

bash
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 groups

Do 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

TaskAlmaLinux / Rocky LinuxUbuntu / Debian
Refresh and apply all updatessudo dnf upgradesudo apt update && sudo apt upgrade
Install a packagesudo dnf install htopsudo apt install htop
Remove a packagesudo dnf remove htopsudo apt remove htop
Search for a packagednf search nginxapt search nginx
List installed packagesrpm -qadpkg -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

bash
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 times

Most 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

bash
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 80

vmstat 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

bash
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:

bash
sudo firewall-cmd --list-all
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

On 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

bash
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 server

Keep 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.

VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details

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.

Your own server, full root access

Self-managed KVM VPS with root SSH access and your choice of Linux distribution.

See VPS plans

Ready when you are

Get VPS from ₹552.65/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Essential Linux Server Commands for Beginners | Domain India