Linux General
Commands
du -hx --max-depth=1 xauth merge ~/.Xauthority 2>&1
Current kernel boot parameters
cat /proc/cmline
Find a running process The first character in brackets is the key, let's you avoid the grep -v grep, etc.
ps aux (or -elf) | grep '[a]ny_.*_process'
File/directory with spaces or special characters:
cd dir\ with \ spaces cd ./-dont_do_this
For Loops
for i in item1 item2 item3 ; do something ; done for i in `cmd` ; do something ; done for i in {1..9} ; do something ; done for i in `seq start increment end` ; do something ; done for ((init, condition, increment)); do something ; done
Fixing filesystem errors:
Ext3 | fsck -y {mount point} |
GFS | gfs_fsck {mount point} |
Bad superblock errors:
Ext3
- dumpe2fs {mount point}
- In output look for “Backup superblock”
- e2fsck -b {backup superblock} {mount point}
Determine if disk is dirty and fsck required:
Look for state not equal “clean”
dumpe2fs {path_to_block_device} | grep state
Set
set -o vi sets editor to vi set -vx sets command tracing (+vx to turn off)
Select
select i in list ; do something ; done
Telnet
Escape out of telnet or Xen console = Ctrl+]
AWK
awk -F{delim} '/search_pattern/ { print $1 }'
Job Control
Background running job
- xeyes
- ^Z
- bg
Less
vi from less/more = v
Boot Issues
- No boot - grub prompt
- rescue mode
- grub-install boot_device (ie /dev/sda)
- No boot - corrupt grub
- root(hd0,0) = hd#,part#
- setup(hd0)
- exit
Cron
crontab: minute hour dayofmonth month dayofweek command
Calc
Calc (simple):
echo $[ a + b ]
Calc (better):
echo "a / b" | bc
Big File
Make big file:
dd if=/dev/zero of=bigfile bs=1k(1M) count=N
SSH
SSH tunnelling on gumstix:
ssh -L 443:192.168.1.100:22 -g localhost
remote:
ssh mtonneson.homelinux.org -p 443
RHEV
HOST: RHEL AP 5.4 with KVM and libvirt installed.
- Have to do a yum erase libvirt for RHEV-M install to work.
- Failed to create RHEVM bridge - needed to reinstall.
- No message or warning regarding auto-rebooting RHEL HOST - NOT GOOD!
- Reinstall from “click here” does not work - endless loop - must activate-
- must put into maintenance - then can't connect. Only way is to deleteand re-add.
- FC - powerpath works but can't filter out emcpower in lvm.conf or thedisk creation will fail, in RHEV-M
RHCE
RHCE Study Topics
Local users & groups Cron/crontab tcpwrappers SELinux NFS server vsftpd sendmail/postfix apache dhcpd
Boot Process
- Kernel loads
- Writes to /var/log/messages
- Starts init daemon
- Reads /etc/inittab
- Runs /etc/rc.d/rc.sysinit
- Runs /etc/rc.d/rc.local
- rc.sysinit logs to /var/log/dmesg
- Additional logging to /var/log/boot.log
man pages
man1 | cmds all users can access |
man2 | kernel errors & system subroutines |
man3 | library of subroutines |
man4 | network protocols, devices and drivers |
man5 | formatting info |
man6 | games and demos |
man7 | misc |
man8 | cmds only root can access |
man9 | linux kernel |
man -a <keyword> = shows all pages matching keyword
Apache
program root - usually /etc/httpd/conf or /usr/local/apache web root - usually /home/httpd or /var/www/htdocs config file - httpd.conf
apachectl - control script
- start/stop/restart
- graceful - continues current child procs before restart
- configtest - tests syntax of httpd.conf
- status/fullstatus
inetd
inetd
/etc/services - lists network services and ports /etc/inetd.conf - config file
xinetd
/etc/xinetd.conf - config file /etc/xinetd.d/ - service specific parameter files
Debian
Debian package mgmt
dpkg --install - install package --remove - remove package --print-avail - general info about package --list - list installed packages --listfiles - list files installed by package --status - full package details --search - which package owns/installed file
/var/lib/dpkg/available - available packages /var/lib/dpkg/status - package status
dselect - menu driven version of dkpg apt-get - cmdline package installer alien - package converter
ARCHIVE INFO BELOW
ARCHIVE INFO BELOW
RHEL 3
RHEL3 local login w/o LDAP:
Try adding the following to nss_initgroups_ignoreusers line to the file /etc/ldap.conf:
Just assume that there are no supplemental groups for these named users nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,ntp,smmsp,xfs
RH online virts
RH Virtualization
aws.amazon.com ec2 SPEC Virt overt.et.redhat.com
LDAP
passwd: ldapsearch -x -v -h directory -b “o=domain.com” “uid=UID”
CDROM from HP iLO
VM install = cdrom://hdc:/mnt/source
VMWare
vmware-cmd -l | xargs -ipath -t -e vmware-cmd path getpid
Installing VMware Tools in a Linux Guest
Choose Settings > VMware Tools Install, then click Install. This step connects the virtual machine's CD-ROM drive to an ISO image file on the ESX Server machine.
In your Linux guest, become root, mount the VMware Tools virtual CD-ROM, copy the installer file from the virtual CD-ROM to /tmp, then unmount the CD-ROM.
mount -t iso9660 /dev/cdrom /mnt cp /mnt/vmware-linux-tools.tar.gz /tmp umount /dev/cdrom
Untar the VMware Tools tar file in /tmp and install it.
cd /tmp tar zxf vmware-linux-tools.tar.gz cd vmware-tools-distrib ./vmware-install.pl
Note: When installing VMware Tools in some versions of Linux, the installer will need to recompile VMware Tools. For this to work, you need to have a C compiler installed in the guest. In some cases you may get compiler warning messages during the VMware Tools installation. However, the control panel and drivers still work correctly.
Follow the remaining steps. Choose directories for the various files. Choose a display size for the virtual machine. Enter the number for the choice and press Enter. If you wish, start X and your graphical environment and launch the VMware Tools background application.
vmware-toolbox &
Note: If you created this virtual machine using the vmxnet driver, you now need to run netconfig or another network configuration utility in the virtual machine to set up the virtual network adapter.
HP RSM
During operation, the service logs events from the infrastructures on tty1 through tty10 (if available), as well as /var/log/messages. If this produces too much text on the screen, adding the option “-V0x0” to the hprsm startup script will silence the text.
Host rename
Server rename
/etc/hosts /etc/sysconfig/network /usr/openv/netbackup/bp.conf Restart nscd service
Samba client
smbclient //windows/share -W activedirectory.domain.com -U username mount -t smbfs -o username=user,workgroup=activedirectory.domain.com //server/share /mnt/smb
RHEL 4 upgrade on VMWare
Upgrade VM RHEL4.0 → RHEL4.2
- cp {BusLogic}.ko /root/
- shutdown
- Connect floppy and CD
- LSILogic → {BusLogic}
- Update to RHEL4.2 (linux dd text)
- boot linux rescue
- cp /etc/modprobe.conf.anacbak /etc/modprobe.conf
- add 'alias scsi_hostadapter {BusLogic}' to modprobe
- cat /etc/issue.rpmsave > /etc/issue
- cp /root/BusLogic.ko /lib/modules/2.6.9-22.EL/kernel/drivers/scsi/
- mkinitrd -v -f /boot/initrd-2.6.9-22.EL-buslogic.img 2.6.9-22.EL
- edit grub.conf - add new initrd
- reboot
- /usr/bin/vmware-config-tools.pl