Faq

How to see all enabled services with systemctl

The systemctl command can be used to show all service units and filter those that are enabled.

Summary

The systemctl command show active unit. To see only services that are enabled, we need to filter the output. This can be achieved using the list-unit-files subcommand and combined with the --state= option. As we are interested in enabled services only, set the value to enabled. Want to parse the output with a script? Consider adding --legend=false to remove the header and footer text (X unit files listed.). Usage systemctl list-unit-files --type=service --state=enabled UNIT FILE STATE VENDOR PRESET apparmor.

What does systemctl daemon-reload do?

When making changes to systemd unit files, you may need to use systemctl daemon-reload. This article explains what happens next.

Summary

Systemd stores the configuration for units, like services, in individual unit files. When changes are made to these units, a reload might be needed. This is where systemctl daemon-reload comes into play. But what exactly does the daemon-reload subcommand really do? In short: rerun generators, reload units files, recreate the dependency tree. Let’s have a look at the more detailed answer. Running generators Generators are helper scripts to convert non-native scripts to unit files that are usuable by systemd.

How to check if 'systemctl daemon-reload' is needed

When systemd units are changed, a 'systemctl daemon-reload' might be needed. Need to know if this is the case? Let's test for that.

Summary

Systemd may need to reload a part of the unit configuration if changes were made. To find out if the related systemctl daemon-reload command is needed, the state of the individual units can be tested. This is done by querying the property using the --property=NeedDaemonReload option. Testing a single service like nginx, can be done this way: # systemctl show --property=NeedDaemonReload --value nginx.service yes This output will return a ‘yes’ or ’no’ value.

How to see which syscalls are part of a systemd syscall filter set

Learn how to see what syscalls are part of a particular syscall filter set in systemd.

Summary

Systemd can restrict services from using particular syscalls with the help of the unit setting SystemCallFilter. Instead of mentioning all individual syscalls, systemd has predefined sets that can be used. These sets group functions that are related. To see which syscalls are part of a set, use the systemd-analyze command. # systemd-analyze syscall-filter @ipc @ipc # SysV IPC, POSIX Message Queues or other IPC ipc memfd_create mq_getsetattr mq_notify mq_open mq_timedreceive mq_timedreceive_time64 mq_timedsend mq_timedsend_time64 mq_unlink msgctl msgget msgrcv msgsnd pipe pipe2 process_madvise process_vm_readv process_vm_writev semctl semget semop semtimedop semtimedop_time64 shmat shmctl shmdt shmget See systemd syscall filtering for all details.

What is the difference between systemctl disable and systemctl mask?

Want to disable a service, but wondering the difference between systemctl disable and systemctl mask? This article shows the differences between the two.

Summary

Systemd and its services can be in several states, such as enabled, disabled, failed, running. If you no longer need a particular service to run, then the first step is to stop a service. systemctl stop nginx.service But stopping a service is not the same as disabling a service. With that comes a very frequently asked question: what is the difference between a service that is disabled and one that is masked?

How to use systemctl edit to change a service?

Learn how to edit an existing systemd service unit with the systemctl edit command.

Summary

Systemd allows service units to be configured using a drop-in file, which is often called override.conf. It overrides the vendor-supplied version of a service to customize it. Instead of duplicating the configuration, the override file contains the differences. Editing service file Changing a service can be done using systemctl, followed by the edit subcommand and service unit. The editor that is configured on the system will be opened and any changes can be made between the comment section at the top and the comment section a little bit lower.

How to see only running services with systemctl

The systemctl command can be used to filter its output and only show all running services.

Summary

The systemctl command will normally all active units. To filter this output to just the running services, we can combine the options --type= and --state=. For this particular case we set the type to service and the type state to running. Usage # systemctl --type=service --state=running --legend=false accounts-daemon.service loaded active running Accounts Service avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack colord.service loaded active running Manage, Install and Generate Color Profiles dbus-broker.

How to disable the background color of run0

Learn how to disable the change of the background color when using run0.

Summary

Systemd introduced run0 as its alternative to sudo. One of the features if a colored background when your privileges are elevated. To disable this behaviour, use the option --background= with an empty value. run0 --background= The red background now will be gone, which can be useful if the color conflicts with the output or when it is unwanted.

How to remove trailing whitespace from a file

Learn how to remove trailing whitespace from a file using the sed command.

Summary

To remove any trailing whitespace from a file, we can use sed. By using in-place editing -i, sed can be provided with a search-and-replace action to filter out whitespace at the end of each line. By replacing it with nothing, it will effectively be removed. sed -i 's/[[:space:]]*$//' mytextfile.txt Explanation -i = inline file edit s/ = search [[:space:]]*$ = search one or more occurences of whitespace just before the end of the line // = No text, so any occurences of the whitespace will be emptied The [[:space:]] is called a character class and refers to space characters.

How to insert a line at the beginning of a file

Learn how to insert a line of text at the beginning of a file using the sed command.

Summary

To insert a line at the beginning of a file, we can use sed to achieve this task. By using in-place editing -i, we can instruct sed to make a change to an existing file. The next step is to tell sed what to change or insert and at what place. sed -i '1i # New first line' mytextfile.txt Explanation -i = inline file edit 1i = insert at first line # New first line = Text to add

Data processing: Frequently Asked Questions

Frequently asked questions about data and text processing.

Summary

How to see memory usage of a service with systemctl?

The systemctl command can be used to show the memory usage of a service managed by systemd.

Summary

The systemctl command has multiple options to show the memory usage. With the status subcommand followed by the service, it will show the basics, including memory usage. To retrieve the information that easier to parse, then use show followed by --property=MemoryCurrent and the service name. Usage The status output will include memory usage. systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.

How to see the active settings of a systemd unit

The systemctl command can be used to show the settings of a systemd unit, like a service.

Summary

The systemctl command can be used to show all settings of an unit, such as a service. To display the full list of applicable settings, use the show subcommand followed by the unit name. Besides the settings, the output will also include actual runtime information, such as memory usage, when the unit was started, etc. Usage Just provide the unit file to see all available information. # systemctl show nginx.service Type=forking Restart=no PIDFile=/run/nginx.

How to override the settings of a systemd unit

The systemctl command can be used to override settings of a systemd unit, like a service.

Summary

The systemctl command can show settings of a systemd unit, such as a service. It can also assist in overriding these settings by using the edit subcommand followed by the unit name. This will open the editor that is configured on the system and create the override file. Usage Run the edit command with the unit, and the editor like vim or nano will show up. ### Editing /etc/systemd/system/nginx.service.d/override.conf ### Anything between here and the comment below will become the new contents of the file [Service] ProtectSystem=strict ReadWritePaths=/run /var/log/nginx ### Lines below this comment will be discarded <snip> Important: Do not remove the comments and only insert or change between the specified comment lines.

How to see the cgroup of a process

Learn how to find the control group (cgroup) of a process by using /proc, pidof, or ps.

Summary

The control group of a process can be retrieved from the /proc directory. We only need to know the PID of the process, which can be found using ps or pidof. Usage If we know that our PID is 1234, then showing the cgroup is as easy as using cat to see the contents of the ‘cgroup’ file. cat /proc/1234/cgroup To see the cgroup for the nginx process (or one of them), we could something like this.

How to see cgroup in ps output

Want to see the control group in the output of the ps command? Here is how to tune your command options to include that.

Summary

The ps command can show the control group of a process using the -o option, followed by the right column names. Usage To show processes and the control group, we can filter the output columns. # ps -e -o pid,cgroup:64,args PID CGROUP COMMAND 1 0::/init.scope /lib/systemd/systemd --system --deserialize 58 2 - [kthreadd] 3 - [rcu_gp] <snip> 576 - [xprtiod] 634 0::/system.slice/dbus.service @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only 640 0::/system.slice/networkd-dispatcher.service /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers 645 - [nfsiod] 653 0::/system.

How to see the time synchronization details with timedatectl

Show time synchronization details with the systemd timedatectl command and related subcommands.

Summary

The timedatectl command can show the time, time zone information, and its status. Add the timesync-status subcommand to see synchronization details. Usage Use timedatectl with the timesync-status command to see the actual status. Under normal conditions, the leap should show ’normal'. # timedatectl timesync-status Server: 185.125.190.56 (ntp.ubuntu.com) Poll interval: 34min 8s (min: 32s; max 34min 8s) Leap: normal Version: 4 Stratum: 2 Reference: 4FF33C32 Precision: 1us (-25) Root distance: 762us (max: 5s) Offset: +882us Delay: 15.

How to show the systemd machine ID

Find the machine ID that was generated by systemd.

Summary

With the hostnamectl command basic system information like the operating system, hostname, and machine ID can be displayed. Usage Run the command without any parameters to get the status displayed, including the machine ID. hostnamectl

How to see the dependencies of a systemd unit

The systemctl command has the list-dependencies option to show dependencies between units. But there are more options to query a little bit more information.

Summary

The systemctl command can be used to show dependencies between units with the list-dependencies subcommand. A nicely human-readable output will be displayed showing the selected unit, followed by the dependencies that rely on this unit. This is useful when a unit is in a failed state due to a dependency on another unit. Usage To see which units require the multi-user target to be active: # systemctl list-dependencies multi-user.target multi-user.target ● ├─apport.

How to see the available systemd unit types

The systemctl command can be used to show all available systemd unit types.

Summary

The systemctl command can show the available systemd unit types when using the option --type=help. Usage # systemctl --type=help Available unit types: service mount swap socket target device automount timer path slice scope

How to see all active systemd units of one type

The systemctl command can be used to show all active systemd units of one particular type with the --type option.

Summary

The systemctl command will show by default all active units. To filter down on a particular unit type, use the --type= option, followed by the type. Not sure what types are available? Run systemctl --type=help. Usage systemctl list-units --type=target

How to limit the disk usage of the systemd journal

Learn how to define the maximum size that the systemd journal daemon may use for storing journals.

Summary

To limit the maximum size that journals may use on the system, define the setting SystemMaxUse in /etc/systemd/journald.conf. Save the file, confirm that the settings are correct, then restart the journal daemon. Configuration Open /etc/systemd/journald.conf, copy the commented line, remove the hash, and assign it a value. SystemMaxUse=256M Note: depending on how many events happen on a system, this value might be too small. Make sure that the size for logs is big enough.

How to see the size of the systemd journal

Summary

The journalctl command can be used to show the journal. By using the --disk-usage option, the size of the journal is displayed. This includes the archived and active journal files. When the journal is using too much disk space, consider performing a vacuum task. Usage Showing the disk usage is quick and easy. # journalctl --disk-usage Archived and active journals take up 56.0M in the file system. Does the journal take up too much space?

How to see kernel messages with journalctl

Learn how to show all kernel events by using journalctl and filter out the kernel entries in the journal.

Summary

The journalctl command can show all events related to the kernel itself usig the --dmesg option. This option will filter out kernel messages and has a similar output as the dmesg command. Usage Use the full or shorter option to query the kernel messages. journalctl -k Looking for only the kernel messages of today? Combine it with the --since= option. journalctl -k -S "today"

What is a systemd unit?

Learn more about systemd units and what they do.

Summary

Systemd units define resources that can be used by the system. Examples of these units are a service, path, socket, and timer. Each unit type has its own basic set of properties that then individually can be configured. Unit types can be recognized by their file extension. A service will use the ‘.service’ extension, making it easy to recognize. Units are usually managed with the systemctl command. See systemd unit types and their purpose for a full overview of the units.

How to see only recent journal entries

Learn how to filter journal entries by specifying a date or time interval.

Summary

The journalctl command shows by default the oldest entries it has in the journal. Typically we are not interested in that, for that purpose there is the --since= option. This option defines that entries should be after the specified moment in time. Besides using an actual date, a shortened name like ’today’ can also be used that automatically defines the date and time. Usage To see the entries of today, use the aptly named ’today'.

How to see new log entries automatically with journalctl

Learn how to continuously show new log entries with journalctl like the tail -f command.

Summary

The journalctl command can show continuously new log entries with the --follow option. When new entries are added to the journal, they are automatically shown. Usage The follow option is a great option to continuously monitor a particular unit. journalctl --follow --unit=nginx.service Without providing a unit, all system events will be shown and followed.

How to see logging for a specific unit or service

Limit the number of log entries from the systemd journal by filtering journalctl output by unit.

Summary

The journalctl command can show the events from its journal by --unit= followed by the service or its unit name. This way events will be filtered, making it much easier to troubleshoot a particular service. Example journalctl -u nginx.service

How to reload the systemd configuration

How can systemd be instructed to reload its configuration?

Summary

Reload systemd

What is systemd?

Learn what systemd is and the main components of this system and service manager.

Summary

Systemd is a system and service manager. The name is short for ‘system daemon’, an ongoing service that manages the system. As it is also a service manager, it is responsible for start, stopping, and monitoring services. Systemd replaces the SysV init system and focuses on performance and resource management. It was created by Lennart Poettering in 2010, with Fedora Linux being the first to adopt it in May 2011. In 2015, several major Linux distributions started shipping with systemd.

What is a masked systemd unit?

What does it mean when a systemd unit is masked? Learn about this state.

Summary

Systemd units that are in a masked state are administratively disabled. While being in this state, they can not be started until they are unmasked. Typically a unit is masked when it should not start by default or manually, to prevent it causing issues or running an unwanted service. With systemctl and the subcommand mask, a systemd unit can be masked. Relevant FAQ: How to see all masked units with systemctl?

What is SSH agent forwarding?

Learn more about the SSH agent forwarding feature and what problems it tries to resolve.

Summary

The agent forwarding feature in SSH allows using your local SSH agent to be reached through an existing SSH connection. This way you don’t have to store copies of your private keys on intermediate systems to use them for authentication. While SSH agent forward simplifies things, it also introduces a new risk related to Unix domain socket. If a user on the intermediate system can access the related socket, then it may abuse this connection back to the SSH agent to authenticate on your behalf.

How to start the SSH agent?

When the SSH agent is not running, how can you start it? In this article we will have a look at the options.

Summary

The ssh-agent command is started manually using eval $(ssh-agent). This will initiate the SSH agent and make it available for clients, such as ssh, to use it. To confirm that the agent is running is by looking at the SSH_AUTH_SOCK environment variable. Automatic start of SSH agent Gnome Keyring SSH Agent When using Gnome, it typically comes with its SSH agent as part of Keyring. This will automatically load any files in ~/.

What is the purpose of the SSH agent?

What is the purpose of the SSH agent and when to use it?

Summary

The ssh-agent command starts the SSH agent, a helper utility to store private keys when using public key authentication. The ssh-agent process is usually started at the the beginning of a login session and then can be connected to by a SSH client. Clients can detect the environment variable named SSH_AUTH_SOCK. Related settings on the client IdentityAgent

How to disable the usage of the SSH agent

Learn how to disable the usage of the SSH agent when authenticating.

Summary

Disable usage of SSH agent identities

How to show all installed packages with pacman

Query the pacman package manager on systems like Arch to show installed packages.

Summary

Querying pacman

How to stop all processes of a single user

Learn how to stop all processes of a single user using the killall command.

Summary

Killing processes with a filter

How to disable the SSH host key check?

Learn how to disable the SSH check of host authenticity and key fingerprint with ssh option StrictHostKeyChecking.

Summary

Disable check for host authenticity

How to terminate a SSH connection that does not respond to CTRL+C

Learn about SSH escape sequences and how they can help with terminating a SSH connection that does not respond to CTRL+C.

Summary

Use an escape sequence to terminate a connection that is stuck

How to remove the passphrase from a SSH key

Remove the password or passphrase from a SSH key using the ssh-keygen command.

Summary

Remove a passphrase from existing SSH key

How to see the available SSH keys in the OpenSSH authentication agent

Show the available SSH keys that are loaded in the SSH authentication agent.

Summary

How to see the available SSH keys in the OpenSSH authentication agent

SSH: Frequently Asked Questions

Frequently asked questions about SSH, such as SSH keys, configuration, and usage.

Summary

What is a zombie process?

What is a zombie process on Linux and how to deal with it? In this article we will have a look at the details.

Summary

Zombies…

How to kill a zombie process

How to kill a zombie process if it does not respond to kill -9? Here are a few last steps that you can try.

Summary

Killing zombies, for fun?

How to show a running process name and its process ID (PID)

Find the process ID (PID) and process name on Linux with the help of the pgrep command.

Summary

Search for PID and process name

How to find all process IDs by its process name

Discover the process ID (PID) on Linux for a running process by searching for its process name.

Summary

Retrieve PIDs for a service

How to kill a running process by its name

Find and stop a running process on Linux by searching for its name using the killall or pkill command.

Summary

Stop a process by searching for its name

Processes: Frequently Asked Questions

Frequently asked questions about start and stop processes, discover information, and monitoring them.

Summary

How to see the the network IP address of your system

Show the IP address of your system with the help of the ip command.

Summary

Show your local IP address

How to see the IP address of your internet connection

Show the IP address of your internet connection using the dig command.

Summary

Query the IP address of your internet connection

How to see which DNS server is used

Find the active DNS server being used by reviewing the network configuration, including common commands to query this information.

Summary

Show the active DNS server

How to find writable files

Learn how to the use the find command to find any files that are writable.

Summary

Find the files that are writable

How to see the size of a directory

Learn how to see the size of a directory or folder on Linux systems using the du command.

Summary

Show disk usage by files and directories

How to see hidden files

Learn how to see any hidden files on the command line or in the terminal using the ls command.

Summary

Show hidden files

How to see files great than a specific size

Learn how to see files smaller or bigger than a specific defined size on Linux, using the du command.

Summary

Show files bigger or smaller than a specified size

How to find when the last modification happened in a directory

Learn how to find the last modification time of a file or subdirectory in a specified directory on Linux.

Summary

Show when the last modification was made within a directory

How to see inode usage

Learn how to see inode usage on a Linux file system or mount point.

Summary

Show used and free disk space

How to see used and free disk space

Learn how to see used and disk space of file systems or mount point on Linux systems.

Summary

Show used and free disk space

How to find symbolic links that point to a directory

Learn how to use the find command to discover symbolic links that refer to a directory.

Summary

Find symbolic links pointing to a directory

How to compare two directories and find the differences

Learn how to compare two directories and see their differences or what files they are having in common.

Summary

Compare two directories, find their differences and what they have in common

How to see the number of open connections on Linux

Show the number of open connections using the ss command on Linux.

Summary

Show number of open connections per protocol

How to see when a process was started

Show process details to learn more about when a process was started using the ps tool.

Summary

Show start time of a process

How to see when the system was started (uptime)

When did a system start? Learn how to query the boot time (uptime) of a system using commands like uptime and ps.

Summary

Show uptime of the system

System administration: Frequently Asked Questions

Frequently asked questions about system administration, system state, and how to perform common tasks.

Summary

How to see active connections and bandwidth usage on Linux

Show actual bandwidth usage and active connections using the iftop tool on Linux.

Summary

Show actual bandwidth usage

Show to clear the DNS cache with systemd

Learn how to inspect and clear the DNS cache when using the systemd resolver daemon.

Summary

Clear DNS cache using resolvectl

How to show network TCP statistics and counters

Show counters related to the TCP connections by using the nstat command. This small utility will quickly retrieve the related statistics and display them.

Summary

Show TCP connection statistics

How to see CPU details

Show CPU details such as architecture, vendor, caches, virtualization options, and even known CPU vulnerabilities such as Meltdown and Spectre.

Summary

Show CPU details

Methods to find the Linux distribution and version

Learn how to find the Linux distribution and version of a system. Use the right tool or file to find the relevant details.

Summary

Find the Linux distribution name and version

How to see memory information such as type and speed

Show memory information and details such as the number of banks in use, the memory type and speed.

Summary

Show memory details

How to securely delete a file and its contents

Need to delete the contents of a sensitive file? Instead of just deleting it with rm, look at this option first.

Summary

Learn how to purge data before deleting a file

How to see the creation date of a file

Learn how to use the stat command to find the initial creation time of a file, also known as its birth time.

Summary

Find out when a file was initially created

What is a tainted kernel

Learn what it means when the Linux kernel is marked as tainted, including finding the cause.

Summary

Learn what it means when the kernel is tainted

How to find the specific cause of a tainted kernel

Learn what it means when the Linux kernel is marked as tainted and in particular the underlying cause.

Summary

Learn about the specific cause that tainted the kernel

Kernel: Frequently Asked Questions

Frequently asked questions about the Linux kernel and kernel security.

Summary

How to see errors and dropped packets on a network interface on Linux

Show the network link details using the ip command to find out if a network has errors or dropped packets on a Linux system.

Summary

Show network link statistics to discover errors or dropped packets

How to see the default gateway on Linux

Show the network routing table to discover the default gateway used on a Linux system.

Summary

Show network table to discover the default gateway

How to see which process is using a port

Show which process is already opened an UDP or TCP port on Linux by using the ss command.

Summary

Show which process is listening to a port

How to see open ports on Linux

Show which UDP/TCP ports are opened on a Linux system, including the related process. Use the ss tool to see more details about these sockets.

Summary

Show open network ports such as TCP and UDP

Networking: Frequently Asked Questions

Frequently asked questions about networking, such as DNS, IP configuration, TCP/UDP details, and more.

Summary

How to see the TTL value of a DNS record

Learn how to query the Time To Live (TTL) for a DNS record by using the dig tool.

Summary

Query DNS to reveal the TTL value of a DNS record.

How to show all installed packages on Ubuntu

Query the package manager to show installed packages on Ubuntu systems including version details.

Summary

Query tools like dpkg to show installed packages

Package manager: Frequently Asked Questions

Frequently asked questions about software, such as package manager, package versions, and how to configure them.

Summary

How to list all USB devices

Retrieve device information from USB hubs and devices using the lsusb command.

Summary

Retrieve USB device information using lsusb

How to see the available hard disks

Show the available hard disks in a system by using the right Linux tool. There are multiple options to pick, so let's have a look.

Summary

Query the available hard disk(s)

How to see hard disk specifications and details

Show more detailed information about the available hard disks in the system. Specifications like speed, serial number, firmware, and other details.

Summary

More in-depth information about the available hard disks

How to see BIOS details

Show bios details from within a Linux system. Learn how to query these details and where to find more information.

Summary

Show BIOS information using dmidecode

Hardware: Frequently Asked Questions

Frequently asked questions about hardware information such as bios, USB devices, memory, and other details.

Summary

How to find the biggest directories on disk

Find the biggest directories and files on disk by using the du command.

Summary

Leverage the du command to find the biggest directories

How to see all masked units with systemctl

Want to find all masked unit files? In this article we show how to do this with systemctl and query those units.

Summary

Show all masked units

How to see the last X lines with journalctl

Limit the output from journalctl by defining the number of lines you want to see.

Summary

Perform smarter queries when requesting information from journalctl

How to disable a systemd unit with systemctl

Want to disable a service or specific systemd unit? Use systemctl to configure units and disable it on boot or completely.

Summary

Disable a service or specific unit with systemctl

How to start and enable a unit with systemctl

Combine the start and enable command when using systemctl to get a unit like a service started at boot and right away.

Summary

Start and enable a unit with one command

How to show failed units with systemctl

Want to check the system for failed systemd units? In this article we show how to do this with systemctl and query the units with a failure state.

Summary

Show failed systemd units with systemctl

Systemd: Frequently Asked Questions

Frequently asked questions about systemd, systemctl, and journalctl. Learn by pratical examples how to use these tools.

Summary

File systems: Frequently Asked Questions

Frequently asked questions about file systems, file permissions, directories and files.

Summary