HOW-TO

This Linux guide is my own notes on Linux, for stuff that I did not like to documents that I have found on the internet. It is RedHat centric.

 

Linux Admin 101

Linux init mode are not "cumulative". So, if default init is 5, script in run level 3 would not be run. If adding a Start script, may want to add them in both in rc3.d and rc5.d, unless it is really only wished to be available at one of the run level and not the other. Kill script should be placed in rc6.d, which shutdown/reboot scan.

Single User Mode

To boot into single user mode for maintenance,
enter "linux single" or "linux emergency" at the LILO boot: prompt.

If using GRUB, then, at the menu for choosing kernel, do:
 hit 'e'
 then arrow down to the kernel line
 hit 'e' again
 add 'single' to the end of the line
 hit enter
 hit 'b' to boot
 lather, rinse, repeat

Core dump

Linux kernel panic does not core dump to a file.
it will print output of the kernel core dump result to the stdout device:
a vga screen or a serial console.  
To setup serial console, do:
console=ttyS0,115200 console=tty0
but this would mean console boot/shutdown/panic message will no longer
be send to the VGA, but to serial port.  VGA may get a spawned
login prompt after OS is up.

Linux "deviation" from Solaris

Some of the most notable things that Linux does rather differently than Solaris or traditional Unix.

64-bit Platforms

RHEL 3.0 and 4.0 maintains simultaneous relese/update levels for 64-bit platforms as their popular 32-bit x86 OS. Just need to get the "special" distro ISO to install on the 64-bit hardware and it will be good to go. Not all the AS/ES/WS flavor maybe available to all platform.
RHEL 4.0   	

rhel-ia64-as-4		Red Hat Enterprise Linux AS (v. 4 for 64-bit Intel Itanium)
rhel-x86_64-as-4	Red Hat Enterprise Linux AS (v. 4 for 64-bit AMD64/Intel EM64T)
rhel-ppc-as-4		Red Hat Enterprise Linux AS (v. 4 for 64-bit IBM POWER)
rhel-s390-as-4		Red Hat Enterprise Linux AS (v. 4 for 31-bit IBM S/390)
rhel-s390x-as-4		Red Hat Enterprise Linux AS (v. 4 for 64-bit IBM zSeries)
rhel-i386-as-4		Red Hat Enterprise Linux AS (v. 4 for 32-bit x86)   [typical intel pentium 4/80x86 release]
rhel-i386-ws-4		Red Hat Enterprise Linux WS (v. 4 for 32-bit x86)

RHEL 3.0 	

rhel-ia64-as-3		Red Hat Enterprise Linux AS (v. 3 for Itanium)
rhel-x86_64-as-3 	Red Hat Enterprise Linux AS (v. 3 for AMD64/Intel EM64T)   
rhel-ppc-as-3		Red Hat Enterprise Linux AS (v. 3 for iSeries and pSeries)

Initial Setup

Things to keep in mind when installing Linux.

For RHEL 3 and 4, once the OS is installed, additional international language support cannot be added (easily), RH recommends a reinstall. So, if you might need to support any given natural language, install it when you do the system install!
Starting with Fedora Core 4, additional language can be added from system-configure-packages.

Updating Machine

Binary Compatibility

The Linux community embraces the source code, and compatibility between different release is to recompile the code. Binary compatibility is not maintained between different (minor) releases of the glibc. So, be careful not to update the libraries, kernels, and gcc compiler unless you are ready to recompile everything in the system! (And if you have 3rd party libraries dependencies, then really think twice before changing the system library level).
If using up2date for RHEL, it would be safe as only compatible updates are listed in the channel. I would assume the same is true for yum.
(Add chart about system levels, see gmail).

XDMCP

enabling XDMCP will allow program like X Manager to use browser and login via virtual screen, 
fully X Manager, Remote Display Manager style, rather than having to login 
using ssh and start VNC first.  However, VNC is nicer in that 
the session stays on the server, XDMCP, if client is a laptop and disconnect, 
session will be reset.
Note that botyh XDMCP and VNC are insecure by default!

vi /etc/X11/fs/config
# don't listen to TCP ports by default for security reasons
###no-listen = tcp
### commented out line above to enable XDMCP

service xfs restart

vi /etc/X11/xdm/xdm-config
! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
!!!DisplayManager.requestPort:  0
!!!Line above commented out to enable XDMCP


vi /etc/X11/xdm/Xaccess
# *                                     #any host can get a login window
*       # have start by itself will allow all host to get login window


vi /etc/X11/gdm/gdm.conf
[xdmcp]
###Enable=false
Enable=true
### XDMCP is enabled using the above clause
### this file need to be updated when GNOME is default windows manager/Display Manager

vi /etc/kde/kdm/kderc
[Xdmcp]
###Enable=false
Enable=true
### XDMCP is enabled using the above clause
### this file need to be updated when KDE is default windows manager/Display Manager

chmod 444 /etc/X11/xdm/Xservers                 # probably correct already
chmod 755 /etc/X11/xdm/Xsetup_0


older config need to update /etc/X11/XF86Config, but circa 2003
most distro use Xorg,

check /etc/X11/xorg.conf
and ensure FontPath uses Xserver:
        FontPath     "unix/:7100"

restart X:
- killall gdm-binary 	# if running GNOME byy default
- ctrl+alt+bacckspace	# if in front of machhing/keyboard
- init 3; init 5	# This may work
- reboot		# :)



LDAP

authconfig 		# TUI, select to use ldap, etc.
			# upon completion, ldap should work for user login.

/etc/sysconfig/autofs	# update BASEDN to define where autofs will look for maps.  eg
			# BASEDN="ou=us,dc=unixville,dc=com"
service autofs restart	# restart autofs to effect the changes

/usr/lib/autofs/autofs-ldap-auto-master		# list all known automount maps from ldap



Kickstart

A step-by-step command listing for setting up kickstart, (hopefully easier to read than Red Hat kickstart instructions, once it is working, tweaking it is much easier to comprehend). ...

Quick Ref

Connectivity (Network)



mii-tool -vv		# determine NIC speed, duplex.

Spawn login session on serial port:
echo "7:2345:respawn:/sbin/agetty -h 9600 ttyS0" >> /etc/inittab
echo "8:2345:respawn:/sbin/agetty -h 9600 ttyS1" >> /etc/inittab

above does NOT redirect VGA to console, to do that, use
(nothing will show on VGA output at boot):
	[check zambeel notes, TBA]

Package/Software management

rpm -ivh [path/file.rpm]     # install rpm, vh = verbose hash for progress monitor
    --nodeps                 # install pkg even if fail dependencies check
    --noorder                # 
for File in `ls -1`; do rpm -ivh --nodeps  $File; done
                             # install all rpm in a dir eg cdrom
                             # it seems that already installed packages will be overwritten by default
                             # there is no "force" options needed to overwrite package to redo bad install.

rpm -qa                      # query for all installed rpm packages in the machine
rpm -qa | grep glibc         # query for glibc version
rpm -qpl [rpmfile]           # list where are the files installed to.
rpm -ql  [pck_name]          # query installed package to see where files were send to
                             #  (partial package name will work). 
rpm -qi                      # query info of a specified package.
rpm -qf /path/file           # query see which package installed the given file 
rpm -e [pck_name]            # erase pcka_name as listed in rpm -qa from computer.  stop if it break deps
rpm -e [pck_name] --nodeps   # forceful erase, even if it breaks dependencies.
-Uvh [pkgname]               # Upgrade (eraasing old packages, which install don't do)
                             #  h= print hash sign as it goes, 
                             #  v = nicely formated output
rpm -Fvh *.rpm               # Freshen/update all rpm if an older version is installed
                             # eg.  Refresh from AS 4.0 Update 1 to Update 2 via -F of all the rpm from cd.
-V [pkgname]                 # Verify integgrity of installed package.



System Services

chkconfig                       # Easiest way to manipulate rc services, 
                                # bettter than ntsysv or mangling xinetd file manually!
chkconfig --list xinetd         # see if xinetd service is enabled
chkconfig --list rsh            # see if specific xinetd service is running, eg rsh
chkconfig --list telnet         # see if specific xinetd service is running, eg telnet
chkconfig --list autofs         # see if specific xinetd service is running, eg autofs automount
chkconfig --list amd            # see if specific xinetd service is running, eg amd automount
chkconfig --add ypbind		# register ypbind into service db
chkconfig --level 345 ypbind on	# enable ypbind on run level 3,4,5
chkconfig --level 345 rsh    on # enable rsh on run level 3,4,5, starting the service now also.
chkconfig --level 35  httpd  on # enable httpd in init 3 and 5
chkconfig vsftpd on             # enable  ftp  as xinetd controlled service (level 2,3,4,5)
chkconfig talk   off            # disable talk as xinetd controlled service (all level)


service iptables stop           	# temporary stop firewall service (till reboot)
service iptables status         	# check running status 
chkconfig --level 345 iptables stop 	# disable firewall service from starting on run level 3,4,5
					# RHEL 2.1 use ipchains.


for SVC in `ls -1 /etc/xinetd.d`; do chkconfig --list $SVC; done
                                # see which xinetd service is on or off.
for SVC in `ls -1 /etc/init.d`; do chkconfig --list $SVC; done
                                # see which init service run when
				# but some file are not actually service

serviceconf			# GUI, see what service run at what run level.
redhat-config-services 		# same as above
ntsysv 				# TUI of serviceconf

LVM


File System:	FS: one ext3 fs on top of a given LV.
Logical:	LV: many virtual/logical partitioins on top of a single VG.
Aggregation:	VG: volume group, encapsulate many PVs. 
Physical:	PV: whole disk or partition



system-config-lvm			# GUI for LVM.  Pretty neat.
lvm					# interactive shell for LVM, all cmd avail as stand alone.

pvdisplay				# display info such as PV size, PE size, avail PE.
pvcreate /dev/sda2			# create pv on partition, def RHEL 4 setup
pvcreate /dev/sde

vgdisplay				# display vol grp info such as lvm/lvm2.
           -v				# list all LV on the vol group, which PV it uses.
vgcreate VolGroup00 /dev/sda2		# create a new VG, this is the def in RHEL 4 setup.
vgextend
vgreduce

lvscan						# brief list of LV and their size.
lvdisplay					# show info of all LV: path, LV size, Status, which VG it resides in.
lvdisplay /dev/VolGroup00/LogVol01		# display specific info of a single LV (instead of all LV)
lvcreate -n LogVol00 --size 500M VolGroup00	# create a new LV called LogVol00 of size 100 MB

lvextend -L+100M /dev/VolGroup00/LogVol01	# extend existing LV (hosting swap of fs) by given size
						# -L20G would set exact size of 20G
lvremove					# remove unused LV

mkfs -j /dev/VolGroup00/LogVol02	# create fs on the LV (-j will use jounal, ie ext3)
					# NOTE: old kernel may give error.  2.6.16-1.2069_FC4 works.
mkswap /dev/VolGroup00/LogVol02		# create swap partition on the LV 
					# Doesn't seems to work, actually confuses kernel to the point that
					# all subsequent mkfs command will also be refused.  BUG??!!


e2fsadm					# extend or reduce fs and LVM1 at the same time 
					# but not avail with LVM2 (eg FC4, RHEL 4)

ext2online /dev/VolGroup00/LogVol00	# extend ext3 FS online (for LVM 1 or 2)
ext2online /				# can use mount point instead of dev path
ext2resize				# change ext2 FS after it has been UNMOUNTED.  ?? does not exist??


resize2fs /dev/VolGroup00/lv101 1000000	# reduce ext2/ext3 FS to size to exactly 1,000,000 bytes. 
					# UMOUNT+FSCK FIRST
lvreduce -L1G /dev/VolGroup00/LogVol00	# reduce the LV the FS is on 
					# (Don't make it smaller than FS size!)
					# After these procedure, there maybe some left over space,
					# if using ext3, can use ext2online to reclaim the space.
					# ext2 somehow can't be re-expanded, use ext3 !!
					# use tunefs -j to convert to ext3 :)
	

/etc/fstab				# typically list which LV dev used by which FS
??					# no cmd to display what LV is being used by which FS :(


http://www.redhat.com/magazine/009jul05/features/lvm2/

Kernel


Kernel Compilation


compiling linux kernel  
(similar procedure for old 2.4, new 2.4, and 2.6)

download kernel source (srpm, rpm -ivh ...)
Get the version applicaple to the base OS (eg RH 8.0) and kernel similar to the one installed 
(latest maybe okay, but then other support may not be available).

[
For ES2.1/RH7.2, 
building custom kernel just req getting RPMS packages for:
kernel-headers-2.4.9-e.12	(disk1)
kernel-source-2.4.9-e.12 	(disk2)
SRPMS are not needed!  Though there are dependencies such as gcc, glibc-dev, 
kernel dev, etc, which are RPMS, not Source RPMS!
Files from SRPMS/ are not really needed unless really do heavy dev, 
and they do not show up in rpm -qa!
Note that RH does not provide support for customized kernel.
]

cd /usr/src/linux-2.4* [ use /usr/src/kernels/2.6.11-* for FC4 ]

make menuconfig
this lauches a text menu program to createa config file.
* indicates compiled into kernel
M indicates loadable modules.

make xconfig
# GUI, an alnternate to the TUI menuconfig.
# RHEL 2.1 (RH 7.2) GUI is a big grid
# 2.6 kernel is a tree based GUI with lot of explanations; auto compile when done.

make dep; make bzImage; make modules
make modules_install

#make install		# may not be avail.
cp vmlinux... ...

For old machines runing LiLo (RHEL 2.1 and older):

cp /etc/lilo.conf.anaconda /etc/lilo.conf
vi /etc/lilo.conf
/sbin/lilo -v -C  /etc/lilo.conf
to install a new boot loader w/ new config into MBR.


For newer machines running Grub (RHEL 3.0/RH 8.0/Fedora):
grub
/etc/grub.conf (link to /boot/grub/grub.conf).
edit of such file doesn't require lilo install, but then need to reactivate grub...


---

From README

 - make config : standard kernel compiling config.
 - Alternate configuration commands are:
        "make menuconfig"  Text based color menus, radiolists & dialogs.
        "make xconfig"     X windows based configuration tool.
        "make oldconfig"   Default all questions based on the contents of
                           your existing ./.config file.
   
Then do:

make bzImage	# create compressed kernel image
		# files are placed in .../linux/arch/i386/boot/bzImage
make bzdisk	# optional, make boot floppy disk.

make modules 	# needed if anything is in loadable module
make modules_install	# suggested to do backup, but not sure where


Upgrading Kernel


Upgrading RH kernel, just need to get the later RPMS, package format kernel-VER.rpm, and install that.  
No other packages are needed, and no recompiling needed.   It insall a stock RH tested general kernel.

rpm -Uvh new-kernel-ref.rpm
Install stuff like /boot/vmlinux-... vmlinuz-... System.map-... initrd-... 
plus lot of files with version number on filename into /lib, etc

The rpm has to be from RH.  Changes to /boot/grub/grub.conf may be needed.

Easiest is just to use up2date and let it update kernel also, 
then just reboot, it will do all the necesary update and changes.

Kernel Tuning


http://www-106.ibm.com/developerworks/linux/library/l-adfly.html?ca=den-wud
describe the major /proc entries in Linux, what they do and stuff.

configurable params are listed in /proc/sys

viewing the settings: simply cat the desired /proc value, eg:

$ cat /proc/sys/kernel/threads-max
20479
$ cat /proc/sys/kernel/shmmax
33554432

Changes:
Edit /etc/sysctl.conf for permanent changes (replace / in path with
. for variable name), or
echo VALUE > /proc/path/param
for one time change.

Alternate "formal" method:
sysctl 		main tool to view/set param
	-a	display parameter and its setting.
	-w	write new value for a given param
	-n 	supress printing of key, just print value.

eg, for viewing:
$ sysctl kernel.threads-max
kernel.threads-max = 20479
$ sysctl -n kernel.shmmax
33554432
$ sysctl -a
...
kernel.tainted = 0
kernel.core_name_format = core
kernel.core_uses_pid = 0
kernel.child-runs-first = 1
kernel.panic = 0
kernel.domainname = brio.com
kernel.hostname = lancer
kernel.version = #1 SMP Tue Feb 11 02:24:10 EST 2003
kernel.osrelease = 2.4.9-e.12smp
kernel.ostype = Linux
fs.aio-max-pinned = 163836
fs.aio-max-size = 131072
...

---
http://groups.google.com/groups?q=increase+thread+linux&start=10&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=jw98.77j.1%40gated-at.bofh.it&rnum=20

A thread where it seems linux kernel only support 1024 threads.
Changes would be in the config file and recompile kernel.
Info on 2.4

http://www.volano.com/linux.html
Older info, 2.2 kernel.
Info about source file to change to alter kernel param.



Linux Desktop Progies

mtv  		mpegtv ($10 shareware req reg) for viewing mpeg video.   mpegtv.com
mvtp		cli of mtv, free.  
		-z = 2x2 zoom.  
		-G+10+10 = place window in specified +x+y geometry 
mpeg_play	bmrc.berkeley.edu mpeg video player.  in old a.out (ZMAGIC) binary though.
		avail for solaris, etc.
mpegplay	mpeg video player found in Knoopix distro.


mpg123		cli for playing mp3 audio
mpg321		drop in replacement for mpg123
xmms		winamp like mp3 player (GUI for mpg123?)

kate		KDE editor w/ many extras, like CLI window, mgnt tabs, somewhat like Visual Studio editor

---

fsview			# A GUI to see directory/file space usage, kinda interesting.
redhat-logiviewer	# GUI tool to parse many diff logs
authconfig		# change Login Auth Methods (NIS, LDAP, etc)




Links

Stress test program, to help diag nasty hardware problems:


TBD



# cmd.linux.ref

# some content formerly adapted from cmd.admin.ref.

************************************************************
Red Hat 4.0   (and not available in 3.0)
************************************************************
/usr/sbin/system-config-kickstart	kickstart configurator.
system-config-netboot			pxe, tftp boot setup
system-config-language			GUI language config tooll for the machine

many of these system-config-* had been named redhat-config-* in RH 3.0


************************************************************
Red Hat 9.0    2003/07
Also for RH 3.0 (and presumably available in RH 4.0)
************************************************************

yum			# yellow dog update modified, better rpm updated than up2date
			# run cmd by itself will do all update automatically.
			# not installed by default in RHEL 4, only in FC.
yum update		# can be added to cronjob for auto update
yum list		# list avail pkg and version number
yum list  autofs	# list installed and avail pkg/ver for the pkg autofs
yum info [pkgname]	# only display info of avail packages, opt followed by pkg name.
		

/etc/X11/XF86Config	# config file read by X server.
redhat-config-xfree86	# config tool to create XF86Config, try system-config-display in ES 4.0 and later.
redhat-config-*		# lot of red hat gui config tool.
nautilus		# file explorer
gqview			# acdsee like image viewer

up2date			# GUI/CLI program to download patches, need RH registration.
up2date ypbind		# ypdate ypbind client package to latest version
#up2date nis		# update the nis package to latest version (??)
up2date libstdc++-3.2.3-42	# update a specific rpm
up2date -l		# list available downloads
up2date -d		# download patches (as per config)
up2date -i 		# install downloaded patches
up2date --config	# run configuration (GUI or TUI), register machine, set exclusion, etc

hwbrowser		# GUI hardware browser, in /usr/bin


************************************************************
Red Hat ES 2.1  (7.2 base)
************************************************************

/usr/sbin/setup		# rh version of aix smitty, not all that.

gnorpm				# GUI rpm manager, not in 3.0 or 4.0 (/usr/bin)

************************************************************

/etc/sendmail.cf
edit DS line to read
DSsv-smtp.hybridauto.com
and sv-smtp will become the smarthost that will be used to realy all the outbound mail.


linux adding route cmd:

route add default gw 192.168.1.1

route delete -net 172.16.16.0 netmask 255.255.255.0 eth3
route add -net 172.16.16.0 netmask 255.255.255.0 gw 172.16.0.1 eth2
(but going out from first interface)
route add -net 172.16.16.0 netmask 255.255.255.0 gw 172.16.0.1
metric 1 dev eth2
route add -net 172.16.16.0 netmask 255.255.255.0 dev eth3


ypcat (group, passwd)
ypstart		# linux
ypbind
ypinit 		# client, specify machines to bind to
		# server, specify whether master or slave
		# Often messed up client, "up2date yp" to ensure running latest code with bug fixes.
ypwhich		# tell what NIS server machine is bound to.
passwd
yppasswd (obsolete, for combatibility only)

ypcat -k auto.master	(-k to display the key name too!)
ypcat -k auto.direct	(the direct map, use /-)


/etc/init.d/autofs	# most standard automount from auto.master, etc.  
			# /net need to be enabled by uncommenting entry in /etc/auto.master .
			# Some version of autofs (eg RH 4.0) have nasty bug that stale NFS mount
			# may result in autofs daemon wanting to erase all files on server,
			# at the very least, seen it cause lot of errors in syslog.

/etc/init.d/amd		# an alternate for automount for /net/HOST/... paths
			# install as up2date am-utils, and enable always start via ntsysv
			# amd maybe a bit older than autofs and performance may not be as good.

/etc/rc.d/init.d/ 
/etc/rc[35].d/		# newer RH system, note that links need exist in 3 and 5

runlevel		# what init level machine currently in
who -r			# RH 9 and AS 3.0 (cmd exist in Solaris)


/etc/inetd.conf
/etc/xinetd.conf, /etc/xinetd.d/

/etc/printcap  or /etc/printer.conf
/etc/motd
/etc/release		# see which os cd was used eg sol 8 01/00 for Jan 2000 build. 

/etc/resolv.conf	# dns setup
/etc/nsswitch.conf	# order of search for files/dns/nis

/etc/fstab



du -kxS * 	= display space usage Summary for only (x) one file sys (ie local)
				linux only
du -kl		= local disk in solaris?

df -kl 		= report fs space usage of local fs, solaris and linux


dhclient	= get dhcp address from server for current client.
ifconfig hme0 dhcp		see purple book.


********************************************************************************
linux:
********************************************************************************

irouted

printtool  (red hat print config)

e-conf		enlightment configuration


linux-conf	most essential config of linux in here
control-panel	old red hat panel, configure network, printer, etc


mkswap  /dev/hdd3			# def RHEL 2.1 swap dev
mkswap  /dev/VolGroup00/LogVol01	# def RHEL 4   swap dev
swapon  -s 				# list swap dev (eg, which LV is swap partion hosted on)
swapon  -a 				# turn on  all swap partitions/files
swapoff -a 				# turn off all swap partitions/files


fdisk /dev/hda

mkfs -t ext3 /dev/hdd2	# create a new fs on ide drive secondary slave.
			# probably only create as ext2;  then:
tune2fs -j /dev/hda3 	# add journaling to it via tune2fs  (manual for ext2 in 2.1)
			# (probably automatic/default in ext3/as 3.0)

e2label /dev/hda3 [Partition-Label]
		view/change label of a partition
		used in /etc/fstab LABEL=/label-name for mounting
		so that mapping does not have to be maintained in fstab
findfs LABEL=/boot	# determine which disk host a given FS with the assigned label.

raven:/usr/local/bin/wshaper  traffic shaping and throttle specific connection bandwidth usage.

ntsysv		text based UI for enabling service such as telnet/rlogin/vsftp, etc.
		Need to have ntsysv-1.3.13.2-0.3.rpm


ethtool -i eth0 	# list ethernet driver info
lspci			# list pci info

xterm, use rxvt color scheme, grey on black. MiscFixed font, 8pt.

**************************************************

[Doc URL: http://www.cs.fiu.edu/~tho01/psg/linux.html]
(cc) Tin Ho. See main page for copyright info.


"LYS on the outside, LKS in the inside"
"AUHAUH on the outside, LAPPLAPP in the inside"