Skip to content

First steps on a Linux server

In this tutorial, we will take a first look around a freshly installed Debian 13 server from the command line. By the end, you will have found out which system you are on, explored its directory tree, created and copied files, changed who may read them, looked up help for a command, installed a package and checked that a service is running.

This is the first lesson of the Magellanic learning path. Apart from installing one small package, nothing here changes the server's configuration or affects its services, so you can follow it on any test machine without worrying about breaking it.

Before you begin

  • A fresh Debian 13 ("trixie") server or virtual machine.
  • An ordinary user account on it that is allowed to use sudo. Cloud images create one for you; on a manual install, it's the user you created during installation.
  • You are logged in to that account over SSH, and you see a shell prompt such as labuser@server1:~$.

In the examples, the user is called labuser and the server server1. Your names will differ, and so will dates, sizes and other details in the output. Type each command after the $ prompt and press Enter.

Step 1: Find out where you are

When you log in to an unfamiliar server, first make sure it's the machine you think it is. Ask for your user name and the server's host name:

$ whoami
labuser
$ hostname
server1

Now ask which operating system is installed. Every modern Linux distribution describes itself in the file /etc/os-release, and cat prints a file to the screen:

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.7
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Notice PRETTY_NAME and VERSION_CODENAME: this is Debian 13, code-named "trixie".

Finally, find out how long the server has been running:

$ uptime
 10:42:07 up 3 days,  2:15,  1 user,  load average: 0.00, 0.01, 0.00

The output shows the current time, how long the system has been up, how many users are logged in (you), and the load average: roughly how busy the processors have been over the last 1, 5 and 15 minutes. On an idle server, the load is close to zero.

Step 2: Look around the directory tree

On Linux, every file lives somewhere in a single tree of directories that starts at /, called the root directory. Find out where in the tree you are now:

$ pwd
/home/labuser

pwd prints the working directory. You start in your home directory, /home/labuser, which belongs to you.

List what is at the top of the tree:

$ ls /
bin   dev  home  lib64       media  opt   root  sbin  sys  usr
boot  etc  lib   lost+found  mnt    proc  run   srv   tmp  var

Three of these directories are worth knowing from your first day:

  • /etc holds the system's configuration files.
  • /var/log holds log files.
  • /home holds one home directory for each ordinary user.

Look inside each one. /etc contains well over a hundred entries, so show only the first ten with head:

$ ls /etc | head
adduser.conf
alternatives
apparmor
apparmor.d
apt
bash.bashrc
bash_completion
bash_completion.d
bindresvport.blacklist
binfmt.d

The | symbol, called a pipe, sends the output of ls into head, which keeps the first ten lines.

$ ls /var/log
README  cloud-init-output.log  journal  private  unattended-upgrades
btmp    cloud-init.log         lastlog  runit    wtmp
$ ls /home
labuser

Notice the journal directory in /var/log. Debian 13 keeps most system messages in the systemd journal rather than in plain text files, so you won't find the /var/log/syslog file that older guides mention. And /home contains just one directory: yours.

Step 3: Create, copy and view files

Make a directory to practise in, inside your home directory:

$ mkdir practice
$ ls
practice

Create a small text file in it. The > symbol sends the output of echo into a file instead of to the screen:

$ echo "My first file on this server" > practice/notes.txt
$ ls practice
notes.txt
$ cat practice/notes.txt
My first file on this server

Copy the file with cp, which takes the source first and the destination second. Then copy a file from /etc into the same directory:

$ cp practice/notes.txt practice/notes-copy.txt
$ cp /etc/hostname practice/
$ ls practice
hostname  notes-copy.txt  notes.txt
$ cat practice/hostname
server1

You have just read a configuration file: /etc/hostname holds the server's name. Because you copied it, the copy in practice is yours, and changing it won't affect the system.

Step 4: Read ownership and permissions

Ask ls for a long listing with -l:

$ ls -l practice
total 12
-rw-r--r-- 1 labuser labuser  8 Nov  7 10:44 hostname
-rw-rw-r-- 1 labuser labuser 29 Nov  7 10:44 notes-copy.txt
-rw-rw-r-- 1 labuser labuser 29 Nov  7 10:44 notes.txt

Each line describes one file. Read the line for notes.txt from left to right:

  • -rw-rw-r-- is the file type and the permissions. The first character, -, means a regular file (a directory shows d). The next nine characters are three groups of three: what the owner may do, what members of the file's group may do, and what everyone else may do. r means read, w means write, x means execute, and - means not allowed.
  • The first labuser is the file's owner: you.
  • The second labuser is the file's group. Debian gives every user a private group with the same name.
  • Then come the size in bytes, the time the file was last changed, and its name.

So you and your group may read and write notes.txt, and everyone else may only read it.

Suppose these notes are private. Change the permissions with chmod so that only you can read and write the file:

$ chmod 600 practice/notes.txt
$ ls -l practice/notes.txt
-rw------- 1 labuser labuser 29 Nov  7 10:44 practice/notes.txt

Notice that the group and other permissions are now all -. The number 600 is a shorthand: 6 (read and write) for the owner, 0 (nothing) for the group and 0 for everyone else. You can change the permissions of this file because you own it.

Now see the same rules protecting the system. /etc/shadow stores the password hashes of every account:

$ ls -l /etc/shadow
-rw-r----- 1 root shadow 730 Nov  7 10:30 /etc/shadow

It belongs to the user root and the group shadow, and other users have no permissions at all. Try to read it:

$ cat /etc/shadow
cat: /etc/shadow: Permission denied

Linux refused, because you are neither root nor a member of the shadow group.

Step 5: Find help

Almost every command describes its own options when you add --help. The output is long, so look at its first lines:

$ ls --help | head -n 6
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .

For the full description, read the command's manual page with man:

$ man ls
LS(1)                            User Commands                            LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

The manual page opens in a viewer. Scroll with the arrow keys or the space bar, search by typing / followed by a word and pressing Enter, and press q to quit and return to the prompt. Look up the -a option you saw in the --help output, then quit.

Step 6: Install a package

Software on Debian comes in packages, which the apt tool downloads and installs. Installing software changes the system, so you need administrator rights. The sudo command runs a single command with those rights; it may ask for your own password first.

Refresh the list of available packages:

$ sudo apt update
Get:1 https://deb.debian.org/debian trixie InRelease [140 kB]
Get:2 https://deb.debian.org/debian trixie-updates InRelease [47.3 kB]
Get:3 https://deb.debian.org/debian-security trixie-security InRelease [43.4 kB]
...
Fetched 28.6 MB in 33s (866 kB/s)
3 packages can be upgraded. Run 'apt list --upgradable' to see them.

Notice the last line: apt also tells you whether updates are waiting to be installed. Installing them is a topic for a later lesson.

Install the tree package, a small program that draws a directory tree:

$ sudo apt install tree
Installing:
  tree

Summary:
  Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 3
  Download size: 59.4 kB
  Space needed: 132 kB / 19.1 GB available

Get:1 https://deb.debian.org/debian trixie/main amd64 tree amd64 2.2.1-1 [59.4 kB]
...
Setting up tree (2.2.1-1) ...
Processing triggers for man-db (2.13.1-1) ...

If apt asks Do you want to continue? [Y/n], press Enter to accept. Now use your new program on the directory you created:

$ tree practice
practice
├── hostname
├── notes-copy.txt
└── notes.txt

1 directory, 3 files

Step 7: Check that a service is running

A service is a program that runs in the background, such as the SSH server you connected to. On Debian, services are managed by systemd, and systemctl status shows the state of one. Check the SSH service, which Debian calls ssh:

$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Wed 2026-11-04 08:27:15 UTC; 3 days ago
 Invocation: b26d8e3efb9540fbafd7f60c31fe7e17
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 778 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 783 (sshd)
      Tasks: 1 (limit: 2338)
     Memory: 7.6M (peak: 10M)
        CPU: 188ms
     CGroup: /system.slice/ssh.service
             └─783 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Notice two lines:

  • Active: active (running) means the service is running now, and since when.
  • enabled on the Loaded line means it starts automatically when the server boots.

If the output doesn't fit on the screen, it opens in the same viewer as man; press q to return to the prompt. Below the status, systemctl prints the service's most recent log messages if you are allowed to read them. If your account may not read the system journal, you see a warning that some journal files couldn't be opened instead: the permission system at work again.

What you have learned

  • whoami, hostname, /etc/os-release and uptime tell you who you are, which machine you're on, what it runs and how long it has been up.
  • The directory tree starts at /; configuration lives in /etc, logs in /var/log and the journal, and users' files in /home.
  • mkdir, echo … >, ls, cat and cp create, list, view and copy files.
  • ls -l shows each file's owner, group and permissions, and chmod changes the permissions of files you own.
  • --help and man explain any command.
  • sudo apt update and sudo apt install install software.
  • systemctl status shows whether a service is running and enabled.

Next steps