by pkkm · 1y ago · 0 comments
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-fileI'll add the abstraction for anyone confused
program [command [subcommand]] [flags] [object]
e.g.s
systemctl status sshd.service
systemctl enable --now sshd.service
touch -c test.sh
echo 'Hello World'
echo "Hello ${USER}"
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
program [command [subcommand]] [flags] source destination
e.g.s
cp /foo/bar/baz.txt "${HOME%/}/"
scp -i "${HOME}/.ssh/foo" ${HOME}/to_upload.sh user@remote:~/
dd if=/dev/urandom of=/dev/diskToDestroy
rsync /mnt/hdd1/ /mnt/hdd2/Also, it looks like you are one of today's lucky 10,000 ! https://xkcd.com/1053/
systemctl status myapp mydb
Something like:
systemctl --stop myapp mydb
systemctl myapp mydb --stop
^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.
[1] https://www.gnu.org/software/bash/manual/html_node/Word-Desi...
[2] https://www.johndcook.com/blog/2022/10/21/shell-replace-word...
(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)
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.
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.
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 backward step in intuitive CLI usage.
We can be such a fuddy-duddy gray-beards.
Too bad it doesn't have a '--status 2' flag to show the status after two seconds too.
Normally when I'm doing things on the terminal, I do one thing at a time.
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.
* /etc/init.d/my-service stop
and Ubuntu’s:
* service my-service stop
both lurk in my brain.
And yet my fingers still want to type it the other way.
Ah well, it's all been said before.
It took me ages to unlearn that pattern for using systemctl, even though as you say: it's far more consistent
NAME
service - run a System V init script
SYNOPSIS
service SCRIPT COMMAND [OPTIONS]
(the manpage wasn't updated, but the same command also supports systemd services nowadays)sudo service my-service stop