terminal.cab

Linux Basics Lesson 37 of 38

guestLevel 1Badges and progress0/100 XP, XP to the next levelStreak0

The system and your shortcuts

8 minutes

Learning goals

uname: kernel and machine

uname describes the running kernel. -r gives its release, -m the architecture, -a everything:

uname -r

Purpose: Names the kernel and the machine. /etc/os-release names the distribution.

Syntax: uname [-r | -m | -a] | . /etc/os-release

Options:

  • -r the kernel release
  • -m the architecture, x86_64 or aarch64
  • -a everything in one line

Example:

uname -r
6.12.48+deb13-amd64
uname -m
x86_64
uname -a
Linux web-01 6.12.48+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.48-1 (2026-09-20) x86_64 GNU/Linux

in the glossary: uname

6.12.48+deb13-amd64 is a Debian 13 kernel, and x86_64 is the usual architecture of servers and PCs. ARM servers say aarch64. The simulator always shows this kernel. On a real machine the number is different, and after every kernel update it changes again.

uname knows nothing about the distribution. That is in /etc/os-release, a file of NAME=value lines. cat and grep are not loaded on this page, and ls is missing too. They answer with command not found. You get there another way: the file is written so that the shell can read it in with ., and then every line is a variable:

. /etc/os-release
echo "$PRETTY_NAME"
Debian GNU/Linux 13 (trixie)
echo "$VERSION_ID"
13

On a real server, cat /etc/os-release shows the whole file, and on RHEL and Rocky Linux it is the same file with other values.

alias: your own short names

An alias replaces a word at the start of a command line with a longer text:

alias kver='uname -r'

Purpose: Gives a command line a short name of your own.

Syntax: alias NAME='COMMAND' | alias | unalias NAME | type NAME

Options:

  • alias without arguments, lists every alias
  • type NAME says whether NAME is an alias, a builtin or a program
  • ~/.bashrc the place for aliases that should stay

Example:

alias kver='uname -r'
kver
6.12.48+deb13-amd64
type kver
kver is aliased to `uname -r'

in the glossary: alias

type tells you that kver is an alias, and for what. That is also the first thing to check when a command behaves strangely on one machine only. alias without arguments lists every alias, and unalias kver removes it again.

One trap: an alias counts only from the next line on. bash reads the whole line before it runs any of it, so the new alias does not exist yet when the rest of the line is read. alias kv='uname -m'; kv ends with bash: kv: command not found, and only on the next line does kv print x86_64. Try it in the terminal.

~/.bashrc: so that it stays

An alias from the command line is gone in the next session. Every interactive bash reads ~/.bashrc when it starts, so that is where aliases go that should stay. >> appends a line, and source reads the file into the running shell at once:

echo "alias kver='uname -r'" >> ~/.bashrc
source ~/.bashrc
type kver
kver is aliased to `uname -r'

. ~/.bashrc does the same as source ~/.bashrc. Whatever else you want in every session goes into this file too, export EDITOR=vim for example.

Practice

Terminal task 1/3

Which kernel release runs on this machine?

Task 1/3: Which kernel release runs on this machine?

Which kernel release runs on this machine?

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Not done yet

Terminal task 2/3

Which distribution is this? Read /etc/os-release into the shell and print the variable PRETTY_NAME. cat is not on this page.

Task 2/3: Which distribution is this? Read /etc/os-release into the shell and print the variable PRETTY_NAME. cat is not on this page.

Which distribution is this? Read /etc/os-release into the shell and print the variable PRETTY_NAME. cat is not on this page.

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Not done yet

Terminal task 3/3

Make the alias kver for uname -r permanent, so that every new session has it. It belongs in ~/.bashrc.

Task 3/3: Make the alias kver for uname -r permanent, so that every new session has it. It belongs in ~/.bashrc.

Make the alias kver for uname -r permanent, so that every new session has it. It belongs in ~/.bashrc.

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Not done yet

Fill the gap

Every interactive bash reads the file ~/. when it starts.

Every interactive bash reads the file ~/.… when it starts.

Check works once you have typed an answer.

Predict the output

Command

type uname

Before the command, in your home folder ~

  • ~/.bashrc
  • ~/.profile
  • ~/.secret
  • ~/Documents/
  • ~/logs/
  • ~/notes.txt
  • ~/projects/
  • ~/archive/
What does type uname print?

Check works once you have chosen an answer.

Next up: the last case of this path. The backup did not run.

Quiz

  1. Question 1 of 3Where do you find which distribution a machine runs?

    Check works once you have chosen an answer.

  2. Question 2 of 3ll behaves differently on one machine than on all the others. What do you check first?

    Check works once you have chosen an answer.

  3. Question 3 of 3You appended an alias to ~/.bashrc, but your open shell does not know it. Why?

    Check works once you have chosen an answer.

Cards

  1. Card 1 of 3

    Tap the card or press Space to turn it over.

  2. Card 2 of 3

    Tap the card or press Space to turn it over.

  3. Card 3 of 3

    Tap the card or press Space to turn it over.

End of the lesson

Still open: 5 exercises, 3 quiz questions

Next: lesson 38, The backup did not run (10 min)

What you can do now: uname -r, alias kver='uname -r'

+0 XP in this lesson

  1. Lesson 1: open
  2. Lesson 2: open
  3. Lesson 3: open
  4. Lesson 4: open
  5. Lesson 5: open
  6. Lesson 6: open
  7. Lesson 7: open
  8. Lesson 8: open
  9. Lesson 9: open
  10. Lesson 10: open
  11. Lesson 11: open
  12. Lesson 12: open
  13. Lesson 13: open
  14. Lesson 14: open
  15. Lesson 15: open
  16. Lesson 16: open
  17. Lesson 17: open
  18. Lesson 18: open
  19. Lesson 19: open
  20. Lesson 20: open
  21. Lesson 21: open
  22. Lesson 22: open
  23. Lesson 23: open
  24. Lesson 24: open
  25. Lesson 25: open
  26. Lesson 26: open
  27. Lesson 27: open
  28. Lesson 28: open
  29. Lesson 29: open
  30. Lesson 30: open
  31. Lesson 31: open
  32. Lesson 32: open
  33. Lesson 33: open
  34. Lesson 34: open
  35. Lesson 35: open
  36. Lesson 36: open
  37. Lesson 37: done
  38. Lesson 38: open
1 of 38

Next: lesson 38, The backup did not run (10 min) That's enough for today

Path complete

You finished all 38 lessons of Linux Basics.

Back to the path

Cheat sheet

The most important command lines of this module on one A4 page, black and white, to print or keep on your phone.