Copyright 2004 John S. Stile http://www.stilen.com/linux101.txt License: GPL: please see http://stilen.com/gpl.txt Changes: I make frequent updates, so please just make a link to this doc. Usage: To use this doc, use the find command on your browser to search the text for your area of interest. ------------------------------------------------- BASIC SURVIVAL STUFF FOR LINUX ------------------------------------------------- vi Open file in vi: vi Once in vi: Go to bottom of doc: g Go to line in doc: g Move to beginning of line: 0 Move to end of line $ Move Down one line: j Move Up one line: k Move rihgt one letter: l Move left one letter: h Find word in doc: / Find again: n Delete a letter, left to right x Delete a letter, right to left x Delete a line & copy into buffer: dd Delete a lines & copy into buffer: dd Copy line into buffer: yy Copy lines into buffer: yy Paste buffer contents : p Paste buffer contents times: p Insert new text mode i Undo: u Redo: R Remove Newline (merge lines) j Save changes to doc: w Save changes to doc and quit: wq Quit without saving: q! Replace old with new on each line :.,$s/old/new/g . means the current line $ means the last line Can also use line numbers Search for word: /search_string Search hilighiting on: : set hlsearch Search hilighiting off: : set nohlsearch Search custom colors: :hi Search ctermfg=6 ctermbg=8 guifg=#10f010 guibg=bg gui=none - Reference: http://www.geocities.com/volontir/ - Reference: http://www.tldp.org/HOWTO/Vim-HOWTO-12.html#ss12.1 - To turn on syntax highlighting, edited ~/.vimrc color=true " We use a vim set nocompatible " " Colo(u)red or not colo(u)red " If you want color you should set this to true " let color = "true" " if has("syntax") if color == "true" " This will switch colors ON so ${VIMRUNTIME}/syntax/syntax.vim else " this switches colors OFF syntax off set t_Co=0 endif endif " ~/.vimrc ends here ------------------------------------------------ emacs: Open file in emacs (pronounced emax) emacs Once in emax: Open anohter file: x f Switch between buffers: +x o Delete text: Go to beginning of a line: a Go to end of a line: e Go to beginning of a buffer: < Go to end of the buffer: > Save changes to a file: xs Save buffer to file: xw Swap current screen with a buffer: x 0; Swap other screen with a buffer: x 1; Bring a buffer to current screen, by name: x b Bring a buffer to current screen, from list: x b -->scroll list with: x o -->select from list: Close buffers, from a list: x k Quit emax: x c ------------------------------------------------- To shutdown the computer halt -or- "shutdown -h 0" -or- "telinit 0" reboot -or- "reboot" -or- "telinit 6" init 0 ------------------------------------------------------- GRUB - GRand Unified Boot Loader -- To install to /dev/hda1: Method1 mkdir /mnt/hda1 mount /mnt/hda1 grub-install --no-floppy --root-directory=/mnt/hda1 /dev/hda Method2 grub-install '(0,0)' grub-install '(hd0,0)' grub-install '(hd0)' -- If that fails, one may need to run: grub --batch --device-map=/boot/grub/device.map 49, 100->124, and 199 The chainloader file in the first block of the first disk (hd0,0)+1 This is the GRUB chainloader command: chainloader +1 -- Booting--------------------------------------------- A menu will appear, select your kernel from the list with arrow keys press 'e' for the edit menu, In the edit menu arrow to the line to edit, press 'e' to edit the line append a run level (1 through 5, 'single', or 'emergency') to boot a run level. press and 'b' on the next screen. press 'O' to add a line before the current line press 'o' to add a line after the current line press 'd' to delete a line press 'b' executes the current line ------------------------------------------------ List symbols (function and variable names) that a binary uses nm ------------------------------------------------ List symbols (functions and variable names) in the kernel cat /proc/kallsyms cat /proc/ksyms ------------------------------------------------ list library dependencies for a given program i.e. for ssh run this: which ssh -print |xargs -i ldd {} ------------------------------------------------ Disable SuSE spash screen from proc echo 0 > /proc/splash Activate SuSE splash screen from proc echo 0x0f01> /proc/splash Disable SuSE splash screen with grub: edit /boot/grub/menu.1st Change: splash=silent To: splash=0 Change: vga=0x314 To: vga=normal ------------------------------------------------ Install a new kernel Short: cd /usr/src/linux make mrproper make symlinks make menuconfig make dep make make bzImage make modules make modules_install Long: -- To make a new kernel from source and do th grub thing: Get kernel from www.kernel.org. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.9.tar.bz2 Unpack cd /usr/src tar -zxvpf -or- tar -jxvpf cd Clean old build and removes .config make -j4 mrproper # Trivia: "Mr. Proper" is a renamed "Mr. Clean", like the bald guy with the ear ring. Make Symlinks make symlinks To copy an old config, make oldconfig # Selects default answers to all the kernel stuff --- or --- make clonconfig # Selects the options that re set in the running kernel. # on suse, clonconfig works using kernnel-source rpm from SuSe, # In 2.6.9 source from kernel.org, make cloneconfig failed: ** No rule to make target `cloneconfig' # I installed suse's kernel-source, then ran make clonconfig in their source dir. # then I coppied the resulting .config to ../linux-2.6.8-24/.config # then I ran 'make oldconfig' Select your options in a .config file make xconfig --- or --- make menuconfig --- or --- make config You must run this next command without error (errors come from a misconfigured .config file or a mispatched kernel) make dep # not needed in the 2.6 kernel This removes headers from a previous build attempt. make clean Not sure what this is yet, but I started seeing it in 2.6 make prepare-all Make a compressed kenrel ( it will land in /usr/src//arch/i386/boot/bzImage) make bzImage Create modules make modules Copy them to /lib/modules/ make modules_install Copy new kernel into place cp /usr/src//arch/i386/boot/bzImage /boot/vmlinuz- For Grub: Add a line to /boot/grub/menu.1st title Linux root (hd0,1) kernel (hd0,1)/vmlinu-2.6.9 root=/dev/hda3 vga=normal selinux=0 splash=0 resume=/dev/hda1 desktop elevator=as showopts Copy system map cp /usr/src//System.map /boot/System.map- Copy the .config to /boot for the kernel documentation cp /usr/src//.config /boot/.config- Make a new ramdisk for booting cd /boot mkinitrd --image-version initrd mv initrd- initrd-.img Edit grub config file: /boot/grub/grub.conf title Custom Linux () root (hd0,0) kernel /vmlinuz- ro root=/dev/hda2 initrd /initrd-.img # oneline: make config, make dep, make clean, make bzImage (or bzlilo), make modules, make modules_install, make install, a few cp commands, run lilo ------------------------------------------------------- Got Root So you lost the root password. mount drive in another system -or- boot from bootable linux distro (bbc, knopix, ...) -or- for lilo boot with: linux --single -or- for grub boot, mount partition with /etc/ vi /etc/passwd Remove x for the line for root: root:x:0:0:root:/root:/bin/bash -to- root::0:0:root:/root:/bin/bash Reboot target machine. ------------------------------------------------------- lilo -u will uninstall lilo but will not repair mbr --------------------------------------------------------- mbrcheck.exe for nt and 9x will find the old mbr --------------------------------------------------------- CAN'T BOOT!!! @ "boot:" type "linux init=/bin/sh" If that doesn't work, boot off floppy, @ "boot:" type "linux root=/dev/hda1 initrd=" Boot only to "li" I solved my "li" lilo problem on one system. It turnes out the system has no serail ports, and it was cloned from a system with serial ports. The first 2 lines of lilo.conf contain: serial=1,9600n8 append="console=ttyS1,600 consloe=tty1 This was to send console messages to the serial port. Once I erased the lines and ran lilo, the system was bootable. I solved another "li" program by making sure the system was boot as hda, but I booted off the SuSE disk one, choase abort in the install, selected to load drivers for reiserfs and jfs, then chose "boot installed system". Once booted, I mounted the driver partitons / then /boot then /usr. Then I ran chroot; lilo -v -v -v. And finally rebooted without the cd. ------------------------------------------------------------ Boot Process ------------------------------------------------------------ init - father of all processes, - launches the kernl. - suppresses 'signal 9' (the halt process) - location of init /sbin/init in SuSE - location of configuration /etc/inittab (specifies run levels) - run levels specifed in inittab are in /sbin/init.d/ in old SuSE, /etc/init.d on RedHat and new SuSE After booting, the system starts in Run Level speified in /etc/inittab, line "initdefault". Change Run Level by becoming super user, "init ". Halt system with "init 0", Restart system with "init 6" init config file = /etc/inittab line syntax: cc:states:action:process action keywords: wait -wait for process to finish before running next respawn -auto restart if it dies. once -start process if not already runing, no wait boot -only execute at boot time, no wait bootwait -only execute and wait before running next initdefault -specify default run level (usually 2 or 3, or 5 for linux) sysinit -execute before init accesses the system console (driver loading) off -if a process is running, kill it ---------------------------------------------------- To remove a file that starts with a dash: rm -- -filename ---------------------------------------------------- OLD: Start xwindows by default by changing /etc/inittab, on a redhat system, append this line to the end of /etc/inittab: # syntax= cc:states:action:process # xdm is now a separate service x:5:respawn:/etc/X11/prefdm -nodaemon Now: runlevel 3 does not start xdm/gdm/kdm, but runlevel 5 does. The actual init scirpt is ----------------------------------------------------- # system stats: Drive stats /sbin/hdparm /dev/hda IO stats: vmstat 1 Network: iptraf cat /proc/net/tcp # list listening TCP sockets, and next list all established TCP connections. Memory: memprof /proc/meminfo ----------------------------------------------------- # Printing: lpq # display items in the print server queue lprm - # remove all jobs from queue lprm # remove just job# from queue lpc #interactive in-yer-face to lpq. ? for help lpc topq # move job to front of the queue # printing a pdf to a non postscript device gs -dSAFER -dNOPAUSE -sDEVICE=deskjet -sOutputFile=\|lpr my.pdf ----------------------------------------------------- /etc/X11/prefdm should look likethis: #!/bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin # We need to source this so that the login screens get translated . /etc/profile.d/lang.sh # Run preferred X display manager preferred= if [ -f /etc/sysconfig/desktop ]; then if grep -q GNOME /etc/sysconfig/desktop 2>/dev/null; then preferred=gdm elif grep -q KDE /etc/sysconfig/desktop 2> /dev/null; then preferred=kdm elif grep -q AnotherLevel /etc/sysconfig/desktop 2> /dev/null; then preferred=xdm fi fi if [ -z "$preferred" ]; then if which gdm >/dev/null 2>&1; then preferred=gdm elif which kdm >/dev/null 2>&1; then preferred=kdm elif which xdm >/dev/null 2>&1; then preferred=xdm fi fi if [ -n "$preferred" ] && which $preferred >/dev/null 2>&1; then exec `which $preferred` $* fi exit 1 ----------------------------------------------------- Configure xdm's chooser for host selection http://www.linuxdoc.org/HOWTO/Tips-HOWTO-3.html#ss3.8 1.Edit the file that launches xdm most likely /etc/rc/rc.6 or /etc/rc.local) so that it contains the following lines in the xdm startup section. /usr/bin/X11/xdm exec /usr/bin/X11/X -indirect hostname 2.Edit /usr/lib/X11/xdm/Xservers and comment out the line which starts the server on the local machine (i.e. starting 0:) 3.Reboot the machine and you're home and away. ----------------------------------------------------- SUSE vs. RedHat gdm Config files for RedHat gdm are located in /etc/X11/gdm Config files for SuSE gdm is located in /etc/opt/gnome/gdm Modify login image by editing gdm.conf, Logo= ----------------------------------------------------- Configure start and stop runlevel scripts (start or stop service) chkconfig off /sbin/chkconfig --list ----------------------------------------------------- - Process of changing run levels, 'stop scipts' of the current run level shut down system, then 'start scripts' launch the new run leve. -init reads /etc/iniitab, which specifies the path to /sbin/init.d/rc -'rc' calls stop scripts on any process which will not be started in the new run level. -comparison between /sbin/init.d/rc.d && /sbin/init.d/rc.d -Stop scripts in rc#.d start with the letter 'K' -Start scripts in rc#.d start with the letter 'S' 2 types of scripts (directly vs. indirectly stared by init) -directy: boot time, power failure, Ctrl-Alt-Del -indirectly: changing run levels, init starts 'rc' which runs a script. init starts 'boot', configured from /sbin/init.d/boot.d -file system is checked, -kernel daemon is launced, -files are deleted from /var/lock, -network loopback is activated (specified in /etc/rc.config), -system time set, -'isapnp' starts plug-n-play hardware. -init starts 'boot.local' -Sononomous to Autoexec.bat -boot.setup ------------------------------------------------------------------------ System information: ------------------------------------------------------------------------ utils: Modem: /usr/bin/control-panel /usr/bin/modemtool /bin/linuxconf /usr/bin/rp3 /bin/xconf /usr/bin/kppp /bin/netconf mouse: networking: /usr/sbin/mouseconfig /usr/sbin/netconfig #non-gui gpm /bin/netstat /bin/netconf process monitoring: /sbin/ifconfig -a /usr/bin/top /usr/sbin/lsof -i tcp # protocal-port bonding /etc/nsswitch.conf /etc/pcmcia/network.opts (SUSE) starup items: print: /usr/X11R6/bin/tksysv /usr/bin/printtool pcibus: Scsibus: lspci cdrecord -scanbus Scann for all Hardware: hwscan --list Get drive info, if dmesg doesn show it: cat /proc/scsi/scsi ------------------------------------------- Finding a command: which type whereis Kernl version, network name for machine, processor: type 'uname -a' Switch to the other shells What is your current shell? type env |grep SHELL Change permissions on all files to 644, and dirs to 577 chmod 644 $( find ./ -type f |sort -n ) chmod 755 $( find ./ -type d |sort -n ) Customizing your prompt and enviornment in this file: Shell Config File ksh, ash, sh .profile bash .bashrc ----> for bash env variables, type `shopt` -----> enable one dimentional arrays with extglob=on csh, tcsh .cshrc # dot file generator: http://www.imada.ou.dk/~blackie/dotfile/ zsh .zshrc The prompt is set based on the shell: type PS1="[\u@\h \W]\\$ " Type man to see the settings for each env. to tell you the truth, I've learned most of it from people, but a man page is more accessable. If you use bash (shell) use the tab for filename compleation. Type the first part and press tab to coplete the name. If it doesn't finish the word, press tab again. If multiple matches exist, they will print. If no matches exist, nothing is displayed. Open Tar files ( *.tar and *.tar.gz, *.tgz) tar -xzvpf gzip -d then tar -xvpf To compile and install a program: untar the package. Inside the dir read the 'README' and/or 'INSTALL'. type './configure' type 'make' type 'make install' If it fails for some reason, get on the news groups and read. Ctrl-Alt-stuff: restart Xserver ctrl-alt-backspace Switch terminals ctrl-alt-F1 to F7 will Work. change resolution ctrl-alt-- and ctrl-alt-+ -------------------------------------------------- dule boot- install 9x then nt then linux. lilo prompt is configurable. edit /etc/lilo.conf and man lilo commercial versons of suse, caldara. For Imac- Yellow Dog distriblution of Linux. *Mandrake is the only distribution to take advantabe of the pentium instructions. Text Editors: Linuses favorite editor is nedit http://www.nedit.org/ Slick edit costs too much Utility on the web for checking PNP devices, and tells you the right settings: www.lunux.org/hardware has a link. sunsite.unc.edu linux section. ----------------------------------------------------------- floppy mount mount /dev/fd0 /mnt/floppy -r vfat ---------------------------------------------------------------- mount /dev/cdrom /mnt/cdrom http://www.linuxfocus.org/English/September1998/article106.html What device is it: dmesg |grep hdc |grep -v error ide1: BM-DMA at 0xfcf8-0xfcff, BIOS settings: hdc:DMA, hdd:pio hdc: HITACHI DVD-ROM GD-S200, ATAPI CD/DVD-ROM drive hdc: no flushcache support hdc: ATAPI 24X DVD-ROM drive, 512kB Cache Enable MDA for less chopy dvd play hdparm -d1 /dev/dvdrecorder ------------------------------------------------------------------- zip mount mkdir /mnt/zip mount -t vfat /dev/hdd4 /mnt/zip ------------------------------------------------------------------- Copy contents of floppy to home directory cp -r /mnt/floppy/* /home/username/ r stands for recursive Enable Color ls type "ls --color=auto" if it worked, type "alias ls='ls --color=auto'" make it perminent by putting the alias in /etc/bashrc To change which colors are used download this file into your home dir http://stilen.com/.dircolors ------------------------------------------------- Recording your commands to a file type "script ~/" * Use this before someone starts doing stuff on your system. -S to pause recording, -Q to restart recording, -D or -C to kill the recorded information. When you are done with a script it will need some cleaning (due to control chars) Run this command on the file: sed 's/\^M//' use this command to do global search and replace. --------------------------------------------------------- Network card setup looked for my nic on the web by searching for linux and card number. they refered me to modprobe *.o depmod insmod cd /lib/modules/2.2.5-15/pcmcia depmod 3c589_cs.o start linuxconf go into basic host information go to adapter 1 chose eth0 for Net device chose dhcp or give static IP. quit, quit, quit type /etc/rc.d/init.d/network restart ----------------------------------------------------------- DHCP refresh: type pump -R ----------------------------------------------------------- Set DNS manually: vi /etc/resolve.conf Control the order of name resolution: vi /etc/nsswitch.conf Now you need to restart the service /etc/rc.d/init.d/network restart all ----------------------------------------------------------- Why does sendmail hang for 5 minutes on startup with RedHat? /etc/hosts file: change to 127.0.0.1 localhost 10.56.142.1 yourbox <<---this will be your ip insted ---------------------------------------------------------- Find files over a certian size Find big files ( big large files ) find / -xdev -size +100000c ---------------------------------------------------------- du -ks cache w gives the size tar czpvf root.tgz root ---------------------------------------------------------- RPM rpm help, common commands: Adding RPM packages install: rpm -i upgrading: rpm -R List installed rpm's and grep for a particular one, rpm -qa |grep i.e. This will show you the version numbers: rpm -qa | grep XFree86 i.e. Find all the files that belong to a rpm rpm -la |grep XFree86 Show the owner rpm for an installed command/program rpm -qf `which X` Check the sig of the rpms on Suse: fingerprint = 79C1 79B2 E1C8 20C1 890F 9994 A84E DAE8 9C80 0ACA pushd /var/lib/YaST/patches/i386/update/7.2/ for direct in $dir do cd $direct files=`ls` for file in $files do rpm -v --checksig $file done cd .. done Building rpm's: # determine what paths your installation of RPM expects rpm --showrc # _sourcedir =Where RPM looks for source files (tar files, etc.) # _srcrpmdir =Where RPM puts new source RPM files # _rpmdir =Where RPM will put new binary RPM files (in an architecture-specific subdirectory) Rebuild rpm from src.rpm file # Prior to rpm-1.4, one could use '--rebuild' option to create an rpm inside the /usr/src/ directory. rpm --rebuild my_package.src.rpm (Redhat: ls /usr/src/redhat/RPM ) (SuSE: ls /usr/src/packages/RPM ) # Since rpm-1.4, the option is gone, so the other way is: Option1: rpm -ivh my_package.src.rpm (Redhat: ls /usr/src/redhat/SOURCES ) (SuSE: ls /usr/src/packages/SOURCES ) rpmbuild -bi my_package.src.rpm Option2: rpmbuild --rebuild my_package.src.rpm ---------------------------------------------------------- Configuring my sound card: sndconfig does not support my laptop sound card A perfect site for the IBM ThinkPad 600's: http://www.pc.ibm.com/qtechinfo/MIGR-4BP6Q6.html first it will play a stupid test, and then it plays a cool midi test. mine is working. It replaced a file /etc/conf.modules and renamed it conf.modules.bak ------------------------------- Sample /usr/sbin/sound_control: #!/bin/bash #a script to load/unload the sound modules #on an IBM ThinkPad 600e #1999 Ben Brillat - brillb@rpi.edu #thanks to the linux kernel people for their instructions on the CS4232 chip. #this file should be named: # /root/scripts/sound_control #this should ONLY be called from the APM scripts # REMOVE ALL /etc/rc.d/rcN.d/S85sound files!!! (check rc3.d and rc5.d) #source function library . /etc/rc.d/init.d/functions case "$1" in start) /sbin/modprobe sound dmabuf=1 /sbin/insmod ad1848 /sbin/insmod uart401 /sbin/insmod cs4232 io=0x530 irq=5 dma=0 dma2=1 sleep 1 /usr/bin/aumix -f /etc/aumixrc -L > /dev/null stop) /usr/bin/aumix -f /etc/aumixrc -S /sbin/rmmod cs4232 /sbin/rmmod uart401 /sbin/rmmod ad1848 /sbin/rmmod sound /sbin/rmmod soundcore restart) $0 stop sleep 5 $0 start *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit 0 -------------------------------------- Sample /etc/conf.modules alias eth0 tulip keep options thinkpad enable_smapi=1 enable_superio=1 enable_rtcmosram=1 # Added by tpctlify keep # Added by tpctlify keep # Added by tpctlify path[thinkpad]=-? # Added by tpctlify alias char-major-10-170 thinkpad # Added by tpctlify -------------------------------------- disk hard drive partition table run fdisk --help or fdisk -l -------------------------------------------------- Caldare and Red Hat will look the same. Suse is much different. Fry's Electronics didn't have all this last year last year!!!!! SUSE 7.0 (kernel 2.2.16) SUSE 6.4 (kernel 2.2.14) SUSE 6.3 (kernel 2.2.13), SUSE 7.3 (kernel 2.4.10-4GB), SUSE 8.0 (kernel 2.4.18-4GB), TurboLinux6.0 (kernel 2.2.13) Corel (it didn't say on the box, but it comes with Civilization) Slackware 7 (kernel 2.2.13, Redhat 6.2 (kernel 2.2.14) Redhat 6.1 (kernel 2.2.12) Caldara OpenLinux 2.3 (kernel 2.2.10) macs-> YelloDog Linux 1.2 (http://www.yellowdoglinux.com/) -------------------------------------------------- dos utils rawrite.exe to creat boot unix command to crate the floppies would be: dd if=bare of =/dev/rfd0 obs=18k dd if=lnx.img of=/dev/fd0 -------------------------------------------------- Cable modem users: if you have a cable modem, and want to server web pages, go to: www.powerpegwin.net register your computer on there domain, and run a pirl script that will update your IP as the cable modem ip changes. -------------------------------------------------- ctrl-alt-backspace will restart xwidows, but not the computer. -------------------------------------------------- Samba Stuff -------------------------------------------------- Testing the server: ------------------- net time date smbd -b |egrep 'KRB|LDAP' # Shows Samba has needed Libs. wbinfo -u # Shows winbind is doing lookups from ADS wbinfo -g # Shows winbind is doing lookups from ADS getent passwd # Shows nsswitch is correct, to resolve ADSusers. getent group # Shows nsswitch is correct, to resolve ADS groups. net ads info # Show AD info net ads join -Ujohns%passwd # Joined the domain net ads testjoin # Shows join is ok Join is OK wbinfo -a MS+johns%password # Test if winbind can authenticate kinit johns # Test if ??? can authenticate winbindd -d 3 -i # Ran winbindd damon interactively in debug. client side: ------------ Find all servers on network: /usr/bin/smbclient -L -W -U -d1 List shares on a srver: /usr/bin/smbclient -L -W -U -d1 -or- /usr/bin/smbclient -L -I -U/% -d3 bouce server (smbd): /etc/rc.d/init.d/smb restart from clinet check the samba shares: smbclient -L nmblookup -S try to list shares with a null passwd smbclient -L -U% try a real user user name, to see if smbd uses the guest account smbclient -L -Uroot%password mount a share mkdir -p /mnt// smbmount /// /mnt// -o username=/ smbmount /// /mnt// -o username=/%,fmask=644,dmask=755,uid=500,gid=100,ip=10.0.0.39,debug=0 let any user run smbmount people say use setuid to let a user run a command as root they never tell you how to do it. which smbmount #to find the path chmod +s /usr/local/smbmount #to set the setuid bit on the file ls -l /usr/local/smbmount #now you will see an S insted of an x fstab can contain smbmounts like this: /// // smb username=/,password= 0 0 gui browsers you may want to use: xSMBrowser (im using 2.2.9) http://www.bnro.de/~schmidjo LinNeighborhood looks better (0.4.3) www.public.iastate.edu/~chadspen/ Config files are in /etc/smb.conf.sample /etc/smb.conf Read this file, since it will tell you about each area. I uncommneted the following lines: workgroup= server string = hosts allow = (i.e. 192.168.1. 127. ) printcap name = /etc/printcap load printers = yes guest account = nobody max log size = 500000000 smbpasswd file = /etc/smbpasswd username map = /etc/smbusers socket options = TCP_NODELAY SO_RCVBUF=1892 SO_SNDBUF=8192 interfaces = encrypt passwords = no map to guest = never password level = 0 null passwords = no ; allow hosts = deny hosts = no os level = 0 preferred master = no domain master = no wins support = yes dead time = 0 debug level = 0 comment = Mother # sample share to my drive /dev/sdz5 [sda5] comment = Local sda5 Drive browseable = yes writable = yes public = yes path = /mnt/sda5 [printers] comment = All Printers path = /var/spool/samba browseable = no guest ok = yes writable = yes printable = yes [netlogon] comment = all path start samba for the first time samba start go to localhost:901 for the web administration for samba www.flux.org for links to setup cable modem/dsl CREATE SAMBA USER AND GROUPS coas/system/accounts/ add smbuser (useradd smbuser) make group (groupadd -g 505 smb) make directory for samba and public ( cd /home/ mkdir samba mkdir public chown smbuser:smb /home/public chmod 2777 /home/public ---------------------------------------------------- licq the only one that has come close to working. latest one can be found at http://licq.wibble.net/ this is what i did: logon as root down load to /root/ type configure and a directory will be made cd into the directory type make type make install cd into the plugins dir, and cd into one of the available plugins type configure type make type make install type cd /user/local/bin type licq& a box will appear telling you to reg a new user, so click ok select system/user ---------------------------------------------------------------- php (personal home page) of 3.0: to get this to work you must have the librarys, no mater what system you use. Is analagous to active server pages. Works on appachi on a unix machine, by default. Works on a nt machine if the ODBC drivers are present. Tutorial at http://www.php.net/als99/ ----------------------------------------------------------------------------- xscreensave screensaver screen saver problems When you type xscreensaver in a terminal you get # xscreensaver Xlib: connection to ":0.0" refused by server Xlib: Client is not authorized to connect to Server -or- # xscreensaver -display Xlib: connection to ":0.0" refused by server Xlib: Client is not authorized to connect to Server xscreensaver: Can't open display: :0 xscreensaver: initial effective uid/gid was root/root (0/0) xscreensaver: running as nobody/nobody (99/99) xscreensaver: Errors at startup are usually authorization problems. Did you read the manual? Specifically, the parts that talk about XAUTH, XDM, and root logins? http://www.jwz.org/xscreensaver/man.html Fix: Don't logon as Root and try to run the xscreensaver, or hack it. man xhost xhost +localhost xhost+root@johns.ohlone.cc.ca.us xhost +root@johns.ohlone.cc.ca.us xscreensaver -display localhost:0.0 xscreensaver -display johns.ohlone.cc.ca.us:0.0 ------------------------------------------------------------------------------- export display su root - xhost +127.0.0.1 xeyes -display 127.0.0.1:0.0 this will pop up on the remote machine (or 127.0.0.1 in this case) ------------------------------------------------------------------------------- apache web server start apache by typing /usr/local/apache/bin/apachectl start ---------------------------- etherial netxray snif your self! --------------------------- # display all your serial settings setserial -g -a /dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3 /dev/ttyS4 fix serial problems ttyS0 - 4 man setserial /etc/rc.local -> look for rc.serial --------------------------- if you have more than 64 mb ram, need to append to the lilo.conf file the line "mem=" I have 128mb ram, so I entered mem=130496 --------------------------------- Install ssh on 2 machines. I used sshd version 1.2.27 [i586-unknown-linux] Redhat 6.1 setup: 1. su root 2. tar -xzvpf ssh-1.2.27.tar.gz 3. cd ssh-1.2.27 4. ./configure 5. make asroot->6. make install 7. ./sshd 8. Each user account will need to run "ssh-keygen" Replace "telnet " with "ssh " Replace "ftp " with "scp @:~/ 9. from one system, copy your key to the other system: scp ~/.ssh/identity.pub @:~/.ssh/authorized_keys 11.type ssh The user creates his/her RSA key pair by running ssh-keygen(1). The private key in ~/.ssh/identity The public key in ~/.ssh/identity.pub The user should then copy the identity.pub to .ssh/authorized_keys in his/her home The directory on the remote machine (the authorized_keys file corresponds to the conventional .rhosts file, and has one key per line, though the lines can be very long). After this, the user can log in without giving the pass­ word. RSA authentication is much more secure than rhosts authentication. If you need to replace the machine's /etc/ssh_host_key and /etc/ssh_host_key.pub Type ssh-keygen -f /etc/ssh_host_key -N '' Remove any enteries from all users ~/.ssh/known_hosts --------------------------------------- Syntax for the Secure copy: scp @:/home// ----------------------------------------------------- Adding your applications to the right tool bar: When you seee applications listed in a tool bar, in any window manager they are located in only a few places: Case in point, I found all the locations for Identifying the instance of "Applications" /etc/X11/applnk/Applications /usr/share/gnome/apps/Applications /usr/share/applnk/Applications /usr/share/applnk/Settings/Applications so I created a dir, in tach palce and tried to see what worked. mkdir /etc/X11/applnk/MySit_MoFo mkdir /usr/share/gnome/apps/MySit_MoFo mkdir /usr/share/applnk/MySit_MoFo mkdir /usr/share/applnk/Settings/MySit_MoFo Preferences > Mail & Newsgroups > Formatting: Use the HTML Editor to Compose Messages 3. Under EDIT > Preferences > Mail & Newsgroups > Identity: You *must* specify signature file. ------------------------------------- disk wont' boot. lilo messed up make backup of mbr dd if=/dev/hda of=backup-archive-date bs=512 count=1 su fdisk /dev/hda p for listing the partitions /dev/hda was not active a to make a partion active 1 to select partiion 1 ------------------------------------------ Mirror Download an entire website /usr/bin/wget --glob=on --recursive --http-user=HTTPUSERNAME --http-passwd=PASSWORD www.groovejuice.com/photo/wallpaper/ ------------------------------------------ Backup for entire Linux System # The cool people at Road Warrior made this possible # Soren Curry helped me run rsync # 2/9/2000 by: John Stile #==================================================== # Clone disk using bullet drive: #==================================================== # I have a Road Warrior Bullet Drive Express # Which is an PCMCIA-to-IDE interface # A laptop hard drive plugs in, and # Appers as hde when the kernel module idecs is loaded # Your kernel must have the option CONFIG_BLK_DEV_IDECS=y # Partition new disk fdisk to crate a 6Gb partition of ext2 file system. # I don't have the details. # Make sure the drive is empty # ** If you have to restart this process, start here ** /sbin/mke2fs /dev/hde1 # create a place to mount the drive. mkdir /mnt/harddrive2 # mount the drive mount /dev/hde /mnt/harddrive2 -t ext2 # Now shut off some basic things that drag on cpu kill -9 `ps -el |grep xlock |awk '{print $4}'` kill -9 `ps -el |grep x-scereensaver |awk '{print $4}'` # setup a monitor: gdiskfree or use a while loop # gdiskfree is a graphical display of drive space gdiskfree # while loop runs in a terminal, displaying disk usage # once you hit after end, the loop begins. # If you want, also add ls /mnt/harddrive2 while (1) df -k sleep 1 end # In another window start rsync # options a is archive to preserves attributes, v is verbose # [!mpl]* means everything that does not start with m, p, or l in current dir. # rsync -av [!mpl]* lib /mnt/htt2 # when this process is over, make a proc and mnt directory mkdir /mnt/harddrive2/proc mkdir /mnt/harddrive2/mnt # move everything in /mnt except /mnt/harddrive2 cd /mnt rsync -av [!h]* /mnt/htt2/mnt/ Reboot and pray it works Mine didn't work, and I was left with a macine that read LI at boot time I got no help from anyone, because it was soo easy for them. So I made a boot floppy form anohte macine: su mkbootdisk --device /dev/fd0 2.2.12-20 But that didn't fix the problem, so I started messing with files in /boot This resulted in breaking things further, with ony a LIL- at boot time So I made a new boot disk off another macine, and at lilo: I typed linux root=/dev/hda1 initrd=/boot/vmlinuz-2.2.12-20 -------------------------------------------- Advanced stuff ============================================ man and learn uniq man and learn sort -------------------------------------------- Mail all users on a system mail `cat /etc/passwd |awk '{print $1}'` < memo_file.txt -------------------------------------------- clean file system and get drive space back (drivespace) -------------------------------------------- Find the biggest files as root type: du -S / | sort -n ls -lR / | sort +4n as joe user type: du -S / | sort -n 2> /dev/null Find the total size of many directoryies directory du -skd /* find all core dumps on system: ls -laF `find / -name core` see the size of the directoryies in an a directory: ls -lAF /datatel/ |du -sbr * look at specific lines in an output use awk: ls -lAF |awk '{print $6, $7, $8, $9}' awk -F. '{print $1}' shsed1.txt find find / -name '*nfs*' |grep sbin ./portmap start 948 ./nfs start mount localhost:/ ~jstile/damn ps -aux |grep '*nfs*' find what is using the files in a directory: find ./ |xargs fuser {} find all jpg files in a directory tree and move them to a new directory find ./directory -name "*.jpg" -print |xargs -i mv{} images/ list files in a dir, print just the file name, and remove the last .# characters. ls -lF |awk '{print $9}' | rename files with spaces from .doc to .txt find -type f -print0 | xargs -0 perl -n 'chomp; $orig=$_; s/.doc$/.txt$/; rename($orig; $_);' rename files with spaces from nothing to .jpg find ./ -type f | perl -e 'while (<>){ chomp; $orig=$_; s/\s+/_/; s/$/.jpg/; rename($orig,$_);}' ------------------------------------------- Fix file mermissions: recursively turn off execute on files but not directories born find . -type f -print |xargs chmod -x zsh chmod -x **/*(.) ------------------------------------------- How-to sed: sed 's/LookForThis/ReplaceWithThis/' file # s = subsitute sed 's/Unix/UNIX/g' file # g=global sed -n '1,2p' file # -n=only print lines that match pattern # print just first 2 lines of a file sed -n '/UNIX/p' file # print just lines containing UNIX sed '1,2d' file # d=delete. delet first 2 lines of the file sed '/UNIX/d' file # delete lines containing UNIX sed '5d' file # delete first 5 lines sed '1,3d' -e 's/Unix/UNIX/g' file #First delete the top 3 lines, and then upcase the occurance of all Unix sed '/west/,/east/s/$/***VAC***/' datafile #from the first line in a file that contains the word west, #to the the next line in a file that contains the word east, #append ***VAC*** to the end of each line. --------------------------------------------- pipes >> append or create with std out > create or replace with std out 2> create or replace with std error < feed with std in --------------------------------------------- glob-expressions/file name substitution: * = zero or more characters ? = single character [ ... ] = specifies any character enclosed between the brackets for a single postion. --------------------------------------------- regurlar expressions: . = single character .* = zero or more characters ^ = match the beginning of a line $ = match the end of a line \ = treat next char as literal (not special) ^\. = match files that begin with . [^A-Z] = match lines that begin with A thorugh Z .$ = match a single character at the ned of a line. ^$ = match line with no characters. ^ $ = match line with single space \( \) = load pattern into register ---------------------------------------------- Math with variables: ---------------------- this does not work ---------------------- i=1 i=$i+1 echo $i 1+1 ----------------------- in bash ----------------------- i=1 let i=$i+1 echo $i 2 ----------------------- sh ----------------------- sh i=1 i=`expr $i + 1` echo $i 2 ----------------------- precedence */ % -+ ----------------------- expr 10 + 20 / 2 20 ------------------------ match chars in the first argument against a regex in the second arg. expr "$file" : ".*" ------------------------ grep for more than one thing: egrep 'thing1|thing2|thing3' ---------------------------------------------- NFS ---------------------------------------------- Keywords: rpcinfo -p, nfs [start,stop,status] exportfs -a /etc/export etc/fstab /var/log/syslog ---------------------------------------------- RUNLEVEL SETTINGS control-panel, click nfs/add/runlevel5/id 61 control-panel, click nfs/start/start/done ps -aux |grep '*nfs*" -> [nfsd] usr/sbin/rpcinfo -p localhost program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100003 2 udp 2049 nfs START/STOP /etc/rc.d/init.d/nfs [start/stop/status] this will not work without /etc/exports file CREATE SHARE mkdir /export vi /etc/exports and type this: rp# #NFS share for the network # /export/ johns2(rw) :wq Reload file in rpc.nfsd and rpc.mountd type: /usr/sbin/exportfs -a ADD TO THE SHARE WITH SYMBOLIC LINKS ln -s /usr/local/download/ /export/download ACCESS SHARE /etc/fstab file config on client. -------------------------------------------------- # Create 2 users that will share one home dir: -------------------------------------------------- 1. add umask=002 into .profile, local.cshrc, 2. vi etc/passwd make group 106 the primary group for lweiner 3. useradd -u 1079 -g 106 -d /export/htdocs/computer_st/lweirner -s /sbin/ sh pyoung 4. chgrp -hR 106 lweirner 5. chmod 775 lweirner 6. chmod 664 .profile local.* 7. vi .profile, local.profile, local.cshrc, and local.login to each, add "umask 002" --------------------------------------------------- # Send all syslogs from one server to another server --------------------------------------------------- 1. On the syslog reciever system: On SuSE7.3: vi rc-script for starting syslogd a. Allow the domain: syslog -r -s my.domain.name b. Allow a host: syslog -r -l On SuSE8.0: /etc/sysconfig/syslog a. Allow the doamin: SYSLOGD_PARAMS="-r -s .my.domain" b. Process changes: SuSEconfig Restart /etc/init.d/syslog Test to see if system is now listeing: netstat -a | grep syslog udp 0 0 *:syslog *:* 2. On the syslog sender system: vi /etc/syslog.conf # add the line *.* log.server.fqdn restart syslogd from rc-scripts ---------------------------------------------------- # Quotas, quotas, setup quotas --------------------------------------------------- # trun it on edit /etc/fstab appending usrquota /dev/sda7 /home etc2 default,usrquota 1 2 touch /home/quota.user /home/quota.group chmod 600 /home/quota.user /home/quota.group reboot #Edit quotas (soft and hard) edquota -u edit /etc/security/limits.conf @users soft item value # set for all users in group john hard item value # set for one user items= core, cpu, nproc, or maxlogins #ulimits are as follows: #ulimit shell command to set system wide limits -- or -- edit /etc/profile ulimit -n 512 # -a Display all limits # -c Max core file size # -d Max size fo a process's data segment # -f Max size of files created by the shell # -m Max resident set size # -n Max open files # -p Pipe size # -s Max stack size # -t Max CPU time in seconds # -u Max processes # -v Max virtual memory edit /etc/security/limits.conf --------------------------------------------------- # Security # Audit for programs that can run as root (setuid bit) --------------------------------------------------- Display all the vulnerable files: find / -perm -4000 -uid 0 only fix is to turn them all off. i.e. chmod u-s /bin/ping chmod u-s /bin/mount chmod u-s /bin/umount could make /bin/su executable only by the wheel group chmod u-s /sbin/dump (backup utility) chmod u-s /sbin/restore (backup utility) chmod u-s /usr/bin/at ; chkconfig atd off (use cron insted) chmod u-s /usr/bin/chage (password ageing) chmod u-s /usr/bin/chsh (lets users change their default shell) chmod u-s /usr/bin/crontab (only root should have use cron) chmod u-s /usr/bin/gpasswd (change group passwd in /etc/gshadow) chmod 0000 /usr/bin/{rcp,rlogin,rsh} chmod u-s /usr/sbin/traceroute chmod u-s /usr/sbin/userhelper (lets users chagne pw with a gui, known vulner.) chmod u-s /usr/sbin/usernetctl (allows users to bring down network interface) ok /usr/sbin/sendmail (if you want users to send mail) ok /usr/libexec_ptchown (used by terminal programs and the like to grab pty's) ok /usr/bin/sperl5.00503 ok /usr/bin/procmail (Unless you receive no mail on this host) ok /usr/bin/{lpq, lpr, lprm} (if you print from the machine, leave it alone) ok /usr/X11R6/bin/Xwrapper ok /usr/bin/passwd ? /sbin/unix_chkpwd ? /sbin/pwdb_chkpwd Four ways to limit the danger of SUID root programs: 1.Strip the SUID bit, so the program runs as the running user, instead of running as root. 2.Define a special group for the program and make the program executable by members of the group 3.Strip the world(other)-execute bit, leaving it executable by the owner and group, but still SUID 4.Strip SUID and use Sudo to allow only certain users to run this command. -------------------------------------------------------------- changing the ip : moble ip ipswitcher network config -------------------------------------------------------------- I use my computer at work and home, so I need to change the network settings. 1st, I configure my laptop at work with yast, then copied /etc/pcmcia/network.opts to /etc/pcmcia/network.opts.work 2nd, when I went home I used yast to configure my laptop for home, and I copied /etc/pcmcia/network.opts to /etc/pcmcia/network.opts.home for work, I run: cp /etc/pcmcia/network.opts.work /etc/pcmcia/network.opts 3rd, pop the card out and put it back in, or type /etc/pcmcia/network check And that's it. This is so simple, no wonder I couldn't find anything on it. --------------------------------------------------------------- Lessons from Tim Tuck ctrl-a takes you to the beginning of a prompt line, ctrl-u erases everything on the right ntsysv interface for runleves crtl-t transpose the last 2 letters of a line crtl-r gives a reverse search ctrl-w does same as ctrl-u ------------------------------------------------------------------ more shell stuff: upcase contents of a variable: TESTSTUFF='abaelkjlakdjf' typeset -u TESTSTUFF echo $TESTSTUFF ABAELKJLAKDJF truncate to 8 chars and lowercase everything. TESTSTUFF='ABAELKJLAKDJF' typeset -l8L TESTSTUFF echo $TESTSTUFF abaelkjl ------------------------------------------------------------------ xinetd - the replacemnet for inetd Text menu for changeing run levels: ntsysv To list whats running: chkconfig --list To disable services at all but run level 2 use: chkconfig --level service off To delete a services use: chkconfig --delete service ntsysv ------------------------------------------------------------------ Setup net nic, set ip, configure network ------------------------------------------------------------------ ---------------------------- Traditional method to set ip ---------------------------- ifconfig eth0 192.168.1.100 netmask 255.255.255.0 route add net default gw 192.168.1.254 ----------------------- New method to set an ip ----------------------- Flush Route Table: ip route flush table main Set IP: ip add flush eth0 ip addr add 192.168.0.42/24 broadcast 192.168.0.255 dev eth0 ip link set eth0 up ip route add default via 192.168.0.60 dev eth0 Set second IP: ip addr add 10.100.100.1/24 dev eth0 label eth0:1 Check IP/Route: ip route Traditional commands: ifconfig, route, ping, traceroute, netstat, nslookup New commands: dig, ip dig ns (ns = nameserver for the domain) dig mx (mx = mail exchanger for the domain) Examples: 'ifconfig' - To assign the ip and subnet of the nic: -------------------------------------------------------------------- Desc: command nic host ip subnet-mask -------------------------------------------------------------------- loop back setup i.e. /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 ipaddress setup i.e. /sbin/ifconfig eth0 192.168.1.100 netmask 255.255.255.0 view setup i.e. /sbin/ifconfig -a 'route' - To setup a default gateway or route to network: -------------------------------------------------------------------- Desc: command option option Subnet -------------------------------------------------------------------- loop back route i.e. /sbin/route add -host 127.0.0.1 route to local network i.e. /sbin/route add -net 192.168.1.0 default gateway (the last ip is the gateway server/router on your subnet) ie. /sbin/route add -net default gw 192.168.1.10 Remove the route: 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlan0 i.e. /sbin/route del -net 169.254.0.0 gw 0.0.0.0 netmask 255.255.0.0 -------------------------------------------------------------------- Resolution: the order in which name resulition will occur: -------------------------------------------------------------------- order of name resolution /etc/hosts.conf: order hosts, bind, dns order of name resolution /etc/nsswitch.conf hosts: files dns networks: files dns Local HosName to IP resolution /etc/hosts: 127.0.0.1 localhost 192.168.1.100 linux_workstation_1.mydomain.com linux_workstation_1 lw1 Local NetworkID to IP resolution /etc/network: 192.168.1.0 mydomain.com 192.168.2.0 my_second_domain.com ------------------------------------------------------------------------------ Persistant Multihome ip's: eth0:0 eth0:1 eth0:2: ------------------------------------------------------------------------------ If you use SuSE8.0, you will need 3 files /etc/sysconfig/network/ifcfg-eth1 BOOTPROTO="static" # 2 Options: dhcp or static BROADCAST="192.168.0.255" # Broadcast address space IPADDR="192.168.0.02" # IP of card NETMASK="255.255.255.0" # Subnet Mask NETWORK="192.168.0.0" # Network ID STARTMODE="onboot" # Start interface when system is booted. UNIQUE="" # I have no idea what this is for LINK_OPTIONS="mtu 1500" # Set to 1492 for broken dsl service, for better service. /etc/sysconfig/network/ifcfg-eth0 < Same a above > /etc/sysconfig/network/routes default 192.168.0.01 - - # Gateway to other subnets. To add new IP addresses to network interface in FreeBSD you need to manually edit /etc/sysconfig file. One line per IP. Format of the file is self-explanatory. To add IPs in LINUX you need to create a new file per each IP in /etc/sysconfig/network-scripts directory. Open it in editor, you will easily recognize the first ip of your computer and figure out file format. Now copy this file: $ cp ifcfg-eth0 ifcfg-eth0:0 Now edit a new file: you need to change original ip to a second one. Save edited file. To add a third ip: cp ifcfg-eth0 ifcfg-eth0:1 Again edit it to change the first ip to a third one. Now you have three similar files in directory /etc/sysconfig/network-scripts: ifcfg-eth0, ifcfg-eth0:0, ifcfg-eth0:1. Please notice filename format: it is mandatory. Each of these files will provide IP information for a network initialising script. To activate new IPs just reboot a computer. You could activate new IPs by running network initialization script. In LINUX: /etc/rc.d/init.d/network -reload In Windows NT you add IPs in Settings > Control Panel > Network >Protocols > TCP/IP > Properties > Ad ---------------------------------------------------------------------- Good tcpdump options to read about: tcpdump -vv -u -s 192 -X -i eth0 alias tcpdump_eth0='tcpdump -i eth0 -n "(udp or tcp[tcpflags] ) and (net 192.168.50.0/24)"' find dhcp servers tcpdump -i eth0 port bootps -vvv Examples: man tcpdump | less -Ip examples ---------------------------------------------------------------------- #### The package iproute2 adds a bunch of kernel routing capabitity /usr/sbin/ip link 1: lo: mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:10:a4:e5:bc:12 brd ff:ff:ff:ff:ff:ff 3: sit0@NONE: mtu 1480 qdisc noop link/sit 0.0.0.0 brd 0.0.0.0 /usr/sbin/ip address show shows your ip's /usr/sbin/ip route show shows your route /usr/sbin/ip neigh show shows your ARP table /usr/sbin/ip neigh delete 9.3.76.43 dev eth0 delete the ARP entery for 9.3.76.43 from the table /usr/sbin/ip rule list List the routing rules used by the kernel Default of 3 rules For policy based routing, compile kernel with IP::advanced router and IP:policy routing ip route list table local List all /usr/sbin/ip route list table main /usr/sbin/ip route ls List the current routing table in CIDR # source routing example # create a new table in the table index file echo 200 Rule1 >> /etc/iproute2/rt_tables ip rule add from 10.0.0.10 table Rule1 ip route add default via 192.96.98.253 dev ppp2 table Rule1 ip route flush cache #------------------------------------------------------------- #Subnet Mask Binary CIDR #------------------------------------------------------------- #255.0.0.0 11111111.00000000.00000000.00000000 /8 #255.255.0.0 11111111.11111111.00000000.00000000 /16 #255.255.255.0 11111111.11111111.11111111.00000000 /24 #255.255.255.255 11111111.11111111.11111111.11111111 /32 #------------------------------------------------------------- Set up network ############################################ # Old method ############################################ ifconfig eth0 192.168.0.42 route add -net default gw 192.168.0.60 ############################################ # New method ############################################ ip addr add 192.168.0.42/24 broadcast 192.168.0.255 dev eth0 ip link set eth0 up ip route add default via 192.168.0.60 dev eth0 ############################################ # Other commands ############################################ # Show ip ip addr show # Show all links ip link show # Show all routes ip route list all # Link down ip link set eth0 down # Tunnels: IP-IP, GRE, PPTP insmod ip_gre insmod ipip new_tunnel ip tunnel add Tunnel_Side_A mode gre remote 172.19.20.21 local 172.16.17.18 ttl 255 ip link set Tunnel_Side_A up ip addr add 10.0.1.1 dev Tunnel_Side_A ip route add 10.0.2.0/24 dev Tunnel_Side_A ############################################## # Tunnels: IP-IP, GRE, PPTP ##IP-IP: insmod ipip new_tunnel network A: network B: network 10.0.1.0 10.0.2.0 netmask 255.255.255.0 255.255.255.0 router 10.0.1.1 10.0.2.1 172.16.17.18 172.19.20.21 RouterA: ifconfig tunl0 10.0.1.1 pointtopoint 172.16.17.18 route add -net 10.0.2.0 netmask 255.255.255.0 dev tunl0 RouterB: ifconfig tunl0 10.0.2.1 pointtopoint 172.19.20.21 route add -net 10.0.1.0 netmask 255.255.255.0 dev tunl0 ##GRE Tunnel: insmod ip_gre RouterA: ip tunnel add tunl0 mode gre remote 172.19.20.21 local 172.16.17.18 ttl 255 ip link set tunl0 up ip addr add 10.0.1.1 dev tunl0 ip route add 10.0.2.0/24 dev tunl0 RouterB: ip ip tunnel add tunl0 mode gre remote 172.16.17.18 local 172.19.20.21 ttl 255 ip link set tunl0 up ip addr add 10.0.2.1 dev tunl0 ip route add 10.0.1.0/24 dev tunl0 ##IPsec: Not Done Yet ): sorry. Load Sharing between 2 adapters: Filters put traffic in queues. Use fwmark for netfilter filters Queues decide the order stuff is sent. ClassBasedQueue IF roterA has 2 nics, and routerB has 2 nics, and we want the nics to laod balance: These commands must be run on both machines tc qdisc add dev eth1 root teql0 tc qdisc add dev eth2 root teql0 RouterA: ip addr add dev eth1 10.0.0.0/30 ip addr add dev eth2 10.0.0.2/30 ip addr add dev teql0 10.0.0.4/30 RouterB: ip addr add dev eth1 10.0.0.1/30 ip addr add dev eth2 10.0.0.3/30 ip addr add dev teql0 10.0.0.5/30 ---------------------------------------------------------------------- Enlightenment interface: Im still figuring it out but type eesh then type help for each thing you can type help for more info. ---------------------------------------------------------------------- Changeing directories with push and pop commands cd /home/jstile pushd cd /usr/locla pwd /usr/local popd pwd /home/jstile ---------------------------------------------------------------------- Command history in bash can be recalled in a few ways. $! # last line of last command !! # last line !* # vererything but the command from the last line ^foo ^bar # in the last command, change foo to bar !! # reexecute previous command !N # execute the Nth command from history !-N # execute the Nth command back from the current fc -l 100-1 # put your history in a list fc -s sting # access command starting with a string ctrl-r # search history ctrl-p ctrl-n # scroll history (also use arrow keys). ctrl-k # erase, from curser to end of line ctrl-a # move to beginning of a line ctrl-e # move to end of a line ---------------------------------------------------------------------- Common xwindows issues: MIT-MAGIC-COOKIE-1 Error ------------------------------------------------ Running a gui window as root, in a regular user's x-winodws session resutls in this error: root@nost_name:/home/jstile > nedit Xlib: connection to ":0.0" refused by server Xlib: Client is not authorized to connect to Server NEdit: Can't open display Solution 1: As joe user extract your ~/.Xauthority info: 1. List all your magic cookies # the /unix:0 is the one we want to move xauth list # hostname.stilen.com:0 MIT-MAGIC-COOKIE-1 07e77a9f3793622f25640047c600a956 # webber/unix:0 MIT-MAGIC-COOKIE-1 07e77a9f3793622f25640047c600a956 2. Save it to one to a tmp file xauth extract /tmp/foo webber/unix:0 # for perminance, As Root, add the current display authority to root's /root/.Xauthority: 3. Load the MAGIC-COOKIE into root's /root/.Xauthority xauth merge /tmp/foo 4. Verify that it loaded xauth list # 127.0.0.2:0 MIT-MAGIC-COOKIE-1 edda6146f1ae2293bc5b8005a21c6abe # host_name/unix:0 MIT-MAGIC-COOKIE-1 07e77a9f3793622f25640047c600a956 5. Launch the xwindows application. nedit Soltuion 2: Configure ssh to automatically tunnel X windows For SSH1: /etc/ssh_config: ForwardX11 yes /etc/sshd_config: X11Forwarding yes For SSH2: /etc/ssh2/sshd2_config: ForwardX11 yes With TCP Wrappers, you also need: /etc/hosts.allow sshdfwd-X11: * Soltuion 3: SuSE has this thing called 'sux' Run 'sux' # it does all the other key manipulation for you. ------------------------------------------------------ Run an X client on another machine, send magic cookie for the local machine to the remote machine. % xauth extract - $DISPLAY | rsh otherhost xauth merg ----------------------------------------------------- Better Solution: Important points to know about pam_xauth: pam_xauth (8) - forward xauth keys between users without manually doing it. session optional /lib/security/pam_xauth.so arguments when you run su from an xterm sesssion, you will be able to run X programs without explicitly dealing with the xauth command or ~/.Xauthority files. Source users can add the names of other users that they trust as target users in the file ~/.xauth/export Similarly, pam_xauth looks at the target user's ~/.xauth/import file if the target user wants to accept xauth keys from the source user pam_xauth will do nothing if you create the empty file ~/.xauth/import and pam_xauth will do nothing to neither import keys, nor remove keys. pam_xauth will only forward keys if xauth can list a key connected to the $DISPLAY environment variable. reference counts are kept in the file ~/.xauth/refcount/targetname/keyname along with the keys. pam_xauth will work only if it is used from a setuid application If you wish the root account to collect all possible keys and never remove them from the database, you should Disable pam_xauth key import: mv ~root/.xauth/import ~root/.xauth/import.bak touch ~root/.xauth/import Add this to root's .profile: if [ -n "$DISPLAY" -a -n "$LOGNAME" -a "$LOGNAME" != root ] then su -c $LOGNAME xauth -iq nextract - "$DISPLAY" | \ xauth nmerge - fi Setup: mkdir ~/.xauth chmod 700 ~/.xauth # Don't export any xauth keys touch ~/.xauth/import # Want X to work when su'ed to any user. echo '*' > ~/.xauth/export # Frank trusts Bill and the root user, but no one else echo 'root bill' > ~/.xauth/export ---------------------------------------------------------------------- Common xwindows issues: Running many xservers on one workstation ----------------------------------------------------------------- You want to start a second xserver on the workstation, to run one as root and one as joe-user at the same time. 1. On the command line, become root. su 2. Launch the xserver to ctrl-alt-F8: startx -- :1& ----------------------------------------------------------------- Burning an iso image ----------------------------------------------------------------- 1. To create an iso file: mkisofs -R -J -hfs -V CD_title_in_windows -o mynewcd.iso /path/of/the/shit/i/stick/in/the/iso/ /and/this/one/too/ 2. Scan the buss for the cdr device id cdrecord -scanbus 0,6,0 6) 'SONY ' 'CD-R CDU926S ' '1.1f' Removable CD-ROM 3. Access contents of iso and verify it looks good mount mynewcd.iso -r -t iso9660 -o loop /mnt 4. burn the cd cdrecord -overburn -dev=0,6,0 -v -eject mynewcd.iso 5. copy a music cd with one burner (http://www.yolinux.com/TUTORIALS/LinuxTutorialCDBurn.html) cdrdao copy --device 0,4,0 --buffers 64 --driver generic-mmc-raw --read-raw toc-file.toc - If you need to make many backup's, then keep the toc file, an reuse it: cdrdao copy --device 0,0,0 --buffers 64 --driver generic-mmc-raw --read-raw --keepimage toc-file.toc Burn from saved image cdrdao write --device 0,0,0 --buffers 64 --driver generic-mmc-raw cd5180.toc ------------------------ vcd ripping ------------------------ http://arson.sourceforge.net/ http://www.vcdimager.org/faq.phtml gnu-vcdimager (contains vcdrip) #make one big .mpg file cdrip --cdrom-device=/dev/scd0 --rip ----------------------------------------------------------------- SUSE ----- Use /etc/rc.config to set all kinds of options: edit this file and execute /sbin/SuSEconfig ------------------------------------------------ MAIL_REPORTS_TO="you@your_email_address.com" TIMEZONE="US/Pacific" IFCONFIG_0="192.168.2.68 broadcast 192.168.2.255 netmask 255.255.255.0 up" DEFAULT_PRINTER="hplj4050" FQHOSTNAME="johns2.ohlone.cc.ca.us" OWNER_TO_KEEP_IN_TMP="root" START_CRYPTO_FILESYSTEMS="yes" MOUSE="/dev/psaux" KEYTABLE="us.map.gz" COCONSOLE_FONT="lat1-16.psfu" NSOLE_FONT="lat1-16.psfu" START_GPM="yes" GPM_PARAM="-t ps2 -m /dev/mouse" DISPLAYMANAGER="gdm" DEFAULT_WM="kde" SERIAL_CONSOLE="ttyS0,9600" CRON="yes" START_PCMCIA="yes" START_ATD="yes" START_FAM="no" START_IDEDMA="no" START_ISAPNP="yes" START_USB="yes" KDM_SHUTDOWN="root" START_AUTOFS="yes" START_PORTMAP="no" START_XNTPD="yes" CREATE_YP_CONF="yes" Firewall: START_FW="no" START_SSHD="yes" START_ALSA="no" START_ALSA_SEQ="no" YAST2_LOADFTPSERVER="yes" START_HTTPD="yes" START_DHCPD="no" START_SMB="no" START_SNMPD="no" START_ZEBRA="no" START_BGPD="no" START_RIP="no" START_HYLAFAX="no" START_TOMCAT="no" TOMCAT_HOME="/opt/jakarta" START_RADIUSD="no" START_IPSEC="no" START_MYSQL="yes" BOOT_SPLASH="yes" START_POSTGRES="no" -------------------------------------------------------------------------- NTP servers: To setup 3 servers to act as peers, and update off different time servers. Everything about setup of a clock on linux. http://www.linuxsa.org.au/tips/time.html Quick fix: # set the hardware clock /sbin/hwclock --utc --set --date="10/29/2001 08:36:16" # set os clock based on hardware clock /sbin/hwclock --hctosys --utc For auto daylight savings, check /etc/sysconfig/clock: UTC=true -------------------------------------------------------------------------- hylafax: setup run faxsetup and answer yes to everything run faxaddmodem Wich device is your modem set to? answer modem or ttySx W sed a test message sendfax -n -D -d 123-4567 test_txt_file Config files /var/spool/etc/config.ttyS0 -------------------------------------------------------------------------- netcat : Outbound or inbound connections, TCP or UDP, to or from any ports outbound: nc host port echo -e "GET http://mason.stearns.org HTTP/1.0\n\n" | nc mason.stearns.org 80 | less Full DNS forward/reverse checking, with appropriate warnings Ability to use any local source port Ability to use any locally-configured network source address Built-in port-scanning capabilities, with randomizer Built-in loose source-routing capability Can read command line arguments from standard input Slow-send mode, one line every N seconds Hex dump of transmitted and received data Optional ability to let another program service established connections Optional telnet-options responder Listen on port 5600 nc -l -p 5600 Connect to port 5600 nc 127.0.0.1 5600 Listen with verbosity nc -l -p 5600 -vv Accept an incomming file nc -v -w 30 -p 5600 l- > filename.back Send the file to the server nc -v -w 2 10.0.1.1 5600 < filename Allow anyone to connect with a root shell on your box nc -l -p 5600 -e /bin/bash Now connect to that root shll nc 127.0.0.1 5600 Reverse telnet/ftp: the ftp server has a fake ip, behind a firewall, only allowed out on port 80. client has a real ip, any port can be opened. CLIENT: nc -vv -l -p 80 SERVER: nc -e /bin/bash Now from CLIENT we have a root shell on server over port 80. ------------------------------------------------------------------------- Quotas: repquota -u -v # Command to list users on a filesystem repquota -g -v # Command to list groups on a filesystem edquota -u # Edit user quota edquota -g # Edit group quota quota -v -u # Check user quota quota -v -g # Check group quota edquota -u -p # Command to copy a user's quota edquota -g -p # Command to copy a group's quota quotaon -u # Command to turn on user quotas quotaon -g # Command to turn on group quotas quotaoff -u # Command to turn off user quotas quotaoff -g # Command to turn off group quotas quotacheck -u -g # Command to check quotas edquota -u -t # Command to edit user grace times edquota -g -t # Command to edit group grace times ------------------------------------------------------------------------- qmail queue reset: Stop qmail for i in bounce info intd local mess remote todo; do find /var/qmail/queue/$i -type f -exec rm {} \; done Restart qmail ------------------------------------------------------------------------- serial port communication between computers: 1. Attach a null-modem cable between the serial port on 2 linux boxes. 2. On the Sender, type: cat < /dev/ttyS0 3. On the Reciver, type: echo Hello > /dev/ttyS0 ------------------------------------------------------------------------ LDAP/ldap ---I need to make a cheet sheet for ldap. CN= myserver, Manager, joe user (can have more than one cn) OU= Sales, Marketing, Ops O= Stilen Corp, Pervasive Netwroks C= US DN= Distinguishing name (i.e. dn="cn=Manager,ou=Ops,o=Stilen Corp,c=US,dc=stilen,dc=com") Search: ldapsearch -b "my_search_base" "(search filter)" \ -H ldap://localhost \ -p 389 \ -D "dn to bind as" -W \ -s "list of attribs" # this found and returned just jstile's cn. ldapsearch -H ldap://localhost \ -p 389 \ -D 'uid=jstile,ou=People,dc=test1,dc=com' \ -x \ -b 'ou=People,dc=test1,dc=com' \ -LLL "(uid=jstile)" cn # this found and returned just jstile's password ldapsearch -H ldap://localhost \ -p 389 \ -D 'uid=jstile,ou=People,dc=test1,dc=com' \ -x \ -b 'ou=People,dc=test1,dc=com' \ -LLL "(uid=jstile)" userpassword # this found and returned all users password ldapsearch -H ldap://localhost \ -p 389 \ -D 'uid=jstile,ou=People,dc=test1,dc=com' \ -x \ -b 'ou=People,dc=test1,dc=com' \ -LLL "(uid=*)" userpassword # this failed ldapsearch -H ldap://localhost \ -p 389 \ -D 'uid=jstile,ou=People,dc=test1,dc=com' \ -X 'uid=jstile,ou=People,dc=test1,dc=com' \ -W \ -b 'ou=People,dc=test1,dc=com' \ -LLL "(uid=*)" userpassword ------------------------------------------------------------------------ Is a "smurf amplifier" (i.e. it responds to ICMP broadcasts): cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts if it is a 0 then # you are a "smurf amplifier" #insert this line in /etc/init.d/boot.local echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts if it is a 1 then # you are not a "smurf amplifier" # don't need to do anything ------------------------------------------------------------------------ Find IP's on a subnet (hosts): ping -b -c 2 -i 15 192.168.0.255 cat /proc/net/arp arp -a Put static info into /etc/ether ------------------------------------------------------------------------ restrict login to root... one possiblility /etc/profile and /etc/csh.login scripts. for the /etc/profile: name=`logname` if [ $name != root ] then echo "$name not allowed to login, System is Unavailable" echo "Exiting" sleep 2 exit fi for the /etc/csh.login: set name = `logname` if ( $name != 'root' ) then echo "$name not allowed to login, System is Unavailable" echo "Exiting" sleep 2 logout endif ------------------------------------------------------------------------ Linux Standard Base (LSB): LSB1.1 is Final http://www.linuxbase.org/spec/ ------------------------------------------------------------------------ Need to see which pam libraries are authenicating a user with ssh? Strace the ssh daemon on another port sending the output to the file ssd.output strace -ossd.output -f /usr/sbin/sshd -p 6666 From another terminal connect with ssh: ssh -p localhost -p 6666 Look for the word pam in the ssd.output file: grep pam ssd.output ------------------------------------------------------------------------ Learning KDE: kmenuedit - Edit the programs in the menu for kde Change default video player to mplayer: Older kde: Control Center KDE Video Click on the video file type, then go to the right and click Move Up to make Mplayer the first choice. In 3.3 Control Center Kde Components File Assocations |-kdedevice | dvd_mounted | Add | Multimedia | Vido Player | Mplayer ( or a one line shell script 'mplayer dvd://') |-Video Add Multimedia Vido Player Mplayer GUI scp in Konqueror: Fish in Konqueror came with Suse 9.2's kde3.3 In Konqueror, type in this "Location:" fish:///home/ You will be prompte for a username and passwd. Once complted, you can drag-n-drop files to the remote location. If you try to open a remote file, it will first copy it locally and then open it. ------------------------------------------------------------------------ kde defaults are stored in: SuSE: /opt/kde3/share/config/SuSE/default/ Other: $KDEDIR/apps/kdesktop/Desktop See: http://people.fruitsalad.org/phil/kde/userguide-tng/customizing-kde.html ------------------------------------------------------------------------ Install a perl module: For some modules, you need to run this from the command line first: export FTP_PASSIVE=1 -or- perl -MCPAN -e '$ENV{FTP_PASSIVE} = 1; shell' The next line installs a module called Bundle::CPAN from the CPAN site perl -MCPAN -e'install "Bundle::CPAN"' This is a manual way to install: 1. download. 2. tar -zxvpf .tgz 3. cd 4. perl Makefile.PL 5. make 6. make test 7. make install Update your perl modules: perl -MCPAN -e'install "shell" cpan > reload index cpan > reload cpan cpan > autobundle cpan > install Bundle::Snapshot_2005_01_19_00 Set passive ftp as default after Net::FTP has been installed: Edit /usr/local/lib/perl5/5.8.1/Net/libnet.cfg 'ftp_int_passive' => 1, Set env variable before running cpan export FTP_PASSIVE=1 Force: If install fails due to dumb test failure cpan > force install Debug: If it just keeps dieing and you want to get more info cpan> install Wx cpan> look Wx # make test TEST_VERBOSE=1 TEST_FILE=t/ | tee test.log ------------------------------------------------------------------------ Read the perl docs on an installed module: perldoc Bundle::CPAN ------------------------------------------------------------------------ Backup your mysql database from cron: /usr/bin/mysqldump -q --all-databases > /var/lib/mysql/all_databases.sql -uroot -ppassword ------------------------------------------------------------------------ Change mysql root password: bash$ mysql mysql mysql> UPDATE user SET password = password('new_password') WHERE user = 'root'; mysql> FLUSH PRIVILEGES; ------------------------------------------------------------------------ How to recreated a deleted /dev/null: /bin/mknod /dev/null c 1 3 -m=rw For a list of device numbers, check out /usr/src/linux/Documentation/devices.txt ----------------------------------------------------------- minicom: exiting minicom: -a q Man minicom for much more ----------------------------------------------------------- kernel : change module support, recompile, reinstall lilo cd /usr/src/linux make mrproper make cloneconfig make menuconfig make dep debian: mkinitrd SuSE: mk_initrd lilo -v -v -v ----------------------------------------------------------- Debuggying rrdtool issues: Suse calls rrdtool i386-suse-linux-rrdtool, so don't get confused. On suse, to loook at what is in your *.rrd /usr/bin/i386-suse-linux-rrdtool fetch gateway_eth0_in.rrd AVERAGE /usr/bin/i386-suse-linux-rrdtool fetch gateway_eth0_in.rrd MAX # do this to see if you are getting new data. scroll to the right time /usr/bin/i386-suse-linux-rrdtool dump CPU Temp.rrd" |more # Print data from the last 5 min from bash TIME=$(date +%s); RRDRES=900; /usr/bin/i386-suse-linux-rrdtool fetch "/var/lib/ganglia/rrds/unspecified/daman.stilen.com/CPU Temp.rrd" AVERAGE -r $RRDRES -e $(echo $(($TIME/$RRDRES*$RRDRES))) -s e-1h ---------------------------------------------------------- # Need memory in a pinch, but you have disk space #Create 1GB file dd if=/dev/zero of=/swapfile bs=1k count=1048576 #Make it a spwap mkswap /swapfile #Acivate swapon /swapfile # #Now do your memory hog business # #When done, turn it off swapoff /swapfile #Remove rm -rf /swapfile ----------------------------------------------------- # X2X allows you to share multiple monitors with one mouse and keybaord # `xhost +` must be run for this to work. # one person used this-> &/devnull; x2x -to receiving_ip:0 -west -resurface >& /dev/null x2x -to :0 -west -resurface >& /dev/null& ----------------------------------------------------- # synergy allows you to share multiple monitors with one mouse and keybard # Due to the client server model, `xhost +` does not need to be run vi ~/.synergy.conf # synergy config file for host_name_on_left # 2003/03/12 ################################### section: screens host_name_on_left: host_name_on_right: end section: links host_name_on_left: right = host_name_on_right up = host_name_on_right host_name_on_right: left = host_name_on_left down = host_name_on_left end section: aliases host_name_on_left: host_name_on_left.stilen.com host_name_on_right: host_name_on_right.stilen.com end On host_name_on_right, synergys -f -1 On host_name_on_left, synergyc -f -1 --no-camp host_name_on_right Now the mouse and keyboard on host_name_on_right can opperate on host_name_on_left ----------------------------------------------------- # Terminal defenitions infocpm - dumps the specifications on a terminal type (like xterm, nterm...) (hpux has 'untic') tic - to add a new termainl spec to a system. (I did this for term type putty). ----------------------------------------------------- # Fonts in kde are all messed up, and I needed to reset them. Fonts are fine for every other user, other than me, so I made my ~/.kde2/share/config/kdeglobals look like another users, then log out, without saving your session, and log in again. ----------------------------------------------------- # Check stuff out of a cvs tree # examples cvs -d :pserver:anonymous@cvs.sourceforge.net:cvsroot/nilo login cvs -z3 -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/nilo co nilo cvs -d :pserver:anon@cvs.lm-sensors.nu:/home/cvs checkout lm_sensors2 ----------------------------------------------------- # SuSE8.1 Network card would not configure. # Had to add e100 module to the list in /etc/sysconfig/kernel INITRD_MODULES="aic7xxx reiserfs e100" # Then had to run SuSEconfig /sbin/SuSEconfig # And finally make initrd /sbin/mk_initrd ----------------------------------------------------- # Xwindow popup notify: #this is in tcsh alias atnotify 'echo xmessage -display :0 \!:2-$ | at \!:1' # Now set the message and time atnotify 16:20 "Safty Meeting!" ----------------------------------------------------- # Build man pages on a sun catman -w \# run as root, builds man pages ----------------------------------------------------- # Partitioning a 6Gb drive for linux: / 488Mb /boot 15Mb /home 2.1Gb /usr 3.3Gb ----------------------------------------------------- RCS - Revision Control System # #Make a directory RCS # The fist time you create a file, first line # $Id: $ # Check out ( co=check out, -l=lock ) co -l filename # Checking in files (ci=check in, -u=unlock) ci -u filename # Break lock cp filename filename.user rcs -u filename co -l filename ----------------------------------------------------- volume control - sound aumix =shell interface to sound gmix =gnome volume contorl ----------------------------------------------------- #Mounting an initrd immage with # Run 'file' command against your /boot/initrd file initrd.suse initrd: Linux rev 1.0 ext2 filesystem data # Make temp directory as the mount point mkdir tmp # Mount the initrd immage usign the 'loop' option # (unlike a hard drive which is a block dev) mount -o loop -t ext2 initrd.suse tmp/ # Now we go in and check if the proper modules are in there cd tmp/lib/modules/2.4.4-4GB/kernel/drivers/scsi/ ls -alF -rw-r--r-- 1 root root 65180 May 18 07:36 ncr53c8xx.o ------------------------------------------------------ --------------------------------------------- Automatic background changes in Window Maker --------------------------------------------- http://portico.org/articles/background.php3 Normally changed by modifying the file: ~/GNUstep/Defaults/WMRootMenu Line: ("Images", OPEN_MENU, "/usr/share/WindowMaker/Backgrounds ~/GNUstep/Library/WindowMaker/Backgrounds WITH wmsetbg -u -t") This script to change the background in Window Maker ================================= background.pl ==========BEGIN=============== #!/usr/bin/perl $my_images="/usr/share/WindowMaker/Backgrounds"; $wmsetbg="/usr/X11R6/bin/wmsetbg"; opendir DIRECTORY, '$my_images'; @images = readdir DIRECTORY; #get a list of all the backgrounds closedir DIRECTORY; $ENV{DISPLAY} = "gawk.wwc.edu:0.0"; #sets DISPLAY #This following line runs wmsetbg -t -s /usr/share/WindowMaker/Backgrounds/randomimage system ('$wmsetbg','-t','-s', "$my_images$images[(rand $#images)+2]"); ============END================ chmod +x background.pl crontab -e * 0 * * * /home/linuxboy/background.pl --------------------------------------------- shortcuts in kde to have your F-keys launch an application, try installing http://lineak.sourceforge.net/ or Klineakconfig or Macro Express haven't tried it yet In KDE: K->system -> tools -> menu editor Added Item to Editors named 'nedit' Under the 'Current key' -> Primary->F2 Also get there via kmenuedit ##################################################### # Respond to spam # If you can first use rbl lists like: # relays.osirusoft.com rbl-plus.mail-abuse.org bl.spamcop.net relays.ordb.org sbl.spamhaus.org relays.osirusoft.com # KR.rbl.cluecentral.net JP.rbl.cluecentral.net CN.rbl.cluecentral.net BR.rbl.cluecentral.net blackholes.mail-abuse.org # If you get spam, # 1. View all headers, and record the "Received: from" IP address # 2. Run 'whois ' # 3. Look for an email address like abuse@offending_domain.net or whatever the record lists for abuse or technical contact. # 4. Create an email to the abuse address: # a. include a message like: # The appended spam was unsolicited and is unwanted. # Please deactivate that email account or shut down your spam server. # b. include the full headers for the message. # c. include the original email # 5. If you get more spam from them, create an iptables rule to ignore the spam: # iptables -I INPUT -s -j drop-log # ##################################################### Push the processor- put needless load on a system #!/bin/sh cd /usr/src/linux-2.4.19 touch /usr/tmp/log.loader while [ 1 ] ; do make mrproper > /dev/null make oldconfig > /dev/null make -j 4 dep > /dev/null make -j 4 bzImage > /dev/null ls -l /usr/src/linux-2.4.19/.config >> /usr/tmp/log.loader sleep 3 done ##################################################### # Good diagram tool for linux kivio http://www.thekompany.com/projects/kivio/ dia http://www.lysator.liu.se/~alla/dia/ ##################################################### # Set the default printer for a linux account ## in tcsh/csh edit .cshrc setenv PRINTER (PRINTER NAME) ##################################################### booting to single-user mode with grub -------------------------------------- To boot a grub system in single user mode 1. boot system to grub menu 2. select the kernel from the list 3. press 'e' to edit. 4. got to end of line and type single. 5. press [enter] to exit edit mode 6. type 'b' to boot. This will allow you to log into the system as root in single user mode without providing a password. ####################################################### unix commands for different platforms: http://bhami.com/rosetta.html ####################################################### ------------------------ new nedit look ------------------------ Set your dot files tcsh: vi ~/.cshrc setenv XAPPLRESDIR ~/app-defaults bash: vi ~/.bashrc export XAPPLRESDIR=~/app-defaults Then create the dir mkdir ~/app-defaults Then create resource for nedit vi /home/jstile/app-defaults/NEdit NEdit.geometry: -92+5 nedit*text.background: black nedit*text.foreground: white *pane*textHorScrollBar*background: grey75 *pane*textVertScrollBar*background: grey75 *text.blinkRate: 0 *statsLine.background: white *text.selectForeground: black *text.selectBackground: wheat *remapDeleteKey: false nedit*text.heavyCursor: true nedit*text.cursorForeground: #fffffe nedit*preferencesMenu.overtype.accelerator: Insert nedit*preferencesMenu.overtype.acceleratorText: Insert source your dot file tcsh source ~/.cshrc bash: . ~/.bashrc launch nedit form the same prompt where you source the dot files. ---------------------------- Drag text around in nedit ---------------------------- 1. highlight the text, 2. put your mouse over the area 3. hold down control and the center mouse button and drag it around. :) ---------------------------------------- Delete the middle words for every line on a page in nedit ---------------------------------------- 1. hold down control 2 position mouse just to the upper left of center page 3. hold down left mouse button 4. drag mouse just to lower right of center page (so text in middle is selected). 5. Now hit delete (or try the Drag method on the selected area). hit ctrl-z to get it back. --------------------------------- snoop spy xwindows --------------------------------- This works if xhost+ is on xwd -root -display $1:0 | xwud --------------------------------- copy a floppy --------------------------------- Before mounting the floppy cc fi=/dev/fd0 fo=/usr/tmp/floppy.img --------------------------------- Set font size in xwindows edit .Xresources aterm*font: -*-console-medium-*-*-*-16-*-*-*-c-*-*-* run xfontsel to pick a font --------------------------------- Configuring SawFish Font --------------------------------- sawfish-ui ->click on "Appearance" and then ->click on the Browse button next to the "Default Font". -urw-bookman l-light-r-normal-*-*-140-*-*-p-*-iso8859-2 ------------------------------------------------------------------------ Change language keyboard input from Western/English to another language ------------------------------------------------------------------------ To change your keyboard in X, see your /etc/X11/XF86Config-4 file. Search for 'Option "XkbLayout"' and change that to "de", "hu", "dvorak", etc. The layout files are in /usrX11R6/lib/X11/xkb/. --------------------------------- Mouse doubelclick settings --------------------------------- It seems that it's controlled on a per-application basis by the X resource multiClickTime, for example xterm*multiClickTime: 2 -------------------------------- Foregin language keyboard problems ---------------------------------- For a table of "compose characters", see /usr/X11R6/lib/X11/locale/iso8859-1/Compose ---------------------------------- Foreign Language Keyboard remapping? ------------------------------------- To change your keyboard in X, see your /etc/X11/XF86Config-4 file. Search for 'Option "XkbLayout"' and change that to "de", "hu", "dvorak", etc. The layout files are in /usrX11R6/lib/X11/xkb/. For a table of "compose characters", see /usr/X11R6/lib/X11/locale/iso8859-1/Compose ------------------------------------ Your console froze ------------------------------------ If you hit -s in a terminal, your typing freezes. The way to get your typing back is to hit -q ----------------------------------- Kde configuration command ----------------------------------- kcmshell --list # show all available config tools kcmshell # runs specific config tool for kde ------------------------------------ Why does w or finger not show a logged in user? The reason no user is reported using w or finger is because alanr is running icewm and his own version of aterm out his home directory. Since his executables are not owned nor suid root, they won't be able to write into utmp, which is where finger gets its info. ------------------------------------- Set background in Gnome (from: http://www.gnome.org/learn/admin-guide/2.0/gconf-9.html) check /etc/gconf//path for Key path locactions: xml:readonly:/etc/gconf/gconf.xml.mandatory include "$(HOME)/.gconf.path" xml:readwrite:$(HOME)/.gconf xml:readonly:/etc/gconf/gconf.xml.defaults To set desktop background preferences, you modify the values of the preference keys in the /desktop/gnome/background location. For example, to set a mandatory image for the desktop background, run the following command: # gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /desktop/gnome/background/picture_filename filename.png To set a default value for this preference, run the following command: # gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/background/picture_filename filename.png You can also set other desktop background preferences. For information on the other desktop background preferences, see the desktop_gnome_background.schemas schema definition file. ------------------------------------------------ Typing in a console everything seems to freeze in aterm, typing -s will 'stop scrolling' the terminal. To restore normal operation, type -q To disable the 'stop scrolling' feature, type tty -ixon To send progam output to /dev/null, type -o You can remap to another key combination with : stty erase ^h stop ^] start ^\\ That will bind Crtl-] to where Ctrl-S once was, and Ctrl-\ to Ctrl-Q ------------------------------------------------ Convert jpeg to gif, or gif to jpeg Use the prgram 'convert' to switch from one media format to another. # Example: convert -resize 640x480 -colors 14 mycoolpicture.jpg mybootsplash.xpm # resize image to 640x480 # reduce colors to 14 # save new image as xpm ------------------------------------------------ Mouse click speed Put this in your .Xresources or .Xdefaults file, or create one if you don't already have one: *MultiClickTime: 250 Then type this: 'xrdb -m .Xresources' ------------------------------------------------ xmodmap notes: xdm uses .xsession xinit/startx uses .xinitrc Put your keyboard shortcuts in ~/.xmodmaprc Put a line in your .xsession (or .xinitrc) calling: xmodmap ~/.xmodmaprc A line the .xmodmaprc looks like this: keysym F4 = Insert - List current mappings: xmodmap -pk | more -or- xmodmap -pke | more - List current mouse pointer map/table: xmodmap -pp - Make mouse "left-handed": xmodmap -e "pointer = 3 2 1" - "xkeycaps" is a gui to "xmodmap" - "xev" will list all X events, mouse movement, keypress, etc. ------------------------------------------------ mouse control: # this might set click speed /usr/bin/X11/xset r rate 250 40 m 4 6 b on ~/.Xdefaults or ~/home/cjam/.Xresources # click speed xterm*multiClickTime: 3 ~/.xsession # set handed ness xmodmap -e "pointer = 3 2 1" /etc/X11/XF86Config-4 # 3 button mouse via ps2 Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "PS/2" Option "Device" "/dev/psaux" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection # 3 button wheel mouse via usb Section "InputDevice" Identifier "Mouse1" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection Section "ServerLayout" Identifier "Anaconda Configured" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Mouse1" "SendCoreEvents" # Second mouse (USB). EndSection ------------------------------------------------ Setup Evolution mailto The Mozex Plugin on http://mozex.mozdev.org/ download and in the Browser integrate. Attitudes in the Plugin meet as follows: " intercept mailto: clicks "- > hooks set under the COMMANDS simply "Mailer" - > " evolution mailto:%A?Subject=%S&Cc=%C&body=%B " enter without the quotation marks. ------------------------------------------------ curses menues: in shell try the 'dialog' command in perl install curses module: perl -MCPAN -e 'install Curses' in perl also install perlmenu module: perl -MCPAN -e 'install perlmenu' in perl also install Cmenu module: perl -MCPAN -e 'install Cmenu' ------------------------------------------------ To Force qmail to process all of queue now send ALRM signal to qmail-send process Pid=`ps -ax |grep qmail-send |awk '{print $1}'` kill -ALRM ${Pid} ------------------------------------------------ Add this to your .bashrc to dynamically change the title bar of your shell # Dynamic titlbar for aterm # http://www.tldp.org/HOWTO/Xterm-Title.html PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' ------------------------------------------------ Get a hint: if you get named errors like: check_hints: A records for B.ROOT-SERVERS.NET class 1 do not match hint records Found this debug page: http://www.reedmedia.net/misc/dns/errors.html Problem: J.ROOT-SERVERS.NET changed around November 5th, 2002 Fix: Get a new hint file pushd /var/named/ dig ns . @M.ROOT-SERVERS.NET > root.hint.20040702 mv root.hint root.hint.20020323 cp root.hint.20040702 root.hint ------------------------------------------------ Video Stuff: MTRR registers: cat /proc/mtrr grep SVGA /var/log/messages lspci -v |grep -C10 VGA grep -C10 VGA /proc/pci dmesg |grep -C10 mga_mem_base video RAM size to hexadecimal 1 MB 0x100000 2 MB 0x200000 4 MB 0x400000 8 MB 0x800000 16 MB 0x1000000 32 MB 0x2000000 Check to see if xvideo extentions are loaded grep XVideo /var/log/XFree86.0.log Check if card has card has Xv: xvinfo, for mplayer, must suport types YUY2 packed and YV12 planar Try to record television with my Hauppauge WinTV card: mplayer -vo x11 -tv on:driver=v4l:device=/dev/video0:norm=NTSC:width=640:height=480 Try to record S-Video with my Hauppauge WinTV card: mplayer -vo x11 -tv input=2:driver=v4l:device=/dev/video0:norm=NTSC:width=640:height=480 ----------------------------------------------- benchmarking /usr/sbin/dbeanch 100 bonnie++ -s 65536 openssl -speed hdparm -t /dev/sda CPU and RAM test: for x in 1 2 3 4 ; do time ( (dd if=/dev/mem bs=4096 count=51200 ; dd if=/dev/urandom bs=4096 count=1024 ) 2> /dev/null | gzip -1 | md5sum >/dev/null ) & done ----------------------------------------------- Set default browser in evolution to firebird: * Firebird is broken, such that %s does not contain the URL correctly when "Custom Web Browser: Command:" is set to run firebird directly. This is a hack to make it work. (for Gnome 2) run 'gnome-default-applications-properties' command Default Web Browser: x Custom Web Browser: Command: ~/bin/firebird.bin Create ~/bin/firebird.bin #!/bin/bash URL="$@" FIREFOX_PATH="/opt/firefox" $FIREFOX_PATH/firefox -a firefox -remote "openURL(${URL},new-tab)" || exec $FIREFOX_PATH/firefox "${URL}"; (for Gnome 1.4) Edit ~/.gnome/Gnome [URL Handlers] default-show=gnome-moz-remote --newwin "%s" * Change http-show or similar entries as well. ----------------------------------------------- Clean your evolution install: exit evolution /opt/gnome/lib/evolution/2.0/killev cd ~/.evolution find ./ -name "*ibex.index*" |xargs rm -rf {} find ./ -name "*ev-summary"|xargs rm -rf {} ----------------------------------------------- Backup your evolution for a user: gconftool-2 --shutdown evolution-2.0 --force-shutdown cd ~ tar -czvpf evolution.tar.gz .evolution .gconf/apps/evolution .spamassassin .gnome2_private/Evolution ----------------------------------------------- Set default email program in firefox to evolution: Don't know yet. You have to do it via the gnome control area, or the kde default applicaiton area, i think. ----------------------------------------------- Firefox version 0.93 was the lasat version that cleared a field when ctrl-u is pressed To make firefox-1.0 and newer, on SuSE, I had to edit /opt/firefox-1.0/res/builtin/platformHTMLBindings.xml In the section: Restart firefox. ----------------------------------------------- Run evolution in debug mode CAMEL_VERBOSE_DEBUG=1 evolution ----------------------------------------------- Killing gnome1.4 killev;oaf-slay Killing gnome2 bonobo-slay oaf-slay ----------------------------------------------- Alter the term type from command line: TERM=kermit tset -r ----------------------------------------------- After installing new fonts, loading X will be slow unless you run /usr/bin/fc-cache --verbose /usr/sbin/fonts-config --verbose Install fonts on SuSE >8.2 and above SuSEconfig --module fonts runs script named: fonts-config # taken from : http://www.suse.de/~mfabian/suse-cjk/installing-fonts.html Get a bunch of fonts: mkdir fonts; cd fonts TOTAL=3218 COUNTER=$TOTAL until [ $COUNTER -lt 1 ]; do wget http://www.highfonts.com/download.asp?fontID=$COUNTER; let COUNTER=$COUNTER-1; done added a line to /etc/X11/fs/config ------------------------------------------------ # test scan your host and security policy #nmap -S ip.of.your.router -e eth0 -sS your.machines.ip ----------------------------------------------- Debian useful package commands If you are going to use Debian, increase your apt aptitude http://www.debian.org/doc/manuals/apt-howto/index.en.html Short bit of debian notes: configure-debian the Debian Configuration interface first run 'apt-spy testing' to bench mark debian package sources on the web, setting up /etc/apt/sources.list cron 'apt-get update' to update the list of available packages and versions. cron 'apt-get -y -u upgrade -f' to auto install updates, assuming default to all answers. 'apt-get install ' to install a package 'apt-get install =' to install a specific version of a package 'apt-get --reinstall install ' to reinstalled files and upgrade to newest version. 'apt-get remove ' to uninstall a package, but configuration files remain 'apt-get --purge remove' to uninstall a package, and configuration files remain ** There is no way to remove a package using APT without also removing those packages that depend on it. 'apt-get -u upgrade' to update the files 'apt-get -u dist-upgrade -f' to upgrade distrobutions 'apt-get -o Debug::pkgProblemResolver=yes dist-upgrade -f -y' to upgrade distrobutions, and see why packages are 'kept back' 'apt-get clean' to removes everything except lock files in /var/cache/apt/archives/ and /var/cache/apt/archives/partial/ 'apt-get autoclean' to remove older package versions 'apt-get -b source package' to download source and auto build 'apt-get source --download-only ' to download source only (this will get 2 files: a patch and the source) 'dpkg-source -x .dsc' to apply the debian patch to the source 'apt-show-versions -p ' to get current version of package 'apt-show-versions -u' to list upgradeable packages 'apt-cache search ' to search for a package with 'pattern' 'apt-cache show ' to see info about a package 'apt-cache showpkg ' to see dependencies and package info 'apt-cache depends ' to show just dependencies 'apt-file update;apt-file list ' to list the contents of a package 'auto-apt run ./configure' to auto-install dependencies while running a command ** http://www.debian.org/doc/ddp A mixed system: 1. Set Main distro: /etc/apt/apt.conf -> APT::Default-Release "version"; version options: stable, testing, unstable 2. Then install the distro specific packages: apt-get -t install 3. Upgrade with apt-get install `apt-show-versions -u -b | grep unstable | cut -d ' ' -f 1` 'dpkg -S ' to find what package a file belongs to. 'dpkg -l' to list all installed packages, to search for installed packages 'dpkg -L ' to list files installed by a package 'dpkg -i .deb' to install a local file 'aptitude' Advanced text and command line front end for APT 'synaptic' Gtk GUI front end for APT 'dselect' Menu-driven package manager 'tasksel' Task installer ------------------------------------------ kde startup files created by a soft link in an Autostart directroy Each time I log into kde I want to start Synergy Created a script: ~/bin/sync.sh #!/bin/sh synergyc --daemon 192.168.0.42 Created a link in kde autostart: cd ~/.kde/Autostart ln -s /home/jstile/bin/sync.sh . ------------------------------------------ limit who can run su Add users who can run 'su' to group 'wheel' usermod -G wheel Add line to top of /etc/pam.d/su auth required /lib/security/pam_wheel.so use_uidauth required /lib/security/pam_wheel.so use_uid ------------------------------------------ find broken links (find / -type l |xargs file ) | grep 'broken' ------------------------------------------ Troubleshoot kde tips: From http://wiki.kde.org/tiki-index.php?page=Troubleshooting+KDE+Problems Run kde as another user, to show it can work (if that works look to ~/.kde) Clean out rm -rf /tmp/* rm -rf /var/tmp/* rm -rf ~/.DCOPserver-* (there are usually two of these; one is a symlink to the other) rm -rf ~/.kde/socket- rm -rf ~/.kde/tmp- which is normally a symlink to the next file: rm -rf /tmp/tmp-kde- rm -rf ~/.kde/socket- which is also normally a symlink to: rm -rf /tmp/ksocket- Update install Search bugzilla: http://bugs.kde.org Try a different windowmanager Search in http://wiki.kde.org/ ------------------------------------------ cups Setup cups printer: lpadmin -p hplj5 -v socket://192.168.60.32 /usr/bin/enable hplj5 /usr/sbin/accept hplj5 vi /etc/cups/mime.convs uncomment the line: application/octet-stream application/vnd.cups-raw 0 - vi /etc/cups/mime.types uncomment the line: application/octet-stream -------------------------------------------- Test https certificate from the client openssl s_client -connect stilen.com:443 -------------------------------------------- Get some info lspci -vv cf-cards dmesg ls -laF /dev/hda1 vi /usr/src/linux/.config udevinfo cat /proc/iomem cat /proc/ioports cat /proc/bus/pccard/drivers cat /proc/interrupts pcimodules grep -v "^#\|^$" /etc/modules.autoload.d/kernel-2.6 -------------------------------------------- Setup Address Book to use Active Directory: Evolution: General tab: Name: Name of your domain x Copy book contents locally for offline operation x Mark as default folder Server Information Server: Port: 389 Use Secure Connection: "No encryption" Authentication: Login method: "Using distinguishing name (DN)" Login: "CN=First Last,CN=Users,DC=my,DC=domain,DC=com" Details: Search base: CN=Users,DC=my,DC=domain,DC=com" "Find Possible Search Bases" is Worthless Search scope: Sub" -------------------------------------------- for loop to process list of files in a directory. ls /my/directory | (while read FILE; do echo "$FILE" du -sh "$FILE" done) -------------------------------------------- Gentoo reinstall all packages that have usefalg python3_3 emerge --newuse -1 $( eix --installed-with-use python3_3 'I*' --format '' ) --keep-going --------------------------------------------