Systemctl --dry-run Doesn't Work?

I used timeshift before I did this.
I didn’t actually lose it.

man systemctl mentions --dry-run as an option.

When I tried a dry-run of disabling NetworkManager-wait-online.service, I used
sudo systemctl --dry-run disable NetworkManager-wait-online.service

Then checked systemd-analyze blame and it actually was disabled.

Why didn’t the --dry-run option work?
I hope it isn’t because I used sudo.

Here on Xubuntu 22.04, man systemctl says

–dry-run
Just print what would be done. Currently supported by verbs halt, poweroff, reboot, kexec, suspend, hibernate, hybrid-sleep, suspend-then-hibernate, default, rescue, emergency, and exit.

Not seeing disable in that list

3 Likes

Ok, so because disable isn’t in the list of supported verbs, the --dry-run option doesn’t work.

How else can we test disabling service’s?
Timeshift is one way to test service disabling, I’m not sure but I believe using timeshift for testing is somewhat hard on the disk drive.

Do what you did, but don’t use the dry run option. The way to test disabling is… to… disable.

1 Like

Let’s see if I got this part correct.
If one finds later that what was disabled is actually needed, just use ‘enable’ and ‘start or reboot’ to regain it?
Or will I run into needing to re-install something?

There tends to be a certain precision with language in software. Read the Debian Packaging Guide or Freedesktop Specifications and you’ll see what I mean.

My point: disable means just that. It does not mean uninstall, remove, purge, reboot, shutdown, start, or anything else other than disable. So that means to undo it, you enable.

You might want to look into a virtual machine or a container so you have a little playground to test things like this.

1 Like

Is virtual machine actually a seperate partition on the disk drive?
What is a container?

I think it is really important to read the man page for systemctl, including understanding the subtle differences between the commands:
https://www.man7.org/linux/man-pages/man1/systemctl.1.html

For example, disable and mask or start and enable.

I am not able to reference containers as I do not use them.

But, when you use a virtual machine hypervisor such as GNOME Boxes or VirtualBox you are creating a machine that resides within the hypervisor. It does not touch your physical partitions.

I use virtual machines all the time to test new versions, commands or whatever.

One mistake and you can delete the VM and start over.

One mistake on your physical partitions may often result in a complete reinstall depending on the damage.

Others will recommend different virtual machine software and all have their own value depending on your needs.

By the way, if it is not already enabled, you need to enable Virtualization in BIOS in order to use the software and play around with VMs.

Both are similar concepts. Basically you’d be running a separate operating system within your existing operating system.

Kind of like @rubi1200 says below, you can totally mess up the entire operating system within them and you could just delete it and start over without it ever affecting your host system.

I think this is essential for any command line tool you use.

That same wording is also here in Lubuntu.

This is a perfect example of why I feel the manpages aren’t written to help others and were written only as a reference tool for it’s author.
Why not use a more generally understandable descriptive phrase like “The only verbs that will work with this option are”.
Using less generally understood phrases add to the learning curve when phrases more easily understood would make the learning less frustrating.

–dry-run isn’t alway’s interchangable with the more widely used -s.
In systemctl, -s mean’s nothing near a simulated run or dry run.

So yea, read the manpages, hopefully you “just know” what is meant.

“Currently supported by verbs” is the same as “The only verbs that will work with this option are” with one extremely subtle difference: the first one leaves it open to the possibility that other verbs could be supported in the future.

I would think that disable, mask, start, and enable would definitely be in that --dry-run list of verbs automatically.

…but they’re not. Lesson learned: never assume!

I’ve seen many times in both open source and proprietary software where what seem like incredibly obvious things to me are simply not obvious to the developers. That or they haven’t had the resources to dedicate to that particular issue. Or it’s such a low priority concern relative to the bigger picture items. There’s countless reasons.

But if you want it fixed, one good way is to fix it yourself. Patches welcome, as they say! :slight_smile:

ok self…get back on topic.

Do I have to have the software to be able to setup a VM?
Hypervisor…sounds like Hyper-V in Windows 10 and newer.

Yes.

I mentioned two options but there are others.

On my Ubuntu 24.04 install I use GNOME Boxes; simple but effective

On Kubuntu 24.04 I have VirtualBox: more options for finer-grained control

I usually download the ISO to a temp folder and then point the software to that place, add my options for RAM, disk space etc. and then the software starts the ISO as if you were running a live USB.

Once installed, you are using a full version of whatever you try out and you start and stop as you would for a normal install on bare metal.

Never used it but I believe it is the same concept, a means to install and run virtual machines.

1 Like

Alternatively you can use a container with very low effort:

sudo snap install lxd
sudo lxd init --auto
lxc launch ubuntu:24.04 noble
lxc shell noble

You can leave the container with Ctrl-D or by typing “exit”

1 Like

Is there a non-snap version?

Not on Ubuntu (you could probably build it from upstream source though, but the snap version is the one maintained by Canonical and the one used in millions of businesses so it gets the most attention and quality checks)…

This page…

https://documentation.ubuntu.com/lxd/en/latest/installing/#install-lxd-from-source

Has this command…

command -v snap >/dev/null || sudo apt-get install snapd

If I run that command, will it install things like firefox and other default snaps?
I have a decision to make here.
Everywhere I look, I see a debate about snaps.
I need to research snaps for myself and not go on what other people are saying about snaps.

1 Like

If you don’t have a minimal installation of Lubuntu, you already have them.