Linux Administration Handbook notes
man
manpathshows equivalent ofPATHfor man pagesexport MANPATH=/home/share/localman:/usr/share/man
bash
fcto send last command to$EDITOR[ -w file ]and[ -r file ]to check for readable and writable filesfile {-nt|-ot} fileto compare file dates
Regexp
[char]any character from the set[^char]any character not in the set\wany word\sany white space char\dany digita|beither a or b(expr)limits scope and captures?: 0 or 1 of the preceding element*: 0+ of the preceding element+: 1+ of the preceding{n}exactly n instances{min,}at least min instances{min,max}matches any number of instances from min to max*?and+?are lazy versions, they catch the first instead of the last.*is generally dangerous
/proc
cmdCommand or program the process is executingcmdlineComplete command line of the process (null-separated)cwdSymbolic link to the process's current directoryenvironThe process's environment variables (null-separated)exeSymbolic link to the file being executedfdSubdirectory containing links for each open file descriptormapsMemory mapping information (shared segments, libraries, etc.)rootSymbolic link to the process's root directory (set with chroot)statGeneral process status information (best decoded with ps)statmMemory usage information
cmdline and environ files are separated by null characters, filter their contents through tr "\000" "\n"
strace
-ffollow forks-e fileonly file operations
find
find -print0 | xargs -0for files with spaces
mount
fuser -c mountpointprints the PID of every process that's using a file or directory on that filesystem- Then check with
ps -fp "157 315 5049"
chmod
- Copy permissions:
chmod --reference=fileA fileB
hdparm
Spin down HDD when not in use:
hdparm -S 5 /dev/sdX
mdadm
Generate config file:
echo DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
Enable array:
mdadm -As /dev/md0
Debian install
Generate preseed file:
debconf-get-selections --installer > preseed.cfg
debconf-get-selections >> preseed.cfg