Difference between revisions of "CentOS8 CheatSheet fuer System Administratoren"

From Bitbull Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
 
[[Category:Linux]]
 
[[Category:ReferenceCards]]
 
[[Category:Training]]
 
 
 
=System=
 
=System=
 
* Show hardware details
 
* Show hardware details
Line 21: Line 15:
 
  lsblk
 
  lsblk
  
 +
* get 10 biggest files in current dir
 +
du -sm * .[^\.]* | sort -n | tail
  
 
+
* use ncdu to find large files
 +
dnf -y install epel-release
 +
dnf config-manager --enable epel
 +
dnf -y install ncdu
 +
ncdu -x /  #replace / with needed mountpoint
  
  
Line 31: Line 31:
 
  top
 
  top
  
[[Category:Linux]]
+
==CPU==
[[Category:ReferenceCards]]
+
* show system load (1m, 5m, 15m)
[[Category:Training]]
+
w
 +
 
 +
 
 +
==Processes==
 +
* show processes with tree
 +
ps -f fax
 +
 
 +
 
 +
* count processes per user
 +
ps hax -o user | sort | uniq -c
 +
 
 +
 
  
 
=Services=
 
=Services=
Line 53: Line 64:
 
* check if service is enabled to autostart after reboot
 
* check if service is enabled to autostart after reboot
 
  systemctl is-enabled <svc-name>
 
  systemctl is-enabled <svc-name>
 
[[Category:Linux]]
 
[[Category:ReferenceCards]]
 
[[Category:Training]]
 
  
 
=Events=
 
=Events=
Line 85: Line 92:
 
* Match device node, e.g. /dev/sda
 
* Match device node, e.g. /dev/sda
 
  journalctl /dev/sda
 
  journalctl /dev/sda
 
[[Category:Linux]]
 
[[Category:ReferenceCards]]
 
[[Category:Training]]
 
  
 
==Log Files==
 
==Log Files==
Line 98: Line 101:
  
  
=CentOS 8 Stream migration=
+
=This and That=
 +
==SOS Report (Log Bundle)==
 +
This collects a log bundle which can be used for later debugging and analyzing. <br>
 +
Start this BEFORE you try to repair or change something, as well do not forget to snapshot/backup System/Application before debugging.
 +
dnf -y install sos
 +
sosreport
 +
cp -av /var/tmp/sosreport* /root/
 +
 
 +
==CentOS 8 Stream migration==
 
CentOS8 will be discontinued by the Red Hat team. All the effort will go into CentOS Stream operating System which is a rolling release of CentOS.<br>
 
CentOS8 will be discontinued by the Red Hat team. All the effort will go into CentOS Stream operating System which is a rolling release of CentOS.<br>
 
You can directly migrate a CentOS8 into a CentOS8 Stream in place:
 
You can directly migrate a CentOS8 into a CentOS8 Stream in place:

Revision as of 15:53, 11 December 2020

1 System

  • Show hardware details
lshw
  • show bios hardware details
dmidecode

1.1 Disk

  • Show block uage of mounted disks
df -hP
  • Show inode uage of mounted disks
df -hiP
  • show how blockdevices are configured in system
lsblk
  • get 10 biggest files in current dir
du -sm * .[^\.]* | sort -n | tail
  • use ncdu to find large files
dnf -y install epel-release
dnf config-manager --enable epel
dnf -y install ncdu
ncdu -x /  #replace / with needed mountpoint


1.2 Memory

  • Show memory statistics
free -th
  • Top provides memory information as well
top

1.3 CPU

  • show system load (1m, 5m, 15m)
w


1.4 Processes

  • show processes with tree
ps -f fax


  • count processes per user
ps hax -o user | sort | uniq -c


2 Services

  • list all services
systemctl list-units --type service
  • List failed services on boot
systemctl --failed
  • show all running services
systemctl --all --state=running
  • show detailed service status
systemctl start <svc-name>
  • service handing
 systemctl [start|stop|restart|enable|disable|mask] <svc-name>
  • check if service is enabled to autostart after reboot
systemctl is-enabled <svc-name>

3 Events

3.1 Show last boots

journalctl --list-boots
last reboot

3.2 Journal

  • Show log since last boot
journalctl -b
  • Kernel messages (like dmesg)
journalctl -k
  • Show latest log and wait for changes
journalctl -f
  • Reverse output (newest first)
journalctl -r
  • Show only errors and worse
journalctl -b -p err
  • Filter on time (example)
journalctl --since=2014-06-00 --until="2014-06-07 12:00:00"
  • Since yesterday
journalctl --since=yesterday
  • Show only log of SERVICE
journalctl -u SERVICE
  • Match executable, e.g. dhclient
journalctl /usr/sbin/dhclient
  • Match device node, e.g. /dev/sda
journalctl /dev/sda

3.3 Log Files

  • tail all currently open text files
lsof -F | sed '/^n\//!d;s/^n//;s/ .*//' | sort -u | xargs file | grep ' text$' | cut -d: -f1 | xargs tail -fn0
  • tail all files under /var/log
tail -f -n0 /var/log/* /var/log/*/*


4 This and That

4.1 SOS Report (Log Bundle)

This collects a log bundle which can be used for later debugging and analyzing.
Start this BEFORE you try to repair or change something, as well do not forget to snapshot/backup System/Application before debugging.

dnf -y install sos
sosreport
cp -av /var/tmp/sosreport* /root/

4.2 CentOS 8 Stream migration

CentOS8 will be discontinued by the Red Hat team. All the effort will go into CentOS Stream operating System which is a rolling release of CentOS.
You can directly migrate a CentOS8 into a CentOS8 Stream in place:

dnf install centos-release-stream
dnf distro-sync
cat /etc/centos-release
reboot