Difference between revisions of "Systemd"
From Christoph's Personal Wiki
Line 50: | Line 50: | ||
$ alias psc='ps xawf -eo pid,user,cgroup,args' | $ alias psc='ps xawf -eo pid,user,cgroup,args' | ||
− | ==systemd-analyze== | + | ==Related commands== |
+ | ===systemd-analyze=== | ||
* Analyze system boot-up performance | * Analyze system boot-up performance | ||
Line 65: | Line 66: | ||
$ eog targets.svg | $ eog targets.svg | ||
− | ==journalctl== | + | ===journalctl=== |
''Note: combine with syslog-ng for backward compatibility.'' | ''Note: combine with syslog-ng for backward compatibility.'' | ||
Line 76: | Line 77: | ||
$ journalctl -f -u ssh.service # show only logs for ssh unit and follow | $ journalctl -f -u ssh.service # show only logs for ssh unit and follow | ||
− | ==timedatectl== | + | ===timedatectl=== |
''Note: Most of these commands will need to be run as either root or sudo and is only valid for systems using systemd.'' | ''Note: Most of these commands will need to be run as either root or sudo and is only valid for systems using systemd.'' | ||
Line 123: | Line 124: | ||
Active: active (running) since Fri, 2012-11-02 09:36:25 CET; 5s ago | Active: active (running) since Fri, 2012-11-02 09:36:25 CET; 5s ago | ||
... | ... | ||
+ | |||
+ | ===Other=== | ||
+ | ''See: [http://www.freedesktop.org/software/systemd/man/ for a complete list] | ||
+ | |||
+ | * Control the system locale and keyboard layout settings: | ||
+ | $ localectl | ||
+ | System Locale: LANG=en_US.UTF-8 | ||
+ | VC Keymap: n/a | ||
+ | X11 Layout: us | ||
+ | X11 Model: pc105 | ||
+ | |||
+ | $ loginctl # Control the systemd login manager | ||
+ | $ busctl # Introspect the bus | ||
+ | $ hostnamectl # Control the system hostname | ||
+ | $ machinectl # Control the systemd machine manager | ||
+ | $ networkctl # Query the status of network links | ||
+ | $ systemd-cgls # Recursively show control group contents | ||
+ | $ systemd-cgtop # Show top control groups by their resource usage | ||
+ | $ systemd-path # List and query system and user paths | ||
==External links== | ==External links== |
Revision as of 02:28, 14 May 2015
systemd is a suite of system management daemons, libraries, and utilities designed as a central management and configuration platform for the Linux computer operating system.
Contents
Example usage
- Check if you are running "init" or "systemd":
$ cat /proc/1/comm systemd
- Restart network:
$ systemctl restart network.target
- stop and mask the firewalld service (see: iptables vs. firewalld):
$ systemctl stop firewalld $ systemctl mask firewalld
- Miscellaneous:
$ systemctl list-units $ systemctl list-units -t service $ systemctl list-units | grep .service $ systemctl list-units -t target $ systemctl list-unit-files $ systemctl list-unit-files -t target $ systemctl list-dependencies multi-user.target $ systemctl [status|stop|enable|disable|restart] ssh.service $ systemctl is-enabled ssh.service $ systemctl [reboot|poweroff|suspend]
$ systemctl --failed UNIT LOAD ACTIVE SUB DESCRIPTION ● pollinate.service loaded failed failed Seed the pseudo random number generator on first boot ● vboxadd.service loaded failed failed LSB: VirtualBox Linux Additions kernel modules LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
- cgroup tree
$ systemd-cgls ├─1 /sbin/init ├─system.slice │ ├─dbus.service │ │ └─776 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation │ ├─cron.service │ │ └─692 /usr/sbin/cron -f ...
- ps with cgroups:
$ alias psc='ps xawf -eo pid,user,cgroup,args'
Related commands
systemd-analyze
- Analyze system boot-up performance
$ systemd-analyze Startup finished in 5.223s (kernel) + 7.781s (userspace) = 13.004s
- Plot all dependencies of any unit whose name starts with "avahi-daemon":
$ systemd-analyze dot 'avahi-daemon.*' | dot -Tsvg > avahi.svg $ eog avahi.svg
- Plot the dependencies between all known target units:
$ systemd-analyze dot --to-pattern='*.target' --from-pattern='*.target' | dot -Tsvg > targets.svg $ eog targets.svg
journalctl
Note: combine with syslog-ng for backward compatibility.
$ journalctl $ journalctl | grep -Ei 'error|fail' $ journalctl -b # show only logs from this boot $ journalctl -b -1 # show only logs from previous boot $ journalctl -u ssh # show only logs for a given unit $ journalctl -f # follow (somewhat analogous to `tail -f /var/log/messages`) $ journalctl -f -u ssh.service # show only logs for ssh unit and follow
timedatectl
Note: Most of these commands will need to be run as either root or sudo and is only valid for systems using systemd.
- List all available timezones on your computer/server:
$ timedatectl list-timezones
- Set your computer's/server's timezone:
$ timedatectl set-timezone region/timezone
- For instance, to set your timezone to United States Pacific Time (PST; -8GMT):
$ timedatectl set-timezone America/Vancouver
Your system will be updated to use the selected timezone. You can verify with:
$ timedatectl
Local time: Fri, 2012-11-02 09:26:46 CET Universal time: Fri, 2012-11-02 08:26:46 UTC RTC time: Fri, 2012-11-02 08:26:45 Timezone: Europe/Warsaw UTC offset: +0100 NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: no Last DST change: CEST → CET, DST became inactive Sun, 2012-10-28 02:59:59 CEST Sun, 2012-10-28 02:00:00 CET Next DST change: CET → CEST, DST will become active the clock will jump one hour forward Sun, 2013-03-31 01:59:59 CET Sun, 2013-03-31 03:00:00 CEST
- Enable an NTP daemon (chronyd):
$ timedatectl set-ntp true ==== AUTHENTICATING FOR org.freedesktop.timedate1.set-ntp === Authentication is required to control whether network time synchronization shall be enabled. Authenticating as: user Password: ******** ==== AUTHENTICATION COMPLETE === $ systemctl status chronyd.service chronyd.service - NTP client/server Loaded: loaded (/lib/systemd/system/chronyd.service; enabled) Active: active (running) since Fri, 2012-11-02 09:36:25 CET; 5s ago ...
Other
See: for a complete list
- Control the system locale and keyboard layout settings:
$ localectl System Locale: LANG=en_US.UTF-8 VC Keymap: n/a X11 Layout: us X11 Model: pc105
$ loginctl # Control the systemd login manager $ busctl # Introspect the bus $ hostnamectl # Control the system hostname $ machinectl # Control the systemd machine manager $ networkctl # Query the status of network links $ systemd-cgls # Recursively show control group contents $ systemd-cgtop # Show top control groups by their resource usage $ systemd-path # List and query system and user paths