- Shell
- Distributions & Lineage
- Cron
- Timezone
- Networking
- CGroups
- Disk Management
- DRBD
- Binaries Debugging
- Linux Boot Process
- Linux Filesystem Layout
Shell - the command line program with some scripting constructs that calls the binary programs in
/bin
, /usr/bin
and similar directories.
Start with Bash which is the standard open source Linux shell.
-
Debian - the standard open source distribution
- Ubuntu - more updated distro, originally Desktop focused then expanded into cloud distro focus too
-
Redhat - used to the standard enterprise distro but has killed its open source credentials by strangling CentOS and consequently become legacy
- Amazon Linux
- Centos
- Fedora
- RockyLinux
-
Gentoo - l33t but takes time to compile.
-
Alpine - slim distribution designed for Docker
The generic way:
cat /etc/*-release
These files have different contents:
Distro | File |
---|---|
Alpine | /etc/os-release /etc/alpine-release |
Amazon Linux | /etc/os-release /etc/system-release /etc/amazon-release |
CentOS | /etc/os-release /etc/system-release /etc/redhat-release /etc/centos-release |
Debian | /etc/os-release |
Gentoo | /etc/os-release /etc/gentoo-release |
Redhat | /etc/os-release /etc/system-release /etc/redhat-release |
RockyLinux | /etc/os-release /etc/system-release /etc/redhat-release /etc/rocky-release |
Ubuntu | /etc/os-release /etc/lsb-release |
In RHEL 6
/etc/cron.allow
/etc/cron.deny
/var/spool/cron
root:root 700
Stored in /var/spool/cron/$USER
.
crontab
command is suid to allow user to manage it.
Opens the crontab in $EDITOR
(default vi
if $EDITOR
environment variable is not set):
crontab -e
This affects the cron scheduling above and recorded dates of jobs eg. data loading and recording.
For modern Linux systems with systemd:
timedatectl list-timezones
Servers should usually be set to UTC for consistent easy comparison across international systems unless this affects data loading dates from cron above.
timedatectl set-timezone UTC
See Networking doc.
Top for iptables, awesome!
iptstate
List rules with line numbers:
iptables -nL -line-numbers
Install ISC DHCPd:
yum install -y dhcp
Edit config:
vim /etc/dhcp/dhcpd.conf
Enable it at boot:
systemctl enable dhcpd.service
Start the service:
systemctl start dhcpd.service
Install dhcping
tool:
yum install -y dhcping
Test DHCP response:
dhcping -s localhost
Limit resource usage.
This is used by modern containerization like containerd
and Docker.
Can limit:
- CPU Time
- CPU core assignments
- Memory
- Devices
- Disk / Block I/O
- Network bandwidth
yum install -y libcgroup
service cgconfig start
ls /cgroup
lscgroup
Create cgroup - /etc/cgconfig.conf
:
group blah {
cpu {
cpu.shares = 400;
}
}
service cgconfig restart
then add processes (tasks) into cgroups according to parameters in the file:
/etc/cgrules.conf
:
<user> <subsystems> <control_group>
@<group> <subsystems> <control_group>
<user>:<command> <subsystems> <control_group>
eg.
*:firefox cpu,memory browsers/
service cgred start
Sysconfig services can instead add this to their /etc/sysconfig/<servicename>
file
CGROUP_DAEMON="<subsystem>:<control_group>"
List disk space of mounted partitions:
df -h
List partitions:
cat /proc/partitions
Format a spare partition:
mkfs.ext4 /dev/sda2
Check and recover filesystem, replay journal, prompts for fixes:
fsck /dev/sda2
Mount a filesystem to the directory /data
:
mount /dev/sda2 /data
Ensure the partition is:
- mounted by UUID as device numbers can change
- has
nofail
option set to make sure that a machine will attempt to come up to be able to SSH manage it otherwise you may end up in an AWS EC2 Disk Mount Recovery situation.
First inspect your /etc/fstab
:
cat /etc/fstab
Back up /etc/fstab
before editing it:
sudo cp -av /etc/fstab /etc/fstab.bak."$(date +%F_%H%S)"
Add the nofail
option on any lines on which it does not exist:
sudo sed -i '/nofail/ ! s/defaults/defaults,nofail/' /etc/fstab
Inspect the changes:
cat /etc/fstab
Each line in the /etc/fstab
should then look like:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /tmp xfs defaults,nofail 0 2
Validate your /etc/fstab
by mounting using the short form of the mount
command that reads and uses the /etc/fstab
:
mount /tmp
- awesome disk replication, used this in the mid to late 2000s
- mainline Linux kernel now
- dual-primary (0.9+)mount
- requires clustered filesystem (GFS, OCFS2)
mount -o ro
to avoid complexity of dual primary cluster filesystems- sync + async repl options
- get check_drbd nagios plugin to see how far behind replica is, automatically catches up, low maintenance once set up
See the Binaries Debugging doc for commands to examine and work with binaries.
Ported from various private Knowledge Base pages 2002+