linux_introduction/essential/readme.md

1132 lines
79 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Essential Linux
## Introduction to Linux
### Where does Linux originate from?
* The spiritual mother of Linux is [Unix](https://en.wikipedia.org/wiki/Unix).
* [POSIX](https://en.wikipedia.org/wiki/POSIX) is not an OS in itself but a **standard**.
* Which OS's are [POSIX compliant](https://en.wikipedia.org/wiki/POSIX#POSIX-oriented_operating_systems)
### Who is behind this project?
* Who is [Richard Stallmann](https://en.wikipedia.org/wiki/Richard_Stallman)?
* Who is [Linus Torvalds](https://en.wikipedia.org/wiki/Linus_Torvalds)?
### What is the deal with 'GNU-slash-Linux'?
* [GNU/Linux](https://en.wikipedia.org/wiki/GNU/Linux_naming_controversy) controversy
* What is a [kernel](https://en.wikipedia.org/wiki/Kernel_(operating_system))
* What does [GNU](https://www.gnu.org/software/) bring to the table?
* What's the deal with [userspace and kernelspace](https://unix.stackexchange.com/questions/137820/whats-the-difference-of-the-userland-vs-the-kernel)?
* [userspace](http://www.linfo.org/user_space.html)
* [kernelspace](http://www.linfo.org/kernel_space.html)
![Linux kernel](../assets/linux_kernel.png)
### Where can you *get* some Linux?
* You probably already have a Linux computer running at [home](https://opensource.com/article/19/8/everyday-tech-runs-linux)!
![Timeline](../assets/distro_timeline.png)
### Debian
* [Reasons](https://www.debian.org/intro/why_debian) to choose Debian.
* Why is Debian called [the universal operating system](https://www.reddit.com/r/debian/comments/22j0wf/so_why_debian_is_called_the_universal_operating/)?
* [comparison](https://en.wikipedia.org/wiki/Comparison_of_instruction_set_architectures) of CPU architectures
* [download](https://www.debian.org/distrib/netinst) Debian
## How to create a virtual machine
In order to run virtual machines, or VM's, we need a **host** program.
One of the most popular ones out there is called `virtualbox`.
It should be installed on your machine but in case it's not you can download it [here](https://www.virtualbox.org/wiki/Downloads).
If you **expand** the section below you'll see a step by step walk-through of a VM creation in virtualbox with some notes on each step with best practice pointers.
<details>
<summary>Expand me...</summary>
**Nice!**
1. Name your machine and select *linux* if it's not chosen automatically.
![virtualbox setup](../assets/2022-02-18-122703_1920x1080_scrot.png)
1. Set the amount of RAM for your machine.
This can be anything between an absolute minimum and your physical machine's limit.
You can't *magically* use more RAM than physically available!
![virtualbox setup](../assets/2022-02-18-122833_1920x1080_scrot.png)
1. You need a virtual hard drive to store the OS and all your data to.
![virtualbox setup](../assets/2022-02-18-122930_1920x1080_scrot.png)
1. The format doesn't matter that much.
I always go for the default one.
![virtualbox setup](../assets/2022-02-18-122943_1920x1080_scrot.png)
1. Most of the time you'll want dynamic size meaning the disk **file** will only take up as much **space** as it needs.
For example, if you set a size of 50GB for your disk and your OS plus personal files take up 12GB, the actual space this image takes op on the physical disk of your **host** will be about 12GB.
![virtualbox setup](../assets/2022-02-18-122951_1920x1080_scrot.png)
1. We'll soon discover **how much space** a basic Linux installation takes up but for now I would recommend the following.
* **with** a graphical environment: 20GB
* **without** a graphical environment: 10GB (minimal/server/headless install)
![virtualbox setup](../assets/2022-02-18-123011_1920x1080_scrot.png)
1. By default your machine will have only **one** CPU core but you can add more via the settings.
This is something you can change whenever you need more processing power but the same rule as with the RAM applies, it's not a magical way to add resources to your machine.
![virtualbox setup](../assets/2022-02-18-123047_1920x1080_scrot.png)
1. Last but not least we need to insert the installation disk into the virtual machine and boot it up!
![virtualbox setup](../assets/2022-02-18-123121_1920x1080_scrot.png)
</details>
## Breakdown of the Debian installation
All right, enough talking, let's get started!
I'll install a full blown and modern graphical Debian machine and I would like you to **not** do it yourself but take **notes** on each step so you'll be able to reference your notes later **when** I ask you to install a machine yourself.
Below is a gain a step by step walk through with some of my tips but a more details guide can be found in the [Debian Administrator Handbook](https://debian-handbook.info/browse/stable/sect.installation-steps.html).
This book is a real *bible* of information and I highly advise you to read through it.
My most important notes would be the following.
* **Read** each section carefully and you'll know what to do.
* Don't set a root password but use `sudo` instead.
* Don't install a graphical environment if you don't need one.
It's a lot easier to add one later than to remove it.
* Don't forget to install `grub` at the end otherwise your installation will not be able to boot.
You *can* recover from this mistake with [supergrub2](https://www.supergrubdisk.org/super-grub2-disk/) but that's for an other day.
<details>
<summary>Expand me...</summary>
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_32_45.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_32_57.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_33_07.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_33_11.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_33_18.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_33_21.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_33_27.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_18.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_29.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_34.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_39.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_52.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_34_55.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_01.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_17.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_20.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_23.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_27.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_35_32.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_37_53.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_37_57.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_38_00.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_38_02.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_39_44.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_39_53.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_40_07.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_49_11.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_49_15.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_50_26.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_50_38.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_50_55.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_51_07.png)
</details>
### Exercise
OK, now it's up to you!
Please install a Debian machine with the default graphical environment.
Once installed, take some time out to explore the system.
Which software is installed by default?
How can you tweak the system settings such as language, keyboard, networking?
Can you install extra software?
## Quick look at an idle system
You can inspect the system by running the *gnome task manager*.
It lists all your running processes, sorted by CPU percentage, in the first tab which can give you a good idea of what's happening on your system.
Note that an idle system uses almost **no resources**!
Plus, a fresh install, with quite a few essential programs such as a browser, music player, text editor, etc only takes up about 5GB of disk space!
This is mind blowing compared to a windows installation.
How is this possible?
That's the magic of a good package manager!
<details>
<summary>Expand me...</summary>
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_53_40.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_54_33.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_54_41.png)
</details>
## Package managers
What is a [package manager](https://en.wikipedia.org/wiki/Package_manager)
### Graphical installation
Modern Linux has come a long way and it's now quite usable without any command line knowledge.
We can install extra software from the graphical environment if we want.
Let's look for `vlc`, a popular open source video player.
When we look for it from `activities` we *see* a reference to it via the `software` program.
If we click on it we'll be take to a sort of *app or play store* where we can choose to install or uninstall programs.
Because adding and removing software from our machine is quite *invasive*, we need to **prove** we have the right to do so.
A prompt will pop up where you'll need to input **your** password.
If your password does not work, you probably set a `root` password and you should use that one instead.
<details>
<summary>Expand me...</summary>
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_51_24.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_52_06.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_52_15.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_52_36.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_52_46.png)
![Debian installation](../assets/VirtualBox_debian_18_02_2022_12_52_53.png)
</details>
### Command line installation
```bash
waldek@hellodebian:~$ htop
-bash: htop: command not found
waldek@hellodebian:~$ apt install htop
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
waldek@hellodebian:~$ sudo apt install htop
[sudo] password for waldek:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
lm-sensors strace
The following NEW packages will be installed:
htop
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 127 kB of archives.
After this operation, 328 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 htop amd64 3.0.5-7 [127 kB]
Fetched 127 kB in 0s (2,030 kB/s)
Selecting previously unselected package htop.
(Reading database ... 141359 files and directories currently installed.)
Preparing to unpack .../htop_3.0.5-7_amd64.deb ...
Unpacking htop (3.0.5-7) ...
Setting up htop (3.0.5-7) ...
Processing triggers for mailcap (3.69) ...
Processing triggers for desktop-file-utils (0.26-1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1) ...
Processing triggers for man-db (2.9.4-2) ...
waldek@hellodebian:~$
```
![htop](../assets/VirtualBox_debian_18_02_2022_13_18_25.png)
![htop](../assets/VirtualBox_debian_18_02_2022_13_18_51.png)
The *menu bar* at the bottom shows you can press **F10** to quit.
This does not work because of a shortcut of gnome-terminal!
You can deactivate this shortcut in the preferences though.
But pressing **q** also exits the program.
![htop bug with gnome-terminal](../assets/VirtualBox_debian_18_02_2022_13_19_35.png)
### Adding a secondary desktop environment
During the initial installation we where offered a choice of desktop environments to install.
This menu was an actual program called `tasksel` we can run again to add different ones!
As it's a program that can heavily modify the system, we need administrator privileges.
```bash
waldek@hellodebian:~$ sudo tasksel
[sudo] password for waldek:
```
![tasksel](../assets/VirtualBox_debian_18_02_2022_13_21_33.png)
![tasksel](../assets/VirtualBox_debian_18_02_2022_13_22_33.png)
![tasksel](../assets/VirtualBox_debian_18_02_2022_13_22_47.png)
![tasksel](../assets/VirtualBox_debian_18_02_2022_13_23_57.png)
## Changing the runlevel
The **first** process started by the kernel can be discover by `htop` and is `/usr/sbin/init`.
This is rather vague but we can find out a *bit* more about this program via `ls` which we'll get into more detail later.
For now just have a look at the output of the following commmand.
```bash
waldek@hellodebian:~$ ls -l /usr/sbin/init
lrwxrwxrwx 1 root root 20 Jul 13 2021 /usr/sbin/init -> /lib/systemd/systemd
waldek@hellodebian:~$
```
Now, what *is* this [systemd](https://en.wikipedia.org/wiki/Systemd)?
And more importantly, *how* do we interact with it?
For now just accept that the main program to communicate with `systemd` is `systemctl`.
A quick look at the `man` pages gives us the following.
```bash
SYSTEMCTL(1) systemctl SYSTEMCTL(1)
NAME
systemctl - Control the systemd system and service manager
SYNOPSIS
systemctl [OPTIONS...] COMMAND [UNIT...]
DESCRIPTION
systemctl may be used to introspect and control the state of the "systemd" system and service manager. Please refer to systemd(1) for an
introduction into the basic concepts and functionality this tool manages.
```
```bash
waldek@hellodebian:~$ sudo systemctl set-default multi-user.target
[sudo] password for waldek:
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target.
waldek@hellodebian:~$ sudo reboot now
```
After the reboot you'll be confronted with the following screen.
Don't stress, your machine is not broken!
It's just running in a more *minimal* mode.
You can log in just as with the graphical login window but you'll only have a command line to interact with the machine.
A quick look at `htop` tells us not a lot of stuff is running, just the bare minimum.
![minimal runlevel](../assets/VirtualBox_debian_18_02_2022_13_40_00.png)
![minimal runlevel](../assets/VirtualBox_debian_18_02_2022_13_40_11.png)
To *undo* this change and regain the graphical interface again you can run the following commands.
```bash
waldek@hellodebian:~$ sudo systemctl set-default graphical.target
[sudo] password for waldek:
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.
waldek@hellodebian:~$ sudo reboot now
```
## Exercise
Please create a second virtual machine and install a **minimal** Debian.
Minimal means **no graphical environment**.
I advise you to **not** set a root password.
Once this machine is up and running, install a few programs.
The only one we saw up until now is `htop` but maybe try out `bmon`, `elinks` and/or `ranger`.
Once these are installed have a look at the running services and programs via `htop` and compare it to both your graphical installation **and** your graphical install but running in `multi-user.target`.
## Guest additions
Let's make our user experience a bit nicer.
Virtual machines can *integrate* with the host machine more fluently when you install the guest additions in the VM.
It's a three step process.
1. install the required packages to build the guest additions in you VM
1. insert the guest additions CD into your VM
1. run the correct script from the CD
The dependencies can be installed as follows.
First you `update` your package list, next you install three packages.
* `build-essential`
* `dkms`
* `linux-headers-$(uname -r)`
The *third* package name is a bit weird looking no?
This is a bit of command line kung fu.
The actual *name* of the package is as follows.
```
waldek@hellodebian:~$ echo linux-headers-$(uname -r)
linux-headers-5.10.0-11-amd64
waldek@hellodebian:~$
```
The `$(uname -r)` is a call to a program called `uname` with the option `-r`.
We'll go more into detail on this later.
```
waldek@hellodebian:~$ sudo apt update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
waldek@hellodebian:~$ sudo apt install build-essential dkms linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu dctrl-tools dpkg-dev fakeroot g++ g++-10 gcc gcc-10 libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
libctf-nobfd0 libctf0 libfakeroot libgcc-10-dev libitm1 liblsan0 libnsl-dev libstdc++-10-dev libtirpc-dev libtsan0 libubsan1
linux-compiler-gcc-10-x86 linux-headers-5.10.0-11-common linux-headers-amd64 linux-kbuild-5.10 linux-libc-dev make manpages-dev patch
Suggested packages:
binutils-doc debtags debian-keyring g++-multilib g++-10-multilib gcc-10-doc gcc-multilib autoconf automake libtool flex bison gdb gcc-doc
gcc-10-multilib gcc-10-locales glibc-doc libstdc++-10-doc make-doc ed diffutils-doc
The following NEW packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential dctrl-tools dkms dpkg-dev fakeroot g++ g++-10 gcc gcc-10 libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
libctf-nobfd0 libctf0 libfakeroot libgcc-10-dev libitm1 liblsan0 libnsl-dev libstdc++-10-dev libtirpc-dev libtsan0 libubsan1
linux-compiler-gcc-10-x86 linux-headers-5.10.0-11-amd64 linux-headers-5.10.0-11-common linux-headers-amd64 linux-kbuild-5.10 linux-libc-dev make
manpages-dev patch
0 upgraded, 43 newly installed, 0 to remove and 0 not upgraded.
Need to get 62.0 MB of archives.
After this operation, 258 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
```
Once this is done we can **insert** the CD.
You can verify the disk's content via the files explorer in gnome.
![CD](../assets/VirtualBox_debian_18_02_2022_15_01_18.png)
Now, open a terminal and run the following.
```
waldek@hellodebian:~$ cd /media/cdrom0/
waldek@hellodebian:/media/cdrom0$ ls
AUTORUN.INF NT3x TRANS.TBL VBoxLinuxAdditions.run VBoxWindowsAdditions.exe
autorun.sh OS2 VBoxDarwinAdditions.pkg VBoxSolarisAdditions.pkg VBoxWindowsAdditions-x86.exe
cert runasroot.sh VBoxDarwinAdditionsUninstall.tool VBoxWindowsAdditions-amd64.exe
waldek@hellodebian:/media/cdrom0$ sudo bash VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.28 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.10.0-11-amd64.
update-initramfs: Generating /boot/initrd.img-5.10.0-11-amd64
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted
waldek@hellodebian:/media/cdrom0$ sudo reboot now
```
Once the machine is rebooted you'll can resize the window and the screen resolution will adapt automatically!
You can also enable copy/paste and drag and drop between your host and VM now.
![full screen](../assets/VirtualBox_debian_18_02_2022_15_08_01.png)
## Introduction to the command line
We'll be using a few new *words* to reference the command line such as *shell*, *bash* and *terminal* through out the course.
They all pretty much mean the same thing but with some small, and not so important, differences between them.
Essentially a command line is a **textual interface** for humans to operate a computer.
What is very important to understand is that textual commands and graphical actions operate on the **same** computer.
For example, if you create a file via the command line, it will show up in you file explorer and vice versa.
The graphical and textual interfaces are just different *representations* of the same machine.
Now open up a terminal and you'll see the following.
```
waldek@hellodebian:~$
```
This is what we call a [prompt](https://en.wikipedia.org/wiki/Command-line_interface#Command_prompt).
It's not much but it's our *window* into the computer.
As with most things in life you can question it's *who, where, what and when*.
This information is actually **embedded** in the prompt.
Let's break it down.
* `waldek` is **who** I am on this computer
* `hellodebian` is the **what**, as in what computer I'm operating on
* `~` is **where** I am located on this computer
What about the *when* then?
Let's type in `date` and see what happens.
```
waldek@hellodebian:~$ date
Fri 18 Feb 2022 03:46:59 PM CET
waldek@hellodebian:~$
```
There we see our **when**!
But this miniscule operation illustrates us the **fundamental** operation of a command line!
1. we have a prompt where we can run a program
2. the program runs and outputs it's information on the terminal
3. once the program **finishes** we can run an other program
I'm deliberately saying program here but is `date` *really* a program?
It's a bit basic no?
Well, it is a program and most *commands* you'll type into your terminal are actually programs.
We can illustrate this as follows.
```
waldek@hellodebian:~$ vlc
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)
[0000559c46ee95b0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0000559c46f89790] main playlist: playlist is empty
```
Vlc is now running and the terminal is *blocked* meaning we can't run other programs or commands in it.
If you try to run the `date` command again, or `ls` or `htop`, it won't work!
Try it out if you don't believe me.
But what happens if you **close** vlc?
The commands you typed get executed!
This is an illustration of the **sequential** nature of a command line.
Now, I don't think we have sufficiently *proven* that `date` is a full blown program so let's dig a bit deeper.
```
waldek@hellodebian:~$ which vlc
/usr/bin/vlc
waldek@hellodebian:~$ which date
/usr/bin/date
waldek@hellodebian:~$ which which
/usr/bin/which
```
There is quite bit to *unpack* in the example above.
First, what on earth is `which`?
Well, it's *also* a program and it's sole purpose in life is to tell you **where** a program is located on your system.
Because `which` by itself does not make a lot of sense it needs what we call an **argument**.
Here the argument is the name of the program we want to know it's location of.
The existence of arguments is the second big thing we discovered here.
The third new thing we can observe here is what we call **paths**, meaning locations on the system.
For example, `vlc` is a *binary* program located in a **folder** called `bin` which is located in a folder called `usr` which is at the *root* of your system.
If this sounds complicated, don't worry, we'll go into detail a bit later.
Now that we know **where** some of our programs are located, let's find out **what** they are.
The methodology is the same as with `which` but we'll use an other program called `file` who's purpose in life is to tell more about the **content** of a certain file.
Logically, `file` needs an argument and this argument is the **path** to the file you want to inspect.
```
waldek@hellodebian:~$ file /usr/bin/vlc
/usr/bin/vlc: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=51c40f8234213415771b3a344cab25a140543f8a, for GNU/Linux 3.2.0, stripped
waldek@hellodebian:~$ file /usr/bin/date
/usr/bin/date: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b740f054aaef6a85aff024858c914c7eae70a6a5, for GNU/Linux 3.2.0, stripped
waldek@hellodebian:~$ file /usr/bin/which
/usr/bin/which: POSIX shell script, ASCII text executable
waldek@hellodebian:~$ file $(which which) # this is some command line kung fu...
/usr/bin/which: POSIX shell script, ASCII text executable
waldek@hellodebian:~$
```
Here we learn that both `vlc` and `date` are **executables**, compiled for an x86-64 system.
I would say they are both created *equally* no?
Both are actual programs.
But what about `which`?
It's also an executable but not compiled, it's a *POSIX shell script*.
So not all programs *are* created equally?
### Compiled vs interpreted
Executing a file, or program, means you take this file and tell the computer it needs to execute the actions that are stored in the file.
Compiled programs contain actual [instructions](https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions) the computer understands out of the box.
This means that programs that are compiled are always compiled for a specify architecture which in our case is x86-64.
On a Raspberry Pi this would be armhf or arm64.
Interpreted programs are not compiled to machine code but when we run them each line is passed to an appropriate **interpreter** and executed **line by line**.
The first line of a script is often the path to the interpreter that *understands* the code that will follow.
Popular interpreted languages are `bash`, `sh`, `python`, `php`, ...
We can take it *one* more step forward and peak into the *content* of the files.
A nice little program to do this is called `head` who's purpose in life is to show the first few lines of a file.
First for `vlc`.
```
waldek@hellodebian:~$ head /usr/bin/vlc
ELF>@<40>1@8
HHh,h<h<<3C><><EFBFBD>,<2C><<3C>< <20><><EFBFBD>DDP<44>td###<23><>Q<EFBFBD>tdR<64>tdh,h<h<<3C><>/lib64/ld-linux-x86-64.so.2GNUQ<EFBFBD><EFBFBD>4!4w4L<34>%<25>@T?<3F>GNU)<29>)*<2A>e<EFBFBD>m9<6D>y<EFBFBD><79><EFBFBD><EFBFBD> <20><>)F <20>, X<>`
Pco<EFBFBD><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><EFBFBD>ZD<EFBFBD>
<20><>/<2F><><EFBFBD>h<EFBFBD>"<22> _ITM_deregisterTMCloneTable__gmon_start___ITM_registerTMCloneTablelibvlc_set_app_idlibvlc_newlibvlc_set_user_agentlibvlc_get_changesetlibvlc_get_versionlibvlc_set_exit_handlerlibvlc_add_intflibvlc_playlist_playlibvlc_releasesigwaitflockfilepthread_killpthread_sigmaskpthread_mutex_lockpthread_mutex_unlockfunlockfilesigactiondlsymdlerrorfflushsignal__stack_chk_failabortisattysigemptysetrand_r__fprintf_chksigaddsetmemcpystderrsigdelsetalarmfwritegeteuid__vfprintf_chk__cxa_finalizepthread_self__libc_start_main__register_atforklibvlc.so.5libpthread.so.0libdl.so.2libc.so.6GLIBC_2<EFBFBD>ri5GLIB<EFBFBD>ti.14GL<EFBFBD>u<EFBFBD>i2.4Glh<EFBFBD>p<EFBFBD>@<40>?<3F>?GLIBC_2.3.G u<>i lW u<>i lb<6C><62>xii
<EFBFBD>?
<20>?<3F>?) @*<2A>><3E>><3E>><3E>><3E>><3E>><3E><>> <09>>
??? ?(?0?8?@?H?P?X?`?<3F>h??x?<3F>?<3F>?<3F>? <20>?!<21>?"<22>?#<23>?$<24>?%<25>?&<26>?'<27>?(H<>H<EFBFBD><48>/H<><48>t<EFBFBD><74>H<EFBFBD><48><EFBFBD>5<EFBFBD>.<2E>%<25>.@<40>%<25>.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%z.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%r.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%j.h<><68><EFBFBD><EFBFBD><EFBFBD>%b.h<><68><EFBFBD><EFBFBD><EFBFBD>%Z.h<><68><EFBFBD><EFBFBD><EFBFBD>%R.h<><68><EFBFBD><EFBFBD><EFBFBD>%J.h<>p<EFBFBD><70><EFBFBD><EFBFBD>%B.<2E>`<60><><EFBFBD><EFBFBD>%:.h <09>P<EFBFBD><50><EFBFBD><EFBFBD>%2.h
<EFBFBD>@<40><><EFBFBD><EFBFBD>%*.h
<20>0<EFBFBD><30><EFBFBD><EFBFBD>%".h
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%.h<><68><EFBFBD><EFBFBD><EFBFBD>% <20> <20><><EFBFBD><EFBFBD>%<25>.h
.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD>%<25>-h<>p<EFBFBD><70><EFBFBD><EFBFBD>%<25>-h<>`<60><><EFBFBD><EFBFBD>%<25>-h<>P<EFBFBD><50><EFBFBD><EFBFBD>%<25>-h<><68>@<40><><EFBFBD><EFBFBD>%<25>-h0<68><30><EFBFBD><EFBFBD>%<25>-h<> <20><><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD>%<25>-h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>L<EFBFBD><4C>H<EFBFBD><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>k<EFBFBD><6B><EFBFBD><EFBFBD>S<EFBFBD>[Hc<48>H<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>:<3A><><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>-<2D><><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD> <20><><EFBFBD><EFBFBD>
L<><4C>
H<><48>H<EFBFBD>5<EFBFBD>
fHn<48>H<EFBFBD>BfHn<48>H<EFBFBD><48> H<><48><EFBFBD>fl<66>I<EFBFBD>H)<29>L<EFBFBD>t$L<><4C>I<EFBFBD><49><EFBFBD>H<EFBFBD><48>L<EFBFBD><4C><EFBFBD>I<EFBFBD>~<7E>o<EFBFBD><6F><EFBFBD>Lc<4C>K<EFBFBD><4B><EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49>H<EFBFBD><48><EFBFBD><EFBFBD>H<EFBFBD><48>H<EFBFBD><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>5<EFBFBD><35>S<EFBFBD><53><EFBFBD>H<EFBFBD>
H<EFBFBD>/
L<><4C>H<EFBFBD>5
<20>v<EFBFBD><76><EFBFBD>H<EFBFBD>
H<>5
L<><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>5!
L<><4C><EFBFBD>!<21><><EFBFBD>H<EFBFBD>5
L<EFBFBD><EFBFBD><EFBFBD>'<27><><EFBFBD>H<EFBFBD><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>H<EFBFBD><48><EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>S<EFBFBD><53><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>F<EFBFBD><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD>&<26><><EFBFBD>H<EFBFBD>=<3D>*M<><4D>H<EFBFBD><48><EFBFBD>@<40><><EFBFBD>u
H<><48><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD><6E><EFBFBD>A<EFBFBD>H<EFBFBD>E<EFBFBD>dH+%(u?H<>e<EFBFBD>D<EFBFBD><44>[A\A]A^]<5D>I<EFBFBD>M<EFBFBD>H<EFBFBD>=\*H<><48>
CH<EFBFBD>=L<><4C><EFBFBD><EFBFBD><EFBFBD>)<29>DH<44>=<3D>)H<><48>)H9<48>tH<74><48>)H<><48>t<EFBFBD>f.<2E>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>=<3D>)H<>5<EFBFBD>)H)<29>H<EFBFBD><48>H<EFBFBD><48>?H<><48>H<EFBFBD>H<EFBFBD><48>tH<74>U)H<><48><EFBFBD><EFBFBD>fD<66><44><EFBFBD>=q)u/UH<55>=6)H<><48>t
H<>=:)<29><><EFBFBD><EFBFBD><EFBFBD>h<EFBFBD><68><EFBFBD><EFBFBD>I)]<5D><><EFBFBD><EFBFBD><EFBFBD>{<7B><><EFBFBD>f.<2E><>1<EFBFBD><31><EFBFBD>$<24><><EFBFBD>@H<>?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><>AUI<55><49>ATI<54><49>UH<55><48>SH<53><48>H<EFBFBD><48><EFBFBD>L<EFBFBD>D$@L<>L$H<><48>t7)D$P)L$`)T$p)<29>$<24>)<29>$<24>)<29>$<24>)<29>$<24>)<29>$<24>dH<64>%(H<>D$1<>H<EFBFBD>={(H<>T$ H<><48>$<24>$ <20>D$0H<30>DH<44>T$<24><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><>v1H<31>=B(<28><><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>D$dH+%(uH<75><48><EFBFBD>[]A\A]<5D><><EFBFBD><EFBFBD>H<EFBFBD>=(I<><49>1<EFBFBD><31>
H<EFBFBD><EFBFBD>H<EFBFBD>=7 H<>5H<35>=?'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD>#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>ATI<54><49><EFBFBD>f<EFBFBD><66><EFBFBD>H<EFBFBD>=<3D>'L<><4C>H<EFBFBD>I<EFBFBD><49><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD>i<EFBFBD><69><EFBFBD>1<EFBFBD>1<EFBFBD><31>.(<28>f<EFBFBD><66>=(UH<55><48>u#H<>5H<35><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD><48>t5H<35><48>]<5D><>DI<44><49>1<EFBFBD>H<EFBFBD>
<EFBFBD>H<EFBFBD>H<EFBFBD>5<EFBFBD>H<EFBFBD>=7&<26><>&<26><><EFBFBD><EFBFBD>X1<58>Z]A\A]<5D>H<EFBFBD><48><EFBFBD><EFBFBD><EFBFBD>ff.<2E><><EFBFBD>='UH<55><48>u#H<>5<EFBFBD>H<EFBFBD><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD><48>t5H<35><48>]<5D><>DI<44><49>1<EFBFBD>H<EFBFBD><48>RH<52>
!"<22><><EFBFBD><EFBFBD>H<EFBFBD>H<EFBFBD><48>DESKTOP_STARTUP_ID--no-ignore-config--media-library--dbusvlcorg.VideoLAN.VLCVLC/3.0.16VLC media playerglobalhotkeys,noneVLC is not supposed to be run as root. Sorry.
If you need to use real-time priorities and/or privileged TCP ports
you can use %s-wrapper (make sure it is Set-UID root and
```
And now of `which`.
```
waldek@hellodebian:~$ head /usr/bin/which
#! /bin/sh
set -ef
if test -n "$KSH_VERSION"; then
puts() {
print -r -- "$*"
}
else
puts() {
printf '%s\n' "$*"
waldek@hellodebian:~$
```
Notice how the `vlc` file is mostly **not human readable** but we can still make out some keywords?
The `which` file however is perfectly readable!
The first line of the `which` file is `#! /bin/sh` which is the path to the interpreter.
The `#!` is called a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)).
We can dig into this to learn more about this mysterious `sh`.
```
waldek@hellodebian:~$ file /bin/sh
/bin/sh: symbolic link to dash
waldek@hellodebian:~$ which dash
/usr/bin/dash
waldek@hellodebian:~$ file /usr/bin/dash
/usr/bin/dash: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=cb6911fd56559717336c938bef1ce479b0a85b35, for GNU/Linux 3.2.0, stripped
waldek@hellodebian:~$
```
Surprise surprise!
The *interpreter* is a compiled program!
When you think about it it does make sense because at the end of the day the computer *only* understands machine instructions.
So when you execute a script each line of code is converted to machine instructions on the spot.
This makes scripts easier to write but slower at execution.
## More about paths
The prompt in our terminal tells us who we are, on which machine, and **where** we are located.
This where is symbolized with the `~` character.
But where is this where?
```
waldek@hellodebian:~$ pwd
/home/waldek
waldek@hellodebian:~$
```
The `pwd` program **p**rints our **w**orking **d**irectory, meaning where we are located on our system.
A user's home directory is symbolized with this tilde character.
We can move around our system with the `cd` command which is an abbreviation of **c**hange **d**irectory.
`cd` by itself seems to to *nothing* but this is not the case.
It's a *shortcut* to go to your user's home directory.
Let's try this out.
```
waldek@hellodebian:~$ cd
waldek@hellodebian:~$ cd /usr/bin
waldek@hellodebian:/usr/bin$ cd
waldek@hellodebian:~$ cd -
/usr/bin
waldek@hellodebian:/usr/bin$ cd
waldek@hellodebian:~$
```
The first line appears to do nothing because we are already in our home directory.
Next we move to the directory which contains the programs we discovered before and we see our prompt change.
It now shows *where* we are located!
The next line takes us back to our home and from there we can move *back to where we were before* with the `cd -` command.
This last command is also a handy *shortcut*!
Moving around is nice but once we arrive at our destination it would be practical to be able to list the files in that directory no?
This can be done with the `ls` program.
For example.
```
waldek@hellodebian:~$ cd /usr/bin/
waldek@hellodebian:/usr/bin$ ls
'[' getconf nmtui-hostname systemd-escape
7z getent nohup systemd-hwdb
7za getfacl notify-send systemd-id128
7zr getkeycodes nproc systemd-inhibit
aa-enabled getopt nroff systemd-machine-id-setup
aa-exec gettext nsenter systemd-mount
aconnect gettext.sh nslookup systemd-notify
add-apt-repository gio nstat systemd-path
addpart gio-querymodules nsupdate systemd-resolve
addr2line gjs ntfs-3g systemd-run
alsabat gjs-console ntfs-3g.probe systemd-socket-activate
alsaloop gkbd-keyboard-display ntfscat systemd-stdio-bridge
alsamixer glib-compile-schemas ntfscluster systemd-sysusers
alsatplg gmake ntfscmp systemd-tmpfiles
alsaucm gnome-calculator ntfsdecrypt systemd-tty-ask-password-agent
amidi gnome-calendar ntfsfallocate systemd-umount
amixer gnome-characters ntfsfix tabs
apg gnome-clocks ntfsinfo tac
apgbfm gnome-contacts ntfsls tail
aplay gnome-control-center ntfsmove tar
aplaymidi gnome-disk-image-mounter ntfsrecover tasksel
appres gnome-disks ntfssecaudit taskset
appstreamcli gnome-documents ntfstruncate tbl
apropos gnome-extensions ntfsusermap tbl-dctrl
apt gnome-extensions-app ntfswipe tee
apt-add-repository gnome-font-viewer numfmt telnet
apt-cache gnome-help numlockx telnet.netkit
apt-cdrom gnome-keyring nvlc tempfile
apt-config gnome-keyring-3 obamenu test
apt-extracttemplates gnome-keyring-daemon obconf thunar
apt-ftparchive gnome-logs obexctl Thunar
apt-get gnome-maps objcopy thunar-settings
apt-key gnome-music objdump thunar-volman
apt-listchanges gnome-screenshot obsession-exit thunar-volman-settings
apt-mark gnome-session obsession-logout tic
apt-sortpkgs gnome-session-classic obxprop time-admin
ar gnome-session-custom-session oclock timedatectl
arch gnome-session-inhibit od timeout
arecord gnome-session-quit odp2pdf tjbench
arecordmidi gnome-shell odp2ppt tkjpeg
as gnome-shell-extension-prefs ods2pdf tload
aseqdump gnome-shell-extension-tool odt2bib toc2cddb
aseqnet gnome-shell-perf-tool odt2doc toc2cue
aspell gnome-software odt2docbook toe
aspell-import gnome-sound-recorder odt2html top
atobm gnome-system-monitor odt2lt totem
atril gnome-terminal odt2pdf totem-video-thumbnailer
atril-previewer gnome-terminal.wrapper odt2rtf touch
atril-thumbnailer gnome-text-editor odt2sdw tput
awk gnome-thumbnail-font odt2sxw tr
axfer gnome-todo odt2txt traceproto
b2sum gnome-tweaks odt2txt.unoconv traceproto.db
baobab gnome-weather odt2xhtml traceroute
base32 gnome-www-browser odt2xml traceroute6
base64 gold ooxml2doc traceroute6.db
basename gpasswd ooxml2odt traceroute.db
basenc gpg ooxml2pdf traceroute-nanog
bash gpg-agent open tracker
bashbug gpgcompose openbox transmission-gtk
bccmd gpgconf openbox-lxde transset
bdftopcf gpg-connect-agent openbox-session troff
bdftruncate gpgparsemail openssl true
bf_compact gpgsm openvt truncate
bf_compact-bdb gpgsplit operon trust
bf_copy gpgtar orca tryaffix
bf_copy-bdb gpgv orca-dm-wrapper tset
bf_tar gpg-wks-server os-prober tsort
bf_tar-bdb gpg-zip p11-kit tty
bitmap gpic p7zip tzselect
bluemoon gpicview pacat ucf
bluetoothctl gprof pacmd ucfq
bluetooth-sendto grep pactl ucfr
bmtoa grep-aptavail padsp ucs2any
bogofilter grep-available pager udevadm
bogofilter-bdb grep-dctrl pa-info udisksctl
bogolexer grep-debtags pamon ul
bogolexer-bdb grep-status paperconf umax_pp
bogotune gresource paplay umount
bogotune-bdb groff parcellite uname
bogoupgrade grog parec unattended-upgrade
bogoupgrade-bdb grops parecord unattended-upgrades
bogoutil grotty parole uncompress
bogoutil-bdb groups partx unexpand
boltctl grub-editenv passwd unicode_start
bootctl grub-file paste unicode_stop
broadwayd grub-fstest pasuspender uniq
btattach grub-glue-efi patch unity-scope-loader
btmgmt grub-kbdcomp pathchk unlink
btmon grub-menulst2cfg pavucontrol unlzma
buildhash grub-mkfont pax11publish unmkinitramfs
bunzip2 grub-mkimage pcmanfm unoconv
busctl grub-mklayout pdb3 unopkg
busybox grub-mknetdir pdb3.9 unshare
bwrap grub-mkpasswd-pbkdf2 peekfd unxz
bzcat grub-mkrelpath perf unzip
bzcmp grub-mkrescue perl unzipsfx
bzdiff grub-mkstandalone perl5.32.1 update-alternatives
bzegrep grub-mount perl5.32-x86_64-linux-gnu update-desktop-database
bzexe grub-ntldr-img perlbug update-menus
bzfgrep grub-render-label perldoc update-mime-database
bzgrep grub-script-check perli11ndoc upower
bzip2 grub-syslinux2cfg perlivp uptime
bzip2recover gsettings perlthanks usb-devices
bzless gsf pgrep usbhid-dump
bzmore gsf-office-thumbnailer pic usbreset
c++ gsf-vba-dump pico userinfo
c89 gstreamer-codec-install piconv usermount
c89-gcc gtbl pidof userpasswd
c99 gtf pidwait users
c99-gcc gtk-builder-tool pinentry users-admin
cancel gtk-encode-symbolic-svg pinentry-gnome3 utmpdump
captoinfo gtk-launch pinentry-x11 VBoxClient
caribou-preferences gtk-query-settings ping VBoxClient-all
cat gtk-update-icon-cache ping4 VBoxControl
catchsegv gucharmap ping6 VBoxDRMClient
catman gunzip pinky vdir
cc gzexe pipewire vi
cd-create-profile gzip pipewire-media-session view
cd-fix-profile h2ph pipewire-pulse viewres
cd-iccdump h2xs pkaction vim.tiny
cd-it8 hciattach pkcheck vlc
cdrdao hciconfig pkcon vlc-wrapper
c++filt hcitool pkexec vmstat
chacl hd pkg-config vmwarectrl
chage head pkill w
chardet HEAD pkmon w3m
chardetect helpztags pkttyagent w3mman
charmap hex2hcd pl2pm wall
chattr hexdump pldd watch
chcon host plog watchgnupg
cheese hostid plymouth wc
chfn hostname pmap wdctl
chgrp hostnamectl pod2html wget
chmod htop pod2man whatis
choom i386 pod2text whereis
chown ibus pod2usage which
chrome-gnome-shell ibus-daemon podchecker whiptail
chrt ibus-setup poff who
chsh iceauth pon whoami
chvt ico POST widget
ciptool icombine ppt2odp word-list-compress
cjpeg iconv pr wpa_passphrase
ckbcomp id precat write
cksum iecset preconv write.ul
clear ijoin preunzip wrjpgcom
clear_console im-config prezip www-browser
cmp im-launch prezip-bin X
codepage infocmp print X11
col infotocap printenv x11perf
colcrt install printf x11perfcomp
colormgr install-menu prlimit x86_64
colrm install-printerdriver prove x86_64-linux-gnu-addr2line
column instmodsh proxy x86_64-linux-gnu-ar
comm intel-virtual-output prtstat x86_64-linux-gnu-as
compose ionice ps x86_64-linux-gnu-c++filt
consolehelper ip psfaddtable x86_64-linux-gnu-cpp
consolehelper-gtk ipcmk psfgettable x86_64-linux-gnu-cpp-10
corelist ipcrm psfstriptable x86_64-linux-gnu-dwp
cp ipcs psfxtable x86_64-linux-gnu-elfedit
cpan ipod-read-sysinfo-extended pslog x86_64-linux-gnu-g++
cpan5.32-x86_64-linux-gnu ipod-time-sync pstree x86_64-linux-gnu-g++-10
cpio iptables-xml pstree.x11 x86_64-linux-gnu-gcc
cpp ischroot ptar x86_64-linux-gnu-gcc-10
cpp-10 isdv4-serial-debugger ptardiff x86_64-linux-gnu-gcc-ar
c_rehash isdv4-serial-inputattach ptargrep x86_64-linux-gnu-gcc-ar-10
crontab ispell ptked x86_64-linux-gnu-gcc-nm
csplit ispell-wrapper ptksh x86_64-linux-gnu-gcc-nm-10
ctstat join ptx x86_64-linux-gnu-gcc-ranlib
cupstestppd join-dctrl pulseaudio x86_64-linux-gnu-gcc-ranlib-10
cut journalctl pw-cat x86_64-linux-gnu-gcov
cvlc jpegexiforient pw-cli x86_64-linux-gnu-gcov-10
cvt jpegtran pwd x86_64-linux-gnu-gcov-dump
cvtsudoers json_pp pw-dot x86_64-linux-gnu-gcov-dump-10
dash kbdinfo pw-dump x86_64-linux-gnu-gcov-tool
date kbd_mode pwdx x86_64-linux-gnu-gcov-tool-10
dbus-cleanup-sockets kbxutil pw-metadata x86_64-linux-gnu-gold
dbus-daemon kernel-install pw-mididump x86_64-linux-gnu-gprof
dbus-launch kill pw-midiplay x86_64-linux-gnu-ld
dbus-monitor killall pw-midirecord x86_64-linux-gnu-ld.bfd
dbus-run-session kmod pw-mon x86_64-linux-gnu-ld.gold
dbus-send l2ping pw-play x86_64-linux-gnu-lto-dump-10
dbus-update-activation-environment l2test pw-profiler x86_64-linux-gnu-nm
dbus-uuidgen laptop-detect pw-record x86_64-linux-gnu-objcopy
dbxtool last pw-reserve x86_64-linux-gnu-objdump
dconf lastb pw-top x86_64-linux-gnu-pkg-config
dd lastlog py3clean x86_64-linux-gnu-ranlib
deallocvt lcf py3compile x86_64-linux-gnu-readelf
debconf ld py3versions x86_64-linux-gnu-size
debconf-apt-progress ld.bfd pydoc3 x86_64-linux-gnu-strings
debconf-communicate ldd pydoc3.9 x86_64-linux-gnu-strip
debconf-copydb ld.gold pygettext3 x86_64-pc-linux-gnu-pkg-config
debconf-escape less pygettext3.9 xarchiver
debconf-set-selections lessecho python3 xargs
debconf-show lessfile python3.9 xauth
debianbts lesskey querybts xbiff
deb-systemd-helper lesspipe quodlibet xbrlapi
deb-systemd-invoke lexgrog qvlc xcalc
defmt-c lft ranger xclipboard
defmt-sh lft.db ranlib xclock
delpart libnetcfg rbash xcmsdb
delv libreoffice rcp xconsole
desktop-file-edit libwacom-list-local-devices rctest xcursorgen
desktop-file-install light-locker rdjpgcom xcutsel
desktop-file-validate light-locker-command rdma xdg-autostart
df link readelf xdg-dbus-proxy
dfu-tool linux32 readlink xdg-desktop-icon
dh_bash-completion linux64 realpath xdg-desktop-menu
dh_dkms linux-boot-prober rendercheck xdg-email
dh_installxmlcatalogs linux-check-removal renice xdg-icon-resource
dh_perl_openssl linux-update-symlinks reportbug xdg-mime
diff linux-version report-hw xdg-open
diff3 listres reset xdg-screensaver
dig ln resizecons xdg-settings
dir lnstat resizepart xdg-user-dir
dircolors loadkeys resolvectl xdg-user-dirs-gtk-update
dirmngr loadunimap rev xdg-user-dirs-update
dirmngr-client localc rfcomm xditview
dirname locale rgrep xdpyinfo
discover-config localectl rhythmbox xdriinfo
djpeg localedef rhythmbox-client xedit
dmesg lodraw rifle Xephyr
dm-tool loffice ristretto xev
dnsdomainname lofromtemplate rlogin xeyes
dnstap-read logger rm xfburn
doc2odt login rmdir xfce4-about
doc2pdf loginctl rnano xfce4-accessibility-settings
domainname logname routef xfce4-appearance-settings
dotlockfile loimpress routel xfce4-appfinder
dpkg lomath rpcgen xfce4-clipman
dpkg-architecture look rsh xfce4-clipman-history
dpkg-buildflags loweb rstart xfce4-clipman-settings
dpkg-buildpackage lowntfs-3g rstartd xfce4-color-settings
dpkg-checkbuilddeps lowriter rtstat xfce4-dict
dpkg-deb lp runcon xfce4-display-settings
dpkg-distaddfile lpoptions run-mailcap xfce4-find-cursor
dpkg-divert lp_solve run-parts xfce4-keyboard-settings
dpkg-genbuildinfo lpstat run-with-aspell xfce4-mime-helper
dpkg-genchanges ls rview xfce4-mime-settings
dpkg-gencontrol lsattr rvlc xfce4-mouse-settings
dpkg-gensymbols lsblk rygel xfce4-notifyd-config
dpkg-maintscript-helper lsb_release sane-find-scanner xfce4-panel
dpkg-mergechangelogs lscpu savelog xfce4-popup-applicationsmenu
dpkg-name lsinitramfs scanimage xfce4-popup-clipman
dpkg-parsechangelog lsipc scp xfce4-popup-clipman-actions
dpkg-query lslocks scp-dbus-service xfce4-popup-directorymenu
dpkg-realpath lslogins screendump xfce4-popup-places
dpkg-scanpackages lsmem script xfce4-popup-whiskermenu
dpkg-scansources lsmod scriptlive xfce4-popup-windowmenu
dpkg-shlibdeps lsns scriptreplay xfce4-power-manager
dpkg-source lsof scrot xfce4-power-manager-settings
dpkg-split lspci sdiff xfce4-screenshooter
dpkg-statoverride lspgpot sdptool xfce4-sensors
dpkg-trigger lsusb sdw2odt xfce4-session
dpkg-vendor lto-dump-10 seahorse xfce4-session-logout
du luit sed xfce4-session-settings
dumpkeys lwp-download see xfce4-settings-editor
dwp lwp-dump select-default-iwrap xfce4-settings-manager
echo lwp-mirror select-editor xfce4-taskmanager
edit lwp-request sensible-browser xfce4-terminal
editor lxappearance sensible-editor xfce4-terminal.wrapper
editres lxclipboard sensible-pager xfconf-query
egrep lxde-logout sensors xfd
eject lxhotkey sensors-conf-convert xfdesktop
elfedit lxinput seq xfdesktop-settings
enc2xs lxlauncher sessreg xfhelp4
encguess lxlock setarch xflock4
enchant-2 lxmusic setfacl xfontsel
enchant-lsmod-2 lxpanel setfont xfrun4
env lxpanelctl setkeycodes xfsettingsd
envsubst lxpolkit setleds xfwm4
eog lxrandr setlogcons xfwm4-settings
eqn lxsession setmetamode xfwm4-tweaks-settings
evince lxsession-db setpci xfwm4-workspace-settings
evince-previewer lxsession-default setpriv xgamma
evince-thumbnailer lxsession-default-apps setsid xgc
evolution lxsession-default-terminal setterm xhost
ex lxsession-edit setupcon xiccd
exfalso lxsession-logout setvtrgb xinit
exifautotran lxsession-xdg-autostart setxkbmap xkbbell
exo-desktop-item-edit lxsettings-daemon sftp xkbcomp
exo-open lxtask sg xkbevd
expand lxterminal sh xkbprint
expiry lynx sha1sum xkbset
expr lzcat sha224sum xkbset-gui
factor lzcmp sha256sum xkbvleds
faillog lzdiff sha384sum xkbwatch
faked-sysv lzegrep sha512sum xkeystone
faked-tcp lzfgrep shares-admin xkill
fakeroot lzgrep shasum xload
fakeroot-sysv lzless shotwell xlogo
fakeroot-tcp lzma showconsolefont xls2ods
fallocate lzmainfo showkey xlsatoms
false lzmore showrgb xlsclients
fc-cache make shred xlsfonts
fc-cat make-first-existing-target shuf xmag
fc-conflist mako-render simple-scan xman
fc-list malcontent-client size xmessage
fc-match malcontent-control skill xmms2d
fc-pattern man slabtop xmms2-launcher
fc-query mandb sleep xmodmap
fc-scan manpath slogin xmore
fc-validate man-recode smproxy Xorg
fgconsole mapscrn snice xprop
fgrep mawk soelim xrandr
file mcookie soffice xrdb
file-roller md5sum software-properties-gtk xrefresh
fincore md5sum.textutils sort xsane
find mdig sort-dctrl xscreensaver
findaffix memusage sotruss xscreensaver-command
findmnt memusagestat spa-acp-tool xscreensaver-demo
firefox mesa-overlay-control.py spa-inspect xscreensaver-getimage
firefox-esr mesg spa-monitor xscreensaver-getimage-file
flock mid3cp spa-resample xscreensaver-getimage-video
fmt mid3iconv spd-conf xscreensaver-systemd
fold mid3v2 spd-say xscreensaver-text
fonttosfnt migrate-pubring-from-classic-gpg spdsend x-session-manager
free mimeopen speaker-test xset
funzip mimetype speech-dispatcher xsetmode
fuser mkdir splain xsetpointer
fusermount mkfifo split xsetroot
fusermount3 mkfontdir splitfont xsetwacom
fwupdagent mkfontscale sprof xsm
fwupdate mk_modmap ss xstdcmap
fwupdmgr mknod ssh xsubpp
fwupdtool mktemp ssh-add x-terminal-emulator
fwupdtpmevlog mmcli ssh-agent xvidtune
g++ moggsplit ssh-argv0 xvinfo
g++-10 monitor-sensor ssh-copy-id Xwayland
gamma4scanimage more ssh-keygen xwd
gapplication mount ssh-keyscan x-window-manager
gatttool mountpoint startlxde xwininfo
gcalccmd mousepad start-pulseaudio-x11 xwud
gcc mpris-proxy startx x-www-browser
gcc-10 mt startxfce4 xxd
gcc-ar mt-gnu stat xz
gcc-ar-10 mtrace stdbuf xzcat
gcc-nm munchlist streamzip xzcmp
gcc-nm-10 mutagen-inspect strings xzdiff
gcc-ranlib mutagen-pony strip xzegrep
gcc-ranlib-10 mv stty xzfgrep
gcm-import namei su xzgrep
gcm-inspect nano sudo xzless
gcm-picker nautilus sudoedit xzmore
gcm-viewer nautilus-autorun-software sudoreplay yelp
gcov nawk sum yes
gcov-10 nc sushi ypdomainname
gcov-dump nc.traditional su-to-root zcat
gcov-dump-10 neqn svlc zcmp
gcov-tool netcat switcherooctl zdiff
gcov-tool-10 networkctl sxw2odt zdump
gcr-viewer newgrp synaptic-pkexec zegrep
gdbus ngettext sync zenity
gdialog nice system-config-printer zfgrep
gdk-pixbuf-csource nisdomainname system-config-printer-applet zforce
gdk-pixbuf-pixdata nl systemctl zgrep
gdk-pixbuf-thumbnailer nm systemd zipdetails
gdm-control nm-applet systemd-analyze zipgrep
gdmflexiserver nmcli systemd-ask-password zipinfo
gdm-screenshot nm-connection-editor systemd-cat zless
gedit nm-online systemd-cgls zmore
gencat nmtui systemd-cgtop znew
geqn nmtui-connect systemd-delta
GET nmtui-edit systemd-detect-virt
waldek@hellodebian:/usr/bin$
```
That's a **lot** of programs!
Can you find `cd` in there?
Spoiler alert, you wont...
Maybe it's located somewhere else?
Let's have a look.
```
waldek@hellodebian:/usr/bin$ which cd
waldek@hellodebian:/usr/bin$
```
`cd` is not a program but a builtin command.
From a practical point of view there is no difference but I do like to mention it for completeness.
Later down the line it will help you to contextualize the differences between shells a bit better.
But built into *what*?
Below you can see a snippet of a part of the `bash-builtin` manual.
For now just accept the specific shell we're using is called `bash`.
```
BASH-BUILTINS(7) Miscellaneous Information Manual BASH-BUILTINS(7)
NAME
bash-builtins - bash built-in commands, see bash(1)
SYNOPSIS
bash defines the following built-in commands: :, ., [, alias, bg, bind, break, builtin, case, cd, command, compgen, complete, continue, de
clare, dirs, disown, echo, enable, eval, exec, exit, export, fc, fg, getopts, hash, help, history, if, jobs, kill, let, local, logout, popd,
printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, unalias,
unset, until, wait, while.
```
### Absolute and relative paths
> All roads lead to Rome.
There are multiple ways to go to the same location on your system.
You can always go either in an **absolute** way, or in *multiple* **relative** ways.
The root of your system is `/` and to list what we can find there we can use `ls`.
```
waldek@hellodebian:~$ cd /
waldek@hellodebian:/$ ls
bin dev home initrd.img.old lib32 libx32 media opt root sbin sys usr vmlinuz
boot etc initrd.img lib lib64 lost+found mnt proc run srv tmp var vmlinuz.old
waldek@hellodebian:/$
```
From here we can go back home in multiple ways.
```
waldek@hellodebian:/$ cd
waldek@hellodebian:~$ cd -
/
waldek@hellodebian:/$ cd home/waldek/
waldek@hellodebian:~$ cd -
/
waldek@hellodebian:/$ cd /home/waldek/
waldek@hellodebian:~$
```
The first one is the handy shortcut we learned, and we go back to the root of our system with the `cd -` shortcut.
The following two manipulations look very similar but there is a subtle difference.
The first one `home/waldek` is a **relative** path, and the second one `/home/waldek` is an **absolute** one.
Relative paths depend on where you are located, absolute ones always point to the same location.
An example.
```
waldek@hellodebian:~$ cd /usr/bin/
waldek@hellodebian:/usr/bin$ cd /home/waldek/
waldek@hellodebian:~$ cd -
/usr/bin
waldek@hellodebian:/usr/bin$ cd home/waldek
-bash: cd: home/waldek: No such file or directory
waldek@hellodebian:/usr/bin$
```
The second command fails because from where I'm standing, there is no folder called `home/waldek`!
I can however still go to my home in a relative way but I need to *go back* a few directories first.
```
waldek@hellodebian:/usr/bin$ cd ../../home/waldek/
waldek@hellodebian:~$ pwd
/home/waldek
waldek@hellodebian:~$
```
The `..` means go **back** one directory so in our example we go back **two** directories, which brings us to the `/` of our system and from there we go **up** to `home` and then `waldek`.
### Exercise
Explore your system a bit using `cd` and `ls`.
You'll probably encounter some weird messages along the way.
Keep note of them so we can discuss it together.
### `root` and `/` and `/root` are not the same thing
## A pit stop to review what we've learned so far
Below is a list of programs and command we've seen so far.
|command|desciption|
|---|---|
|systemctl|manipulate running services|
|apt|the Debian package manager|
|htop|a command line task manager we installed|
|vlc|a video player we installed|
|date|display the time of day|
|which|show the path to an executable|
|file|print more information about a file's content|
|head|show the first lines of a file|
|pwd|print working directory|
|cd|change directory|
|ls|list content of a directory|