Initial commit

This commit is contained in:
zervo 2024-09-12 09:17:03 +02:00
commit 8dde66558d
16 changed files with 578 additions and 0 deletions

View file

@ -0,0 +1,60 @@
# Connecting to Academedia wifi on a linux system
In order to be able to use your linux system in your academedia school environment, you need to connect to a wifi network.
There are two primary networks available: ACAGuest, and ACANet1x. However, you probably know ACANet1x as Academedia X Profiles.
## Connecting to guest
The guest wifi network is just a simple wpa2 network with a password. The password is as follows:
`FramtidNu`
(as of 2024)
Please note that the guest network and the internal network (ACANet1x) are the same network. You just connect from two different *wifi* networks.
The only difference is that ACAGuest has limited bandwidth. But other than that you have access to everything.
## Connecting to the internal network (ACANet1x)
Connecting to the internal network is slightly more complicated since it is a WPA enterprise network designed for windows environments.
However, setting up a profile with network manager is still quite simple. The following examples use nmtui.
1. Add a new wifi network.
2. Enter your desired name (recommended to be set as ACANet1x) and the name of the wireless network card you want to use.
![entering name and wifi card](image1.png)
3. Set SSID to `ACANet1x` and mode to `Client`.
![setting ssid](image2.png)
4. Set security to `WPA & WPA2 Enterprise`, and set authentication method to `PEAP`.
![set security and auth methods](image3.png)
5. Fill in your "anonymous" identity as well as domain. (the email is the same one you use to connect to the network on windows).
![enter identity and domain](image4.png)
6. Set PEAP version to `Automatic` and the inner authentication method to `MSCHAPv2`.
![set peap version and inner auth](image5.png)
7. Enter the username (email) and password for your learnet account. These are the credentials you use to log into the network on windows.
![enter username and password](image6.png)
8. For security reasons, you should choose only to store the password for this user.
![only save password for own user](image7.png)
9. You should also choose to only store the profile for this user.
![only store profile for own user](image8.png)
And that's it! You should now be able to connect to this network. Note that you might get prompted to enter the password again.
If this happens every time you connect, you might have to modify the profile to store itself and the password for all users.

BIN
ConnectingToWifi/image1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
ConnectingToWifi/image2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
ConnectingToWifi/image3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
ConnectingToWifi/image4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
ConnectingToWifi/image5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
ConnectingToWifi/image6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
ConnectingToWifi/image7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
ConnectingToWifi/image8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

@ -0,0 +1,72 @@
# Setting up Hostname resolution
Dynamic hostname resolution in modern linux distributions is provided by *Avahi*.
## Installation
Refer to the documentation for your linux distribution. The following instructions are for arch linux, but the process should be roughly the same on other distributions as well.
`sudo pacman -S avahi`
Then enable the service. Here you can choose between *enabling the service* or *using socket activation*.
**A.** Socket activation: avahi will only be started when a program or service requests it.
`sudo systemctl enable avahi-daemon.socket`
**B.** Enabling the service: avahi will always be active, even when no service has requested it.
`sudo systemctl enable --now avahi-daemon.service
*systemd-resolved* might conflict with avahi. You can manually go through its config and disable the multicast DNS resolver/responder, or you can disable the service entirely:
`sudo systemctl disable systemd-resolved`
You also need the following package:
`sudo pacman -S nss-mdns`
## Configuration
Edit the file `/etc/nsswitch.conf` and change the `hosts` line to include `mdns_minimal [NOTFOUND=return]` before `resolve` and `dns`.
Here is an example:
```
hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns
```
If you experience slowdowns in resolving `.local` hosts (or you do not want to use IPv6) try to use `mdns4_minimal` and `mdns4` instead of `mdns_minimal` and `mdns` respectively.
### Fix issue with NSS-MDNS caused by systemd-resolved
If you didn't disable *systemd-resolved* entirely, and instead only disabled multicast DNS resolution, please follow this step. If you disabled the service entirely you can skip this.
First, make sure you have the `host` command available on your system. On arch linux, it is installed by the `bind` package in the `extra` repository.
`sudo pacman -S bind`
Then, run the following command and hope that it returns `NXDOMAIN`:
`host -t SOA local`
If the host did respond with `NXDOMAIN`, you don't need to follow the rest of the steps in this section.
If it didn't, continue reading.
Replace `mdns_minimal` in `/etc/nsswitch.conf` that you added earlier, with the full `mdns` module:
```
hosts: mymachines mdns [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns
```
And then create `/etc/mdns.allow` with the following content:
```
.local.
.local
```
Note that this solution might break reverse lookups, such as `traceroute`. To fix this, change back `mdns` to `mdns_minimal`. This will unfortunately sacrifice your dynamic hostname resolution ability.
Other than that, you are done.

35
PolicyKit/README.md Normal file
View file

@ -0,0 +1,35 @@
# Setting up Policy Kit
These instructions were performed on arch linux. The process should be roughly the same on other distributions, but refer to your local wiki anyway.
Policy Kit in Linux can be compared to UAC in Windows.
If you want to perform an admin (root) action in a graphic environment, Policy Kit ensures you get a dialog prompting you for your password.
## Installation
First, you have to install policy kit itself. Policy kit is also known as polkit:
`sudo pacman -S polkit`
If you are in a text-only environment, you don't need to do anything else.
But I assume you are in a graphical environment, in which case you need an *authentication agent*.
Note that if you used an installation script or installed a big DE group package, you might already have an authentication agent installed.
Check your package list before continuing. Here are DEs that typically have an agent pre-installed: Cinnamon, Deepin, GNOME, KDE, LXDE, LXQt, MATE, Xfce.
You have a couple of different ones to choose from, you can find a list in the [arch linux article](https://wiki.archlinux.org/title/Polkit).
In this guide, we will use *lxpolkit*. Let's install it.
`sudo pacman -S lxsession-gtk3`
## Autostart
You need to set your agent to autostart on session start. This is done differently in every DE, WM or other environment.
For example, in KDE plasma you can add autostart commands via the system settings utility.
If you use something like AwesomeWM, you can just spawn a process.
Or you can simply add it to your .xsession or .xprofile.
The only thing you need to add to autostart is the command for your agent. In the case of lxpolkit you would just add the command `lxpolkit` to autostart.

99
PrinterSetup/README.md Normal file
View file

@ -0,0 +1,99 @@
# Printer setup
In the modern world of linux, we use the CUPS printing system to interface with printers.
With modern printers, you usually don't even need drivers. This is known as "driverless printing".
Some older printers may need drivers in order for you to print to them, this will not be covered in this guide. The basic procedure is to look up the drivers for your printer and check if they are available in the repositories of your linux distribution. If you are unsure, you can install a group package with many drivers and hope that one of them works.
## Installation
The first step is installing CUPS. The following instructions were performed on arch linux, but the procedure is roughly the same on other distrubtions. (refer to your local wiki!).
`sudo pacman -S cups`
If you want to be able to "print" to PDF documents, aka save to PDF via the print dialog, you can also install the following package:
`sudo pacman -S cups-pdf`
Then enable the CUPS service. You can either enable the service directly, or use *socket activation*.
**A.** Socket activation: only starts the service when a program needs it.
`sudo systemctl enable cups.socket`
**B.** Enable service: the CUPS service is always active, even when no program has requested it.
`sudo systemctl enable --now cups.service`
## Configuration
Now that you have the printing service installed, you probably want to add some printers.
There are a few way of doing this. If your printer is parallel or USB, it should have been detected automatically (provided your system has the correct kernel modules loaded: lp, parport, parport_pc).
You can manage your printers in the CUPS web interface.
### CUPS web interface
By default, the CUPS configuration web interface can be accessed at [http://localhost:631/admin/](http://localhost:631/admin/).
If you use *socket activation*, you might need to start the service first: `sudo systemctl start cups.service`.
The interface is pretty self-explanatory. If something is unclear, you can read the [CUPS Documentation](https://github.com/OpenPrinting/cups/?tab=readme-ov-file).
Alternatively, there are multiple [GUI Applications](https://wiki.archlinux.org/title/CUPS#GUI_applications) that can be used for configuration instead.
### Adding network printers
If the address of the printer is known (and preferably static) you can add it manually via the web interface or a GUI application.
However, in most network environments you want to set up automatic discovery.
First, follow the steps in the *HostnameResolution* guide and come back once you have it set up.
After doing that, all you have to do is restart the CUPS service and hostname resolution should be working:
`sudo systemctl restart cups.service`
NOTE: If you want to share printer resources, or just interact with windows resources (SMB) in general, you can install the `samba` package (arch linux):
`sudo pacman -S samba`
### Setting up permissions
Normally only system administrators are allowed to manage things like printer queues.
You can add your usergroup to `/etc/cups/cups-files.conf`, but this is not recommended.
Instead, you should configure policy kit to allow passwordless authentication for printer actions.
First, make sure you have policy kit set up. Follow the *PolicyKit* guide for that.
Then, create a policy kit rule: `/etc/polkit-1/rules.d/49-allow-passwordless-printer-admin.rules`:
```
polkit.addRule(function(action, subject) {
if (action.id == "org.opensuse.cupspkhelper.mechanism.all-edit" &&
subject.isInGroup("wheel")){
return polkit.Result.YES;
}
});
```
And that is permissions set up!
### Setting paper size
On arch linux, libpaper is installed with cups. If it wasn't installed, it is recommended to install it to be able to control paper configuration.
The arch package is `libpaper`.
By default, libpaper uses the "Letter" paper size. If you don't want to change this every time you want to print something,
you can edit `/etc/papersize` for systemwide configuration, and `$USER/.config/papersize` for user-specific configuration.
To see available sizes, you can either view `man 1 paper` or `paper --no-size --all`.
### Discovering printers on LDAP servers
In order to discover printers on LDAP servers, please follow "Adding network printers" and then enable `cups-browsed.service`.

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# Linux In School
This is a collection of tutorials on integrating your linux system into a windows environment.
These instructions are specifically written for Academedia-managed schools, but can be applied to any windows network environment with some minor and obvious adjustments.
See the individual folders for instructions.

305
VirtualMachines/README.md Normal file
View file

@ -0,0 +1,305 @@
# Setting up virtualization & virtual machines
You will probably be required to use virtual machines during some classes. The procedure to getting them set up is pretty straightforward, but I will summarize them here anyway.
As usual, these instructions were written and tested on arch linux. The process should be fairly similar on other distributions, but some might have everything set up already, and some may not support virtualization at all.
## Making sure KVM works
KVM is the foundation for virtualization on linux. It allows running performant VMs close to hardware, with support built-in directly in the kernel.
### Check for basic kernel support
First of all, your CPU needs to support virtualization. Let's check it with the following command:
`LC_ALL=C.UTF-8 lscpu | grep Virtualization`
If it outputs the following, your CPU supports virtualization:
```bash
Virtualization: VT-x
```
Note that you might need to enable virtualization support in your BIOS/EUFI firmware settings.
Now we need to make sure the necessary kernel modules are available.
`zgrep CONFIG_KVM= /proc/config.gz`
The module is available only if it is set to either `y` or `m`.
Now we need to make sure the modules are automatically loaded as well.
`lsmod | grep kvm`
If the command returns nothing, you need to manually load the modules. There is a great article on this in the [arch wiki](https://wiki.archlinux.org/title/Kernel_module#Manual_module_handling).
## Installing QEMU
QEMU is also part of the virtualization chain. It uses KVM as a hypervisor and manages machines behind the scenes. It allow guests to execute code directly on the CPU without extra translation layers to achieve near-native performance. (better than hyper-v on windows).
You have a few different options for installing qemu. There is three main packages: `qemu-full`, `qemu-base` and `qemu-desktop`. I won't go through their differenes here, but to save time we will use `qemu-full`:
`sudo pacman -S qemu-full`
You can also install additional packages for additional hardware support, just to be safe:
`sudo pacman -S samba qemu-block-gluster qemu-block-iscsi qemu-user-static`
With this, you should be done (with QEMU). If you need to emulate for other architectures, you need to install separate packages for those.
See the [QEMU arch wiki article](https://wiki.archlinux.org/title/QEMU) for more information.
## Installing libvirt
Now we need to install libvirt, which will provide us with an easy way to manage the virtual machines.
Start by installing the `libvirt` package:
`sudo pacman -S libvirt`
Then we need to install some packages in order for networking to function properly:
`sudo pacman -S iptables-nft dnsmasq`
If it complains about conflicts, you should be able to replace the old package without any issues, unless you have manually made some special complicated network config.
Now edit `/etc/libvirt/network.conf` and change this line:
```
firewall_backend="iptables"
```
Note: If you are using firewalld, as of libvirt 5.1.0 and firewalld 0.7.0 you no longer need to change the firewall backend to iptables. libvirt now installs a zone called 'libvirt' in firewalld and manages its required network rules there.
Now we have to install a GUI client to actually do the managing of virtual machines.
`sudo pacman -S virt-manager`
### Setting up authorization
Your user must have permission to use libvirt. This is to avoid having the enter your password all the time just to use a virtual machine.
If for some reason you want to use policy kit or similar for authentication and enter your password all the time, instructions can be found [here](https://wiki.archlinux.org/title/Libvirt#Set_up_authentication).
What we will do instead is add your user to the `libvirt` group:
`sudo usermod -a -G $USER libvirt`
### Starting the daemon
All you need to do to enable the daemon (and thus libvirt) is run the following command:
`sudo systemctl enable --now libvirtd.service`
And that's it! You should now be able to create and use virtual machines.
### Testing the installation
Let's test if the installation works correctly.
system-level:
`virsh -c qemu:///system`
It should open an interactive prompt.
If it does, good. You can exit it with CTRL+C.
user-level:
`virsh -c qemu:///session`
Same thing here, it should open a prompt and you can exit it with CTRL+C.
If it doesn't work, it could be a due to a load of different issues.
You will have to go researching on your own. Here are some articles to help:
[Libvirt - archwiki](https://wiki.archlinux.org/title/Libvirt)
[QEMU - archwiki](https://wiki.archlinux.org/title/QEMU)
[KVM - archwiki](https://wiki.archlinux.org/title/KVM)
Good luck!
## Creating a Windows VM
Sometimes windows VMs might require some extra tinkering to work properly.
Most of the time they will run out of the box, but have frequent crashes/freezes due to things like CPU configuration.
Here are some tinkering steps to prevent that.
### 1: Create the VM
The first step is to actually create the VM.
If you have already created a VM but is having issues with it, it is recommended to delete it and start from scratch while following these instructions.
1. Open virt-manager and create a new VM. Use ISO media and select the windows ISO.
2. Make sure virt-manager detects the correct operating system, such as `Microsoft Windows 10`. If not, set it to the correct type.
3. Continue forward and set the amount of memory and CPU you want for this machine. We will modify these options a bit more later on.
4. Move to the next step and create a disk image for storage. This is pretty straight forward in the virt-manager interface, but if you need help, google it. Please note that this image cannot easily be expanded later, and you should set a size that is "big enough". If you want to run bare windows, 50GB should generally be fine.
5. In the final step you need to set the name of your VM. Remember that you should always avoid spaces in naming, it is inproper to use spaces.
### 2: Configuration
We need to change some configuration options in order for our windows machine to run smoothly.
This configuration dialog can be found in the virtual machine window (open it by right-clicking the VM in the list and clicking `open`).
Just click the lamp icon instead of the monitor icon.
![open config dialog](image-1.png)
#### CPUs
Navigate to the `CPUs` option in the hardware list.
Check "*Copy host CPU configuration*".
Make sure that virt-manager got your CPU topology right. It will be in grayed-out boxes under "*Topology*".
If not, check "*Manually set CPU topology*" and configure it to be as close to your physical CPU architecture as possible.
The most important one is "*Sockets*" and that "*Cores*" doesn't exceed your amount of physical cores. Leaving "*Threads*" at 1 is generally fine.
Don't forget to click `Apply`.
![cpu gui config](image.png)
#### OPTIONAL: Adding VirtIO drivers.
You can optionally add VirtIO drivers as a CD-ROM device into your VM.
This will allow you to install the drivers into the VM when it's running, which in turn will enable you to use VirtIO devices.
First, get the ISO for the VirtIO drivers. Instructions can be found [here](https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers).
Choose `Add Hardware -> Storage -> Select or Create custom storage`, remember to set the `device type` to `CDROME device`.
Then add the driver image ISO so that windows can grab it during installation.
If you have already installed windows and decided to read through these instructions anyway, you can open the device and run the installer manually just fine.
If you choose to install drivers during windows installation, you have to choose "*additional drivers*" during installation, and might have to enable "*non-compatible drivers*" to see them.
#### Video / display
1. In `Display Spice`, make sure it's set to Spice and not VNC.
2. In `Video QXL`, make sure the model is QXL.
3. Enable XML editing: In virt-manager panel, choose `Edit -> Preference -> Enable XML editing`.
4. Back in `Video QXL`, go to the "*XML*" tab and change the `vgamem` value under the `model` entry from "*16384*" to "*65536*".
Don't forget to click `Apply`.
#### Watchdog
Look in your hardware list for a `Watchdog` device. If there is none, add it.
You can leave "*Model*" as the default value.
Change "*Action*" to `Gracefully shutdown the guest`.
Click `Apply`.
#### Advanced CPU configuration
We need to do some further CPU configs. This might be the most important step to avoid random freezes so make sure you follow along closely.
1. Navigate to `CPUs` again and open the "*XML*" tab.
2. Find the `cpu` block and change the opening tag to the following:
```xml
<cpu mode="host-model" check="partial">
```
3. Add a feature tag inside the CPU block with the following content:
```xml
<feature policy="disable" name="hypervisor"/>
```
4. OPTIONAL: If you later continue to experience issue, considering adding this inside CPU as well:
```xml
<model fallback='allow'/>
```
5. Make sure the CPU configuration looks correct, the final result should look something like this:
```xml
<cpu mode="host-model" check="partial">
<topology sockets="1" dies="1" clusters="1" cores="8" threads="1"/>
<feature policy="disable" name="hypervisor"/>
</cpu>
```
6. In the same XML file, find the `features` block.
7. Inside the features block, you should add this:
```xml
<kvm>
<hidden state="on"/>
</kvm>
```
Make sure to add it to the bottom of the block.
8. Make sure this section of the config is correct, the final result might look something like this:
```xml
<features>
<acpi/>
<apic/>
<hyperv mode="custom">
<relaxed state="on"/>
<vapic state="on"/>
<spinlocks state="on" retries="8191"/>
</hyperv>
<kvm>
<hidden state="on"/>
</kvm>
<vmport state="off"/>
</features>
```
### 3: OPTIONAL: More configuration
If you are still having issues after making these changes, there are some other things you can try.
First, make sure you did a full shutdown of the VM after making these changes. If you did that and still have issues, continue reading.
#### Disk space
Too little disk space is a common issue, especially with windows VMs. Make sure you gave the VM enough storage to operate, and that your machine actually has that storage available. In my experience it's fine to use up some of that storage elsewhere on your machine after creating the VM, as long as the VM doesn't need it.
#### VirtIO drivers.
If you have any of your hardware devices configured as VirtIO, make sure you installed the drivers. If you are able to, it might be worth installing the drivers anyway.
#### Disk config
Under `SATA Disk 1`, you can open the "*Advanced options*" and set "*Disk bus*" to `VirtIO`. Note that this requires VirtIO drivers to be installed on the VM.
If you have performance issues, you can also try changing the cache mode to "*writeback*". Note that this makes your VM more prone to write errors.
#### NIC config
If you are having issues that you think might be caused by the virtual network card, you can try changing the "*Device model*".
The default is `e1000e`, which is what I'm using without issues. However if you have the VirtIO drivers installed, you can give that a shot.
If you know what you're doing you can also try changing the "*Network source*".
#### Add a "channel"
Add new hardware of type "*Channel*" with name "*org.qemu.guest_agent.0*". Leave the other settings as default
#### Fun fact
That's all, it should be working just fine now.
Also, there is quite a big chance that you will get better performance with this VM on linux than you would on windows!
This is thanks to KVM/QEMU/VirtIO allowing VMs to execute code almost directly on the physical hardware (if configured to do so).
"When used as a virtualizer, QEMU achieves near native performances by executing the guest code directly on the host CPU. " - archwiki

BIN
VirtualMachines/image-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

BIN
VirtualMachines/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB