This is the multi-page printable view of this section. Click here to print.
Linux Topics
- 1: Archlinux Installation
- 2: Archlinux on Hetzner Cloud with Btrfs
- 3: Btrfs
- 4: Disk and Partition Management
- 5: File & Disk Tools
- 6: File Compression
- 7: Linux Commands
- 8: NixOS
- 9: Screen
- 10: SSH
- 11: SSL
- 12: Systemd
- 13: Ubuntu
- 14: ZFS
1 - Archlinux Installation
To-do
Consolidate the old versions:
- https://github.com/PhilipMay/may-la-hugo/blob/8863faed26795c63e7daa97fb97b21b651be2d57/content/en/linux/arch-install.md
- https://wiki.archlinux.de/title/Benutzer:PMay/T430s_Setup
Also add
- GDM keyboard config
- firefox
- Gnome Keyboard config
- Gnome Terminal config
- Bootloader
- DISCARD - SSD
- Microcode
- update my PyCharm package
- good mirror list
Bios Settings
- set the BIOS clock to GMT time zone
- turn all virtualization optiona on
Keyboard Settings
- https://wiki.archlinux.org/title/installation_guide#Set_the_console_keyboard_layout
- German keyboard:
loadkeys de-latin1-nodeadkeys
Connect to W-Lan (TODO)
- see https://wiki.archlinux.org/title/Iwd#Connect_to_a_network
iwctl
station <wlan_device> connect <ssid>
exit
- check with
ping archlinux.org
Disks
- show disk status
lsblk
- delete disk if you have a SSD
- also see: https://wiki.archlinux.de/title/Dm-crypt#Verschl.C3.BCsselung_anlegen
blkdiscard -f /dev/nvme0n1
- also might want to use
--secure
or-z/--zeroout
option - see https://wiki.archlinux.org/title/Solid_state_drive/Memory_cell_clearing#Common_method_with_blkdiscard
- create partitions:
gdisk /dev/nvme0n1
- create 512MB boot / EFI - type: ef00
- rest for root (LUKS) - type: 8309
- show disk status again:
lsblk
Create LUKS
cryptsetup luksFormat /dev/nvme0n1p2
cryptsetup open /dev/nvme0n1p2 cryptroot
use lsblk
to check if cryptroot
is created
Create and mount Filesystems
see also: https://wiki.archlinux.org/index.php/EFI_system_partition#Format_the_partition
mkfs.ext4 /dev/mapper/cryptroot
mount /dev/mapper/cryptroot /mnt
mkfs.fat -F 32 /dev/nvme0n1p1
mkdir /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot
Create Swap File (did not do this)
see also: https://wiki.archlinux.org/index.php/Swap#Swap_file_creation
- TODO: Link zu Ubuntu Seite
dd if=/dev/zero of=/swapfile bs=1M count=20480 status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
To resume from swap see: https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file
Select Mirrors
nano /etc/pacman.d/mirrorlist
Install Packages
pacstrap /mnt base linux linux-firmware
pacstrap /mnt nano gnome cryptsetup networkmanager
pacstrap /mnt efibootmgr dosfstools gptfdisk
# gen and check fstab
genfstab -U /mnt >> /mnt/etc/fstab
less /mnt/etc/fstab
#Chroot
arch-chroot /mnt
#Time zone
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
nano /etc/locale.gen
- remove comment for de_DE UTF-8
- remove comment for en_US UTF-8
locale-gen
nano /etc/locale.conf
# see: http://www.gentoo.org/doc/en/guide-localization.xml#doc_chap3
LANG="en_US.UTF-8"
LC_TIME="de_DE.UTF-8"
nano /etc/vconsole.conf
KEYMAP=de-latin1-nodeadkeys
nano /etc/hostname
- enter hostname
nano /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname
nano /etc/mkinitcpio.conf
HOOKS=(base udev autodetect modconf block keyboard keymap encrypt filesystems fsck)
- see https://wiki.archlinux.org/title/Dm-crypt/System_configuration#mkinitcpio
- added after "block" -> "keyboard keymap encrypt"
- no `consolefont`
mkinitcpio -P
passwd
# install systemd-boot
bootctl install
systemd-boot does not accept tabs for indentation, use spaces instead.
nano /boot/loader/entries/arch.conf
title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options cryptdevice=UUID=701fea32-236d-49fd-a0f9-cb9f07c94703:cryptroot root=/dev/mapper/cryptroot rw
use cat to add UUID to file:
use the UUID of the base encryped partition ! NOT cryptroot
blkid >> /boot/loader/entries/arch-uefi.conf
- see https://wiki.archlinux.org/title/Systemd-boot#Adding_loaders
- see https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Configuring_the_boot_loader
nano /boot/loader/entries/arch-uefi-fallback.conf
nano /boot/loader/loader.conf
#timeout 3 #console-mode keep default arch.conf console-mode max editor no timeout 1
bootctl update
exit
cd /
umount -R /mnt
reboot
# create user
useradd <username> -m -s /bin/bash
passwd <username>
#gnome aktivieren
systemctl enable gdm.service
systemctl enable NetworkManager
reboot
# check heyboard layout at login!
# Gnome Settigs
- Keyboard
- add German
- remove en
- Mouse & Touchpad
- Natural scolling aus
- Tap to Click an
- check "Region & Language"
- alle settings prüfen und synchronisieren
- both tabs -> Language: English, Formats: all Deutschland
- Power
- Automatic Suspend - on battery power und Plugged in aus
- show percent
- als root ausführen: `localectl set-x11-keymap de`
# microcode
# https://wiki.archlinux.org/index.php/Microcode
pacman -S amd-ucode
# add in boot config
initrd /cpu_manufacturer-ucode.img
# fstrim
systemctl enable fstrim.timer
# swappiness
# https://wiki.archlinux.org/index.php/Swap#Swappiness
nano /etc/sysctl.d/99-swappiness.conf
vm.swappiness=10
# sudo
pacman -S sudo
EDITOR=nano visudo
%wheel ALL=(ALL) ALL
gpasswd -a <username> wheel
nano /etc/mkinitcpio.conf
MODULES=(amdgpu)
mkinitcpio -P
# enable aur
pacman -S --needed base-devel
nano /etc/makepkg.conf
Lenovo ThinkPad T495x specific
Mask this to avoid Boot Error
also see: https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_T495s#Backlight
systemctl mask systemd-backlight@backlight:acpi_video0.service
2 - Archlinux on Hetzner Cloud with Btrfs
Links
- https://wiki.archlinux.org/title/Installation_guide
- https://community.hetzner.com/tutorials/how-to-install-archlinux-on-a-hetzner-cloud-server
- https://wiki.archlinux.org/title/GRUB
- https://wiki.archlinux.org/title/Systemd-networkd
# boot rescue system
# ssh into rescue system
# download current bootstrap image from https://mirror.chaoticum.net/arch/iso/latest/
wget https://mirror.chaoticum.net/arch/iso/latest/archlinux-bootstrap-<date>-x86_64.tar.gz
wget https://mirror.chaoticum.net/arch/iso/latest/archlinux-bootstrap-<date>-x86_64.tar.gz.sig
# check PGP fingerprint: 0x54449A5C
# check signature
gpg --keyserver keyserver.ubuntu.com --keyserver-options auto-key-retrieve --verify archlinux-bootstrap-<date>-x86_64.tar.gz.sig
# --numeric-owner preserve UID and GID of files in case existing Linux system uses different numbers than Arch
# see https://wiki.archlinux.org/title/Install_Arch_Linux_from_existing_Linux#Method_A:_Using_the_bootstrap_tarball_(recommended)
tar xvfz archlinux-bootstrap-2023.01.01-x86_64.tar.gz --numeric-owner
# hack - see https://wiki.archlinux.org/title/Install_Arch_Linux_from_existing_Linux#Downloading_basic_tools
mount --bind root.x86_64 root.x86_64
./root.x86_64/usr/bin/arch-chroot root.x86_64
echo 'Server = https://mirror.chaoticum.net/arch/$repo/os/$arch' > /etc/pacman.d/mirrorlist
pacman-key --init
pacman-key --populate archlinux
# refresh package lists
pacman -Syyu
# install nano
pacman -S nano
# clean disk
blkdiscard -f /dev/sda
# fdisk
fdisk /dev/sda
# Disklabel type: gpt
# Device Start End Sectors Size Type
# /dev/sda1 2048 4095 2048 1M BIOS boot
# /dev/sda2 4096 39999487 39995392 19.1G Linux filesystem
# install Btrfs tools
pacman -S btrfs-progs
# Btrfs filesystem
mkfs.btrfs /dev/sda2
mount -o compress=zstd /dev/sda2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/@var_log
umount /mnt
mount -o compress=zstd,subvol=@ /dev/sda2 /mnt
mkdir /mnt/home
mount -o compress=zstd,subvol=@home /dev/sda2 /mnt/home
mkdir -p /mnt/var/log
mount -o compress=zstd,subvol=@var_log /dev/sda2 /mnt/var/log
# what about
# /var/cache/pacman/pkg or just /var/cache/pacman
# /var/lib/portables
# /var/lib/machines
# more mount options https://wiki.archlinux.org/title/Security#Mount_options
# pacstrap with -M option:
# -M is to "Avoid copying the host’s mirrorlist to the target."
pacstrap -G -M /mnt base grub linux linux-firmware openssh nano btrfs-progs
genfstab -U /mnt >> /mnt/etc/fstab
nano /mnt/etc/fstab
# remove all space_cache and subvolid entries
arch-chroot /mnt
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
nano /etc/locale.gen
# uncomment en_US.UTF-8 UTF-8
locale-gen
nano /etc/locale.conf
# add LANG=en_US.UTF-8
nano /etc/vconsole.conf
# add KEYMAP=de-latin1
nano /etc/hostname
# add hostname
# Btrfs
nano /etc/mkinitcpio.conf
add btrfs to MODULES
mkinitcpio -P
# set root password
passwd
# install GRUB
# use /dev/sda not /dev/sda1 or /dev/sda2
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
# systemd-networkd
nano /etc/systemd/network/20-wired.network
# add
[Match]
Type=ether
[Network]
DHCP=yes
# enable network
systemctl enable systemd-networkd
systemctl enable systemd-resolved
# enable sshd
systemctl enable sshd
useradd mike -m -s /bin/bash
passwd mike
# logout & reboot
exit
exit
reboot
Post Install
Pacman
nano /etc/pacman.conf
# uncomment Color, VerbosePkgLists and ParallelDownloads
# init pacman
nano /etc/pacman.d/mirrorlist
pacman-key --init
pacman-key --populate archlinux
# refresh package lists
pacman -Syyu
Install snapper
pacman -S snapper
snapper -c root create-config /
btrfs subvolume delete /.snapshots
mkdir /.snapshots
# edit /etc/fstab and mount /@snapshots to /.snapshots
mount /.snapshots
# reboot and see if all is mounted
# first manual test snapshot
snapper -c root create --description test01
# check if snapshot is stored
ls -ls /.snapshots
# install snap-pac to let pacman automatically use snapper to create pre/post snapshots
# install grub-btrfs to be able to boot from snapshots
pacman -S snap-pac grub-btrfs
# the grub main menu needs to be generated to make a menuentry for the snapshots sub menu
# see https://github.com/Antynea/grub-btrfs#-usage
grub-mkconfig -o /boot/grub/grub.cfg
# enable daemon script that automatically updates the grub menu when it sees a snapshot being created or deleted
# see https://github.com/Antynea/grub-btrfs#systemd-instructions
systemctl enable --now grub-btrfsd
Other
# enable periodic TRIM
# see https://wiki.archlinux.org/title/Solid_state_drive#Periodic_TRIM
systemctl enable --now fstrim.timer
Other Post Install Todo
- secure sshd
- check if TRIM and ssd options are correct
- setup sudo and secure root
- apply general recommendations: https://wiki.archlinux.org/title/General_recommendations
- apply security: https://wiki.archlinux.org/title/Security
- check “system maintenance”: https://wiki.archlinux.org/title/System_maintenance
- no
fsck
in hooks (mkinitcpio)?
3 - Btrfs
Links
- Wiki: https://btrfs.wiki.kernel.org/index.php/Main_Page
- Read the Docs: https://btrfs.readthedocs.io/
- Btrfs @ Arch Linux: https://wiki.archlinux.org/title/btrfs
- Videos and Talks
- Linuxcon Japan 2014 - Btrfs Talk
- Btrfs is awesome except when it isn’t (2019) - many good disaster recovery hints: https://www.youtube.com/watch?v=qHalOdCZO9Q
- btrfs: The Best Filesystem You’ve Never Heard Of (2017): https://www.youtube.com/watch?v=-m01x3gHNjg
- TUT91782 Getting the most out of the btrfs filesystem (2017) - tech internals: https://www.youtube.com/watch?v=iwNg_fusT9A
Tasks
- check free space:
btrfs filesystem usage <path>
- allocation of block group types:
btrfs filesystem df <path>
(supports--format json
) - device stats (io errors):
btrfs device stats <path>
(supports--format json
) - show subvolumes:
btrfs sub list <path>
Check redundancy (after a replaced disk)
- use
btrfs filesystem usage -T <path>
to check if all data, metadata and system is not “single” stored - fix this with
btrfs balance start -dconvert=raid1,soft -mconvert=raid1,soft /mnt/btrfs
- see https://wiki.tnonline.net/w/Btrfs/Replacing_a_disk
Commands
balance
- see https://btrfs.readthedocs.io/en/latest/btrfs-balance.html
- filters
soft
: when converting between profiles chunks that already have the target profile are left untouched
replace
- see https://btrfs.readthedocs.io/en/latest/btrfs-replace.html
start
subcommand with-r
: only read from srcdev if no other zero-defect mirror exists. (enable this if your drive has lots of read errors, the access would be very slow)
Other Commands
# create raid1
mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sdb1
# mount
mkdir /mnt/btrfs
mount -o compress=zstd /dev/sda1 /mnt/btrfs
# scrub
btrfs scrub start /mnt/btrfs
btrfs scrub status /mnt/btrfs
# show filesystem
btrfs filesystem show
# pull one drive and scrub + show
# replace disk 1
btrfs replace start 1 /dev/sdc1 /mnt/btrfs -f
btrfs replace status /mnt/btrfs
# device stats
btrfs device stats /mnt/btrfs
4 - Disk and Partition Management
Useful Commands
- get disk UUID (for fstab):
blkid
- filesystem check:
e2fsck -vf /dev/<disk>
- delete all filesystems on disk:
wipefs -a /dev/<disk>
- delete all GPT and MBR data structures:
sgdisk --zap-all /dev/<disk>
Mount
- mount disk or patition:
mount /dev/<disk> /mnt
- mount everything defined in
/etc/fstab
:mount -a
Backup with dd
- https://wiki.archlinux.org/title/Dd
- backup a disk (or snapshot) to a file:
dd if=/dev/<disk> bs=64K status=progress | gzip -c > <backup_name>.img.gz
- backup a disk (or snapshot) to a file (with parallel gzip):
dd if=/dev/<disk> bs=64K status=progress | pigz -c > <backup_name>.img.gz
- restore a backup to disk:
gunzip -c <backup_name>.img.gz | dd of=/dev/<disk>
LVM
- see https://wiki.archlinux.org/title/LVM
- see https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#LVM_on_LUKS
Creation Commands
- create the pv and the vg in a primary partition and not a bare disk
- create physical volume:
pvcreate /dev/<partition>
- create volume group:
vgcreate <volume_group_name> /dev/<partition>
(same<partition>
as for the physical volume) - create logical volume with fixed size:
lvcreate -L <size>G <volume_group_name> -n <logical_volume_name>
- create logical volume with percentage of free size (100 for remaining size):
lvcreate -l <size_in_percent>%FREE <volume_group_name> -n <logical_volume_name>
- format with ext4:
mkfs.ext4 /dev/<volume_group_name>/<logical_volume_name>
List Commands
- list physical volumes:
pvs
- list volume groups:
vgs
- list logical volumes:
lvs
- details about volume groups (including allocated and remaining space):
vgdisplay
- details about logical volumes:
lvdisplay
Snapshots
- https://wiki.archlinux.org/title/LVM#Snapshots
- create snapshot:
lvcreate --size <size>G --snapshot --name <snapshot_name> /dev/<volume_group_name>/<logical_volume_name>
- revert to state of snapshot:
lvconvert --merge /dev/<volume_group_name>/<logical_volume_name>
- delete snapshot:
lvremove /dev/<volume_group_name>/<snapshot_name>
Recover from Image of Snapshot
- create snapshot of disk to recover
- that snapshot must be a bit larget than the disk
- if it is smaller or same size this might happen at merge time:
Unable to merge invalidated snapshot LV vg1/restore_test
- “[…] a small amount of the space you allocate to the snapshot is used to track the locations of the chunks of data, so you should allocate slightly more space than you actually need […]” - see https://linux.die.net/man/8/lvcreate
- use
dd
to copy image to snapshot - merge snapshot
Enlarge a Logical Volume
- https://wiki.archlinux.org/title/LVM#Resize_physical_volume
- https://wiki.archlinux.org/title/Resizing_LVM-on-LUKS
- add size and resize filesystem in one command:
lvresize -L +<additional_size>G --resizefs <volume_group_name>/<logical_volume_name>
- set new size and resize filesystem in one command:
lvresize -L <additional_size>G --resizefs <volume_group_name>/<logical_volume_name>
- change size in two steps:
- add size logical volume:
lvresize -L +<size>G <volume_group_name>/<logical_volume_name>
- set new size of logical volume:
lvresize -L <size>G <volume_group_name>/<logical_volume_name>
- resize filesystem:
resize2fs /dev/<volume_group_name>/<logical_volume_name>
- add size logical volume:
Other Disk Tools / Commands
- see disk activity
- Debian:
apt-get install iotop
- command:
iotop -o -P -d 2
- Debian:
- remove Kubernetes filesystems from
df
:df -x overlay -x tmpfs -h
5 - File & Disk Tools
Remove Things
- remove all comments from file:
sed -e '/^#/d' <input_file> > <output_file>
- remove all blank lines from file:
awk '!/^$/' <input_file> > <output_file>
Split a File
This will not split single lines:
split --line-bytes=<size> <file_to_split>
The size argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,… (powers of 1000).
Un-Split a File
cat <file_to_split>-part-* > <file_to_split>
Remove Duplicates
sort <file> | uniq -u > <new_file>
Delete Disk
shred -vn 1 /dev/<device>
Checksums
- calculate checksum:
sha512sum <file>
- store checksums for multiple files:
sha512sum * > sha512sum.txt
- check checksums for multiple files:
sha512sum -c sha512sum.txt
6 - File Compression
tgz
- compress
- standard:
tar cvfz <target_file>.tgz <source_files_or_dir>
- fast:
tar -I pigz -cvf <target_file>.tgz <source_files_or_dir>
- fast with best compression:
tar -I "pigz --best" -cvf <target_file>.tgz <source_files_or_dir>
- standard:
- view files in archive:
tar -tf <filename>.tgz
- test archive
- standard:
gunzip -t <filename>.tgz
- fast:
pigz -t <filename>.tgz
- standard:
zip
- test a zip archive:
unzip -t <filename>.zip
bz2
- unpack:
bzip2 -dk <filename>.bz2
gzip
- test
.gz
files:gzip -v -t <file>.gz
7 - Linux Commands
User Management
- create a user and set password
useradd <username> -m -s /bin/bash
passwd <username>
- add user to group:
gpasswd -a <username> <group>
- change to other user:
su - <user_name>
- delete a user with home dir and mail spool:
userdel -r <username>
- also see: https://wiki.archlinux.org/index.php/users_and_groups#Other_examples_of_user_management
Hardware
- get info about GPU:
lshw -C display
- get infos about CPU:
cat /proc/cpuinfo
- get infos about CPU temperature and fans
- needs package called:
lm-sensors
- the command is
sensors
- also see: https://askubuntu.com/a/15833/478988
- needs package called:
- infos about USB:
lsusb
- details about USB:
lsusb -vvv
Proxy Handling
SSH through a Proxy (to an EC2 instance in this example)
ssh -i <key_file>.pem <user>@<target_host_or_ip> -o "ProxyCommand=nc -X connect -x <proxy_ip>:<proxy_port> %h %p"
SCP through a Proxy (to an EC2 instance in this example)
scp -i ~/.ssh/<key_file>.pem -o "ProxyCommand=nc -X connect -x <proxy_ip>:<proxy_port> %h %p" <file> <user>@<target_host_or_ip>:
Special
- output to terminal and file:
command | tee <filename>
Rotate Terminal
- to the right:
echo 1 | sudo tee /sys/class/graphics/fbcon/rotate_all
- to the left:
echo 3 | sudo tee /sys/class/graphics/fbcon/rotate_all
Administration
- reboot with timer (5 minutes) and message:
shutdown -r +5 "<message>"
Bash Aliases
alias ls='ls --color=auto -h'
alias la='ls -lA'
alias ll='ls -l'
8 - NixOS
Links
- NixOS Manual (stable)
- Nixpkgs Manual
- Nix Reference Manual
- Searches
- Packages: https://search.nixos.org/packages
- Options: https://search.nixos.org/options
- Flakes: https://search.nixos.org/flakes
- Community
Packages
ZFS
9 - Screen
Commands
- open a session with name:
screen -S <session_name>
- list sessions:
screen -ls
- resume detached session:
screen -r <session_name>
Recover a ’lost’ Screen Session
If your remote connection crashed while you had an open screen session you have to detach it before you can reconnect. You do it this way:
Reattach a session and if necessary detach it first.
screen -rd <session_name>
Rename a session
To rename a session do:
- Attach to the session in question
- Press
ctrl
+a
- Type
:sessionname <your_session_name>
– yes, the first colon is needed there, no extra spaces - Type
enter
10 - SSH
Links
Commands
- generate default RSA key:
ssh-keygen
- generate Ed25519 key:
ssh-keygen -t ed25519
- tell ssh to use password and not key auth: add option
-o PreferredAuthentications=password
Config File
Default Config
The default config looks like this
Host <hostname> <ip>
HostName <ip>
User <username>
IdentitiesOnly yes
IdentityFile ~/.ssh/<sec_key_filename>
Using a Jump Server
If you have a jump server <jump_server_hostname> write a normal config for both servers and add this to the config of the target server: ProxyJump <jump_server_hostname>
If you also want to connect through an HTTP proxy add the proxy config lines to the config of the jump server.
Connect through HTTP proxy
For Linux add this:
ProxyCommand nc -X connect -x <proxy_ip>:<proxy_port> %h %p
ForwardAgent yes
For Windows (git bash) add this:
ProxyCommand connect -H <proxy_ip>:<proxy_port> %h %p
ForwardAgent yes
SSH Tunnel
11 - SSL
Create self-signed SSL Certificate
- also see:
# generate private key
openssl genrsa -des3 -out server.pass.key 2048
# or
openssl genrsa -des3 -out server.pass.key 4096
# remove passphrase from Key
openssl rsa -in server.pass.key -out server.key
rm server.pass.key
# generate csr (certificate signing request)
openssl req -new -key server.key -out server.csr
# generate self-signed certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
or
openssl x509 -req -days 36500 -in server.csr -signkey server.key -out server.crt
Create Client Certifcate that can be used by Firefox and other Browsers
openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12
12 - Systemd
Commands and Locations
- custom services are stored here:
/etc/systemd/system
- analyse security of service unit:
systemd-analyze security <service_unit>
- restart a service:
systemctl restart <application_name>.service
- show logs of a service:
journalctl -u <application_name>.service
List Services
- list enabled services:
systemctl list-unit-files --state=enabled
- list running services:
systemctl list-units --type=service
- list failed services:
systemctl --failed
- list timers:
systemctl list-timers
List all since boot
- all boot cycles:
journalctl -k -b all
- current boot :
journalctl -k
- last boot:
journalctl -k -b -1
- two boots prior:
journalctl -k -b -2
- and so on
Journal
- delete old journal files (ony keep last 2 days):
journalctl --vacuum-time=2d
13 - Ubuntu
Package Management
- clean cache:
apt clean
- list installed packages:
apt list --installed
- list manually installed packages:
apt-mark showmanual
- remove package with dependencies:
apt-get <remove/purge> --auto-remove <package_name>
- list installed packages from a specific source:
aptitude search "?origin (<package_source>) ?installed"
Update the System
# fetch list of available updates
apt update
# list packages that can be upgraded
apt list --upgradable
# install some updates - do not remove packages
apt upgrade
# or
# install updates - also remove packages if needed
apt full-upgrade
# remove any old packages no longer needed
apt autoremove
.deb Files
- get info about a .deb file:
dpkg -I <package_name>.deb
- list Content of a .deb File:
dpkg -c <package_name>.deb
Configuration
- Proxy settings for all users in
/etc/environment
- also see https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-configure-proxy-on-ubuntu-18-04/
Commands
- vheck ubuntu version:
lsb_release -a
Install Ubuntu as a VirtualBox Guest
This describes how to install Ubuntu as a VirtualBox guest system to do experiments with docker or other stuff.
Basic installation
- download a server version of Ubuntu
- the current LTS version might be a good idea
- do normal installation
Install XFCE
To be able to copy and paste to and from the guest system you need a desktop environment like XFCE. XFCE is small compared to GNOME and the minimal installation does not contain LibreOffice and other stuff you do not need.
- install tasksel:
sudo apt install tasksel
- execute tasksel:
sudo tasksel
- select
Xubuntu minimal installation
- press tabulatur and select
Ok
with return key - reboot
Install VirtualBox Guest Additions
apt install build-essential dkms
- link the VirtualBox Guest Additions iso image to a cd drive
- cd should be auto mounted to somewhere at
/media
if XFCE or GNOME is installed - change to that directory and execute installation:
sudo ./VBoxLinuxAdditions.run
- also see here: https://askubuntu.com/questions/1035030/virtualbox-guest-additions-installation-problem/1047193#1047193
Install Docker
To install docker do not install the package called docker
. Docker is
a “System tray for KDE3/GNOME2 docklet applications”. The package you
need is called docker.io
- install with:
sudo apt install docker.io
- start with:
sudo systemctl start docker
- stop with:
sudo systemctl stop docker
- enable (always start at boot time) with:
sudo systemctl enable docker
14 - ZFS
Links
Commands
- list drive ids:
ls -l /dev/disk/by-id/
- show status
- list zpools:
zpool list
- shows raw capacity, to see real capacity usezfs list
- see status of zpool:
zpool status
- list zpools:
- mirror handling
- create mirror:
zpool create tank mirror <vdev_1> <vdev_2>
- add mirror:
zpool add tank mirror <vdev_1> <vdev_2>
- remove mirror:
zpool remove tank <mirror-id>
- get mirror-id withzpool status
- create mirror:
- delete pool:
zpool destroy tank
- dataset handling
- create dataset:
zfs create <nameofzpool>/<nameofdataset>
- list datasets:
zfs list
- create dataset: