Comment by pkkm
1 year ago
> I have to look up the very fiddly and unintuitive systemd commands all the time. service start? service.foo start? start foo.service? Oh right, sudo systemctl start service.foo
I don't get this complaint. It's the same order as almost every other command-line utility that has subcommands: <command> <subcommand> <thing to operate on>. To me, that kind of consistency is very intuitive.
systemctl stop my-service
systemctl status my-service
git add my-file
git remote remove upstream
apt install my-package
docker run my-container
adb push local-file remote-file
I feel the same way. The big part for me is that it tells us that owyn doesn't use tab completion if they're forgetting about the ".service" part. Sure, I don't remember either, I don't have to.
I'll add the abstraction for anyone confused
Anything in brackets is optional and might not appear or be available. By command I mean a category of commands. Such as 'pip install' vs 'pip uninstall', which are sub-programs inside the main program. But this can have layers such as 'uv pip install'. Often flags can be used in any order because you'll just loop over all the arguments but this is still the standard order.
There's also the two actor pattern
Also the `.service` part is optional anyway for most commands (including the start, stop, restart etc. ones they use in their examples). Only commands that can operate on services and other non-service units require it.
When it comes to starting and stopping services I want the verb to go last. Way easier to press up, backspace backspace backspace o p to change service ssh start to service ssh top. This is a frequent pattern I follow as I start/stop/restart/reload. Having to go back at least one word adds keystrokes that aren’t necessary.
Do you use your space bar to handle heating ?
What do you mean?
2 replies →
Doing it the way it does allows specifying multiple services.
systemctl status myapp mydb
I would rather do that as two commands than to scroll to see the output of each.
3 replies →
Why not allow for both and accept the option at any location?
Something like:
systemctl --stop myapp mydb
systemctl myapp mydb --stop
2 replies →
I agree, but here's a handy Bashism:
^art^op
Converts the "start" in "foo start bar" to "stop", ie runs "foo stop bar". Append :p to do the substitution but print the command instead of running it.
Learn something new every day. What is the ^ representing in this case?
1 reply →
Press alt+B twice?
Alt + Bikeshed?
(Kidding aside, quick reminder that on Mac you have to enable Settings>Profiles>Keyboard>Use Option as Meta key, or else Alt doesn't work)
It actually should be possible to switch them around. No-ones going to call their service 'stop' or 'service' right?
Someone should create a set of systemd units that show something funny when entered, like how `sl` does for `ls`.
Just use an alias. I don't understand why a problem with such a simple solution should cause such issues.
Because I switch computers (often, for work), and what's muscle memory on one then becomes "command not found" on others without the alias. Many of those computers I don't control and can't say "well, everyone should just run my aliases".
Because I have to share commands with other people who are troubleshooting their own systems, and copy/paste from history becomes useless if I have specific aliases.
Because someday I or someone will want to script these interactions, and aliases are not available in subprocesses.
People are telling you why. You're just choosing to disregard their answers as insufficient. This is not a them-problem. It's a you-problem.
I think the previous post mentions the `service` command, which has `service foo start` pattern.
I'm used to `service` command, so I have muscle memory which `systemd` breaks. The way `systemd` commands are laid out is better, it just messes with `service` command muscle memory.
I disagree that the way systemd is laid out is better.
With initV, issuing many command in sequence to the same service (enable, then start… stop then start… etc) is much quicker and easier as it’s “up-arrow, control-W, type new command. With the systemd option I either need to navigate one word to the left (or more depending on how the shell is configured wrt word separation) before I replace the command, or I need to delete both the command and the service name, and retype more.
It’s not a huge difference but small downgrades in ergonomics add up over time.
A huge typing pain.
A backward step in intuitive CLI usage.
We can be such a fuddy-duddy gray-beards.
3 replies →
Systemd does have 'restart' and 'enable --now' (which starts the service too).
Too bad it doesn't have a '--status 2' flag to show the status after two seconds too.
The systemd layout allows you to send the same command to multiple services, which is much more frequently useful than sending multiple commands to one service.
1 reply →
It's been a decade at this point since the last big distro (and surrounding drama), Debian and Ubuntu following shortly after, moved to systemd.
Many distros still provide the `service` command, and don't print any warnings when you use it. At best, you might get an informational message that the equivalent systemd command is being called. There is no recommendation to call the systemd command directly, or any sign of the `service` command being deprecated any time soon. As a result, a lot of people are probably still relying on their muscle memory for the `service` command.
I on the other hand DO get this complaint. It’s less about the “word order” and more remembering the words to type. As a software engineer I have to google stuff all the time. I haven’t touched C#’s PLINQ in five years, I doubt I could do it from memory. Likewise, I can count on one hand the number of times I will set up a systemd service in a given year.
Many (most?) of us are all over the place, expected to “wear many hats” and aren’t in a single IDE or language all day every day. Certainly if I were a “Linux admin” I would have systemd pretty committed to memory. Anyone else probably wouldn’t.
For me:
* /etc/init.d/my-service stop
and Ubuntu’s:
* service my-service stop
both lurk in my brain.
Sure, it's different from the old way, but I don't think "unintuitive" is the right word for that. systemd forced people to change their habits so that it could be more intuitive. Of course, people are going to disagree about whether it was worth it - it's the age-old question about breaking backwards compatibility for the sake of minor improvement. Personally, I got used to it pretty quickly and I like it more than the old commands now.
The way I remember this is that the old way didn't allow for applying the verb to multiple units. Now you can "restart" multiple units, i.e. `systemctl restart nginx webapp`, etc.
1 reply →
Yeah, I gave up resisting and I’m rolling with it. Ok, fine, this is the way now.
And yet my fingers still want to type it the other way.
Yet, the "ease" of use is a joke. Every try to stop and start a service at different points? At points you choose? Have fun!
Ah well, it's all been said before.
Plus, you could always write a quick shell script to swap the arguments if it detects this specific failure. Inability to remember or learn which commands expect which arguments is, at some point, not the responsibility of the software to fix. Unfortunately, this field does necessitate some amount of memorization and ability to problem-solve.
If I had to guess it's because of the 'service' command, which goes 'service foo start'.
It took me ages to unlearn that pattern for using systemctl, even though as you say: it's far more consistent
It’s because service was the other way around, I’m sure.
systemd services are named "foo.service", and you do not need to specify the ".service" in almost any case.
They're referring to Debian's service(8) command.
(the manpage wasn't updated, but the same command also supports systemd services nowadays)
sudo service my-service start
sudo service my-service stop