Category Archives: CLI

Error treatment

Have the live system log displayed:

tail -f /var/log/syslog
tail -f /var/log/kern.log

Get all error messages across log files

journalctl -p err -f

or

/cat var/log/syslog |grep -iE "error|fail"
dmesg |grep -iE "error|failed"

Grab the system log from a remote server (and save on your desktop):

scp root@10.X.Y.Z://var/log/syslog ~/Desktop/syslog

Disk management commands

List partitions and drives

lsblk

Manipulate partition or list them with:

fdisk -l

Using the disk free command:

df -h

Partition manager utility

parted -l

Get detailed info on hardware, memory, firmware, mainboard, bus

lshw

Relative to mounted drives:

lshw -class disk

Get that information as html (JSON, XML) page:

lshw -class disk -html

List disks by ID, label, UUID…:

ls -l /dev/disk/by-id
ls -l /dev/disk/by-label
ls -l /dev/disk/by-partlabel
ls -l /dev/disk/by-partuuid
ls -l /dev/disk/by-path
ls -l /dev/disk/by-uuid

sfdisk utility for manipulating disk partitions. List block devices:

fsdisk -l

source: https://learnubuntu.com/list-drives/

Smart monitor tool

smartctl -a /dev/nvme0

Mount a drive

mkdir /media/usbstick
mount /dev/sdbX /media/usbstick

Delete files

Delete all files in all folders starting with 2023 living in the current folder

rm -rf 2023*

Ubuntu: enable root access from SSH

Connecting to a server via SSH as root user is disabled by default. To enable this, edit the sshd configuration file:

nano /etc/ssh/sshd_config

Find the following line:

#PermitRootLogin prohibit-password

Change it to this.

PermitRootLogin yes

Now restart the ssh service:

systemctl restart sshd

Time zone adjustment

To check if the server is in the same timezone than your workstation:

date

To modify the time zone:

sudo timedatectl set-timezone Europe/Luxembourg

Change timezone:

dpkg-reconfigure tzdata