systemd services Status

Example of systemctl status

I’ve just learned by accident that it’s possible to run systemctl status without specifying a name of systemd service – this way you get the listing and status of all the services available in a neat tree structure.

SystemD services

As you may remember, startup services are no longer managed by /etc/init.d scripts in Linux. Instead systemd services are created – this is handy for both managing services and confirming their status (journalctl is great for showing latest status messages like error log).

Show systemd Services Status with systemctl

Run without any parameters, systemctl status command will show you a tree structure like this:

greys@sd-147674:~$ systemctl status
 ● sd-147674
     State: running
      Jobs: 0 queued
    Failed: 0 units
     Since: Sat 2019-11-23 08:45:20 CET; 1 months 20 days ago
    CGroup: /
            │ └─user-1000.slice
            │   ├─user@1000.service
            │   │ └─init.scope
            │   │   ├─19250 /lib/systemd/systemd --user
            │   │   └─19251 (sd-pam)
            │   └─session-1309.scope
            │     ├─19247 sshd: greys [priv]
            │     ├─19264 sshd: greys@pts/0
            │     ├─19265 -bash
            │     ├─19278 systemctl status
            │     └─19279 pager
            │ └─1 /sbin/init
              │ └─361 /lib/systemd/systemd-udevd
              │ └─541 /usr/sbin/cron -f
              │ └─587 /usr/sbin/named -u bind
              │ └─345 /lib/systemd/systemd-journald
              │ └─484 /sbin/mdadm --monitor --scan
              │ └─599 /usr/sbin/sshd -D
              │ ├─634 /usr/sbin/ntpd -f /etc/openntpd/ntpd.conf
              │ ├─635 ntpd: ntp engine
              │ └─637 ntpd: dns engine
              │ └─542 /usr/sbin/rsyslogd -n -iNONE

In this output, you can see systemd service names like cron.server or ssh.service and then under them is the process name and numerical process ID that indicate the how each service is provided.

INTERESTING: Note how openNTPd.service is provided by 3 separate processes: ntpd and two other ntpd processes (NTP engine and DNS engine).

See Also

neofetch in Debian Linux

neofetch on a physical server with Debian Linux

When it comes to reporting basic OS information in one terminal screen for easy screenshot, I’ve been using screenFetch most of the time. Turns out, it’s not the only software of this kind – and neofetch is a great alternative.

neofetch or screenFetch?

Notice how I didn’t say netofetch VS screenFetch!

Because mostly the choice between neofetch and screenFetch is a personal preference: both tools are quite capable and available on majority of popular operating systems.

Reasons to use neofetch

Compared to screenFetch, neofetch has a few really cool features:

  • Server hardware model reported
  • On desktop systems, the following is reported
    • Windows manager and sometimes even desktop theme
    • Screen resolution
  • Better reporting of IP addresses
  • Lots of configuration options

See Also

Ubuntu – Static IP

I’m finishing up the VM based Ubuntu 19.10 setup and decided to make a few screenshots to test new workflow. Instead of random topic, I documented the task of configuring Ubuntu to use static IP address.

Why use Static IP?

Desktops don’t benefit from this much, but servers benefit from having static (fixed) IP addresses because you configure DNS once and then use server hostname and same fixed IP address for using any services.

Even if all you need is connect to server via SSH, static IP address will make things much easier – plus it usually comes as default for most dedicated hosting plans.

In my home lab I prefer to configure most virtual machines with static IP addresses because this allows me to easily access them remotely (working from one of the laptops).

Things to Know Before Configuring Static IP

Assuming you’re going to assisg a static IP from your local network (LAN), you need to have the following information confirmed:

  • what’s the local network addressing in use? It most likely starts with 192.168 or 10.0, but you need to know for sure. You need the full network – so something like 192.168.0.x or 192.168.1.x
  • static IP address you plan to use (from the same network)
    • make sure this IP is available – currently not in use (and at least does not answer to ping)
  • default route (sometimes called gateway) address – this is usually the IP address of your broadband modem. In my case it’s
  • DNS server IP address – usually the same as your gateway IP
    • you can also easily use external DNS server like (CloudFlare) or (Google)

Configure Ubuntu 19.10 for Static IP

Here are the screenshots walking you through the static IP configuration:

Go to app listing:

… choose Settings:

and select Network:

Inspect current settings (they would be automatic IP address and DNS details via DHCP):

…and now go to IPv4 settings:

Now, select Manual option for IPv4 method:

…and provide new values:

Now click Apply (top right) and in the next screen turn the Wired network off:

Now turn it back on and you can review the result:

That’s it – it’s a rather simple procedure but I still find it more comfortable (and easier to manage) when I update configuration directly or via Ansible.

See Also

more or less

Unix Tutorial

I’m working hard to finish off the Basic Unix Commands section of this website – want to have every command there documented before I start recording videos about them. more and less are the most recent additions.

Both more and less are basic commands for viewing text files. Quite often they’re used together with cat command (you cat a file and pipe it into more or less), but that’s actually not necessary – you can get the same result by just using more or less on their own.

more command

more command helps you browse text files in Unix and Linux. Instead of throwing complete contents of the possibly large text file into terminal window, more shows you paginated content – fills up the screen and then waits for a key press to show the next screen’s worth of content.

more command showing /etc/lsb-release file

less command

less command continues traditions of a simple text file viewer of the more command (in many ways, less IS more) but does it with a number of key optimisations.

less command showing /etc/lsb-release file

more or less?

more is a much simpler command and will work on a relatively broken system – no complicated terminal emulation, no possibly broken Up/Down key sequences, etc. more will simply keep showing text output into your terminal session without any built-in scroll-back functionality.

less is more flexible but also expects terminal emulation to be operational for arrow-keys navigation to work. The advantage is you have a fully functional scroll-back.

more is great for small files, but it needs to read the complete text file before showing its paginated contents. So for large (hundreds of megabyes) files, less will be much faster as it only reads the part necessary to show on the screen (and reads more as you keep scrolling).

See Also

Sort Files by Size with ls

Sorting ls output by file size

I love reading man pages for even the most basic Unix commands like ls, because there’s always something interesting to learn. Today I discovered that it’s possible to sort ls output by file size.

Sort ls by file size

Simply add the capital S to command line options and you’ll see your output sorted by file size. Be sure to use long output form (-l option). I’m adding more command to the mix because I know that /usr/lib is a directory with quite a number of files:

greys@srv:/usr/bin $ ls -lS /usr/lib | more
total 492
-rwxr-xr-x  1 root 74688 Feb  1  2019
-rw-r--r--  1 root 56480 Jan 14  2018
-rw-r--r--  1 root 22448 Aug 29  2016 libsupp.a
drwxr-xr-x 27 root 20480 Nov 24 01:00 python2.7
drwxr-xr-x 24 root 20480 Nov 26 22:12 x86_64-linux-gnu
-rw-r--r--  1 root 18336 Feb 26  2019
drwxr-xr-x  3 root 12288 Sep 14 18:43 git-core
drwxr-xr-x 30 root 12288 Sep 14 18:44 python3.7
drwxr-xr-x 15 root 12288 Nov 26 22:12 systemd
drwxr-xr-x  2 root  4096 Aug 30 10:03 apparmor
drwxr-xr-x  5 root  4096 Aug 30 10:02 apt
drwxr-xr-x  2 root  4096 Aug 30 10:05 bfd-plugins

Reverse Sorting with ls command

Don’t know about you, but I prefer reverse sorting in most commands – this means largest objects are shown at the end of the output. The reason I do it this way is to avoid using pagers like more or less. Another reason is I can scroll up to explore further output of the ls command without having to rerun anything.

So here’s the same command run with the -r option for reverse output (I’m only showing last few lines):

drwxr-xr-x  2 root  4096 Aug 30 10:04 discover
drwxr-xr-x  2 root  4096 Aug 30 10:04 dbus-1.0
drwxr-xr-x  2 root  4096 Nov  3 20:02 console-setup
drwxr-xr-x  2 root  4096 Aug 30 10:05 compat-ld
drwxr-xr-x  2 root  4096 Nov 10 06:04 chrony
drwxr-xr-x  2 root  4096 May 24  2019 binfmt.d
drwxr-xr-x  2 root  4096 Aug 30 10:05 bfd-plugins
drwxr-xr-x  5 root  4096 Aug 30 10:02 apt
drwxr-xr-x  2 root  4096 Aug 30 10:03 apparmor
drwxr-xr-x 15 root 12288 Nov 26 22:12 systemd
drwxr-xr-x 30 root 12288 Sep 14 18:44 python3.7
drwxr-xr-x  3 root 12288 Sep 14 18:43 git-core
-rw-r--r--  1 root 18336 Feb 26  2019
drwxr-xr-x 24 root 20480 Nov 26 22:12 x86_64-linux-gnu
drwxr-xr-x 27 root 20480 Nov 24 01:00 python2.7
-rw-r--r--  1 root 22448 Aug 29  2016 libsupp.a
-rw-r--r--  1 root 56480 Jan 14  2018
-rwxr-xr-x  1 root 74688 Feb  1  2019
greys@srv:~ $

That’s it for today – hope you’ve learned something new today.

See Also

Upgrading RHEL 8 to RHEL 8.1

Red Hat Enterprise Linux 8

Needed to reboot my Red Hat Enterprise Linux 8 desktop anyway, so decided to upgrade it to RHEL 8.1.

Check That Your Software Subscription is Active

For example, I realised that I have still been using the RHEL 8 beta subscription instead of the Developers License. After completing Red Hat subscription registration, I got the following:

greys@redhat:~ $ sudo subscription-manager list
Installed Product Status
Product Name: Red Hat Enterprise Linux for x86_64
Product ID: 479
Version: 8.1
Arch: x86_64
Status: Subscribed
Status Details:
Starts: 14/11/19
Ends: 13/11/20

Upgrade Red Hat OS with yum-update

yum tools are more integrated that many people though! So I’m still using yum update instead of dnf:

root@redhat:~ # yum update
 Updating Subscription Management repositories.
 Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                              2.6 kB/s | 4.5 kB     00:01
 Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                              3.0 MB/s |  13 MB     00:04
 Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                 2.4 kB/s | 4.1 kB     00:01
 Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                 2.4 MB/s |  12 MB     00:04
 Last metadata expiration check: 0:00:01 ago on Thu 14 Nov 2019 21:28:59 GMT.
 Dependencies resolved.
  Package                                        Arch      Version                                           Repository                           Size
  yum-utils                                      noarch    4.0.8-3.el8                                       rhel-8-for-x86_64-baseos-rpms        64 k
      replacing  dnf-utils.noarch
  kernel-debug-devel                             x86_64    4.18.0-147.0.3.el8_1                              rhel-8-for-x86_64-baseos-rpms        14 M
  kernel-devel                                   x86_64    4.18.0-147.0.3.el8_1                              rhel-8-for-x86_64-baseos-rpms        13 M
  kernel-core                                    x86_64    4.18.0-147.0.3.el8_1                              rhel-8-for-x86_64-baseos-rpms        25 M
  kernel                                         x86_64    4.18.0-147.0.3.el8_1                              rhel-8-for-x86_64-baseos-rpms       1.5 M
  kernel-modules                                 x86_64    4.18.0-147.0.3.el8_1                              rhel-8-for-x86_64-baseos-rpms        22 M
  netcf-libs                                     x86_64    0.2.8-12.module+el8.1.0+4066+0f1aadab             rhel-8-for-x86_64-appstream-rpms     77 k
  libXt                                          x86_64    1.1.5-12.el8                                      rhel-8-for-x86_64-appstream-rpms    185 k
  alsa-utils                                     x86_64    1.1.9-1.el8                                       rhel-8-for-x86_64-appstream-rpms    1.1 M
  podman-manpages                                noarch    1.4.2-5.module+el8.1.0+4240+893c1ab8              rhel-8-for-x86_64-appstream-rpms    180 k
  python3-pip-wheel                              noarch    9.0.3-15.el8                                      rhel-8-for-x86_64-baseos-rpms       1.2 M
  mozjs60                                        x86_64    60.9.0-3.el8                                      rhel-8-for-x86_64-baseos-rpms       6.7 M
  libssh-config                                  noarch    0.9.0-4.el8                                       rhel-8-for-x86_64-baseos-rpms        18 k
  python3-setuptools-wheel                       noarch    39.2.0-5.el8                                      rhel-8-for-x86_64-baseos-rpms       289 k
 Installing weak dependencies:
  oddjob-mkhomedir                               x86_64    0.34.4-7.el8                                      rhel-8-for-x86_64-appstream-rpms     52 k
  libvarlink                                     x86_64    18-3.el8                                          rhel-8-for-x86_64-baseos-rpms        44 k
 Transaction Summary
 Install   17 Packages
 Upgrade  646 Packages
 Total download size: 1.2 G
 Is this ok [y/N]:

Some 15min later I had my desktop in a much better shape:

   yum-utils-4.0.8-3.el8.noarch                                            kernel-debug-devel-4.18.0-147.0.3.el8_1.x86_64
   kernel-devel-4.18.0-147.0.3.el8_1.x86_64                                kernel-core-4.18.0-147.0.3.el8_1.x86_64
   kernel-4.18.0-147.0.3.el8_1.x86_64                                      kernel-modules-4.18.0-147.0.3.el8_1.x86_64
   oddjob-mkhomedir-0.34.4-7.el8.x86_64                                    libvarlink-18-3.el8.x86_64
   python3-argcomplete-1.9.3-6.el8.noarch                                  oddjob-0.34.4-7.el8.x86_64
   tbb-2018.2-9.el8.x86_64                                                 gnome-shell-extension-horizontal-workspaces-3.32.1-10.el8.noarch
   podman-manpages-1.4.2-5.module+el8.1.0+4240+893c1ab8.noarch             python3-pip-wheel-9.0.3-15.el8.noarch
   mozjs60-60.9.0-3.el8.x86_64                                             libssh-config-0.9.0-4.el8.noarch
 root@redhat:~ #

And that’s it! I rebooted the server and my OS is RHEL 8.1 now:

greys@redhat:~ $ more /etc/redhat-release
Red Hat Enterprise Linux release 8.1 (Ootpa)
greys@redhat:~ $ uname -a
Linux redhat 4.18.0-147.0.3.el8_1.x86_64 #1 SMP Mon Nov 11 12:58:36 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

See Also

Red Hat Enterprise Linux 8.1


Just as I published last Unix Tutorial Digest on November 5th, RHEL 8.1 release got shipped – think this is a great incremental release bringing a number of key improvements to the Red Hat Enterprise Linux 8.

RHEL 8 Release Cadence

Red Hat announced that going forward Red Hat Enterprise Linux OS will be receiving regular updates every 6 months. Since RHEL 8 release was in May 2019, this current RHEL 8.1 update is right on time, 6 months after.

RHEL 8.1 Improvements I Want To Try

There’s a number of great improvements in this release:

  • Live Kernel Patching with kpatch
  • SELinux profiles for containers and tbolt for Thunderbolt devices – will be cool to try on my RHEL 8 PC
  • Perhaps try RHEL 7.6 in-place upgrade to RHEL 8.1
  • Review rhel-system-roles and specifically the new storage role added in RHEL 8.1
  • LUKS2 online re-encryption
  • RHEL 8 Web Console
    • firewall zones management
    • Virtual Machines configuration

I also want to try Red Hat Universal Base Image for RHEL 8 – it’s been around since initial release in May, I just never got the chance to have a look.

See Also

Ubuntu 19.10

Ubuntu 19.10
Ubuntu 19.10 Desktop Wallpaper

Ubuntu 19.10 was released on October 17th, which means it’s time to upgrade Ubuntu on my Dell XPS laptop. Please note this is NOT a long-term support (LTS) release, so 19.10 will only be supported until July 2020.

Ubuntu 19.10 – Eoan Ermine

Seems like a pretty solid upgrade:

  • WPA3 support for improved wireless security – need to check if I can upgrade my Ubiquiti equipment to support it
  • Linux Kernel upgraded to 5.3 – this is where I expect majority of improvements for my laptop
  • Dark Theme – in a very short space of just a few months I’m now using dark themes on my iPhone, desktop and laptop, plus in as many apps as support it properly
  • Ubuntu 19.10 is available for Raspberry Pi 4
  • lots of visual improvements in each of the Ubuntu editions – Xubuntu, Kubuntu, Ubuntu MATE

Download Ubuntu 19.10

As always, the best place to start with Ubuntu download is

Upgrading to Ubuntu 19.10

I did the usual sequence to get my laptop upgraded. Except the last step which needed the -d option to recognise that Ubuntu 19.10 is available. All of these commands were run through sudo.

  • apt update
  • apt upgrade
  • apt dist-upgrade
  • do-release-upgrade -d

Do you use Ubuntu? When are you planning to upgrade?

See Also

ZFS on root in Ubuntu 19.10

Ubuntu 19.10

Just read about ZFS making it into Ubuntu 19.10 installer as an experimental feature here, sounds pretty cool!

What is ZFS?

ZFS (originally called Zettabyte File System) is a revolutionary filesystem introduced by Sun Microsystems in 2005. ZFS took a few years to crystallise and was eventually shipped with Solaris 10 in 2009. It brought a number of fresh ideas to the world of enterprise storage and ZFS management of filesystems:

  • new parity checking modes, even more reliable than RAID5/RAID6
  • storage pool that can consist of different sized disks (typically you expect all disks to be of the same size and model)
  • self-healing
  • extra focus on the data consistency on disk – meaning ZFS caters for typical software and hardware errors
  • smart implementation and use of filesystem journaling
  • snapshots
  • data deduplication

ZFS in Ubuntu 19.10

To be clear, this is big deal not because ZFS is finally available in Ubuntu – it’s been around for quite some time thanks to the ZFS on Linux project. But this is the first time native support will be available in Ubuntu installer and also allow you to not just ZFS enable data disks but use it for root partition.

See Also

preserve-root flag for rm command

rm will warn you instead of removing everything in / recursively

rm command, the one used to delete files and directories, can be very dangerous if used with root privileges. It’s comforting to know that most modern rm implementations attempt to help you avoid a complete disaster (of deleting everything on your OS disk).

What preserve-root Flag Does

Default behaviour of rm command in Linux for quite some time, preserve-root flag means that if you attempt to recursively remove the root (/) directory you would get a warning:

greys@stream:/ $ rm -rf /
rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe

Why would this be dangerous? Because every directory and filesystem in Unix and Linux is mounted off root (/) path. So if you remove files/directories there recursively, you may wipe out your entire operating system (and quite a bit of mounted filesystems, if your’e really out of luck).

Now, I’m running this command as my own regular user in the example above. So even if rm wasn’t protecting me, I would still be unable to do any real harm to the OS due to core OS files being protected from accidental removal by regular users. But if I was running as root, it would have been really dangerous.

Why preserve-root is Really Useful

Of course, most of us would never consciously attempt removing everything under /, but here’s a very typical scenario that is quite common with beginners: using unitialised variables (empty values).

greys@stream:/ $ MYDIR=mydir
greys@stream:/ $ echo rm -rf /${MYDIR}
rm -rf /mydir
greys@stream:/ $ rm -rf /${MYDIR}

In this example above, I have a variable called MYDIR, which points to a directory. I’m runnign echo command first to verify what rm command will look like – and it seems correct, so I attempt it.

But if I forget to initialise the MYDIR variable, its value will be empty, meaning my command will become much more dangerous:

greys@stream:/ $ MYDIR=
greys@stream:/ $ echo rm -rf /${MYDIR}
rm -rf /
greys@stream:/ $ rm -rf /${MYDIR}
rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe

See Also