Linux Systemd Cheat Sheet Useful

Introduction

In this tutorial, I write about the Systemd cheat sheet useful in Linux. Systemd provides a system and service that runs at PID 1. It tracks logged-in users and runs containers virtual machines and more.

The Linux Systemd Cheat Sheet is a handy guide that provides quick and easy-to-understand information about Systemd. Systemd is a system and service manager for Linux operating systems, and this cheat sheet is designed to help users navigate and utilize its features efficiently.

Whether you’re a beginner or an experienced Linux user, this cheat sheet covers essential commands and functions related to Systemd. From starting and stopping services to managing system processes, the cheat sheet is a valuable resource for anyone looking to streamline their Linux system management tasks.

With the Linux Systemd Cheat Sheet, you can quickly reference key Systemd commands, making it easier to troubleshoot issues, configure services, and optimize system performance. This user-friendly guide aims to empower Linux users with the knowledge they need to navigate Systemd effectively, ensuring a smoother and more efficient system administration experience.

Systemd Cheat Sheet in Linux

Logs with systemd

The contentCommand Line
View all system logsjournalctl
List boot numbersjournalctl –list-boots
View logs for unit sshjournalctl –unit ssh
View system logs from the most recentjournalctl -xe

For example the picture below

Systemd Cheat Sheet Useful
Systemd Cheat Sheet Useful 2

Introspection with systemd

The contentCommand Line
show unit file settingssystemctl show sshd
Show contents of the unit filesystemctl cat sshd
Show whether the unit is activesystemctl is-active sshd
Show whether the unit has failedsystemctl is-failed sshd
Edit unit file configurationsudo systemctl edit sshd
Restart daemonsudo systemctl daemon-reload

Services

The contentCommand Line
Start service nginxsystemctl start nginx
Stop service nginxsystemctl stop nginx
Show status of service nginxsystemctl status nginx
Start nginx now and at system startupsystemctl enable –now nginx
At system startup, start (enable) nginxsystemctl enable nginx
At system startup, do not start nginxsystemctl disable nginx
Show whether service nginx is enabledsystemctl is-enabled nginx
Prevent service from starting (mask)systemctl mask nginx
Unmask service, allowing it to be startedsystemctl unmask nginx
List all available servicessystemctl list-unit-files –-type service

For example as below

Start service nginx
stop service nginx

Targets (runlevels)

Targets, also known as runlevels in Linux, play a crucial role in managing the system’s state and functionality. Think of targets as different modes or scenarios your computer can operate in, each with a specific set of services and processes.

In simpler terms, runlevels help define what your computer is supposed to do at different stages – be it during startup, regular operation, or shutdown. For instance, runlevel 3 might focus on a multi-user environment with networking capabilities, while runlevel 5 could include a graphical user interface for a more user-friendly experience.

These runlevels or targets allow users to customize and control the behavior of their Linux system based on their needs. Whether you’re setting up a server that doesn’t require a graphical interface or a desktop environment for everyday use, understanding and configuring runlevels is essential for tailoring your Linux experience.

The contentCommand line
List all available targetssystemctl list-unit-files –-type target
Show dependencies of a targetsystemctl list-dependencies nginx
Show default boot targetsystemctl get-default
Boot to a text consolesystemctl set-default multi-user
Boot to a graphical desktopsystemctl set-default graphical
Show dependencies of a target

Conclusion

You should utilize the helpful Systemd Cheat Sheet in Linux. The cheat sheet includes fundamental systemd commands, and there are even more advanced features and options to explore. For detailed information about specific commands or options, you can check the systemd documentation or man pages (man systemctl). I hope you find this information useful. Thank you for visiting the DevopsRoles page!”

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.