Skip to content

Admin Cheat sheet

Tuomas Nurmi edited this page Jul 23, 2024 · 14 revisions

Cheat sheet for system admins

This page gathers some typical situations faced by system admins and commands needed to solve them.

Basic information about device and image

Find out image version or release name

$ less /etc/puavo-image/name
$ less /etc/puavo-image/release

Find out kernel version

$ uname -a

Find out information about available mass storage devices

$ parted -l
$ fdisk -l

Basic service handling on Puavo-os devices

As Puavo-os uses systemd as init the services are mostly managed via systemctl. Systemctl uses the name unit to refer to services, mount points, devices or sockets. To control a unit, a fullname with suffix (.service, .socket etc.) must be given.

Here are some of the basic commands.

Show system status:

$ systemctl status

List running units:

$ systemctl

or

$ systemctl list-units

List available unit files:

$ systemctl list-unit-files

List failed units:

$ systemctl --failed

Start, stop or restart a unit (if the unit is a service, you can omit the .service from the end):

$ systemctl start unit
$ systemctl stop unit
$ systemctl restart unit

For example:

$ systemctl start puavo-wlanap.service 

Examining system log files

Puavo-os is based on Debian Strech and therefore system log files are handled by journalctl. Still the old syslog file is also available.

Using journalctl

View basic logs. The first line of the output says where the logs start from:

$ journalctl

View logs from the current boot.

$ journalctl -b

View logs from the previous boot:

$ journalctl -b -1

You can substitute -1 with -2 to see an even earlier boot. Use journalctl --list-boots to see the archived logs from previous boots (the first column is the index, use that instead of -1). If there are no archived logs, then someone has configured the system to not retain previous logs. This should not happen in PuavoOS.

View log within a certain time window.

$ journalctl --since "08:00:00" --until "09:00:00"
$ journalctl --since "YYYY-MM-DD" --until "YYYY-MM-DD"

To follow logs in realtime:

$ journalctl -f

To see logs from a single unit only (use this with -f to see the log in realtime):

$ journalctl -u <unit name>

Using syslog

Read syslog using the text editor/viewer you prefer.

$ less /var/log/syslog

Follow syslog in realtime.

$ tail -f /var/log/syslog

Laptop maintenace

Updating devices configuration and launch image update.

$ puavo-update-client

Find out if the laptop is using image overlay.

$ cat /proc/cmdline

Change partition sizes in installed system

It is possible e.g. to shrink home and enlarge images partition on-the-fly with the following steps. Please observe that this should be done in installer; doing it with runlevel 5 and logged in user will probably break the system.

resize2fs -fp /dev/mapper/puavo-home 50G
lvreduce -L 50G /dev/mapper/puavo-home
e2fsck -f /dev/mapper/puavo-home
mount /dev/mapper/puavo-home /home/
lvextend -r -L +10G /dev/puavo/images