Linux Basics Lesson 37 of 38
The system and your shortcuts
8 minutes
Learning goals
- Find out kernel, architecture and distribution with uname and /etc/os-release.
- Define an alias, check it with type and remove it with unalias.
- Keep an alias in ~/.bashrc, and load it with source at once.
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:
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/Linux6.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:
Example:
alias kver='uname -r'
kver
6.12.48+deb13-amd64
type kver
kver is aliased to `uname -r'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?
Task complete
Solution
uname -r Why: 6.12.48+deb13-amd64, a Debian 13 kernel for 64-bit PCs and servers. On a real machine, this is the number that changes after a kernel update and a reboot.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
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.
Task complete
Solution
. /etc/os-release
echo "$PRETTY_NAME" Why: Debian GNU/Linux 13 (trixie). Scripts use exactly this trick to find out where they run, and on RHEL the same lines would say Red Hat Enterprise Linux.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
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.
Task complete
Solution
echo "alias kver='uname -r'" >> ~/.bashrc
source ~/.bashrc Why: The line is in ~/.bashrc, and every new bash reads it. source ~/.bashrc brings it into this session too, and type kver confirms it.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
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 unameBefore the command, in your home folder ~
- ~/.bashrc
- ~/.profile
- ~/.secret
- ~/Documents/
- ~/logs/
- ~/notes.txt
- ~/projects/
- ~/archive/
Check works once you have chosen an answer.
Next up: the last case of this path. The backup did not run.
Quiz
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
Cards
-
Card 1 of 3
Tap the card or press Space to turn it over.
-
Card 2 of 3
Tap the card or press Space to turn it over.
-
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
What you can do now: uname -r, alias kver='uname -r'
+0 XP in this lesson
- Lesson 1: open
- Lesson 2: open
- Lesson 3: open
- Lesson 4: open
- Lesson 5: open
- Lesson 6: open
- Lesson 7: open
- Lesson 8: open
- Lesson 9: open
- Lesson 10: open
- Lesson 11: open
- Lesson 12: open
- Lesson 13: open
- Lesson 14: open
- Lesson 15: open
- Lesson 16: open
- Lesson 17: open
- Lesson 18: open
- Lesson 19: open
- Lesson 20: open
- Lesson 21: open
- Lesson 22: open
- Lesson 23: open
- Lesson 24: open
- Lesson 25: open
- Lesson 26: open
- Lesson 27: open
- Lesson 28: open
- Lesson 29: open
- Lesson 30: open
- Lesson 31: open
- Lesson 32: open
- Lesson 33: open
- Lesson 34: open
- Lesson 35: open
- Lesson 36: open
- Lesson 37: done
- Lesson 38: open
Cheat sheet
-
uname -rthe kernel release -
. /etc/os-release; echo "$PRETTY_NAME"the distribution, without cat -
alias <name>='<command>'a short name for this session -
type <name>alias, builtin or program -
source ~/.bashrcload ~/.bashrc into the running shell
The most important command lines of this module on one A4 page, black and white, to print or keep on your phone.
- Download PDF (PDF, 20 KB)
- View as image (PNG, 67 KB)