---
title: "Linux commands you need on a new server · CloudSat"
description: "The Linux commands that matter on a fresh server: finding your way, reading logs, running services, users and packages, plus habits that prevent mistakes."
url: https://cloudsat.io/learn/essential-linux-commands-for-servers
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Linux](https://cloudsat.io/learn/topic/linux)

# Linux commands you need on a new server

The Linux commands that matter on a fresh server: finding your way, reading logs, running services, users and packages, plus habits that prevent mistakes.

CloudSat team November 18, 2026 8 min read

You have just logged in to a new server over SSH and the prompt is blinking. This guide covers the commands you will actually type during the first week, grouped by job instead of alphabetically. Examples assume Debian or Ubuntu, with the RHEL-family equivalent (AlmaLinux, Rocky Linux, Fedora) noted where it differs. Anything that changes the system needs root, so prefix it with `sudo` when you work as a normal user.

## Get your bearings

Before changing anything, find out what you are logged in to. These commands only read, so they are safe anywhere.

```bash
whoami                 # which user you are
hostnamectl            # hostname, OS, kernel, virtualization type
cat /etc/os-release    # distribution name and version
uptime                 # time since boot, plus load averages
pwd                    # current directory
ls -la                 # all files, hidden ones included, with details
```

`hostnamectl` is worth remembering: on a VPS it reports the virtualization type (for example `kvm`). The three load averages from `uptime` count processes that are running, waiting for a CPU or blocked on disk, averaged over 1, 5 and 15 minutes. A load that stays above your vCPU count means work is queuing.

Moving around uses `cd` with absolute paths (`cd /etc/nginx`), relative paths (`cd ../sites-available`), `cd -` to jump back to the previous directory and a bare `cd` to return home. Tab completion saves typing and typos: press Tab once to complete a name, twice to list the candidates.

## Read files without opening an editor

Most troubleshooting is reading: configuration files, logs and command output.

```bash
less /etc/ssh/sshd_config            # scroll; /word searches, n repeats, q quits
head -n 20 /etc/passwd               # first 20 lines
tail -n 50 /var/log/nginx/error.log  # last 50 lines
tail -f /var/log/nginx/access.log    # follow new lines live, Ctrl+C stops
grep -i "error" /var/log/nginx/error.log
grep -rn "listen" /etc/nginx/        # search a directory, show line numbers
```

Prefer `less` to `cat` for anything longer than one screen, because it does not dump the whole file into your terminal. On recent Debian releases the classic `/var/log/syslog` file is not created by default: system messages live in the systemd journal, which you read with `journalctl` (covered below).

## Change files carefully

```bash
cp -a nginx.conf nginx.conf.bak   # copy, keeping permissions and timestamps
mv -i draft.conf site.conf        # rename, ask before overwriting
mkdir -p /srv/app/releases        # create a path, parents included
rm -i old.log                     # delete, ask first
nano /etc/hostname                # simple editor: Ctrl+O saves, Ctrl+X exits
```

If you prefer vim, `vi` or `vim` is on almost every server: `:wq` saves and quits, `:q!` quits without saving.

Three habits pay for themselves. Back up a configuration file before you edit it. Test the configuration before reloading the service, since most daemons ship a checker: `nginx -t`, `sshd -t`, `apachectl configtest`. And treat `rm -r` with respect. There is no trash folder, and one stray space turns `rm -r /srv/app/old` into `rm -r /srv/app /old`, which deletes the whole application.

## Permissions and ownership

`ls -l` prints a permission string such as `-rw-r-----`, then the owner and the group. Read the string in three sets of three: owner, group, everyone else. `r` means read, `w` write and `x` execute (or enter, for a directory).

| Number | Letters | Typical use |
| --- | --- | --- |
| 600 | `rw-------` | private keys, files holding secrets |
| 640 | `rw-r-----` | config a service group must read |
| 644 | `rw-r--r--` | ordinary files and web content |
| 700 | `rwx------` | private directories such as `~/.ssh` |
| 755 | `rwxr-xr-x` | directories and scripts others may run |

```bash
chmod 640 /etc/myapp/config.yml
chmod u+x deploy.sh                    # add execute for the owner only
chown -R www-data:www-data /srv/site   # web user on Debian/Ubuntu
id deploy                              # a user's groups
```

The web server account differs by family: `www-data` on Debian and Ubuntu, `nginx` or `apache` on the RHEL family. Resist `chmod 777`. It makes a file writable by every account and process on the machine, and it rarely fixes the real problem, which is usually the wrong owner.

## Users and sudo

Working as root all day turns every typo into a system-wide typo. Create a normal user, give it sudo rights and log in as that user.

```bash
adduser deploy                       # Debian/Ubuntu: interactive, creates home
usermod -aG sudo deploy              # Debian/Ubuntu admin group
useradd -m deploy && passwd deploy   # RHEL family equivalent of adduser
usermod -aG wheel deploy             # RHEL family admin group
```

The `-a` in `usermod -aG` matters: without it, the user leaves every group not named in the command. From your own computer, copy your public key to the new account with `ssh-copy-id deploy@203.0.113.10`, check that key login works in a second terminal, and only then think about disabling password logins.

## Services and logs with systemd

Nearly every current distribution uses systemd, so the same two tools manage services everywhere.

```bash
systemctl status nginx           # state, main PID, recent log lines
systemctl restart nginx          # full stop and start
systemctl reload nginx           # re-read config, keep connections
systemctl enable --now nginx     # start now and at every boot
systemctl --failed               # units that crashed
journalctl -u nginx --since "1 hour ago"
journalctl -p err -b             # errors since the last boot
journalctl -f                    # follow every log live
```

Use `reload` when a service supports it; Nginx, for instance, picks up new configuration without dropping open connections. When a unit refuses to start, `systemctl status` shows its last lines and `journalctl -u nginx -e` jumps to the end of the full log.

## Install and update software

The package manager is the biggest difference between distribution families. The concepts are the same.

| Task | Debian / Ubuntu | AlmaLinux / Rocky / Fedora |
| --- | --- | --- |
| Refresh package lists | `apt update` | `dnf check-update` |
| Install all updates | `apt upgrade` | `dnf upgrade` |
| Install a package | `apt install tmux` | `dnf install tmux` |
| Remove a package | `apt remove tmux` | `dnf remove tmux` |
| Search by name | `apt search nginx` | `dnf search nginx` |
| Find which package owns a file | `dpkg -S /usr/bin/curl` | `rpm -qf /usr/bin/curl` |

On Debian and Ubuntu, `apt update` only refreshes the lists and `apt upgrade` installs the new versions; skipping the first step is the classic reason a package "cannot be found" on a fresh server. `dnf` refreshes its metadata on its own when it is stale. Security updates can install themselves with `unattended-upgrades` (Debian and Ubuntu) or `dnf-automatic` (RHEL family).

## Processes and resources

```bash
top                                # live view: M sorts by memory, q quits
ps aux --sort=-%mem | head -n 10   # biggest memory users
free -h                            # RAM and swap
df -h                              # space per filesystem
kill 1234                          # ask process 1234 to stop (SIGTERM)
kill -9 1234                       # force it, as a last resort
```

`free -h` confuses many people. Linux uses spare RAM as disk cache, so the `free` column looks tiny on a healthy server; read the `available` column instead. When `df -h` shows a filesystem close to 100%, follow the steps in [finding what fills a Linux disk](https://cloudsat.io/learn/find-what-is-filling-your-linux-disk).

## Check the network

```bash
ip -br addr                  # interfaces and addresses, one line each
ip route                     # default gateway
ss -tulpn                    # listening ports and the process behind each
curl -I https://example.com  # HTTP status and response headers
ping -c 4 1.1.1.1            # basic reachability
```

`ss -tulpn` answers the most common network question: is my service listening, and on which address? A service bound to `127.0.0.1` is reachable only from the server itself. One bound to `0.0.0.0` or `[::]` listens on every interface, and from then on the firewall decides who gets in.

## Habits that prevent bad days

- Run long jobs inside `tmux`: start with `tmux new -s work`, detach with Ctrl+B then D, and come back with `tmux attach -t work`. A dropped SSH connection then cannot kill an upgrade halfway through.
- Read before you run. `man rsync` and `rsync --help` take a minute; repairing a server takes an evening.
- Press Ctrl+R to search your shell history instead of retyping a long command.
- Take a snapshot before risky changes. On a CloudSat server that is one action in the console ([take a snapshot](https://cloudsat.io/docs/take-a-snapshot)), and restoring it rolls back a bad upgrade.

## FAQ

### Do these commands work on every distribution?

Almost all of them. Navigation, file, permission, process and network commands are the same everywhere. Package management differs (`apt`, `dnf`, `zypper`, `apk`), and tiny images such as Alpine use BusyBox versions of common tools with fewer options.

### What is the difference between sudo and su?

`sudo command` runs one command as root after asking for your own password, and it logs what you ran. `su -` opens a full root shell and asks for the root password. Prefer `sudo`: it leaves an audit trail and works when root has no password at all, which is the default on Ubuntu.

### How do I stop a command that hangs?

Press Ctrl+C to interrupt it. If the terminal itself is frozen, open a second SSH session, find the process with `pgrep -a name`, and end it with `kill`. Ctrl+Z suspends a job instead of stopping it; `fg` brings it back to the foreground.

### Where can I practice without risk?

Any machine you can wipe works: a local virtual machine, or a small VPS that you rebuild whenever you break it. A 512 MB [Cloud VPS](https://cloudsat.io/cloud-vps) from CloudSat costs $1.98/mo and bills by the hour, so an afternoon of practice costs very little.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Linux](https://cloudsat.io/learn/topic/linux)

- [Find what is filling your Linux disk with df, du and ncdu](https://cloudsat.io/learn/find-what-is-filling-your-linux-disk): Linux Find what is filling your Linux disk with df, du and ncdu 7 min read
- [Copy files over SSH with scp, sftp and rsync](https://cloudsat.io/learn/transfer-files-over-ssh-scp-sftp-rsync): Linux Copy files over SSH with scp, sftp and rsync 7 min read
- [Bash if statements with [ ], [[ ]], (( )) and case](https://cloudsat.io/learn/bash-conditionals-if-test-case): Linux Bash if statements with [ ], [[ ]], (( )) and case 8 min read
- [List running services on Linux and audit what should run](https://cloudsat.io/learn/list-and-audit-services-with-systemctl): Linux List running services on Linux and audit what should run 7 min read
