Knowledge Base - Linux Administration APACHE ------------------------------ APACHE-PERMISSIONS chmod -R g+w /var/www or chmod -R 661 /var/www for all web pages to be publicly accessible, you need the 'others' class to have an 'x' on all the directories under /var/www chmod a+x /var/www umask 0022 is good for the web administrators to make sure that the permissions are automatically created correctly. more about umask on the bash man page APT --------------------------------- To put apt info in a file for backup: dpkg --get-selections > my_packages To restore from that file, you can do: dpkg --set-selections < my_packages and then run dselect apt-cache search thumb image | less to search all package descriptions for both words, thum and image. To see info on not-installed packages - apt-cache show apt-get clean erases all of the package files to free up space To uninstall: apt-get remove to check if any package with a name containing "ntp" exists, dpkg -l '*ntp*' dpkg -L to see what was installed as part of a package dpkg -S kdesktop_lock to see what package the program, kdesktop_lock belongs to. sometimes the output of dpkg -l | grep is truncated so you can't see the full package name. In this case, use something like: dpkg-query -W --showformat='${status} ${Package}\n' | grep 2.6 AT ---------------------------------- to set a simple reminder with "beep": at 8:15 beep ctrl-d AWK --------------------------------- replace instances of a bit of text within a file grep SENSEI /home/xuxa/.calendar | awk '{sub(/SENSEI - /,"");print}' BASE-CONFIG ------------------------- When installing Debian, there are a few config quesitons. revisit the initial setup process by running /usr/sbin/base-config BACKUP ------------------------------ See CD BASH -------------------------------- to reload your .bashrc file run: source or . /home/xuxa/.bashrc BOOTING ----------------------------- To view the command line arguments used at boot, type cat /proc/cmdline To view boot messages: more /var/log/dmesg BROWSER ----------------------------- To make firefox the default browser: cd /etc/alternatives ln -sf /usr/bin/mozilla-firefox x-www-browser ln -sf /usr/share/man/man1/mozilla-firefox.1.gz x-www-browser.1.gz CALENDAR ---------------------------- to generate personal calendar: pcal -E -o cal.ps 08 2007 12 lp cal.ps to generate On calendar: grep ON /home/xuxa/.calendar > .oncal pcal -E -H -f .oncal -o onCal.html 09 2007 12 add date after scp it to server CANON CAMERA ------------------------ gphoto2 --list-files gphoto2 --get-all-files CHMOD ------------------------------- if a directory is empty, you have to use -R chmod g+s /var/www will keep the same owntership for directories created inside www CD ---------------------------------- copying data from one cd to a new cd mkisofs -r -l /mnt/cdrom (what you want to copy) This creates a cd image and spits it to std out. So now pipe that to some file with >. mkisofs -r -l /mnt/cdrom > /home/xuxag/jishouSupa.iso To mount an iso image: you need a directory to mount it. You always have to mount things to directories... You'd want to do this to see what's exactly in an iso file. mount -o loop=/dev/loop0 jishouSupa.iso /mnt/loop (this is the mount point) To burn an iso image from disk: modprobe ide-scsi nagado:/tmp# cdrecord dev=2,1,0 speed=2 -dao /tmp/debian-30r1-i386-binary-1.iso backing up to cd as root mkisofs -r -l ./ | cdrecord dev=2,0,0 speed=4 -data - (this '-' after 'data' means to take the data from std in.) (-r = rockridge unix filesystem -J Joliet = Windows cd format -l in other cases give long filenames -data is for data, -audio for audio) -clear maybe for re-writing -erase? what to backup? config files autoexec.bat, config.sys, win.ini, system.ini cdrecord -atip dev=2,0,0 (-atip = is a little info that resides on the cd-r) tar -czvf /usr/backup/2002_02_05_backup.tgz /home/ /etc/ when cdrecord -scanbus doesn't show the cdrw, modprobe ide-scsi should give nothing lsmod should show ide-scsi MIX CD's without mounting (as root): cdparanoia 1 a.wav etc to get the files cdrecord dev=2,1,0 speed=4 -pad -audio -eject * to burn all the tracks in that dir GOOD CD MEDIA: ATIP info from disk: Indicated writing power: 4 Is not unrestricted Is not erasable Disk sub type: Medium Type A, high Beta category (A+) (3) ATIP start of lead in: -11849 (97:24/01) ATIP start of lead out: 359848 (79:59/73) Disk type: Long strategy type (Cyanine, AZO or similar) Manuf. index: 25 Manufacturer: Taiyo Yuden Company Limited These are probably Sony disks setting up a cdrw for grub, I added hdc=ide-scsi to /boot/grub/menu.list like this: ## ## Start Default Options ## ## default kernel options ## e.g. kopt=root=/dev/hda1 ro # kopt=root=/dev/hda6 ro hdc=ide-scsi note that the line is still commented. I then ran update-grub which generates a new menu.list file reboot I installed cdrecord with apt-get and then checked that the drive was recognized cdrecord -scanbus 0,0,0 0) 'PIONEER ' 'DVD-RW DVR-104 ' '1.30' Removable CD-ROM Now you need to do some configuring of cdrecord. edit /etc/default/cdrecord I added CDR_DEVICE=0,0,0 immediately after CDR_DEVICE=yamaha (as per Morph's suggestion) For the actual record, this worked: cdrecord dev=0,0,0 speed=4 -dao /tmp/agnula.iso MYSTERY CDROM If you have a mystery cdrom and it won't mount, use the following to write the data to a file that you can better evaluate: katsugi:/home/xuxa# dd if=/dev/cdrom of=/tmp/mystery_disk In order to determine the DVD-RW target (0,1,0 for katsugi), I found the drive detected at boot in /var/log/messages and that it was connected to /dev/hdb. I then used cdrecord dev=/dev/hdb -scanbus to get the target. I used the following command to burn successfully: cdrecord -dao -pad -overburn -eject ubuntu-6.06-desktop-powerpc.iso Rover helped me edit /etc/defaults/cdrecord to change the following lines: # The default device, if not specified elswhere # CDR_DEVICE=pioneer # drive name device speed fifosize driveropts # pioneer= ATA:0,1,0 -1 -1 burnfree 21:38 < xuxa> 1) check to see where the drive was detected by the system by looking at /var/log/messages 21:39 < xuxa> for example /dev/hdb 21:39 < xuxa> run "cdrecord dev=/dev/hdb -scanbus" to get the target info (0,1,0) 21:39 < xuxa> edit /etc/default/cdrecord to update the drive manufacturer and add the driver name line if necessary 21:40 < xuxa> run cdrecord as root to burn 21:40 < xuxa> heh, forgot the numbers after 1) 21:40 <@rover> that's correct 21:40 < xuxa> great 21:40 <@rover> that's for ATAPI drives 21:40 <@rover> and Linux 2.6 CP ---------------------------------- cp -R -d /home/xuxak/ the -R is recursive to descend into the directories and -d tells cp not to follow links (preserve the actual link, don't follow that.) CRON -------------------------------- for the daily schedule stuff, I've set: chappa:/tmp# crontab -l 00 4 * * * /usr/local/bin/my_daily_reminder_script.sh DESKTOP BACKGROUND ------------------ to put an image on the background in openbox, use feh: feh --bg-scale /home/xuxa/images/journal/2002_12_12_mirror_light.jpg to put mail.log from nichou on top, use: on nichou, root-tail and xauth (xbase-clients) must be installed ssh -X nichou root-tail -g 3000x1150+20+20 -frame /var/log/mail.log DMA --------------------------------- To enable DMA on a DVD drive: run "mount" to see which drive you're looking for then hdparm /dev/hdc (replacing the hd~ with the proper drive) edit /etc/hdparm.conf to add a line enabling dma at boot reboot and check that dma is now on DNS --------------------------------- Things seem to be screwy with the default DNS servers that my clients try. To set it properly, edit /etc/dhclient.conf with : supersede domain-name-servers 192.168.1.125; DU ---------------------------------- du -ak / | sort -nr | less This gives you all the files and directories on the system, in descending order by size. EMACS ------------------------------- apt-get install emacs-goodies-el for color themes and the like... to jump to the mark position ctrl-space to set mark ctrl-x ctrl-x to jump to mark to set the background color - alt-x set-background-color to set it permanently, add this to your .emacs file? (set-background-color "whatever") to count the words in a selection: M-| (to run a shell command) wc or to count the words from the cursor forward, M-x count-matches to replace a selection with the output of a shell command C-u M-| to enter an "enter" key in a minibuffer ctrl-q, ctrl-j put a section of the text into to the copy buffer ctrl-space at beginning to put mark alt-w to copy to kill buffer ctrl-w to cut replace-all (non-interactive) M-x replace-string to cut a rectangle of text ctrl-x r k to paste a rectangle (yank) ctrl-x r y FAVICON ----------------------------- I managed to put a Chinese character into a favicon.ico file using: echo [Chinese character]|bg5ps -s 15| pstopnm -stdout -pbm -|pnmcut -bottom 333|pnmcrop|pnmpad -white -l1 -r1 -t1 -b1|ppmtowinicon -output favicon.ico back when I used big5. FIND -------------------------------- find / -iname *.png -- find all files on the system that end with .png (-iname searches file names and is case insensitive) find /home/xuxa/miscTxt/ -iname "*.tex" <-- sometimes you need quotes if there are .tex files in the current directory that get expanded before going to the find command find /data/shared/miscTxt/ -amin -60 -- find all files accessed within the last hour. find /home/xuxa/miscTxt/onEnsemble/ -iname *050418* -- Searching for the existence of a particular contract GREP -------------------------------- pull all the email addresses from a file: egrep -o '[^[:space:]]+\>@[a-zA-Z_\.]+\.[a-zA-Z]{2,3}' somefile To search recursively for a reference to something in a config file somewhere: chappa:/etc# grep -r 4.2.2.2 * GROUPS ------------------------------ adding an existing user to an existing group: usermod -a -G www-data shoji HOST -------------------------------- host -t mx -v domain.com gives full output, including mx records INKSCAPE PRINTING ------------------- IP ADDRESS CHANGE ------------------- Use these sites to test: www.zoneedit.com/lookup.html http://zmailer.org/mxverify.html KERNEL ------------------------------ 050930 how I built a kernel on the AMD64 box (chappa) downloaded the newest kernel from kernel.org. Happened to be linux-2.6.13.2 moved it to /usr/src/ used bunzip2 and tar xvf to uncompress the kernel created a link: ln -s linux-2.6.13.2 linux in the /usr/src dir apt-get install kernel-package ncurses-dev fakedev (ssh wget etc) cd linux look in /boot/ to see if there is an existing config file make menuconfig at the bottom of the list, choose "Load an Alternate Config File" give the path to the current, working config "/boot/config-2.6.8-2-386" go through the list and make sure the kernel options are correct save the config file make-kpkg clean fakeroot make-kpkg --revision=custom.1.0 kernel_image the --revision part appends your own chosen identifier to the end of the kernel -- oops errors in build -- new attempt: copied /boot/config-2.6.8-2.386 to /usr/src/linux make oldconfig accept all defaults make menuconfig change processor type to athlon64 save config make-kpkg --revision=custom.1.0 kernel_image LATEX --------------------------------- LATEX CAPTIONS --------------------------- \begin{figure}[h] \centering \includegraphics[scale = .25]{/home/xuxa/images/onEnsemble/burn_your_on_audio_prep} \caption{Audio preparation and distribution} \end{figure} LATEX COLOR TEXT ------------------------- \usepackage{color} \textcolor{red}{my red text goes here} LATEX GRAPHICS --------------------------- to use things generated in inkscape export to png, 600dpi in the .tex file, \usepackage{graphicx} \includegraphics{/tmp/session_5_calendar.png} LATEX ITEMIZE ---------------------------- for a tighter itemize list, \usepackage{paralist} \begin{compactitem} \end{compactitem} note that the paralist package changes the way the regular itemize list works too, so it's not a good idea to use it in On Ensemble's contracts LATEX LISTS for a list with custom item headers, including letters instead of bullets, numbers, roman numerals, etc: \begin{description} \item[label] First item \item[label] Second item .... \end{description} for tight lists: \usepackage{paralist} \newenvironment{itemizeC}{\begin{compactitem}}{\end{compactitem}} \begin{itemizeC} \item{} \item{} \end{itemizeC} LATEX LIVE PDF GENERATION ---------------- latexmk -pvc -pdf myfile.tex LATEX MAIL MERGE ------------------------- when doing multi-page letters with a duplex printer, make sure the page number is even before printing. If a letter is 3 pages, for example, add the following to the end of the letter to add a blank page and keep the page count even. \ps{My sincere apologies for the delay!} \pagebreak \textcolor{white}{.} \end{letter}} LATEX MARGINS ---------------------------- when you want to decrease the bottom margin \setlength{\textheight}{9in} LATEX POSITIONING ------------------------ To put bits of text in any position you want \usepackage[absolute]{textpos} \begin{textblock}{5}(0,0) \begin{Huge} \=On Ensemble \end{Huge} \end{textblock} When \vspace doesn't want to work, try \vspace* LATEX SIDE BY SIDE TEXT ------------------ Use two minipages back to back to get side by side text. For some reason, the tabbing environment causes the right side text to be set down page about 1em. The \vspace{-1em} command below sets it back \begin{minipage}{3in} \begin{tabbing} Some\=i Yoshino Taiko Ensemble\\ \> Naoko Amemiya\\ \> Ellen Reiko Bepp\\ \> Hiroyuki Jimi Nakagawa\\ \> Kallan Yoichi Nishimoto\\ \end{tabbing} \end{minipage} \hspace{2em} \begin{minipage}{3in} \vspace{-1em} \begin{tabbing} \=On Ensemble\\ \> Masato Baba\\ \> Kristofer Bergstrom\\ \> Shoji Kameda\\ \> Kelvin Underwood \end{tabbing} \end{minipage} LATEX SYMBOLS ---------------------------- Copyleft symbol: ${\large\textcircled{\tiny\bfseries\sffamily\raisebox{.3ex}{CC}}}$ Ordinals $^{\mathrm{rd}}$ LATEX TABBING ---------------------------- When you want to indent text: \begin{tabbing} ---------------------\= \kill \\ Name: \> Kristofer Bergstrom\\ Organization: \> \=On Ensemble\\ Address: \> PO Box 15992, Los Angeles CA 90015\\ Phone: \> 310-350-8825\\ Email: \> \url{kris@domain.org}\\ Website: \> \url{OnEnsemble.org}\\ \end{tabbing} LATEX TABLES ----------------------------- {\bf \=On Ensemble batchi order for pickup on or after Sept 26} \begin{tabular}{||lll||} \hline \hline Wood & Size & Num pairs \\ \hline \hline Hou & 40cm $\times$ 19mm & 26 pairs\\ Hou & 42cm $\times$ 30mm & 3 pairs\\ Hou & 41cm $\times$ 20/24 tapered & 1 pair\\ Kashi & \#8 & 3 pairs\\ Buna & 42cm $\times$ 28mm & 1 pair\\ Hinoki & 32cm $\times$ 18mm & 1 pair\\ \hline \hline \end{tabular} LATEX TEXT BLOCK ------------------------- Redefine text block size \setlength{\textheight}{8in} \setlength{\textwidth}{6.5in} \setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in} \begin{document} \usepackage[paperheight=9in,paperwidth=6in,noheadfoot,margin=0in]{geometry} LATEX XDVI ------------------------------- viewing landscape dvi files: xd -paper usr wkshp1_tia_intro.dvi MAILMAN ------------------------------- create a new list with "newlist on-announce" MAN ----------------------------------- man -k sieve to see different man pages which include sieve in the name MEMORY STICK -------------------------- mount /mnt/memstick tar -czvf ~xuxak/palmk/backup/jan_11_02.tgz /mnt/memstick (the -c is 'create' the -z is 'compress' the -v is 'verbose' and the -f tells it that the next thing is the file to write to.) MODULES ------------------------------- to check menuconfig to see if a driver is loadable as a module, cd to /home/xuxa/kernel/linux and run make menuconfig lsmod lists all loaded modules rmmod removes a module modprobe adds a module mknod makes the special file that is a device node. A device node is a way to read and write to a device. You can create config files in /etc/modutils and run update-modules to add them to your modules.conf to make modules load on demand (for example, to get ide-scsi and 8139too to load automatically) added "alias eth0 8139too" to the bottom of /etc/modutils/aliases and ran update-modules MOUNT -------------------------------- On a fresh debian install, I couldn't su to root. The drive was mounted read-only. So I hit the shift key during a boot to get to lilo install, used "Linux init=/bin/bash" from the LILO prompt to get a root shell. Then I used mount -t ext2 -o remount,rw /dev/hda2 / to remount the drive. I was then able to change the root password with passwd. To mount the audio recorder: tail /var/log/messages mount -t vfat /dev/sdc1 /mnt/zoom/ (the bottom-most USB slot on the PCI card is /dev/sdb1) MUTT ---------------------------------- to change the from field before sending a message: f to search for messages containing "foo" in the subject line: ~s foo ~f for the from line in header / search-reverse search backwards for a regular expression MYSQL --------------------------------- see knowledge_base_mysql.txt MP3 ----------------------------------- to convert (decode) an mp3 file to wav (for burning to CD, for example) lame --decode myfile.mp3 MYTHTV -------------------------------- importing avi tv shows scp /tmp/mynewshow.avi root@odaiko://myth/tv/ cp /data/mynewshow.avi /myth/tv myth.rebuilddatabase.pl --ext avi it should detect the new avi file and ask a few questions about it it'll then do some sort of encoding and the file in /myth/tv will no longer have the same name (though it'll still end in .avi) NETWORKING ---------------------------- for an NIC, rover suggests Tulip (the original DEC chip) and 3Com 3c905 my NIC is the Netgear FA310TX, and uses the tulip driver when having difficulty, open two consoles: tail -f /var/log/syslog and /etc/init.d/networking stop watch -d ifconfig eth0 in one window ping 192.168.1.101 in another and watch /etc/sysconfig/network-scripts/ifcfg-eth0 is where I set 192.168.1.105 note BOOTPROTO can be set to dhcp here to use ADSL /etc/hosts is where you add hosts to ip addresses so if you change the host names, remember to change these hosts files on both computers. adding a route route add -net 192.168.0.0 netmask 255.255.255.0 eth0 ifconfig eth0 192.168.0.2 to set the IP NTP ----------------------------------- run /etc/init.d/ntp start /var/log/ntpstats rdate -s 192.168.1.101 NUP TEXT PRINTING ---------------------- enscript -U 4 contacts.txt -p contacts.ps OGG ENCODING --------------------------- oggenc input_file.wav -a "OnEnsemble.org" -d "March 11, 2004" -t "On Ensemble KPFK 90.7 Global Village Interview / Live Performance" -o output_file.ogg OGG CONVERSION ------------------------- to burn a CD of an ogg file (Eben Moglen's speech, for example) oggdec file.ogg <- this produces file.wav sox file.wav -c 2 -r 44100 file.wav <- this converts mono to stereo and converts the file to the proper rate OPENBOX -------------------------------- file:///usr/share/doc/openbox/config.html to start: mkdir $HOME/.config/openbox/ cp /etc/xdg/openbox/*.xml $HOME/.config/openbox PARTITIONS ----------------------------- df -h to see partition info PATH ---------------------------------- your path is located in ~/.bash_profile PCI ----------------------------------- lspci -v to see what the vid card is all about PDF ----------------------------------- to take a few pages out of a PDF file and plop them into a new file: pdftk A=myBigFile.pdf cat A1-6 A8 output mySmallFile.pdf you can also merge/join/rotate PDF's with the pdftk program see http://www.pdfhacks.com/pdftk/ for good examples PERMISSIONS --------------------------- (see also chgrp) I think the x bit on a directory controls if you can cd to that directory chmod 1777 "dir" to make files deletable only by owner chmod o+t should be the same POSTGRES ------------------------------ Next time you want to create a DB for the web, su to the www-data user and type createdb rules concerning access are controlled by the pg_hba.conf file delete from data where eid=2 PRINTING ------------------------------ lp printer daemon four pages per sheet: psnup -n 4 calories.ps | lp http://localhost:631 four pages per sheet PDF: lp -o number-up=4 gpl3-dd1to2-markup-rationale.pdf odd pages: lp -o page-set=odd filename lp -d hp5550dn -P 4-6 thank_you_returning_members.pdf PS ------------------------------------ ps -ef | grep mysql to look through all processes for mysql ps -fu root to see what processes are running as root QALC ---------------------------------- RAID ---------------------------------- cat /proc/mdstat will give some info about the status of the raid mdadm --detail /dev/md0 will give details when something looks weird like this: md2 : active raid1 sdb3[2] sda3[1] 19534976 blocks [2/1] [_U] I used the following command to add the missing partition back in mdadm /dev/md2 --add /dev/sdb3 REGULAR EXPRESSIONS ------------------- ^a.*r$ ^ is the beginning of an expression . is any one character zero or more of what comes before it matches zero or more digits [0-9]* [0-9]{3,5} matches at least 3 but not more than 5 digits grep '^[a-z]\{15,15\}$' /usr/share/dict/words gives you all 15-letter words searching within mail.log for rejected email addresses: grep -i "user unknown" /var/log/mail.log | grep -o "to=<.*@.*> " | sort | more RENAMING MULTIPLE FILES --------------- for i in *; do mv "$i" newprefix"$i"; done for f in *.mp3; do mv $f `basename $f .wav.mp3`.mp3; done; RSYNC --------------------------------- to do temp backups to shami: hm... fill in later. RPM ----------------------------------- To check a version of a program installed: rpm -qa |grep rpm -q -a gives you all the packages installed rpm -q -a | grep -i mysql will give you all the mysql packages for i in $(rpm -q -a | grep -i mysql); do rpm -e $i; done RUNLEVELS --------------------------- To set the runlevels of various programs: control-panel To set Debian to boot in single user mode, as root do telinit 1 SCHEDULE ---------------------------- The system sends me daily emails from a cron job that runs this: chappa:/tmp# cat /usr/local/bin/my_daily_reminder_script.sh #!/bin/bash my_date=$(date +%m%d) todays_events=$(grep $my_date /home/xuxa/miscTxt/personal/schedule.txt) echo $todays_events | mail -s "Today's events and to-do" xuxa@domain.org SCP --------------------------------- scp /data/test_file.txt 192.168.1.103:/var/www scp /home root@shami://data/tempBackup/nagado_2003_12_20/ To copy a directory and all it's contents, scp -r SCREEN CAPTURE ----------------------- gimp "acquire" SCREEN RESOLUTION -------------------- to figure out what resolution (modeline) is currently running: xrandr -q SCSI --------------------------------- when installing a new drive: cat /proc/scsi/scsi SECURITY ----------------------------- To check the security of an online retailer: nmap -O -sS -F -P0 -T Aggressive newguy.com and require that all ports show as closed or filtered except for 80, 443, and, possibly, 25 and 22, and that the Operating System is not Windows. SED ---------------------------------- cat my_file_without_commas | sed -e 's/$/,/' cat my_file_with_commas | sed -e 's/,$//' cat file_w_blank_lines.csv | sed '/^$/d' to replace random whitespace (including tabs, I think), with a comma: sed -r 's/[[:space:]]{2,}/,/g' myfile.txt to remove all spaces at the end of lines in a file: sed 's/ *$//' hist.txt > hist2.txt SIEVE -------------------------------- sieveshell -a xuxa@domain.org localhost require "fileinto"; if header :contains "List-Id" "" { fileinto "lists/tlug"; } elseif header :contains "List-ID" "" { fileinto "lists/ardour"; } siveshell -u xuxa@domain.org localhost require "fileinto"; if header :contains "X-Spam-Status" "Yes," { fileinto "Spam"; } elsif header :contains "List-Id" "" { fileinto "Lists/lilax"; } elsif header :is "Sender" "owner-info-cyrus@domain.edu" { fileinto "Lists/cyrus"; } Look into sieveshell when you're ready to post it to the server SORT --------------------------------- To sort a list of names by last name, ie George Abe 2 Eiko Amano 2 Byron Au Yong 4 use sort +1 -2 /file.txt > /tmp/file.txt SPAM --------------------------------- for EMAIL in `cat /tmp/jaccc_email_list.txt`; do mail -s "Subject: Help the JACCC by shopping at Ralph's or Food4Less" -a "From: rewards@domain.org" $EMAIL < jaccc_message_body.txt; done for EMAIL in `cat emailfile.txt`; do mail ..... $EMAIL < messagebody; done xuxa@nagado:/tmp/program$ for EMAIL in `cat /data/shared/miscTxt/onEnsemble/cOntacts/emailList/email_list_041124.txt`; do mail -s "On Ensemble last-minute tickets" $EMAIL < /data/shared/miscTxt/onEnsemble/perf/wip04/email_announcement_2_wip041203.txt ; done sending spam: root@nami:/usr/share/doc/mailman# telnet localhost 25 Trying 127.0.0.1... Connected to nami. Escape character is '^]'. 220 namitsuke.onensemble.org ESMTP Postfix (Debian/GNU) mail from: 250 Ok rcpt to: 250 Ok data 354 End data with . to: "Michael Fair" from: "Kris" Subject: Test this is the body . 250 Ok: queued as 41BCE1518F SSH ---------------------------------- ssh -l xuxa 192.168.1.103 ~/.ssh/authorized_keys2 should be chmod 400 (nobody else can read them) ssh-keygen generates new key pairs. Put the .pub half into the other machine's authorized_keys2 and vice versa. ssh -l xuxak -2 kiwi xuxak is the user name where you're trying to go and kiwi is the hostname of the foreign host add -v for verbose scp -r xuxak@kiwi:miscTxt /oldDrive/xuxag/backup/kiwiBak/ 1) ssh user@hostname # uses defaults in /etc/ssh/ssh_config and ~/.ssh/* Normally that will also enable X11 forwarding, but that is dependent upon the server you are connecting to as well. 2) ssh -X user@hostname # uses defaults as well, but specifically enables X11 forwarding. ssh user@hostname is the same as ssh -l user hostname or ssh hostname -l user 3) ssh -C user@hostname # will compress data as it flows across. Usually results in faster X11 performance. 4) scp /path/to/local/file user@hostname:/path/to/remote/directory 5) scp user@hostname:/path/to/remote/file /path/to/local/directory 6) sftp user@hostname Can't open display is problem. Possible solutions: 1) On the client, in ~/.ssh/config, you have ForwardX11 no. 2) On the client, in /etc/ssh/ssh_config, you have ForwardX11 no. 3) On the server, in /etc/ssh/sshd_config, you have ForwardX11 no. 4) On the server, in ~/.ssh/config, you have ForwardX11 no. SU ---------------------------------- su -c peace will su to root and then run the one-word command su -c "ls -l" SYMBOLIC LINKS----------------------- ln -s /home/xuxak/.bashrc /root/.bashrc TARBALLS ---------------------------- installing from tarballs see /home/xuxag/foundDocs/linuxGazette/issue74/issue74.html#tips/1 2/3 down the page under "Installing Software from Source" DECOMPRESSION for i in lg-issue* ; do tar -zxvf $i ; done To see what's in a tarball tar tvf If everything isn't nicely under its own directory: mkdir rudeprogram-6.66 tar xvf rudeprogram-6.66.tgz -C rudeprogram-6.66 tar xzvf linux.2.6.0...gz for quickly backing up the server: tar czvf var.tar.gz /var TERMINAL ------------------------------ less .bash_history xterm -fn fixed& Shell scripting for i in /dev/cdrom* ; do eject $i ; done ls 0[89]* tracks 8 and 9 ~ whatever ls 0[5-9]* tracks 5 to 9 ~ whatever TEX ----------------------------------- to find where the local dir for teTeX packages on a system is: kpsewhich -expand-var \$TEXMFLOCAL this is where packages should be installed TIME ---------------------------------- ntp - /usr/sbin/ntpd restart ntpq -p to make sure things are running rdate namitsuke to sync to the ntp server TIMESTAMPS ---------------------------- to check the create date of a file: ls -l | cut -b44-55 TIMEZONE ------------------------------ Setting your timezone The timezone under Linux is set by a symbolic link from /etc/localtime[1] to a file in the /usr/share/zoneinfo[2] directory that corresponds with what timezone you are in. For example, since I'm in South Australia, /etc/localtime is a symlink to /usr/share/zoneinfo/Australia/South. To set this link, type: ln -sf ../usr/share/zoneinfo/your/zone /etc/localtime I did ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime TR ------------------------------------ To get rid of weird whitespace in a file, you can replace all repeated spaces with a single space: tr -s ' ' < add_weird_spaces.txt > add_single_spaces.txt TXT PRINTING -------------------------- open in abiword and print. Is there a better cli way? UMASK --------------------------------- check bash man page VI ------------------------------------ skip to the end of a file: G global replace - :%s/superconcentrated/arugakki %s/superconcentrated\.com/arugakki\.org/g copy line - Yp WAV FILES ----------------------------- How to concatenate two wav files: convert the two files to raw (sox -V somefile.wav -s -w -t raw somefile.raw), then do cat somefile.raw somefile2.raw >concatenated.raw and then convert it back to wav (sox -V -t raw -s -w -r 44100 concatenated.raw concatenated.wav). convert sampling rate: sox myfile22050.wav -r 44100 mynewfile44100.wav WGET ---------------------------------- to download everything from a particular web location, do: wget -r -A mp3 www.whatever.com/location/ The -A limits wget to downloading files w/ those extensions WHOIS --------------------------------- whois gives owner info for domain names. For .org use: whois -h whois.pir.org modernbox.org X11 ----------------------------------- If you're root and you get Can't connect to display 0.0, run xhost + from a non-root terminal to give root X access Running an X program on a remote display ssh into the machine, then export DISPLAY=kiwi:0.0 you might need to run xhost kiwi or xhost nagado or something Use ssh -n to run an X program from one computer on another. For example, ssh -n frodo gimp & will run the GIMP on the host frodo, but display locally. Using ssh for this is much easier and more secure than setting it up in X manually. when root can't run X programs, as user: xhost local:root and as root: export DISPLAY=:0.0 local: $ xhost elaine23 remote: $ export DISPLAY=lothlorien:0.0 XCHAT --------------------------------- to send a message to just one person in a room, use /msg or /query ZIP ----------------------------------- to unzip a .zip file: unzip gunzip is for .gz files