> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic Linux Commands for Beginners: 40 Server Essentials

> Basic Linux commands for beginners on a VPS or dedicated server: move around, manage files, read logs, install packages and check resources, with examples.

The basic Linux commands every server beginner needs are `pwd`, `ls` and `cd` to move around, `cp`, `mv`, `rm` and `mkdir` to manage files, `cat`, `less` and `tail` to read them, `sudo` to run admin tasks, `apt` or `dnf` to install software, and `df`, `free` and `top` to check resources. They work the same on Ubuntu, Debian, AlmaLinux and Rocky Linux, except the package manager.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 20 minutes to try them all | Ubuntu 22.04 / 24.04, Debian 12 / 13, AlmaLinux / Rocky 9 / 10 | An SSH session |

## Before you start

* [Connect to your server with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md).
* Log in as a normal user with sudo rights where you can. Commands that change the system start with `sudo`; if you are logged in as `root`, you can leave `sudo` out.
* Every command has a manual. Type `man ls` or `ls --help` to see all options. Press `q` to leave a manual page.

## How to move around the file system

Linux stores everything in one tree that starts at `/` (the root directory). Your home directory is `/home/<user>` (for root it is `/root`), shortened to `~`.

| Command | What it does | Example |
| - | - | - |
| `pwd` | Shows the directory you are in | `pwd` |
| `ls` | Lists files | `ls -lah` (long list, hidden files, readable sizes) |
| `cd` | Changes directory | `cd /var/log`, `cd ~`, `cd ..` (one level up) |
| `tree` | Shows a folder as a tree (install the `tree` package first) | `tree -L 2 /etc/nginx` |

```bash theme={null}
cd /var/log
pwd
ls -lah
```

Expected output of `pwd`:

```text theme={null}
/var/log
```

> [!TIP]
>
> Press `Tab` to complete file and command names, and the up arrow to repeat earlier commands. `history` lists everything you typed recently.

## How to create, copy, move and delete files

| Command | What it does | Example |
| - | - | - |
| `mkdir` | Creates a directory | `mkdir -p ~/backups/2026` (`-p` creates parent folders too) |
| `touch` | Creates an empty file or updates its time | `touch notes.txt` |
| `cp` | Copies | `cp config.yml config.yml.bak`, `cp -r site/ site-copy/` |
| `mv` | Moves or renames | `mv old.txt new.txt` |
| `rm` | Deletes a file | `rm notes.txt` |
| `rm -r` | Deletes a directory and everything in it | `rm -r ~/old-site` |
| `ln -s` | Creates a shortcut (symbolic link) | `ln -s /var/www/example.com ~/site` |

> [!WARNING]
>
> Linux has no recycle bin. `rm` deletes immediately, and `rm -rf` deletes without asking. Check the path with `ls` first, never run `rm -rf` on `/` or a path built from an empty variable, and take a [backup or snapshot](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md) before large clean-ups. Add `-i` (`rm -ri folder`) to confirm each file.

## How to read files and logs

| Command | What it does | Example |
| - | - | - |
| `cat` | Prints a whole file | `cat /etc/os-release` |
| `less` | Opens a file you can scroll and search (`/word`, `q` to quit) | `less /var/log/syslog` |
| `head` / `tail` | First or last lines | `tail -n 50 /var/log/nginx/error.log` |
| `tail -f` | Follows a file as it grows (`Ctrl+C` to stop) | `tail -f /var/log/auth.log` |
| `grep` | Finds lines that contain text | `grep -i "error" /var/log/syslog` |
| `journalctl` | Reads the systemd log | `journalctl -u ssh -n 50` |

`/var/log/syslog` and `/var/log/auth.log` exist on Ubuntu and Debian when `rsyslog` is installed. AlmaLinux and Rocky Linux use `/var/log/messages` and `/var/log/secure`. `journalctl` works on all of them; see [how to read logs with journalctl](https://help.freakhosting.com/portals/other/how-to-read-logs-with-journalctl.md).

To edit a file, use `nano` (easiest) or `vim`: see [how to edit files with nano and vim](https://help.freakhosting.com/portals/other/how-to-edit-files-with-nano-and-vim.md).

## How to install and update software

The package manager downloads software from your distribution's repositories.

> [tab] Ubuntu / Debian
>
> ```bash theme={null}
> sudo apt update            # refresh the package list
> sudo apt upgrade           # install available updates
> sudo apt install htop      # install a package
> sudo apt remove htop       # remove a package
> apt search nginx           # search for a package
> ```

> [tab] AlmaLinux / Rocky
>
> ```bash theme={null}
> sudo dnf upgrade           # refresh metadata and install updates
> sudo dnf install htop      # install a package (htop is in EPEL: sudo dnf install epel-release first)
> sudo dnf remove htop       # remove a package
> dnf search nginx           # search for a package
> ```

More detail: [how to update Linux packages](https://help.freakhosting.com/portals/other/how-to-update-linux-packages.md).

## How to check resources: disk, memory and CPU

| Command | What it shows | Example |
| - | - | - |
| `df -h` | Free disk space per file system | `df -h /` |
| `du -sh` | Size of a folder | `sudo du -sh /var/log` |
| `free -h` | Memory and swap use | `free -h` |
| `top` / `htop` | Live CPU and memory per process (`q` to quit) | `top` |
| `uptime` | Time since boot and load average | `uptime` |
| `nproc` | Number of CPU cores | `nproc` |

Example output of `free -h`:

```text theme={null}
               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       978Mi       5.4Gi        15Mi       1.8Gi       6.9Gi
```

Look at the `available` column: that is what new programs can still use.

## How to manage processes and services

| Command | What it does | Example |
| - | - | - |
| `ps aux` | Lists all running processes | `ps aux \| grep nginx` |
| `kill` | Asks a process to stop | `kill 12345` |
| `systemctl status` | Shows if a service runs | `sudo systemctl status nginx` |
| `systemctl restart` | Restarts a service | `sudo systemctl restart nginx` |
| `ss -tulpn` | Shows which ports are listening | `sudo ss -tulpn` |

See [how to manage services with systemctl](https://help.freakhosting.com/portals/other/how-to-manage-services-with-systemctl.md) and [how to kill a process](https://help.freakhosting.com/portals/other/how-to-kill-a-process-on-linux.md).

## How to manage users and permissions

| Command | What it does | Example |
| - | - | - |
| `whoami` | Shows your user name | `whoami` |
| `sudo` | Runs one command as root | `sudo systemctl restart ssh` |
| `passwd` | Changes your password | `passwd` |
| `chmod` | Changes permissions | `chmod 640 config.php` |
| `chown` | Changes owner | `sudo chown alex:alex file.txt` |

See [how to create a sudo user](https://help.freakhosting.com/portals/other/how-to-create-a-sudo-user-on-linux.md) and [file permissions explained](https://help.freakhosting.com/portals/other/linux-file-permissions-explained-chmod-and-chown.md).

## Networking and transfer commands

| Command | What it does | Example |
| - | - | - |
| `ip a` | Shows your IP addresses | `ip -br a` |
| `ping` | Tests if a host answers | `ping -c 4 example.com` |
| `curl` | Fetches a URL | `curl -I https://example.com` |
| `wget` | Downloads a file | `wget https://example.com/file.tar.gz` |
| `scp` / `rsync` | Copy files between machines | `rsync -avz site/ alex@203.0.113.10:/var/www/site/` |

## How to check it worked

Run these three commands. If each prints a result without an error, your shell, sudo and package manager all work:

```bash theme={null}
whoami
sudo whoami
df -h /
```

`sudo whoami` prints `root`.

## Frequently asked questions

### Is the Linux terminal case-sensitive?

Yes. `File.txt` and `file.txt` are two different files, and `LS` is not the same command as `ls`.

### How do I stop a command that is running?

Press `Ctrl+C`. If a full-screen program such as `less`, `top` or `man` is open, press `q`.

### Why do I get "Permission denied"?

You are trying to change something that belongs to another user or to root. Put `sudo` in front of the command, or check the file owner with `ls -l`. See [file permissions explained](https://help.freakhosting.com/portals/other/linux-file-permissions-explained-chmod-and-chown.md).

### How do I log out of the server?

Type `exit` or press `Ctrl+D`. Running programs started in that session stop unless you use `tmux` or `screen`; see [keep SSH sessions running](https://help.freakhosting.com/portals/other/how-to-keep-ssh-sessions-running-with-tmux-and-screen.md).

### How do I clear the screen?

Type `clear` or press `Ctrl+L`.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md)
>
> Log in to your Linux server.

> [card] [Find files and text](https://help.freakhosting.com/portals/other/how-to-find-files-and-text-on-linux.md)
>
> Use find and grep.

> [card] [Edit files with nano and vim](https://help.freakhosting.com/portals/other/how-to-edit-files-with-nano-and-vim.md)
>
> Change config files safely.

> [card] [First 10 things on a new VPS](https://help.freakhosting.com/portals/other/first-10-things-to-do-on-a-new-linux-vps.md)
>
> Set up a new server properly.

***

> [!NOTE]
>
> **Checked against the official [GNU Coreutils manual](https://www.gnu.org/software/coreutils/manual/coreutils.html) and the [Ubuntu Server documentation](https://documentation.ubuntu.com/server/)** on 4 November 2026; commands tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.