Linux System Administration Guide
by Samar Abbas (Version 1.0, 22/3/2003)
- Installation (a. Stdd. Install, b. Troubleshooting,
c. Partitions, d. Customiz'n or Post-Install Config,
e. Other Install Methods: KickStart, Multi-Boot OS
f. Rescue)
- Pkg.Mgt.
(a. RPM, b. Debian P.M., c. Shared Libs, d. Sample installations,
e. Compression, Backup and Storage)
{LPI-102}
- Hardware Admin
(a. Device admin., b. Sound+Video, c. Printer,
d. Modems,
e. Storage Media: Floppy, CD, f. Installation of New Hardware)
{LPI-102}
- User Admin. (Users and Passwords, Groups, Quotas) {LPI-101}
- System Accounting (a.Logging: syslogd, load monitors,
sniffers, b.Process Management)
- Kernel
(a. Kernel Modules,
b. Boot Process: Boot mgrs: LILO, windows bt mgr,
c.Init. and Shutdown: run-levels
d. Installation and Rebuilding) {LPI-102}
- Security
(System Security: tcp_wrappers, ssh, PAM,
Encryption, tools: TripWire;
Network Security: Proxy (squid), Firewall (ipchains), Router)
I.
Installation
a.
Standard Installation
- Boot from CD : Boot from
install CD, hitting <DEL> to make it default 1st/2nd/3rd bootg dev.
- Partitioning : Use
fdisk or Disk Druid. Optionally mount dos partition as /dosc
in Disk Druid.
- 5 Installation classes RHL 6.2
= Gnome Workstation | KDE Workstation | Server | Custom | Upgrade
- 5 Install classes RHL 7.1 = Workstation | Server | Custom | Laptop |
Upgrade
- Workstation Install: MBR /dev/hda overwritten; all
linux partitions erased + non-linux partitions kept; all free
unpartitioned space used; xinetd not installed ( => incoming finger,
ftp, telnet and talk won't work) [examprep]
- HD(Gnome|KDE for 1 lang) = 1.5G; HD(Gnome+KDE+games) = 1.8G
- auto-partitioning created: swap=1-2x RAM + /boot = 50M +
/ = 1100M (depending on disk space)
- Server Install: removes ALL partitions+ ALL OS's on ALL HDs;
package selection available
- HD(min.+no.GUI) = 1G; HD(all+no GUI) = 1.3G;
HD(all+Gnome+KDE) = 2.0G
- auto-partitioning : swap = 1-2xRAM + / = 384M +
/usr > 1400M + /home > 512M + /var = 256M + /boot = 50M
- Virtual Consoles: F2 (shell prompt) | F3 (install prog. msg's) | F4
(sys.msgs) | F5 (other msg's)
- Min HW = 386 + 32MB RAM + 500M HD
- Reco HW = 64 MB RAM + Pentium + 600M-1.2G
b.
Installation and Post-Installation Problems
c.
Partitions
- fips (`First nondestructive
Interactive Partition Splitting Program') [tackett.90].
part resizing; cmp. Partitn Magic
- parted : linux partitn resizg tool
- rawrite : create root (not boot!) disk
- fdisk
- p - print partition table | m - help | q - quit
- partition id's: swap = 82 |
linux native = 83 | extended linux = 85 | extended = 05
- $fdisk /mbr (remove old boot loader)
- newe2fs (create fs structure)
- free (show free memory)
- fsck (`filesystem check')
- -n (`no verification') |
-a (`automatically' repair any errors detected)
- fsck -t ext2 /dev/hda2
(checks filesystem)
- /etc/rc.d/rc/S contains an fsck entry
- fdformat (low-level `floppy disk format':
lays down sector
and track info on FD such that size can be automatically
used by /dev/fd0)
- -n (`no verification')
- fdformat /dev/fd0 .
- mkfs (`make filesystem')
- mkfs, mkfs.msdos, mkfs.ext2,
mkfs.ext2 = mke2fs for various fs types.
- ext2fs: 5% default space reserved for
root; filename <= 255 chars
- -c (`check' for bad blocks)
- #mkfs -t ext2 /dev/fd0 1440
(create ext2 fs of 1.44
mb (1440 blocks) on floppy, erasg all files)
- stat (disply file inode); eg $stat
/etc/passwd
- hwclock (show hw clock)
- /dev/hda = 1st IDE HD
- /dev/hda1 = 1st partition on IDE drive
- /dev/sda = 1st SCSI HD
- /dev/sdb = 2nd SCSI HD
- /dev/sda1 = 1st partition on SCSI HD
- root partition as small as possible
- <= 4 primary partns = 3 normal + 1 extdd |
<= 1 extended partn (ext partns are primary)
<= 12 logical partns |
<= 16 total partns = 4 primary partns + 12 logical
- < 63 partns for IDE HDs
Swap Partitions
Definition of Swap : -
Generic term for disk storage used to increase the amount
of apparent memory available on the system.
[welsh.185];
ie.
data (ie. memory pages; 1page = 4096b) is written to swap when there is
not enough RAM; although disk access is slower than RAM acess.
|
- Min. swap partition = 2 x RAM > 128 MB.
- If RAM < 16 MB, swap partition is a must.
- 2 kinds of swap exist: partitions or files
- Max. 16 swap areas are allowed,
each swap area = one disk file or
partition < 128 MB.
- < 2GB (2.2.x kernels)
- mkswap (`make swap')
- -c (`check' for bad blocks)
- $mkswap -c /dev/hda3 16447; swapon
(makes swap)
- /etc/fstab : incl. list of swap
partitions.
- creation of swap area :
- $dd if=/dev/zero of=/swap bs=1024 count=8192
read from the null bytes creator
to create 8MB swap file.
- sync the filesystem in case of crash.
- $mkswap -c /swap 8192 to format the swap area using
-c flag to check for bad blocks.
- $sync format info physically written to new swap file.
- $swapon / swap enable swap space.
- $free
to check if swap has increased in size.
/etc/fstab file should contain a line:
/dev/hda6 swap swap defaults 0 0
/etc/rc.d/rc.sysinit
should contain a line:
swapon -a .
- deletion of swap srea :
- $swapoff /dev/hda3
- Use rm only after the swp file has been swapped off.
Do not remove an enabled swap file.
d.
System Customisation
(Post-Install)
e.
Other Install Methods
(Kickstart, etc.)
f.
Rescue + Debug
sync, umount used in rescue mode
since halt|reboot|shutdown not operate properly.
II.
Package Management
a.
RPM
- rpm (`Red Hat Package Manager')
- -a (`all') | -b (`build') |
-i (`install') | -e
(`excise', uninstall) | -f (show `file-owner') |
-F (`freshen': upgrade pkg
only if an earlier version is already installed) |
-h (`hash': print 50 hash marks as pkg is unarchived) |
-q (`query') | -qf (`query file'+ find its pkg) |
-R (`resolve' dependances) |
-U (`upgrade': install if not exists) |
-V (`verify' pkg) | -p (`print' info)
- $rpm -ivh f.rpm (install with progress
hash signs)
- $rpm -Uvh f2.rpm (upgrade existing pkg, removing
old one; using -i would install both)
- $rpm -i --force ftp://ftp.redhat.com/package.rpm
(force install of www rpm)
- $rpm -e --nodeps xsnow (disable dependancy check
+ remove)
- $rpm -q emacs
or $rpm -qa | grep emacs
(see if emacs installed; returns
"emacs-20.7-34")
- $rpm -qi xsnow (query pkg, showing more info)
- $rpm -ql xsnow (list full filenames owned by installed
pkg); $rpm -qlc xsnow; $rpm -qld xsnow
(restrict o/p to cfg or docu files owned by pkg)
- $rpm -qpl xsnow-1.41-1.i386.rpm
(list all files contained in rpm pkg)
- $rpm -qa | wc -l (no. rpm pkgs installed on sys.);
$rpm -qal | wc -l (no. files in all installed rpms)
- $rpm -qf /usr/X11R6/bin/xsnow (returns
"xsnow-1.41-1", pkg owning file)
- $rpm -qpR xsnow-1.41-1.i386.rpm
or $rpm -qR xsnow (list all files
required)
- $rpm --checksig xsnow-1.41.rpm
(yields "md5 GPG NOT OK"; -> find key using
$rpm --checksig -v xsnow-1.41.rpm ; download and
import it: %gpg --import sam.asc;
whence
--checksig should yield "md5 gpg OK")
- $rpm -V xsnow (verify pkg, no o/p = clean;
else lists errors)
- $rpm --rebuild f.src.rpm (reportedly build binary rpm
from src);
$rpm -Uvh f.i586.rpm (in /usr/src/redhat/RPMS)
- [/usr/src/redhat/SPECS:$rpm -bb spec_file (build binary pkg)
- /etc/rpmrc : old cfg file;
moevd to /usr/lib/rpm/rpmrc +not meant to be edited by
sysadmins.
- /etc/rpm/macros: cfg rpm;
read docu: $rpm -qld rpm | grep macros
- /var/lib/rpm (rpm db)
- /usr/src/redhat (source rpms: .pkg.src.rpm)
/usr/src/redhat/[BUILD/, RPMS/, SOURCES/, SPECS/, SRPMS/]
- ~/.rpmrc
- gnorpm (`gnomeRPM':
GUI frontend to rpm running under X)
b.
Debian
- dpkg (`Debian Package Manager':
Primary Debian package manager) [nutshell.Ch5]
- -i (`install') | -l (`list' pkg info) | -r
(`remove') | -c (`chart': list all files in pkg) |
-s (`status') | -I (more info: version, debian section, pkg
dependancies)
- $dpkg -i /tmp/xsnow-1.4.deb (stdd
install)
- $dpkg -s xsnow
("Status: install ok installed" + much info)
- $dpkg -L xsnow
(list files within pkg;
reverse: find pkg owning given file $dpkg -S
/usr/doc/xsnow/copyright
- /var/lib/dpkg/available:
packages available on the system.
- /var/lib/dpkg/status: Status for pkgs
- dpkg-deb (`Debian Package
Manager': lower-level pkg'g tool; accepts and executes
commands from dpkg)
- dselect (`Debian Selector':
GUI to dpkg): interactive update tool
of /var/lib/dpkg/status
- Main Menu =
0. [A]ccess 1. [U]date 2. [S]elect 3. [I]nstall 4. [C]onfig
5. [R]emove 6. [Q]uit
- [S]elect: EIOM column displays Status for each pkg
- apt-get (`Advanced Package
Tool': in development)
- -s (pre-start messages)
- $apt-get install xsnow
(downloads pkg + dependancies and installs them)
[devWorks.102.I]
- $apt-get dselect-upgrade (
install, remove and cfg pkgs as per Status
in /var/lin/dpkg/status =
using dselect menu
- /etc/apt/apt.conf :
main APT config file (cf. $man apt.conf)
- /etc/apt/sources.list: where to find uninstalled
pkgs, ie. www, ftp sites; edited by %apt-setup
or by hand (cf. $man sources.list)
- apt-setup: interactive tool
for editing /etc/apt/sources.list
(sources list for apt-get)
- alien : convert pkg formats to .deb
- dpkg-reconfigure :
$dpkg-reconfigure --all (ensure all debconf pkgs are
completely configured)
c.
Shared Libraries
Statically Linked Executables: "complete", contain all functions
required for execution; good for low-level maintenance tasks
Shared Libraries : - a core set of routines
|
d.
Sample Installs
-
RealPlayer :
http://scopes.real.com/real/player/unix/unix.html:
`Linux 2.x libc i386' pkg downloaded
- $chmod 755 rp8_linux20_libc6_i386_cs2.bin
- $./rp8_linux20_libc6_i386_cs2.bin
- $realplay file.rm
or $~/RealPlayer8/realplay file.rm if installed as non-root.
- run strace on realplay & reportedly increase
color depth
- Flash Player:
http://www.macromedia.com/shockwave/download/index.cgi:
flash_linux.tar.gz
- %cp $HOME/flash_linux/libflashplayer.so /usr/lib/netscape/plugins
- %cp $HOME/flash_linux/ShockwaveFlash.class
/usr/lib/netscape/plugins
(flash player + java class file cp'd into plug-in dir.)
- MPlayer ; http://mplayer.sourceforge.net/:
movie player (mpg, avi, asf)
- ALSA Drivers (Advanced Linux Sound Architecture):
- Using rpm; or
- Downloaded, Unzipped and Extracted to /usr/src :
(www.alsa-project.org),
$bunzip2 alsa-driver-0.5.11.tar.bz2 ;
$bunzip2 alsa-lib-0.5.10b.tar.bz2 ;
$bunzip2 alsa-utils-0.5.10.tar.bz2
$cd /usr/src/ otherwise
a "cannot find ..." error will occur.
#tar -xvf /home/guest/alsa/alsa-driver-0.5.11.tar ;
#tar -xvf /home/guest/alsa/alsa-lib-0.5.10b.tar ;
#tar -xvf /home/guest/alsa/alsa-utils-0.5.10.tar
- Configured Make and Make Installed the Drivers, Libraries
and Utils
#cd /usr/src/alsa-driver-0.5.11
#./configure ; #make ; #make install
#cd ../alsa-lib-0.5.11
#./configure ; #make ; #make install
#cd ../alsa-utils-0.5.11
#./configure ; #make ; #make install
Given order to be followed; drivers before libraries
before the utilities.
- Perpared Devices
#cd /usr/src/alsa-driver-0.5.11 ; ./snddevices
& check that /dev/snd -> /proc/asound/dev
but /proc/asound/dev/ need not exist.
- Modprobed the Card:
#modprobe snd-card-intel8x0
#modprobe snd-card-intel8x0 snd_ac97_clock=48000
snd_mic_frame_size=120 snd_card_frame_size=120 snd_pbb_frame_size=128
this created /proc/asound, and
#cat /proc/modules should now contain a `snd' column.
#cat /proc/asound/cards should list the card.
There is no need to edit /etc/conf.modules for this.
- Unmuted and Set Volume with Amixer :
#amixer showed the default values.
#amixer set Master 100 unmute
or
#amixer -c 0 set Master 100 unmute
where 100% is the % of max. volume
#aplay computer.au still did not work.
#aplay -c 0 set PCM 100 unmute then aplay worked.
#aplay computer.au worked then.
aplay = ASLA audio player, it supports
au and wav (cf. /usr/share/sounds).
- Common Problems:
"No mixers found. Make sure you have snd support
compiled into the kernel" is xmms error, though aplay works.
--> edit /etc/conf.modules
- aviplay: To install DivX codecs, and play avi files,
installed aviplay rpm. Most avi files played well.
- wmv, asx, asf:
cp'd wmvds32.ax (found via google":wmvds32.ax")
into /usr/lib/win32 and aviplay
could play all these files.
- alsaplayer (ALSA player can play mp3's
or MPEG-1 AudioLayer-3);
Sample installation on zircon 8/6/01
- #cd /usr/src to install under this tree;
- #tar -xvf /root/tmp/alsaplayer-0.99.33-pre3.tar
or wherever the tar file is located;
- cd alsa-player-0.99.33-pre3
- # ./configure; make; make install
- $whereis alsaplayer should yield
/usr/local/bin/alsaplayer.
- In IOP the /usr/local/
on zircon had been previously moved to /usr/local_local;
being linked to the remotely mounted executables directory:
#mv /usr/local /usr/local_local
#ln -s /tmp_mnt/usr/local /usr/local
This had to be undone as otherwise an error
`cannot create directory /usr/local/lib/alsaplayer: Read-only file
system' occurred.
e.
Compression, Backup, and Storage
(Using Removable Media)
Incremental Backup : -
A procedure for Backing Up only the Files
that you have changed or added since
doing your last Backup.
Differential Backup : -
A procedure for Backing Up only files that have been
changed
or added since the last full backup.
[xrefer.com]
|
- gzip (compress individual files using
Lempel-Ziv coding (LZ77)
- -d (`decompress' = gunzip) |
-r (`recursively' descend into subdir's) |
-N (restore original `names')
-
Corruption of 1 block can spoil whole file since
gzip compression algorithm dependant on data coherency
across many bytes ---> tar, cpio or
afio better for these cases.
- usual compression rate: 60-70% (text).
- $gzip -9 *.txt
(ultra-compression in maximum time, default is -6)
- $gunzip *.gz
(uncompress all gzipped files)
- $gunzip -l f.txt.gz
(file info)
- $gzip -c f.gz | more
(file stays compressed, same as
$zcat f.gz )
- $ls -lR $HOME | gzip > f.gz
(file info)
- $cat file1 file2 | gzip > foo.gz
(concatenate files and then compress)
- rar: winrar.com, rarsoft.com
- gunzip
(decompress gzip=.gz, zip,
compress=.Z or pack files)
- cpio (`copy in and out'; duplicate
dir trees)
- zip
(compress files in format compatible with
pkzip - Phil Katz's zip for msdos systems)
-
$zip z.zip *.txt
(zip all txt files into a file called z.zip)
- $zip -r zip.zip xdir
(recursively zip all files in xdir)
-
$unzip z.zip
(unzip the given file)
- zcat (cat or display compressed
files)
- gunzip -c = uncompress -c
= zcat
-
$zcat f.gz
(view the compressed file)
- tar (`tape archive'): extracts to
new dir -> not clutter pwd
- partially extraction multi-part rar files:
winrar leaves unpacked files intact.
PowerArchiver:
dont click Cancel or Ok when
the window pops up (else files cleared)
asking for the next file. Leave it as it is and play
the downloaded section.
"D:Program FilesWinRARUnRAR.exe" x -kb (with the 'Start in' folder as t
Desktop - how do you make this the current folder instead?) which aviods all the
To split files on linux, download lxsplit--the linux form of HJ split, or use th
already supplied split command:
split -b 10m file.avi file.avi
To combine them, do:
cat file.avia* > file.avi
If you don't want to use the split command, and use lxsplit instead, then:
lxsplit -s file.avi 10mb
To combine them:
cat file.avi0* > file.avi
- cksum (cyclic redundancy check
(CRC) `checksum' for given file, usu. to ensure
that files transf'd by unreliable means are uncorrupted)
- compress, uncompress
(Use adaptive Lempel-Ziv coding to create .Z files)
(Slightly less efficient than gzip)
- mtools (`msdos tools':
suite of tools to manipulate msdos files from linux)
(http://mtools.linux.lu)
- $mcopy f.txt a:/
(copy to dos floppy)
-
$mcopy -/ a: .
(recursively copy floppy directory tree to present directory)
-
$mdel a:/f.txt
(delete dos directory)
-
$mcd a:/mydir
(change to dos directory)
-
$mrd a:/mydir
(delete dos directory)
- mattrib, mcat, mcd, mcopy, mdel, mdeltree, mdir, mdu,
mformat, minfo, mlable, mkmanifest, mmd, mmount, mpartition, mrd, mmove,
mren, (rename) mshowfat, mtoosltest, mtype, mzip, xcopy (cp
recursively DOS dirs onto one another)
[RH033, 6-11]
- /etc/mtools.conf
- bzip, bzip2 :
(Better Burrows-Wheeler block sorting text compression algorithm, and
Huffman coding)
- mount (mount removable media)
- $mount -t iso9660 /dev/cdrom /mnt/cdrom
(mount new CD-ROM)
- $mount /mnt/cdrom = $mount cdrom
(mount CD-ROM using fstab entry)
- $mount -t vfat /dev/fd0 /mnt/floppy
(mount floppy)
- $umount cdrom or $eject cdrom
- magicdev GNOME/KDE daemon probes CD every sec default
+ mounts new media
- rsync : network backup tool usg incremental backup;
cygwin requd for ms client
- > rsync251-2.exe -e ssh -av --delete /cygwin/c
xserver:backup
III.
Hardware Administration
(Device Admin.)
a.
Hard Drive Admin
IDE (Integrated Drive Electronics): -
A standard electronic interface used between a computer
motherboard's data paths or bus and the computer's disk storage devices.
[whatis.com]
|
SCSI (Small Computer System Interface) : -
Set of
evolving ANSI standard electronic interfaces that allow
personal computers to communicate with peripheral hardware
such as disk drives, tape drives, CD-ROM drives, printers, and
scanners faster and more flexibly than previous interfaces;
Developed at Apple Computer.
[whatis.com]
|
- setserial (get/set Linux serial port info)
- /proc/interrupts : interrupts
currently in use
- /dev/ttyS0 = 1st serial port (COM1 in MSDOS)
- /dev/null = byte sink
- /dev/zero = byte return
- /dev/mem = system physical memory
- serial, parallel + joystick ports supported;
serial UART types 8250, 16450, 16550, 16550A supported
- lspci: of pciutils pkg;
"General Setup" > "PCI Support" enabled in kernel.
$cat /proc/pci info on installed PCI devs.
$lspci -v for more verbose output
%cat /proc/interrupts list interrupts in use;
o/p =
IRQ no.interrupts processed ... short name of HW dev. ;
multiple devs can share same IRQ
%cat /proc/ioports: list IO ports in use
- setpci: change PCI dev. settings
- USB = Universal Serial Bus, EHCI, etc.;
%mount -t usbdevfs none /proc/bus/usb
to mount USB dev. fs
or add
none /proc/bus/usb usbdevfs defaults 0 0
to /etc/fstab
Definition of Block Device : - Data read and written to the
device (usu.a peripheral, eg. HD) as entire blocks of device-determined
size (usu.512b-32kB); denoted by `b' in first col. & canbe randomly
accessed.
eg:
brw--rw----- 1 root disk 3, 0 May 19 1984 /dev/hda
(3, 0 are major device nos: a particular driver in the kernel;
Minor device no. represents a particular device handled by that driver)
Definition of Character Device : -
read/written sequentially
1 byte (ie. char.) at a time in order
(eg. modem, serial port); usu.
denoted by
`c'.
|
- Add Device driver: %mknod -m 666 /dev/bogus b 42 0
where b = type, b or c, and 4 = major no, 0 = minor number
b.
Sound+Video Cards
- sndconfig : Probes and configures sound card.
- minicom (verify modem)
- $modprobe
- $modprobe snd-card-intel8x0
- /lib/modules/2.2.14-12/misc/
- $aumix (test sound): check
`mute' option turned off.
- $playmidi
- $play
- $sox
- "/dev/dsp: Device or resource busy"
is gtv and xmms error msg:
$ /usr/sbin/lsof | grep /dev/dsp or
$ /usr/sbin/lsof | grep plaympeg
then kill all processes locking the audio dev.
[18 Oct 2001]
c.
Printer Admin.
- lpc (`line printer control'):
can rearrange order of queue jobs, can disable/enable printer
- lpq (`line printer queue')
- lpr (`line printer request')
- -b (suppress `banner') |
-# = -K (no. kopies) | -m (`mail' error msgs) |
-T xtitle (specify `title') | -w (`width')
- lprm (`line printer remove'):
eg. $lprm -a (attempt to remove all jobs)
- printtool (GUI)
- /etc/printcap (`printer capability'
database): read once by lpd at startup
- /etc/lpd.perms (LPRng lpd permissions control
file): affects lpc, lpq
- /etc/lpd.conf (`line print daemon cfg'
file): 180 options configurable.
d.
Modems
: SLIP & PPP
PPP (Point-to-Point Protocol: - A communication protocol
|
- Two Authentication Protocols supported by PPP:
- CHAP (Client Handhake Authentication Protocol):
cf. /etc/ppp/chap-secrets
- PAP (Password Authentication Protocol):
cf. /etc/ppp/pap-secrets
- /etc/sysconfig/network-scripts/ifcfg-ppp0 -
options passed to pppd daemon.
- $ifup ppp0 - start ppp
interface.
- winmodems are usu. incompatible with linux
IV.
User Administration
a.
Users and Passwords
- useradd (`add new user')
- -d (home `dir') | -c (`comment':
name of user)
- %useradd -c "Dr. Samar Abbas" -d /users/samar samar
%passwd samar
(add user samar, setting his password,
also possible to use adduser )
-
%adduser -d /users/samar samar; passwd samar
- /etc/skel : template files
(eg. .profile) automatically copied to user's home dir.
- userdel (`delete
user')
- -r (`recursively' remove all files)
- #userdel -r samar (remove user)
- passwd (`change password')
- 6 <= xpasswd <= 255
- 1 <= non-alphanumeric char.
- non-dictionary word; not login; not similar to current passwd
- pwconv (`convert password
to shadow')
- pwunconv (`unconvert password')
- usermod
- -G xgroup
- %usermod -G floppy samar (user floppy even away from
computer)
- linuxconf
- /etc/passwd: general syntax-
1 2 3 4 5 6 7
free text home dir shell
abbas:x:254:202:Samar Abbas:/user7/abbas:/bin/bash
#samr:x:500:501:Samar Abbas:/home/samarx:/bin/bash (disabled user)
- # in front of username temporarily suspends user.
- id :
1 <= uid(sys.users) < 499;
1 <= gid(sys.grps) < 499;
- whoami (print eff. uid): not equal to who am i:
[ zircon > who am i
zircon!lpat pts/2 Aug 7 23:40
[ zircon > whoami
lpat
- users
- who
- w
- groups :
gid >= 499
- /etc/profile: global user profiles
b.
Groups
- group example (zircon Feb.5, 2002):
1) Backup: %cp /etc/group /etc/group.bak; cp /etc/passwd
/etc/passwd.bak
2) /etc/group modified:
lpat:x:502: ---> lpat:x:502:
ubhan:x:503: ---> ubhan:x:503:lpat
3)[ubhan] %chmod 770 ~/ ;
[lpat] %newgrp ubhan & lpat could write to ubhan's files
4) /etc/group modified:
lpat:x:502:ubhan
then ubhan could write to lpat's 770 files
but ubhan had to do `newgrp lpat' first.
- newgrp
- groupadd
- groupmod (`modify group')
- groupdel (`delete group')
- grpconv (shadow group)
- grpunconv (`unconvert group')
- /etc/group: group info
- /etc/gshadow
c.
User Quotas
- quotaon (enable
disk quotas for specific filesystems)
- -a (`all' fs) | -v (`verbose') |
-u (manipulate `user paths') | -q (manage group `quotas')
- /quota.user (at root of filesys)
- /quota.group
- edquota (`edit quota')
- only ext2fs supports quotas,
vfat, iso9660 do NOT support quotas
V.
System Accounting
a.
Logging
- syslogd (`system log daemon')
- /var/log/messages :"System Log" readable by root
only.
- logrotate (`log rotator')
- logger (`logger')
- lastlog (`last login')
- last (`last login')
- lastb (`last bad login
attempts')
- who (`who')
b.
Process Management
- crontab (`cron table')
- /etc/crontab
- syntax:
- minute 0-59
- hour 0-23
- day of month 1-31
- month 1-12
- weekday 0-6: 0 = Sunday.
- 44 14 * 11 wed date :
executes [command] on 2:44 pm every Wednesday in November.
- 0 20 * * 1-5 calendar : runs calendar every 20
minutes starting midnight Mon and ending 11:40 on Fri.
VI.
Kernel Admin
a.
Kernel Modules
Kernel : Abstraction layer interface between raw HW and
appl. programs; the "heart of linux"
[devWorks.102.II]
Monolithic Kernel : support for all HW, NW protocols & FS built
within single file
Modular Kernel : kernel loads required modules (drivers built as
object files) dynamically; saves RAM
Definition of Module : - A Loadable Device Driver,
ie. added to or removed from memory at run-time,
a single object containing all of the code for the driver,
eg. /boot/*.o
[welsh.170]
|
- Linux supports UP (uniprocessor) and
SMP (symmetric multiprocessor) systems, the latter requiring special
compilation.
- tcp/ip stack is in the kernel
- /sbin/init = 1st process run by kernel;
init starts additional processes as spec'd in
/etc/inittab [devWorks.102.II]
- autocleaning: automatic diassociation and unloading from
memory of an unused loaded kernel module.
- /lib/modules/x.y.z/: where modules live;
each module = xmodule.o
- essential functinalities must be in kernel = disk controller, drives,
root fs
- /usr/src/linux: kernel src pkg
- http://www.kernel.org: official kernels released
by Linus or Marcelo
- lsmod (list loaded modules; ie. those
currently resident in kernel)
- insmod (install module into running kernel):
eg. %insmod /boot/ftape.o ;
insmod cmds customarily included in rc scripts
[welsh.170].
- rmmod (remove idle module);
eg. %rmmod ftape
- modinfo (kernel module info)
- -a (show `author') | -d (show
`description') | -n (show fileName) | -p (show
parameters)
- modprobe (probe+install module+dependants)
- -l (`list' modules) | -r (`remove'
modules)
- modprobe > insmod : required underlying
modules loaded + /etc/modules.conf consulted for default params +
a list of modules tried
- depmod (show module
dependencies + create db of dependancies)
- /etc/modules.conf = /etc/conf.modules
(flavour-dependant): "keep" line: default path info to be retained
- /lib/modules/2.2.16-22 : kernel modules home
- /usr/src/linux : kernel headers +
kernel-source pkgs found here
- version no.: linux-2.2.16:
major_ersion 1.minor_version 2.patch level;
extraversion no 2.2.16-22smp by RHL (22smp)
to distinguish various configs of same version
- even-no minor versions (eg. 2.2.x) STABLE;
odd-no minor versions (eg. 2.3.x) DEVELOPMENTAL
- 2.0 kernel: external kerneld daemon loads + unloads modules;
2.2 kernel: internally loads + unloads using modprobe
b.
Boot Managers: LILO etc.
Definition of Boot Loader : -
A small program located in boot sector to allow user to choose an OS
to boot into
[certifyexpress.com]
|
- loadlin (msdos
boot loader)
- lilo; /sbin/lilo (`Linux
Loader')
- -q (`query map'; /boot/map) |
-d n (`delay in deciseconds') |
-R (set default command for next `reboot')
-t (`test only') |
-u -U `(uninstall')
- $lilo (run lilo)
- $lilo -D dos (change default boot partn)
- /etc/modules.conf
- /etc/lilo.conf : %/sbin/lilo after
changing lilo.conf
/etc/lilo.conf [welsh.117]
|
boot = /dev/hda # Dev. where LILO should install itself
compact # Optimization for faster speed
install = /boot/boot.b # File containing the boot sector
# to use on the MBR
map= /boot/map # Map File created by LILO on installatn
prompt
timeout=50
message=/boot/mesage
linear
default=linux
image=/boot/vmlinuz-2.2.16-22 # Location of kernel image
label=linux # Name for LILO boot menu
read-only
root=/dev/hda2 # Location of root partition
vga=ask # Ask for VGA text mode
|
- vga option values =
vga=normal (80x25) | extended (132x60) | ask | integer
(1,2,etc.) .
- add loader=/boot/any_d.b to reportedly dos stanza
to boot msdos located on the second drive [welsh.118]
- for Secondary Boot Loader: add
boot = /dev/hda2 to /etc/lilo.conf
and set the linux partiton to `active' using DOS/Linux
fdisk [welsh.119]
- windows boot manager
- c:\config.sys [pcq march 2001].
- c:\boot.ini [win2k faq].
In the Linux shell:
#lilo -s /tmp/linux.bin
Then copy linux.bin from /tmp to the
Windows boot harddisk.
c:\boot.ini [win2k faq]
|
C:\linux.bin="Linux"
Example:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(1)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(1)partition(1)\WINNT="Microsoft Windows 2000
Professional" /fastdetect
C:\linux.bin="SuSE Linux 7.1"
C:\="Microsoft Windows Millennium"
|
This boot.ini boots Windows Millennium and SuSE Linux from the
first harddisk and Windows 2000 Professional from the second
- dmesg
- %cat /var/log/messages = $dmesg
- shows dev's found on boot
c.
Initialization and Shutdown
(Boot Process)
- init (`initialize')
- -q (boot into single user mode)
- $/sbin/init
- /etc/inittab
/etc/inittab
|
pf ... # PowerFail
bw ... # BootWait
s0 ... # System Init.
id:5:initdefault: # InitDefault : Default runlevel
si::sysinit:/etc/rc.d/rc.sysinit # System initialization.
x:5:respawn:/etc/X11/prefdm -nodaemon # run xdm at level 5
|
Runlevel : - A software configuration of the
system
which allows only a selected group of processes to exist.
States that control what a machine can do.
[man init]
|
- runlevels :
- 0 - powered off
-
1 - single user mode
-
2 - multiple user mode without NFS
-
3 - multiple user mode with NFS
-
5 - X environment
-
6 - reboot
- S or s - bring to single user mode, for scripts entering
runlevel 1 [man init]
- S vs. 1 : further users cannot login in S.
- telinit (`tel-initialize')
(link to init)
- 0-6 (`runlevel': tell init to go to
runlevel)
- $/sbin/telinit q
(tell init to re-examine /etc/inittab)
- $telinit 5
(go to runlevel 5 without reboot)
- shutdown (`shut down')
(%shutdown -h now = %halt
- halt (`stop')
- runlevel (show currt + previous runlevel)
- ntsysv (services to start on boot)
- %ntsysv --level 35 (2 levels, deflt = current
runlevel)
- chkconfig (which service at which runlevel)
- #chkconfig --list | grep swat
- #chkconfig --level 35 swat on
(turn on swat for levels 3+5)
d.
Kernel Building
- make clean: deletes results of previous builds
= make mrproper: mrproper target def'd in Makefile which restores
sources to clean state
- [/usr/src/linux]~$ make mrproper
- [/usr/src/linux]~$ cp -p configs/kernel-i386.config
arch/i386/defconfig
- make oldconfig : recover default kernel config
- make xconfig: X-based GUI (best) |
make menuconfig: GUI |
make config: interactive cmd-line oriented kernel
build
- make menuconfig:
y | n | m (module) |
<> deselected | <*> tobe compiled into kernel img |
<M> tobe compiled as module
(for sections cf. run)
- /usr/src/linux/Makefile:
EXTRAVERSION = -16sam
- make dep: generate dependancy info, create kernel depenancies
+ propagate
top-level configs to subdirs
- make bzImage : compile the bin.kernel img;
creates /usr/src/linux/arch/i386/boot/bzImage
and /usr/src/linux/System.map
- make modules :
%make modules && make modules_install :
compile & install modules from
/usr/src/linux/modules to
/usr/lib/2.2-16/
- cp /usr/src/linux/arch/i386/boot/bzImage
/boot/vmlinuz-2.2.16-22sam :
copy compressed kernel
- cp /usr/src/linux/System.map /boot/System.map-2.2.16-22sam
- make modules_install
- mkinitrd /boot/initrd-2.2.16-22sam.img 2.2.16-22sam :
create RAM disk image
- /etc/lilo.conf: 2 new lines
"image=/vmlinuz2" & "label=newlinux" added, run
%lilo -v -v
VII.
Security
a.
PAM
- /etc/pam.d:
auth-type ctrl-flag mod-path & args
account|auth|password|session
2requisite|required|sufficient|optional
- /etc/pam.d/other :
(cfg file for all services not having their own /etc/pam.d/xyz
file): modules default in /lib/security/
References
- [devWorks.102] = `LPI certification 102 Exam Prep',
parts I-IV, IBM developerWorks.
http://ibm.com/developerWorks
- [nutshell] = `Linux in a Nutshell,' by Stephen Figgins,
Ellen Siever, Stephen Spainhour, Jessica P. Hekman, 3rd ed. 2000,
Oreilly.
http://www.oreilly.com/catalog/linuxnut3/
- [win2k faq] = `Windows 2000 FAQ,'
http://www.ntcompatible.com/faq230.shtml
- [installguide] = `Red Hat Linux Installation Guide'
http://www.redhat.com/support/manuals/RHL-7.1-Manual/install-guide/
- [mandrakeuser] = Mandrake User - a good resource on
emerencgy recovery.
http://www.mandrakeuser.org/docs/admin/index.html
- [mudlog] =
`Using cron basics' by Mo Budlong, Unix Insider 8/25/00,
http://www.itworld.com/Comp/2378/swol-0825-unix101/
- [welsh] = `Running Linux', Matt Welsh, Lar Kaufman, O'Reilly
Publishers.