๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Linux Day 1: A Hands-On First Hour on Debian or Ubuntu

Linux Day 1: A Hands-On First Hour on Debian or Ubuntu

A fresh Debian or Ubuntu install ends at a blinking prompt, and nothing on the screen tells you what to type. Most guides answer with a six-month roadmap or a comparison of thirty distributions, when what you need is the next hour. If you are wondering how to start learning Linux on day 1, this is one session with a strict order and a checkpoint at every step.

Each step has a real command, the output you should expect, and the mistake beginners usually make there. Everything runs inside a throwaway virtual machine, so nothing here can damage a computer you care about. This first part covers the sandbox, orientation and navigation. Keep a terminal open and type every command yourself.

Set up a machine you are allowed to break

Pick a VM, not your only computer

Use a virtual machine: VirtualBox, VMware Workstation Player, Hyper-V, or virt-manager or GNOME Boxes on a Linux host. Install Debian stable or Ubuntu LTS with 2 vCPUs, 2 to 4 GB of RAM and a 25 GB disk. That is enough for everything in this series.

WSL2 is acceptable for pure command-line practice. But it has no real boot process by default, no kernel of its own to inspect, and no desktop, so a VM teaches administration better. Because the aim is a terminal, the Debian netinst image or Ubuntu Server avoids a GUI crutch. A desktop install is fine too: open a terminal emulator and ignore the rest.

Pick a plain username and a password you will remember. The installers differ here. Ubuntu automatically gives your user sudo rights. Debian's installer asks for a root password, and if you leave it blank, it gives your user sudo instead. Leaving it blank is the simplest choice for a lab. For a step-by-step Debian install, see the Debian 13 Trixie guide.

Take a snapshot before you start

Once you can log in, shut the VM down and take a snapshot named clean-install. Every hypervisor above has the feature, usually under a "Snapshots" or "Checkpoints" menu. From now on a wrecked system costs you one minute: restore and carry on.

Find out what machine you are on

Identify the OS, kernel and hostname

Your prompt looks like anna@lab01:~$: user, host, current directory (~ means your home), then $. A $ means a normal user. A # means root, where mistakes have no safety net.

$ whoami
anna
$ hostnamectl
 Static hostname: lab01
       Chassis: vm
  Operating System: Ubuntu 24.04.1 LTS
          Kernel: Linux 6.8.0-45-generic
    Architecture: x86-64
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.1 LTS"
ID=ubuntu
ID_LIKE=debian
VERSION_ID="24.04"
$ uname -r
6.8.0-45-generic
$ uptime
 10:12:41 up 8 min,  1 user,  load average: 0.05, 0.03, 0.01

/etc/os-release is what scripts and bug reports use to identify a distribution. On Debian you will see ID=debian. The three load averages in uptime cover 1, 5 and 15 minutes.

Check disk, memory and network in four commands

$ df -h
Filesystem  Size  Used Avail Use% Mounted on
tmpfs       392M  1.1M  391M   1% /run
/dev/sda2    24G  5.2G   18G  23% /
/dev/loop0   64M   64M     0 100% /snap/core22/1380
$ free -h
        total   used   free  shared  buff/cache  available
Mem:    3.8Gi  410Mi  3.0Gi  1.0Mi      620Mi      3.4Gi
$ ip -br address
lo       UNKNOWN  127.0.0.1/8 ::1/128
enp0s3   UP       10.0.2.15/24
$ lsblk

Look at the line mounted on /. A 100% on /snap or on tmpfs entries is normal, because those are read-only images and memory filesystems. In free, trust the available column, not free.

Interface names are enp0s3 or ens33 rather than eth0. The address with /24 is your IPv4 address and netmask. 10.0.2.15 is what VirtualBox's default NAT hands out. lsblk shows disks and partitions as a tree.

Move around the filesystem and read files without fear

pwd, cd, ls and the directories that matter

pwd prints where you are. cd /etc uses an absolute path, starting at /. cd ssl is relative to where you are. cd .. goes up one level, cd - returns to the previous directory, and plain cd or cd ~ takes you home.

$ ls -lah ~
drwxr-x--- 4 anna anna 4.0K Mar  3 10:12 .
-rw-r--r-- 1 anna anna  220 Mar  3 10:05 .bash_logout
drwxr-xr-x 2 anna anna 4.0K Mar  3 10:12 lab

The columns are: type and permissions (d is a directory), link count, owner, group, size, modification time, name. Names starting with a dot are hidden, and -a shows them. The ls man page lists every flag, and we decode the permission string in a later part of this series.

PathWhat lives there
/etcSystem configuration, mostly plain text
/var/logLogs
/homeUser home directories
/usr/binMost installed commands
/tmpScratch space, cleared on reboot
/optSelf-contained third-party software

Reading and searching files: cat, less, head, tail, grep

$ less /etc/passwd        # q quits, /root searches, n jumps to next match
$ head -n 5 /etc/passwd
$ grep -i ssh /etc/services
ssh             22/tcp
$ tail -f /var/log/syslog

The last command depends on your version. Minimal Debian 12 and later installs may not ship rsyslog, so /var/log/syslog may not exist. Use journalctl -f instead. Press Ctrl+C to stop any command that keeps running.

Creating, copying and deleting safely

$ mkdir -p ~/lab/test
$ cd ~/lab
$ touch a.txt
$ cp a.txt b.txt
$ mv b.txt test/
$ rm -i a.txt
rm: remove regular empty file 'a.txt'? y

Press Tab to complete names, and Ctrl+R to search your command history. There is no recycle bin: rm is final.

Warning: rm -rf never asks. A stray space (rm -rf ~/lab /) or an empty variable (rm -rf "$DIR"/) turns a small cleanup into a large one. Practise with rm -i, and never experiment as root.

Install, update and remove software with apt

Refresh the package index and upgrade

$ sudo apt update
Get:1 http://archive.ubuntu.com/ubuntu noble InRelease [126 kB]
Reading package lists... Done
12 packages can be upgraded. Run 'apt list --upgradable' to see them.
$ sudo apt upgrade

apt update only downloads the current list of packages and versions. It installs nothing. apt upgrade then installs the newer versions of what you already have. Run both, in that order, or you are working from a stale list.

Use apt at the keyboard. In scripts, use apt-get, whose output format is kept stable. Debian and Ubuntu share the same tooling. Ubuntu also pushes snap packages, which you can ignore today.

Search, inspect, install and purge a package

$ apt search htop
$ apt show htop
$ sudo apt install htop tree curl
$ apt list --installed | head
$ which htop
/usr/bin/htop
$ dpkg -L htop | head
$ dpkg -S /usr/bin/tree
tree: /usr/bin/tree
$ sudo apt remove htop
$ sudo apt purge htop
$ sudo apt autoremove

dpkg -L lists every file a package installed, and dpkg -S answers the reverse question: which package owns this file. remove deletes the program but keeps its configuration under /etc. purge deletes that too. autoremove clears dependencies nothing needs any more.

Two errors you will meet. E: Could not get lock /var/lib/dpkg/lock-frontend means another apt or unattended-upgrades process is running, often right after first boot. Wait a few minutes and retry. Do not delete the lock file, because that can corrupt the package database. E: Unable to locate package htop usually means you skipped apt update. Otherwise the package lives in a component you have not enabled, such as universe on Ubuntu.

Understand users, sudo and file permissions

Why you are not root and what sudo does

$ id
uid=1000(anna) gid=1000(anna) groups=1000(anna),27(sudo)
$ sudo whoami
root
$ sudo -l

UID 0 is root, which bypasses permission checks entirely. You work as a normal user so that a typo or a bad script can only damage your own files. sudo runs a single command with root rights and logs it. The first time, it shows a short lecture about great power and great responsibility.

Membership of the sudo group is what grants this on Debian and Ubuntu. On the RHEL family the equivalent group is wheel. sudo -l lists what you are allowed to run.

Reading ls -l and fixing permissions with chmod and chown

Take -rwxr-xr--. The first character is the type. The next three triplets are owner, group and everyone else. Read r, w and x as 4, 2 and 1, so this file is 754.

$ echo -e '#!/bin/bash\necho hi' > ~/lab/hello.sh
$ ~/lab/hello.sh
bash: /home/anna/lab/hello.sh: Permission denied
$ chmod +x ~/lab/hello.sh
$ ~/lab/hello.sh
hi
$ chmod 600 ~/lab/secret.txt
$ sudo chown root:root ~/lab/secret.txt

New files are not executable by default, hence the error. On a directory, x means "may enter". Details are in the chmod man page, and the file permissions cheat sheet is a handy reference.

Warning: Never "fix" a permission error with chmod -R 777, and never run sudo chmod -R or sudo chown -R on / or /etc. Find the one path that is wrong and change only that.

To see a denial for real, create a second user with sudo adduser alice, then su - alice and run ls /home/anna. You get Permission denied. Type exit, then clean up with sudo deluser --remove-home alice.

See what is running and read the logs

Processes and services: ps, top, systemctl

ps aux | head lists the first few processes with their user, PID, CPU and memory share, and command. top shows the same thing live, and q quits it. htop, which you installed earlier, is easier to read. To stop a process, kill PID sends SIGTERM, a polite request to exit. kill -9 PID sends SIGKILL, which the process cannot clean up after, so use it only when the polite version failed.

Services are managed by systemd. Install an SSH server and inspect it:

$ sudo apt install openssh-server
$ sudo systemctl enable --now ssh
$ systemctl is-active ssh
active
$ ss -tlnp
State   Recv-Q  Send-Q  Local Address:Port  Peer Address:Port  Process
LISTEN  0       128     0.0.0.0:22          0.0.0.0:*          users:(("sshd",pid=812,fd=3))
LISTEN  0       128     [::]:22             [::]:*

The unit is ssh on Debian and Ubuntu and sshd on the RHEL family. enable --now starts it immediately and at every boot. In Local Address, 0.0.0.0 means all IPv4 interfaces, [::] means all IPv6, and 127.0.0.1 would mean this machine only. Without sudo, the Process column is empty for other users' programs.

Logs with journalctl: the three filters you need

$ journalctl -b                          # everything since this boot
$ journalctl -u ssh --since '10 min ago' # one service, recent
$ journalctl -p warning -b               # warnings and worse
$ journalctl -f                          # follow live, Ctrl+C to stop

Keep journalctl -f running in one terminal, then run ssh anna@localhost in another and type a wrong password. A line like this appears:

Mar 03 10:41:07 lab01 sshd[1423]: Failed password for anna from 127.0.0.1 port 51322 ssh2

Timestamp, host, service and PID, then the message. Every option is in the journalctl man page.

If you get No journal files were found, or only see your own user's entries, you are probably not in the systemd-journal or adm group, or the journal is not stored persistently. Prefix the command with sudo.

Get unstuck: man pages, --help and the mistakes everyone makes

Three ways to learn a command without a search engine

ls --help gives a short summary. man ls gives the full manual: Space pages down, /pattern searches, n jumps to the next match, q quits. In a synopsis, [optional] is optional and <required> is not.

Manuals have sections. man passwd describes the command, while man 5 passwd describes the /etc/passwd file format. man -k keyword (or apropos) searches page titles. type ls and which ls show what a name resolves to, and /usr/share/doc/<package> often holds examples and changelogs.

Day-one mistakes and how to recover

  • Permission denied: you probably need sudo, but check the path first.
  • Case matters: Documents and documents are different directories.
  • Spaces in names: quote them, as in cd "My Files".
  • Pasted web commands: never run curl ... | sudo bash without reading the script first.
  • Editing configs blind: run sudo cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak before you touch it.
  • Frozen terminal: you hit Ctrl+S. Press Ctrl+Q to resume.
  • Stuck in vim: press Esc, then type :q! and Enter.

Use nano ~/lab/notes.txt instead; its shortcuts are listed at the bottom of the screen.

Connect from your main computer over SSH

Check the VM's network mode first

The default NAT address 10.0.2.15 from earlier is private to the hypervisor, so your main computer cannot reach it. Switch the adapter to bridged, which puts the VM on your home network, or to host-only, which creates a private network between host and VM. VirtualBox's host-only range typically starts at 192.168.56.x. If you must stay on NAT, add a port-forwarding rule (host 2222 to guest 22) and connect to 127.0.0.1 with -p 2222.

If you started the service in the previous section, the server is already installed. Otherwise run sudo apt install openssh-server. Then read the new address inside the VM:

$ ip -br a
lo       UNKNOWN  127.0.0.1/8 ::1/128
enp0s3   UP       192.168.56.101/24

Log in and read the host key prompt

Recent Windows 10 and 11 include an OpenSSH client, so Windows Terminal or PowerShell works, as does Terminal on macOS:

$ ssh anna@192.168.56.101
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
ED25519 key fingerprint is SHA256:k3J...redacted...Q8w.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.56.101' (ED25519) to the list of known hosts.

The prompt means your computer has never seen this server and cannot tell whether something is impersonating it. To verify, run ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the VM console and compare the fingerprints. Once you answer yes, the key is stored in ~/.ssh/known_hosts, and any later change triggers WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!. After you reinstall the VM, that is expected. Clear the old entry with ssh-keygen -R 192.168.56.101.

Replace the password with a key

Generate a key pair on your main computer and copy the public half to the VM:

$ ssh-keygen -t ed25519 -C "laptop-to-lab01"
$ ssh-copy-id anna@192.168.56.101
$ ssh anna@192.168.56.101

Set a passphrase when asked. The private key stays in ~/.ssh/id_ed25519 and never leaves your computer. ssh-copy-id appends the public key to ~/.ssh/authorized_keys on the VM. Windows has no ssh-copy-id, so pipe the key over instead:

PS> type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh anna@192.168.56.101 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Confirm that key login works before you change anything in sshd_config. Disabling password logins while the key setup is broken locks you out of everything except the VM console. The ssh man page documents every client option.

Day 1 checklist and what to practice on day 2

If you can tick every line without looking back, the session worked:

  • A VM with a clean-install snapshot exists.
  • You can tell the distribution, kernel, disk and IP address with hostnamectl, df -h and ip -br address.
  • You can move around with cd and ls -lah, and read files with less and grep.
  • You ran apt update, then installed and purged a package.
  • You know why hello.sh needed chmod +x.
  • You started a service, found port 22 in ss -tlnp, and saw a failed login in journalctl.
  • You opened a man page and left vim alive.

For day 2, restore the snapshot and repeat the whole session from memory. Then add three things: pipes and redirection (|, >, >>), editing a real config such as /etc/ssh/sshd_config with a .bak copy, and a second look at permissions with the complete file permissions guide. When you want a structured path through package management, users, services and security on Debian, Debian System Administration picks up where this hour stops. The Debian Reference is the free upstream manual.

Frequently Asked Questions

Should I install Debian or Ubuntu as my first Linux?

Either works, and everything in this series applies to both. Ubuntu LTS gives you newer software, wide third-party documentation and sudo set up for you. Debian stable is leaner and changes slowly, which suits servers. If you have no preference, start with Ubuntu LTS, and move to Debian when you want a quieter system.

Can I learn Linux on Windows with WSL2 instead of a virtual machine?

Yes, for command-line practice WSL2 is fine: you get a real shell, apt and the filesystem. It lacks a normal boot process and a kernel you manage, and systemd needs enabling in some setups. A VM is better for learning services, logs and boot problems, and snapshots make mistakes free.

What is the difference between apt update and apt upgrade?

apt update refreshes the list of available packages and versions from your configured repositories. It installs nothing. apt upgrade installs newer versions of the packages you already have, using that list. Run update first, otherwise upgrade works from stale information and may miss new versions or fail to find packages.

Is it safe to use sudo for every command?

No. Sudo removes the permission checks that stop a typo from damaging the system. Run commands as your normal user first, and add sudo only when you get Permission denied and understand why. Never use it for editing your own files, or for scripts you have not read, because they then run with full root power.

How long does it take to get comfortable with the Linux command line?

It varies with how often you practise. Daily use for a few weeks usually makes navigation, apt, permissions and logs feel routine, while deeper areas such as networking, shell scripting and troubleshooting take much longer. Short daily sessions on a disposable VM beat one long weekend, because commands stick through repetition.

Share this article:
Dorian Thorne
About the Author

Dorian Thorne

Cloud Infrastructure, Cloud Architecture, Infrastructure Automation, Technical Documentation

Dorian Thorne is a cloud infrastructure specialist and technical author focused on the design, deployment, and operation of scalable cloud-based systems.

He has extensive experience working with cloud platforms and modern infrastructure practices, including virtualized environments, cloud networking, identity and acces...

Cloud Computing Cloud Networking Identity and Access Management Infrastructure as Code System Reliability

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.