LFCS / reference

reference

find / -size +100M -type f 2>/dev/null

Files over 100MB, suppress errors

find /etc -name '*.conf' -mtime -7

Conf files modified in last 7 days

grep -rin 'error' /var/log

Recursive, case-insensitive, with line numbers

sed -i 's/old/new/g' file

In-place global replace

awk -F: '{print $1}' /etc/passwd

First colon-field of each line

cut -d: -f1,7 /etc/passwd

Fields 1 and 7

sort file | uniq -c | sort -rn

Count + rank duplicate lines

tar czf a.tgz dir / tar xzf a.tgz -C /dst

Create / extract gzip tar

ln -s target link

Symbolic link (hard: omit -s)

systemctl enable --now svc

Start now + at boot

systemctl status|restart|reload svc

Inspect / restart / reload

systemctl daemon-reload

Reload unit files after editing

systemctl mask|unmask svc

Block / unblock a service

systemctl get-default / set-default T

View / set boot target

journalctl -u svc -f

Follow a unit's logs

journalctl -b -p err

This boot, errors only

systemctl --failed

List failed units

systemctl list-timers

Show all timers

crontab -e / crontab -l

Edit / list user cron

modprobe mod / modprobe -r mod

Load / unload kernel module

apt install x / dnf install x

Install package

dpkg -S /path / rpm -qf /path

Which package owns a file

useradd -m -s /bin/bash -G grp u

Create user w/ home, shell, group

usermod -aG grp u

Append user to group

usermod -L u / usermod -U u

Lock / unlock account

chage -M 90 -E 2026-12-31 u

Max age + expiry

passwd u

Set password

visudo -f /etc/sudoers.d/u

Safely edit a sudoers drop-in

chmod 750 f / chmod g+s d / chmod +t d

Octal / SGID / sticky

chown u:g f / chgrp g f

Change owner / group

setfacl -m u:carol:rwx f / getfacl f

Set / view ACL

setfacl -d -m u:carol:rwx d

Default (inherited) ACL

chattr +i f / lsattr f

Immutable bit / view attrs

ip a / ip route / ip link set eth0 up

Show addrs / routes / iface up

hostnamectl set-hostname name

Persistent hostname

ss -tlnp

Listening TCP ports + PIDs

ufw allow 80/tcp / ufw status

Debian firewall

firewall-cmd --add-port=80/tcp --permanent && firewall-cmd --reload

RHEL firewall (persist)

nmcli con add/mod/up / nmtui

RHEL persistent networking

ssh-keygen / ssh-copy-id u@host

Keys / push key

timedatectl set-timezone Z / set-ntp true

Timezone / NTP

chronyc sources / chronyc tracking

Chrony status

nginx -t / apachectl configtest

Test web config

restorecon -Rv /path

Fix SELinux file context

semanage port -a -t http_port_t -p tcp 8088

Allow SELinux port

setsebool -P bool on / getsebool -a

Persist / list SELinux booleans

getenforce / setenforce 0

SELinux mode

lsblk -f / blkid / findmnt

Inspect block devices / mounts

parted -s /dev/sdb mklabel gpt mkpart ...

Partition

mkfs.ext4|xfs /dev/sdb1

Make filesystem

mount -a / findmnt --verify

Test fstab safely

pvcreate / vgcreate / lvcreate -L 4G -n lv vg

LVM build

lvextend -r -L +2G /dev/vg/lv

Grow LV + filesystem

resize2fs /dev/vg/lv / xfs_growfs /mnt

Grow FS (ext / xfs)

mkswap f / swapon f / swapon --show

Swap

cryptsetup luksFormat|luksOpen /dev/sdd name

LUKS encryption

partprobe

Re-read partition table