Systemctl Command Examples in Linux (itsfoss.com)
from petsoi@discuss.tchncs.de to linux@lemmy.ml on 09 Apr 2024 06:46
https://discuss.tchncs.de/post/13927964

#linux

threaded - newest

somenonewho@feddit.de on 09 Apr 2024 06:58 next collapse

Two additional commands I regularly use as a Sysadmin are

systemctl status without any unit to list show the general system status (lists units that are running, units that are starting and failed units right at the top) And then systemctl list-units --failed To show me just the failed units and did deeper what the problem is.

On a properly set up system I should quickly be able to ascertain if everything is “up and running” just by systemds status

starman@programming.dev on 09 Apr 2024 11:55 next collapse

Didn’t know that. Thanks!

adavis@lemmy.world on 09 Apr 2024 12:22 next collapse

You can also use systemctl status $pid to find out what service a process is from.

caseyweederman@lemmy.ca on 09 Apr 2024 12:25 next collapse

Oooh. Thank you, I didn’t know that.

somenonewho@feddit.de on 09 Apr 2024 13:23 next collapse

You can … WHAT!?

Wow I did not know that. Incredibly helpful

prime_number_314159@lemmy.world on 09 Apr 2024 14:50 collapse

This and systemctl cat $unit are my favorites.

krolden@lemmy.ml on 09 Apr 2024 13:38 next collapse

You can skip list-units and just do systemctl --failed

spongeborgcubepants@lemmy.world on 09 Apr 2024 13:35 collapse

You can even drop the list-units and just use systemctl --failed

governorkeagan@lemdro.id on 09 Apr 2024 08:53 next collapse

This is somewhat related to the article but also a little off topic.

I started using Linux about 6 months ago now and I feel like it’s been a continual learning experience (in a positive way). I was comfortable enough with Windows that I was on autopilot with most things.

I’ve used systemctl previously but I love seeing articles like this, so freely available, where I have the chance to learn a lot more about my system.

Tangent over, just had this on my mind for a while and needed to share.

AnarchistArtificer@slrpnk.net on 09 Apr 2024 14:51 collapse

I agree - it can be overwhelming to constantly be reminded of areas in which one is lacking in knowledge (like when having to learn how to solve a relatively simple error), but the availability of learning resources really helps avoid demoralisation.

prex@aussie.zone on 09 Apr 2024 09:30 next collapse

Side note: does anyone enable or use the magic sysreq key anymore?

timbuck2themoon@sh.itjust.works on 09 Apr 2024 11:22 next collapse

Honestly no. Haven’t found the need.

DynamicBits@lemm.ee on 09 Apr 2024 12:10 next collapse

If you have a system with long-running leaky browser instances, Alt-SysRq-F is a lifesaver. It calls oom_kill, sacrificing one process to save the rest.

XTL@sopuli.xyz on 10 Apr 2024 07:02 next collapse

It may actually be a security hazard since there is a small chance of e.g. OOM killing your lock screen or other such process.

prex@aussie.zone on 10 Apr 2024 21:43 next collapse

Please tell me that needs physical access to work. Now that I think about it - how does sysrq even work with laptop keyboards?

possiblylinux127@lemmy.zip on 10 Apr 2024 22:35 collapse

Not on Wayland

Samueru@lemmy.ml on 10 Apr 2024 07:17 next collapse

I do, and used it today as well. My AMD gpu sometimes when booting fails to set the correct resolution on the 3rd display, and that causes the graphical session to freeze for some reason and I have to force a restart with sysreq and start the graphical session with a weird script that sets a custom res lol.

possiblylinux127@lemmy.zip on 10 Apr 2024 22:36 collapse

I use it for fun

And sometimes for testing system survivability

prex@aussie.zone on 11 Apr 2024 21:36 collapse

Gotta keep that kernel on its toes.

Naminreb@kbin.social on 09 Apr 2024 11:26 next collapse

Is there an equivalent in SysVInit?

corsicanguppy@lemmy.ca on 09 Apr 2024 14:13 next collapse

There always is. Usually easier.

PCLinuxOS, an offshoot of Mandriva (itself the child of the Mandrake/Conectiva union, both a long derivative of RedHat), still avoids systemd to provide a distro with massive versatility and fast boots.

XTL@sopuli.xyz on 10 Apr 2024 07:04 collapse

No. But you can run some of the init scripts with ‘status’ and they might print something. And telinit can do a few basic things.

LemmyHead@lemmy.ml on 10 Apr 2024 08:04 collapse

Here’s some more examples:

Systemctl edit: create an extension for the unit file and add some changes
S edit --full: edit the full unit file (and timer too iirc)
S enable --now: enable + start
S disable --now: disable + stop