2022-02-18 11:45:27 +01:00
# 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 [Linux 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?
2022-02-18 13:08:30 +01:00
* 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 )
2022-02-18 11:45:27 +01:00
### 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.
2022-02-18 13:08:30 +01:00
* Why is Debian called [the universal operating system ](https://www.reddit.com/r/debian/comments/22j0wf/so_why_debian_is_called_the_universal_operating/ )?
2022-02-18 11:45:27 +01:00
* [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
Step by step walk-through of a VM creation in virtualbox with some notes on each step with best practice pointers.
2022-02-18 13:08:30 +01:00
![virtualbox setup ](../assets/2022-02-18-122703_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-122833_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-122930_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-122943_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-122951_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-123011_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-123047_1920x1080_scrot.png )
![virtualbox setup ](../assets/2022-02-18-123121_1920x1080_scrot.png )
2022-02-18 11:45:27 +01:00
## Breakdown of the Debian installation
2022-02-18 13:08:30 +01:00
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.
2022-02-18 11:45:27 +01:00
* [step by step ](https://debian-handbook.info/browse/stable/sect.installation-steps.html ) installation instructions
2022-02-18 13:08:30 +01:00
* **don't set a root password, use `sudo` instead**
2022-02-18 11:45:27 +01:00
* **stress the graphical/minimal difference**
2022-02-18 13:08:30 +01:00
![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 )
### 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?
2022-02-18 13:59:23 +01:00
## Quick look at an idle system
![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 )
2022-02-18 13:08:30 +01:00
## Package managers
* what is a [package manager ](https://en.wikipedia.org/wiki/Package_manager )
2022-02-18 13:59:23 +01:00
### Graphical installation
2022-02-18 13:08:30 +01:00
![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 )
2022-02-18 13:59:23 +01:00
### 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 )
![htop bug with gnome-terminal ](../assets/VirtualBox_debian_18_02_2022_13_19_35.png )
### Adding a secondary desktop environment
![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
```
![minimal runlevel ](../assets/VirtualBox_debian_18_02_2022_13_40_00.png )
![minimal runlevel ](../assets/VirtualBox_debian_18_02_2022_13_40_11.png )
```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
```
2022-02-18 13:08:30 +01:00