Improved KB's readibility

This commit is contained in:
Michele Cereda
2023-01-11 01:47:22 +01:00
parent 2eb2b7bc72
commit 846179a85e

View File

@@ -7,29 +7,32 @@
systemctl list-unit-files
# List failed units only.
systemctl list-units --state=failed
systemctl list-units --state='failed'
# Start services.
sudo systemctl start adb.service
systemctl --user start keybase.service
sudo systemctl start 'adb.service'
systemctl --user start 'keybase.service'
# Restart services.
sudo systemctl restart bluetooth.service
systemctl --user restart davmail.service
sudo systemctl restart 'bluetooth.service'
systemctl --user restart 'davmail.service'
# Stop services.
sudo systemctl stop cups.service
systemctl --user stop davmail.service
sudo systemctl stop 'cups.service'
systemctl --user stop 'davmail.service'
# Enable services on boot.
sudo systemctl enable sshd.service
sudo systemctl enable --now docker.service
systemctl --user enable --now davmail.service
sudo systemctl enable 'sshd.service'
sudo systemctl enable --now 'docker.service'
systemctl --user enable --now 'davmail.service'
# Disable services from boot.
sudo systemctl disable clamav-freshclam.service
sudo systemctl disable --now gdm.service
systemctl --user disable --now davmail.service
sudo systemctl disable 'clamav-freshclam.service'
sudo systemctl disable --now 'gdm.service'
systemctl --user disable --now 'davmail.service'
# Check a service is currently active.
systemctl is-active 'wpa_supplicant.service'
# Suspend the system.
# Saves the state to RAM only.
@@ -52,8 +55,8 @@ systemctl suspend-then-hibernate
# Show log entries.
journalctl
journalctl -f
journalctl -n 20
journalctl -o json-pretty
journalctl -n '20'
journalctl -o 'json-pretty'
journalctl --no-pager
journalctl --utc
@@ -66,22 +69,22 @@ journalctl -b
journalctl -b -3
# Display logs in a specific time window
journalctl --since yesterday
journalctl --since 'yesterday'
journalctl --since "2015-01-10 17:15:00"
journalctl --since 09:00 --until "1 hour ago"
journalctl --since '09:00' --until "1 hour ago"
journalctl --since "2015-01-10" --until "2015-01-11 03:00"
# Filter logs by unit.
journalctl -u nginx.service
journalctl -u nginx.service -u php-fpm.service --since today
journalctl -u 'nginx.service'
journalctl -u 'nginx.service' -u 'php-fpm.service' --since 'today'
# Filter logs by process, user id or group id.
journalctl _PID=8088
journalctl _UID=33 --since today
journalctl -F _GID
journalctl _PID='8088'
journalctl _UID='33' --since 'today'
journalctl -F '_GID'
# Filter logs by path.
journalctl /usr/bin/bash
journalctl '/usr/bin/bash'
# Display kernel logs only.
# Works like `dmesg`.
@@ -101,18 +104,18 @@ journalctl -a
journalctl --disk-usage
# Delete old logs.
sudo journalctl --vacuum-size=1G
sudo journalctl --vacuum-time=1years
sudo journalctl --vacuum-size='1G'
sudo journalctl --vacuum-time='1years'
# List available timezones.
timedatectl list-timezones
# Set timezones.
sudo timedatectl set-timezone UTC
sudo timedatectl set-timezone Europe/Dublin
sudo timedatectl set-timezone 'UTC'
sudo timedatectl set-timezone 'Europe/Dublin'
# Set the time.
sudo timedatectl set-time 15:58:30
sudo timedatectl set-time '15:58:30'
sudo timedatectl set-time '2015-11-20 16:14:50'
# Set the hardware clock to UTC.
@@ -134,8 +137,8 @@ hostnamectl --pretty status
hostnamectl --static status
# Set hostnames.
hostnamectl set-hostname staticky --static
hostnamectl set-hostname prettiky --pretty
hostnamectl set-hostname 'static_hostname' --static
hostnamectl set-hostname 'pretty_hostname' --pretty
```
## User services
@@ -158,8 +161,8 @@ EOF
and can be acted upon as normal using `systemctl`'s `--user` switch
```sh
systemctl --user enable --now davmail.service
systemctl --user status davmail.service
systemctl --user enable --now 'davmail.service'
systemctl --user status 'davmail.service'
```
## Keep past boots record (persistent logging)
@@ -179,7 +182,7 @@ Storage=persistent
1. disable and stop the systemd-resolved service:
```sh
sudo systemctl disable --now systemd-resolved.service
sudo systemctl disable --now 'systemd-resolved.service'
```
1. set NetworkManager to use the default DNS resolution.
@@ -193,13 +196,13 @@ Storage=persistent
1. delete `/etc/resolv.conf`:
```sh
sudo unlink /etc/resolv.conf
sudo unlink '/etc/resolv.conf'
```
1. restart NetworkManager
```sh
sudo service network-manager restart
sudo service 'network-manager' restart
```
## Sources