Contents
Notes from Bird’s Linux Private Kitchen (3rd edition), kept for quick review.
System services (daemons)
- Modes
- stand alone — self-started, resident in memory;
/etc/init.d/*(httpd, vsftpd) - super daemon — xinetd stays in memory and manages others via
/etc/xinetd.d/*(telnet)- multi-threaded — one service handles multiple programs
- single-threaded — one at a time; extras queue
- stand alone — self-started, resident in memory;
- Services
- signal control
- interval control — cron and similar schedulers
/etc/services— records service ports- Super-daemon config under
/etc/xinetd.d/*socket_typestream: TCP; dgram: UDP; raw: talks to IP directlywaityes: single-threaded control; no: multi-threaded controlinstances— max concurrent connectionsper_source— max connections from one IPcps num1 num2— max new connections per second; service disabled for num2 seconds if exceededredirect ip port— forward the service elsewhereonly-from [0.0.0.0,192.168.1.0/24,hostname,domainname]— access controlno-accessaccess_times [HH:MM-HH:MM]— time window
ldd
- Inspect dynamic libraries linked by an executable
tcp wrapper
- Programs linked with
libwrap.socan use/etc/hosts.{allow,deny}(httpd typically does not) - Example:
rsync:127.0.0.100:deny— third field defaults todenyinhosts.deny - Columns one and two
- ALL — all programs or IPs
- LOCAL — from this host
- UNKNOWN — unresolvable IP, domain, or service
- KNOWN — resolvable IP, domain, or service
- Column three
spawn %d(hostname),%a(address),%d(daemon)twist— run the following command, then drop the connection
service
service --status-all— all service states; same idea asnetstat -anl
chkconfig
--list [service]— list service state--add service--del service--level [0-6] service [on|off]chkconfig --level 345 atd on— startatdin runlevels 3, 4, and 5
Run levels
- 0 halt (power off)
- 1 single-user mode (maintenance)
- 2 multi-user, without NFS (like 3 but no NFS)
- 3 full multi-user, text console with networking
- 4 unused (reserved)
- 5 like 3 with X Window
- 6 reboot
Levels 0 and 6 are boot-related; do not set services on by default there.
runlevel
- Show previous and current runlevel
init
N— switch runlevel
ntsysv
Login archives (logs)
vim /etc/rsyslog.conf— configure logging
log
- cron:
/var/log/cron - dmesg:
/var/log/dmesg - last login per system account:
/var/log/lastlog - mail:
/var/log/maillogor/var/log/mail/* - system errors:
/var/log/messages - auth failures, etc.:
/var/log/secure - successful vs failed logins:
/var/log/wtmp(last) vsfaillog
level
- info, notice, warning, err, crit, alert, emerg [debug, none]
.— this level and above, e.g.mail.info.=— exactly the listed level.!— everything except the listed level
logrotate
-v— verbose-f— force rotate
Working with syslog
# Prevent users from tweaking the log so rsyslog can still append
chattr -a /var/log/messages
# Use prerotate/postrotate so logrotate behaves
vi /etc/logrotate.d/syslog
/var/log/messages
/var/log/secure
/var/log/maillog
/var/log/spooler
/var/log/boot.log
/var/log/cron
{
sharedscripts
prerotate
/usr/bin/chattr -a /var/log/messages
endscript
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
# If you use rsyslogd.pid instead:
/bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
/usr/bin/chattr +a /var/log/messages
endscript
}
logrotate
/var/log/log_name.log— log file/etc/logrotate.d/log_name— matching config
depmod
-A— add new modules-n— dry run to stdout-e— show loaded modules that cannot run
lsmod
- List loaded kernel modules
modinfo
-a [module_name|filename]— authors only-d— description only-l— license only-n— path to the module file only
insmod, rmmod, modprobe
rpm
rpm -ivh *.rpm— installrpm -Uvh— upgrade if installed; install if missingrpm -Fvh— upgrade only when already installedrpm -qa— list installed packages
yum
yum install xxxyum list xxx— package detailsyum search rpmyum update xxxyum -y upgrade— upgradeyum clean [packages|headers|all]— clear cached RPM datayum remove xxxLANG=C yum grouplist— available package groupsyum groupinfo group-nameyum groupinstall [--installroot=/path/]yum groupremove group-nameyum repolist all— list repos
Questions? Leave a comment below or email: newbvirgil@gmail.com![]()
