# Laboration 2
**Course:** Säker konfiguration av operativsystem
**School:** IT-Högskolan HT -23
**Author:** Joakim Thor
## Configuring Kali Linux
**Kali Linux** is a GNU/Linux distribution aimed at advanced penetration testing and security auditing, based on **Debian**.
This report will be a short guide, as well as a reflection on the author's thoughts on how to make an installation of Kali Linux more pleasing to use, and more useful.
### Shells
By default, Kali Linux is using the shell **zsh**, or **z shell**, while many other GNU/Linux distributions make use of the **bash** shell. (GeeksForGeeks, 2023)
Zsh is build on top of bash, adding a few extra features, like better theme support, customization possibilities and spelling correction.
#### Changing shells
To show your current shell, you can use the following command in a terminal:
```bash=
$ echo $SHELL
```
Which will give you an output similar to this:

*fig 1)*
As can be seen by the output `/bin/zsh`, the current shell is **zsh**.
To list all **available shells** on the system, use the `cat` function on the `shells` file in the `/etc` folder:
```bash=
$ cat /etc/shells
```
Which will give you an output:

*fig 2)*
Now, to change your shell to, for example, `bash`, use the `chsh` command in the terminal:
```bash=
$ chsh -s /bin/bash
```
You will be prompted to enter your password, and after entering it, you must **log out** and back in again for the change to take effect.
#### Oh My Zsh! (Author's take)
While zsh and bash is quite similar in everyday use, **zsh** has a trick up its sleeve, namely **plugin support**.
**Ohmyzsh** (found [here](https://ohmyz.sh/#install)) is a framework for zsh, providing themes, auto-completion and other plugins that makes terminal use easier and more pleasant.
I (the author) always end up installing ohmyzsh, a specific theme and a few plugins. These plugins have made me a lot more proficient and faster while using the terminal.
These are the plugins I always end up installing, and recommend people getting, when configuring their terminals:
**zsh-autosuggestions** - This plugin suggests commands and command completion when entering text in the shell. It's basically based on your command history, so it will suggest commands based on commands you've entered frequently, and will dynamically change the suggestions based on what text you enter.
Two examples can be seen below:

*fig 3)*

*fig 4)*
You can find zsh-autosuggestions [here](https://github.com/zsh-users/zsh-autosuggestions/tree/master).
**zsh-syntax-highlighting** - This plugins highlights commands and entries in the shell, making it a lot easier to read and determine whether a command is written correctly. Zsh-syntax-highlighing can be found [here](https://github.com/zsh-users/zsh-syntax-highlighting).
Two examples can be seen below:

*fig 5)*

*fig 6)*
After downloading and installing the plugins, you must enter what plugins you wish to use in the `.zshrc` file in your home folder:

*fig 7)*
**One thing to note**, is that with these plugins, you can also tab through suggestions and directories. See below:

*fig 8)*

*fig 9)*
### Desktop environments
By default, Kali Linux comes with **Xfce**, but can also be installed with other **desktop environments** during installation. However, this is not possible when running the **VM** image of Kali Linux. (Kali, 2023)
To install a new desktop environment, like **Gnome** or **KDE**, you use the package manager **apt**. Kali Linux has several desktop environments to install in their repositories (make sure your repositories are updated before installing):
```bash=
# Update repositories
$ sudo apt update
# Install Gnome
$ sudo apt install kde-desktop-gnome
# Install KDE
$ sudo apt install kde-desktop-kde
```
After downloading and installing a new desktop environment, you can **log out** and log back in again, after choosing the desktop environment you wish to use in the menu in the top bar.
#### Gnome and i3 (Author's take)
While having tried many desktop environments, I usually end up installing **Gnome**, but I also make use of **i3** from time to time, which is a **tiling window manager**, not a complete desktop environment.
While not personally happy with Gnome's RAM usage, nor its (sometimes) laggy animations and instability, Gnome is a great desktop environment, with an unintrusive GUI (see fig 9) and a great activities overview (see fig 10). Also, it has great customizability, with **Gnome extensions** (found [here](https://exetensions.gnome.org)). While I would probably not make use of extensions on a system that's supposed to be especially secure, it's still nice to have the option in other cases.

*fig 10)*

*fig 11)*
The reason for jumping off and on to **i3** is because of its **window tiling** capabilities, making the use of a mouse pretty much obsolete when navigating the system. It has quite the learning curve, but when it's in your muscle memory, it's really convenient navigating that way.
Back in the day, I did prefer **Xfce**, because it was really lightweight and easy on RAM, but back then none of the desktop environments had a search function when the **super** key was pressed, which made me switch over to **Gnome** when they implemented it in **Gnome3**, and since then, I haven't really tried it out again, even though Xfce now has the search function.
The **activity overview** in Gnome also keeps me from the other desktop environments, such as **KDE**, **Cinnamon** and the like, because although at least KDE can be customized to have the same functionality, it just gets in my way and takes up my time to setting up such an environment.
### Software (Author's take)
If I had to choose four essential programs to install on a new computer with GNU/Linux I'm supposed to do work on, it'd be these:
* **htop** - While `top` certainly works, `htop`, with it's more user-friendly interface and color is certainly a lot easier to read. I always keep a terminal window with `htop` open on my computers.
* **Virtual Studio Code** - Anything that requires typing more than a couple of lines of text, I do in VSCode. Having used it for many years, and knowing it inside out, helps when doing anything text related.
* **Ranger** - A terminal file manager. Not having to use the mouse, and navigating files in the terminal with an easy to read interface is bliss. See below:

* **Chromium/Chrome** - Any will do, but I can't live without their inspection tools and development tools.
## Comparing GNU/Linux distributions
| Red Hat Enterprise Linux | Fedora | Debian | Ubuntu | OpenSUSE |
| - | - | - | - | - |
| RHEL is an enterprise distribution aimed at commercial use - not recommended for regular users | Fedora is a community driven project sponsored by Red Hat - serves as the **upstream** for RHEL | Debian is a community driven project focusing on **free, open-source software** | Ubuntu is a commercial project aimed at both regular users and enterprises - targets a wide audience | OpenSUSE is the community driven project sponsored by SUSE, serving as the **upstream** for SUSE Linux |
| Free to use for developers, otherwise cost money if wanting support, can be compiled for free (see **CentOS**) | Free to use | Free to use | Free to use, but Canonical offers solutions to companies that cost money | Free to use |
| Long term stable (LTS) versions only - maintained for about 10 years without extended maintenance | No LTS version - maintained for 13 months for each version | Both LTS (5 year maintenance) and non-LTS (unstable version) available | Both LTS (5 year maintenance) and non-LTS versions available | non-LTS (**Tumbleweed**, rolling release, maintaned "forever") and fixed-release non-LTS (**Leap**, 2 year maintenance) |
| Open-source | Open-source | Open-source | Open-source | Open-source |
| No fixed timeline for releases | New release every 6 months | New LTS release every 2 years | New LTS release every two years |
| FOSS, but can enable non-free repositories | FOSS, but can enable non-free repositories (**RPM Fusion**) | FOSS, but can enable non-free repositories | Both FOSS and non-free by default | FOSS by default, but can enable non-free repositories |
*All information above can be found on their respective website/in their documentation, all included under the "Sources" section.*
### Author's take
The differences between these distributions are both great and minor: as they all make use of the **Linux kernel**, one can expect them to behave pretty similarly, and knowledge about one distribution can be transferred to another, with some minor changes.
There are some things that sets them apart, like bundled software, package managers, release cycles and maintenance, and their target audience and general vision.
**Fedora** is the **upstream** of **RHEL**, meaning that it's basically Red Hat's (although community driven) testing ground for their development. Same goes for **OpenSUSE** (upstream) and **SUSE**.
The upside with having an distribution that sits upstream is of course the bleeding edge software and hardware support it comes with. However, the downside is that it might be unstable, have lots of bugs and things might break when updating packages. Also, in the case of **Fedora**, it can become tedious upgrading every 6-13 months, as an upgrade without reinstalling the system can mess with your system, your software, packages and configurations.
The upside of having an **LTS** distribution, like **Debian** or **Ubuntu**, is that it's often more stable, as they sit downstream, only utilizing packages that has been proven stable. The downside of that is of course that one might miss out on newer software and functions, that might, or might not, be of value or a necessity to you. The upside of Ubuntu utilizing non-free software by default, makes it suitable for many, as it supports a lot of hardware and have many different non-free drivers. Fedora and openSUSE obviously takes the cake when it comes to supporting **new** hardware, as they get kernel updates before everyone else.
For hosting a **web server**, I'd personally make use of **Debian**, as it's considered one of the most stable and secure distributions. A **headless** installation of Debian is also very resource conservative. Usually, when running a web server, bleeding edge technology often isn't important, as you'd want your server to be stable and secure rather than winging it with possible security flaws with barely tested software.
## Sources
GeeksForGeeks (2023), *Bash scripting - Difference between Zsh and Bash*
[Link](https://www.geeksforgeeks.org/bash-scripting-difference-between-zsh-and-bash/)
Kali (2023), *Switching Desktop Environments*
[Link](https://www.kali.org/docs/general-use/switching-desktop-environments)
Ubuntu (2023)
[Link](https://ubuntu.com/)
OpenSUSE (2023)
[Link](https://www.opensuse.org/)
Debian (2023)
[Link](https://www.debian.org/)
Fedora (2023)
[Link](https://fedoraproject.org/)
Red Hat Access (2023)
[Link](https://access.redhat.com/)