Skip to content
BytePath v0.0.35

Linux Essentials

Linux administration pathAvailable

Build a dependable Linux foundation by inspecting before changing, keeping commands reversible, and verifying results.

Difficulty
Beginner
Time
180 min
Practice
Create and restore a small backup
Assessment
Knowledge check

Before you start

Who is this for?

For IT learners who want to administer a Linux VM or server safely from the command line.

Prerequisites

  • Basic computer use
  • A disposable Linux VM or authorised test system

What you'll be able to do

  • Navigate and manage files
  • Use pipes and redirection
  • Inspect processes and logs
  • Install packages safely
  • Reason about permissions
  • Test networking and SSH

Practical outcome

You can build a small backup script and document its permissions, restoration, and failure behaviour.

Linux technically refers to the kernel. A distribution combines it with user-space tools, a package system, installers, defaults, and a release policy. Debian/Ubuntu, Fedora/RHEL, openSUSE/SUSE, and Arch differ in package commands and support models. Use a disposable VM for experiments and read a command before running it, especially when it uses sudo, writes files, or acts recursively.

The shell parses arguments, expands variables and wildcards, and starts a builtin or external program. Linux filenames and commands are case-sensitive:

Terminal window
name="Ada Lovelace"
printf 'Hello, %s\n' "$name"
command -v bash
man ls
ls --help

Quotes protect spaces and prevent unintended expansion. A command’s exit status is available in $?; zero conventionally means success.

The filesystem starts at /. Common paths include /home for user data, /etc for system configuration, /var for changing data and logs, /tmp for temporary files, /usr for installed programs, /dev for devices, and /proc//sys for kernel and device views.

Terminal window
pwd
ls -la
cd /var/log
find . -maxdepth 2 -type f -name '*.log'

Absolute paths start at /; relative paths start in the current directory. Hidden names begin with . but are not automatically protected.

Terminal window
mkdir -p ~/bytepath-lab/input
printf 'sample\n' > ~/bytepath-lab/input/example.txt
cp --preserve=mode ~/bytepath-lab/input/example.txt ~/bytepath-lab/
mv ~/bytepath-lab/example.txt ~/bytepath-lab/archive.txt

Inspect a wildcard before deleting. rm has no automatic recycle bin, and rm -r is irreversible. Prefer a disposable lab and explicit paths.

Programs have standard input, standard output, and standard error. Redirect and combine small tools:

Terminal window
printf '%s\n' *.txt | sort | tee file-list.txt
grep -R --line-number 'timeout' ~/bytepath-lab
command 2>errors.log

> overwrites, >> appends, and 2> redirects standard error. Use awk, cut, sort, and uniq only after confirming the input format.

An archive groups files; compression reduces size. Inspect before extracting:

Terminal window
tar -czf ~/bytepath-lab/backup.tgz -C ~/bytepath-lab input
tar -tzf ~/bytepath-lab/backup.tgz
tar -xzf ~/bytepath-lab/backup.tgz -C ~/bytepath-lab/restore

A backup is trustworthy only after a restore test and an integrity check. Do not extract an unknown archive into a sensitive directory.

Terminal window
ps aux --sort=-%mem | head
pgrep -a ssh
free -h
df -h
systemctl status ssh
journalctl -u ssh --since '15 minutes ago'

kill sends SIGTERM by default and gives a process a chance to stop cleanly. Use SIGKILL only as a last resort. Service names differ by distribution; inspect before changing them.

Use the distribution’s trusted repositories and understand the change before confirming it:

Terminal window
# Debian/Ubuntu
apt search package-name
sudo apt install package-name
# Fedora/RHEL
dnf search package-name
sudo dnf install package-name

Do not mix repositories casually. Verify package origin, signatures, and update policy for third-party software.

Terminal window
id
getent passwd "$USER"
groups
ls -l file
chmod 640 file

Normal work should use an unprivileged account. sudo grants elevated rights for a specific command and should be used with a reason. For deeper mode, ACL, and special-bit practice, continue to Linux Permissions.

#!/usr/bin/env bash
set -euo pipefail
source_dir=${1:?usage: $0 SOURCE_DIR DESTINATION}
destination=${2:?usage: $0 SOURCE_DIR DESTINATION}
mkdir -p "$destination"
tar -czf "$destination/backup-$(date +%F).tgz" -C "$source_dir" .
printf 'Created backup in %s\n' "$destination"

set -euo pipefail makes several classes of mistakes visible, but it is not a substitute for testing. Quote variables, validate inputs, and use a temporary directory for experiments.

Begin with state, then test one dependency at a time:

Terminal window
ip address
ip route
ss -lntup
getent hosts example.test
curl --verbose https://example.test/

A successful ping, DNS lookup, TCP connection, and HTTP response test different layers. SSH is an encrypted remote shell; connect only to authorised systems:

Terminal window
ssh user@192.0.2.10

Verify the host-key fingerprint through a trusted channel on first connection. Protect private keys with restrictive permissions and never commit them.

  1. Create ~/linux-lab/input, archive, and restore.
  2. Add three harmless text files and search them with grep.
  3. Write or adapt a script that creates a dated tar.gz.
  4. Set the archive to 640 and verify owner and group.
  5. List the archive before extracting it.
  6. Restore it and compare contents with diff -r.
  7. Document what happens when the input path does not exist.

You should be able to inspect a Linux system, make a controlled change, verify it, and explain the evidence. Continue with Linux Permissions or use the backup and restore lab.

Related: Bash Scripting, Linux Services and systemd Logs, and SSH and Server Hardening.