Difference: UnixNotes (1 vs. 51)

Revision 5104 May 2014 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 198 to 198
  That command dumps all HTTP traffic to 173.76.76.13 into capture.txt and displays it on the console. -s 0 means no packet size limit, -A means dump in ASCII (good for HTTP), and -vv means verbose.
Added:
>
>

default applications

I had a problem where xdg-open (and all of GNOME) was using Handbrake to open video/mp4 files when I had configured GNOME (using the settings app) and xdg-open (using xdg-mime) to use VLC. It turns out that xdg-open delegates to gvfs-open in a GNOME environment, and for some reason gvfs-open didn't respect what I had done in the settings app. gvfs-mime is supposed to allow you to set the preferences, but they didn't "stick". In the end I had to strace gvfs_mime to see what files it was reading, and then hand-edit ~/.local/share/applications/mimeapps.list. There's a section called [Added Associations] that seems to have precedence over [Default Applications]. When I removed ghb from the added associations gvfs-mime started being willing to use vlc to open videos.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 5023 Jul 2013 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 186 to 186
  to force a full fsck on the next reboot, touch /forcefsck
Added:
>
>

tcpdump

Sometimes there's no substitute for looking at what's crossing the wire. Assuming that it's not encrypted, of course.

$ sudo tcpdump -s 0 -vv -A "host 173.76.76.13 and tcp port http" | tee capture.txt

That command dumps all HTTP traffic to 173.76.76.13 into capture.txt and displays it on the console. -s 0 means no packet size limit, -A means dump in ASCII (good for HTTP), and -vv means verbose.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 4910 Jul 2013 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 184 to 184
  If you find that the disk reports any Current_Pending_Sector errors then this will help: http://smartmontools.sourceforge.net/badblockhowto.html
Added:
>
>
to force a full fsck on the next reboot, touch /forcefsck
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 4720 Aug 2011 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 176 to 176
 $ find -L . -type l
Added:
>
>

It's a good idea to enable the SMART daemon which isn't enabled by default, at least on Debian. It will send an email if the disk reports something is wrong.

HOWTO enable smartd: http://www.cyberciti.biz/tips/monitoring-hard-disk-health-with-smartd-under-linux-or-unix-operating-systems.html

If you find that the disk reports any Current_Pending_Sector errors then this will help: http://smartmontools.sourceforge.net/badblockhowto.html

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 4613 Jun 2011 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 169 to 169
 http://www.sans.org/score/checklists/linuxchecklist.pdf
http://cisecurity.org/en-us/?route=downloads.benchmarks
http://www.nsa.gov/ia/guidance/security_configuration_guides/operating_systems.shtml#linux2
Added:
>
>

http://noone.org/blog/English/Computer/Shell/How%20to%20find%20broken%20symlinks.html - How to find broken symlinks

$ find -L . -type l
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 4522 Feb 2011 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 131 to 131
  that command writes both a big blob (the "batch") and a shell script that will apply the batch on the other side.
Changed:
<
<
This runs rsync as root on the local and remote host but uses a non-root login on the remote host which is great for systems like Ubuntu that don't allow root logins. You need to add root's public key (on the originating machine) to user's authorized_keys on the receiving machine, then run:
>
>
This runs rsync as root on the local and remote host but uses a non-root login on the remote host which is great for systems like Ubuntu that don't allow root logins.
 

Changed:
<
<
sudo rsync --rsync-path "sudo rsync" user@host:'/remotepath' localpath
>
>
$ sudo rsync --rsync-path "sudo rsync" user@host:'/remotepath' localpath
 


Revision 4421 Feb 2011 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 148 to 148
 /home / /var/mail /var /var/lib/squirrelmail /var/lib
Added:
>
>
/var/www /var
 


Revision 4323 Jan 2011 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 131 to 131
  that command writes both a big blob (the "batch") and a shell script that will apply the batch on the other side.
Changed:
<
<
This runs rsync as root on the local and remote host but uses a non-root login on the remote host which is great for systems like Ubuntu that don't allow root logins:
>
>
This runs rsync as root on the local and remote host but uses a non-root login on the remote host which is great for systems like Ubuntu that don't allow root logins. You need to add root's public key (on the originating machine) to user's authorized_keys on the receiving machine, then run:
 

Changed:
<
<
sudo rsync --rsh "ssh -i user_private_key" --rsync-path "sudo rsync" user@host:'/remotepath' localpath
>
>
sudo rsync --rsync-path "sudo rsync" user@host:'/remotepath' localpath


What to sync

When I moved from one cloud machine to another I had to decide what to sync and what to leave behind. I was also moving from Debian to Ubuntu so I couldn't just sync everything.

What I took:

source                target
----------------------------
/home                 /
/var/mail             /var
/var/lib/squirrelmail /var/lib

 


Revision 4212 Dec 2010 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 124 to 124
 
SSH and Rsync are both awesome!
Changed:
<
<
open a connection from inside a firewall allowing tunnelled logins back through: ssh -Nf -R 22222:localhost:22 login@hostname

tunnel back up that tunnel and use a USB disk sneakernet to sync a big directory: rsync -rtPv --rsh="ssh -p 22222" --only-write-batch=/usb-drive /source-dir/* login@target-host:/target-dir

>
>
open a connection from inside a firewall allowing tunnelled logins back through: ssh -Nf -R 22222:localhost:22 login@hostname
 
Added:
>
>
tunnel back up that tunnel and use a USB disk sneakernet to sync a big directory:
rsync -rtPv --rsh="ssh -p 22222" --only-write-batch=/usb-drive /source-dir/* login@target-host:/target-dir
 that command writes both a big blob (the "batch") and a shell script that will apply the batch on the other side.
Added:
>
>
This runs rsync as root on the local and remote host but uses a non-root login on the remote host which is great for systems like Ubuntu that don't allow root logins:
sudo rsync --rsh "ssh -i user_private_key" --rsync-path "sudo rsync" user@host:'/remotepath' localpath
 
Multiline patterns in sed

Revision 4111 Dec 2010 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Added:
>
>
 
Added:
>
>

At some point the nightly man-db update process started going into an endless loop using 100% CPU. I'm not sure what the problem was, but blowing away the database ( /var/cache/man) fixed it.
 

I don't know why, but the mouse (trackpoint) on the IBM A30 stopped working when I upgrade from kernel 2.4 to 2.6. I had to explicitly (i.e. /etc/modules) load mousedev and psmouse and then change gpm's mouse type from autops2 to ps2 and then things worked OK.

Line: 46 to 50
 
Deleted:
<
<
SPAM Filtering

http://www.securitysage.com/guides/postfix_uce.html has detailed info on how to set up the Postfix MTA to filter spam.

HOWTO harden postfix to SPAM: http://www.freesoftwaremagazine.com/articles/focus_spam_postfix/


At some point the nightly man-db update process started going into an endless loop using 100% CPU. I'm not sure what the problem was, but blowing away the database ( /var/cache/man) fixed it.
 chroot

Two HOWTO's that I found useful for setting up chroot jails are: http://www.tjw.org/chroot-login-HOWTO/, http://kegel.com/crosstool/current/doc/chroot-login-howto.html

Revision 4022 Nov 2010 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 151 to 151
 

Hardening Linux Machines

http://www.sans.org/score/checklists/linuxchecklist.pdf
Changed:
<
<
http://cisecurity.org/en-us/?route=downloads.benchmarks
>
>
http://cisecurity.org/en-us/?route=downloads.benchmarks
http://www.nsa.gov/ia/guidance/security_configuration_guides/operating_systems.shtml#linux2
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3919 Nov 2010 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 148 to 148
 }' src
Added:
>
>

Hardening Linux Machines

http://www.sans.org/score/checklists/linuxchecklist.pdf
http://cisecurity.org/en-us/?route=downloads.benchmarks
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3817 Sep 2009 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 135 to 135
  that command writes both a big blob (the "batch") and a shell script that will apply the batch on the other side.
Added:
>
>

Multiline patterns in sed

http://docstore.mik.ua/orelly/unix/sedawk/ch06_01.htm#SEDAWK-CH-6-SECT-1

e.g. "unfold" two lines back to a single line:

sed '/@RolesAllowed($/{                                                
N
s/\n//
}' src
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3707 Sep 2009 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 116 to 116
  HAL is responsible for mounting USB drives when they're plugged in. It will use the partition's label as a mount point if it can or it will fall back to something like "disk". http://www.debuntu.org/device-partition-labeling talks about how to set the labels on ext2 filesystems. For FAT filesystems use the mlabel command.
Added:
>
>
At Boot Time

Here's an article that talks about how to assign labels to partitions to make booting from USB devices more flexible: http://www.ibm.com/developerworks/linux/library/l-boot-rootfs/

 
Network Interfaces Change Names

Revision 3616 Mar 2009 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 122 to 122
  I had to swap a motherboard in my little home server when the old one went south, and when I booted the new one I got a message about udev: renamed network interface eth0 to eth1 which seemed kind of peculiar. It turns out that udev tries to make sure that a given network interface (identified by its MAC address) will always have the same name, even if you change the machine's hardware (e.g. add another network card). It uses a file called /etc/udev/rules.d/70-persistent-net.rules for this purpose. Since it already had some entries for eth0 and it hadn't seen the new motherboard's MAC before, it gave it the name "eth1". This is reasonable behavior once you figure it out. A quick edit to that file to change the name to "eth0" and I was all set.
Added:
>
>

SSH and Rsync are both awesome!

open a connection from inside a firewall allowing tunnelled logins back through: ssh -Nf -R 22222:localhost:22 login@hostname

tunnel back up that tunnel and use a USB disk sneakernet to sync a big directory: rsync -rtPv --rsh="ssh -p 22222" --only-write-batch=/usb-drive /source-dir/* login@target-host:/target-dir

 
Added:
>
>
that command writes both a big blob (the "batch") and a shell script that will apply the batch on the other side.
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3514 Dec 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 25 to 25
 
This appeared in the RISKS digest:
Changed:
<
<
Date: Thu, 22 Nov 2001 23:50:39 +0300 From: Diomidis Spinellis  Subject: Risks of the space character in Unix filenames                      The root of the problem reported in the "Glitch in iTunes Deletes Drives   (Solomon, RISKS-21.74)" article is the default way the Unix shell handles  filenames with embedded spaces.  Although a space can legally appear in a  Unix filename, such an occurrence is not usual; Unix filenames tend to be terse, often even shorter than a single word, (e.g. "src", "doc", "etc",    "bin") so they can be swiftly typed.  A number of more recent and supposedly user-friendly operating systems like the Microsoft Windows family, and, I    understand, the MacOS, use longer and more descriptive file names          ("Documents and Settings", "Program Files").  Many of these filenames contain spaces; the ones I listed are by default used by Windows 2000 as the location to store user data and application files (the equivalent of /home/username and /bin under Unix).  As Unix-style tools and relevant applications are increasingly ported to run under Windows (see for example [1, 2, 3] and my Windows outwit tool suite described in [4]) or natively run under Mac OS X, problems and associated    Risks arise.  The main reason is that some often-used Unix shell constructs fail when applied to filenames containing a space character.  Unfortunately, these constructs appear in many existing programs, and even in the writings of the original system developers, who, in all fairness, could not have     foreseen how their tools would have been used 25 years after their           conception.          Technically, the problem manifests itself when field splitting (the process by which the shell splits input into words) is naively applied on the output of an expansion that generates filenames with embedded spaces.  Consider the following example, appearing on page 95 of one of the classic texts on Unix programming [5]:           for i in ch2.*     echo $i:     diff -b old/$i $i     echo   done  The above code will compare all files matching the ch2.* pattern in the current directory with copies presumably stored in the directory called "old".  Consider what will happen when the code is applied to a file called "ch2.figure 3.dot" (notice the space between the word figure and the "3"). The shell variable i will be set to the correct filename, but then the shell will execute the "diff" command with the following argument list (customarily passed to C programs in the argv array):   argv[0] = "diff"   argv[1] = "-b"   argv[2] = "old/ch2.figure"   argv[3] = "3.dot"   argv[4] = "ch2.figure"   argv[5] = "3.dot"  and diff will complain   diff: extra operand as more than two filenames were passed as arguments.  This happens, because words are expanded by most Unix shells in the following order:   1. Parameter (including variable) expansion, command substitution.   2. Field splitting. As a result, the variable $i is first expanded into "ch2.figure 3" and then the result is split into fields for further processing or for passing them as arguments to a command.  The most common dangerous constructs that can appear in step 1 are variable references (e.g. $PATH, $word) and commands inside backquotes (e.g. `find . -type f -name 'ch2.*'`).  These dangerous constructs are quite common, appearing among other places in the original article describing the Bourne shell [6] (for i in * do if test -d $d/$i [...]), in other scripts in the reference of the original example [5 p. 141, 143], and even in quite recent work by the same authors [7, p. 149].  It is also prevalent in existing operating system tools; I counted 43 occurrences of one suspicious pattern ("$*") in a NetBSD source tree, 8 in a FreeBSD command path, and 49 in the shell scripts of a Mandrake Linux distribution.  The Unix world is definitely not ready to deal with filenames containing the space character.  Avoiding this problem is not trivial.  A radical solution would be to change the value of the shell's "internal field separator" (IFS) variable.  This variable contains the characters that shell uses to split words.  Its default value is ".  This solution however would break more things than it would fix, since most scripts expect words to be separated by spaces.  As an example the construct "A='ls -l';$A" would not work.  The most practical solution is to manually enclose variables inside double quotes when using them in contexts where only a single word is normally expected.  The shell will still expand the variable inside the quotes, but will treat the result as a single word.  Thus the offending part in the original example should have been written as:   diff -b "old/$i" "$i" In addition, whenever a shell script uses the variable $* to obtain the values of all parameters passed to a script, the $* variable should be replaced by the variable $@, again inside double quotes.  Thus the common code pattern   for arg in $* should be written as   for arg in "$@" Interestingly, Kernighan and Pike were aware of the $* problem and the above solution since 1984; they aptly characterize the "$@" solution as "almost black magic" [5 p. 161].  Still, these changes will not correctly handle filenames with embedded whitespace returned from a command substitution.  In this case, temporarily changing the IFS variable before executing a command may be the only feasible solution.  The following example illustrates this approach:   # Save original IFS   OFS="$IFS"   # Set IFS to newline   IFS='   '   # The find command might output filenames with spaces   wc -l `find . -type f`   # Restore original IFS   IFS="$OFS"  By searching existing shell scripts for the patterns I described and applying the suggested changes most problems can be solved.  Other scripting languages like Tcl and, to a lesser extend, Perl may also have problems dealing with filenames with spaces.  Similar approaches (appropriate quoting in Perl "eval" blocks and use of the "list" command in Tcl) can be used to avoid these problems.  References  [1] David G. Korn. Porting Unix to Windows NT. In Proceedings of the USENIX 1997 Annual Technical Conference, Anaheim, CA, USA, January 1997. Usenix Association. [2] Geoffrey J. Noer. Cygwin32: A free Win32 porting layer for UNIX applications. In Proceedings of the 2nd USENIX Windows NT Symposium, Seattle, WA, USA, August 1998. Usenix Association. [3] Stephen R. Walli. OPENNT: UNIX application portability to Windows NT via an alternative environment subsystem. In Proceedings of the USENIX Windows NT Symposium, Seattle, WA, USA, August 1997. Usenix Association. [4] Diomidis Spinellis. Outwit: Unix tool-based programming meets the Windows world. In USENIX 2000 Technical Conference Proceedings, pages 149-158, San Diego, CA, USA, June 2000. Usenix Association.  [5] Brian W. Kernighan and Rob Pike. The UNIX Programming Environment. Prentice-Hall, 1984. [6] S. R. Bourne. The UNIX shell. Bell System Technical Journal, 57(6):65-84 July/August 1978.  (Also appears in volume 2 of the Unix Programmer's Manual and in AT & T, UNIX System Readings and Applications, volume I. Prentice-Hall, 1987.) [7] Brian W. Kernighan and Rob Pike. The Practice of Programming. Addison-Wesley, 1999.  Diomidis Spinellis - http://www.dmst.aueb.gr/dds/ Athens University of Economics and Business (AUEB) 
>
>
http://catless.ncl.ac.uk/Risks/21.79.html#subj3 - Risks of the space character in Unix filenames
 
Line: 114 to 114
 
Mounting USB Devices
Changed:
<
<
HAL is responsible for mounting USB drives when they're plugged in. It will use the partition's label as a mount point if it can or it will fall back to something like "disk". http://www.debuntu.org/device-partition-labeling talks about how to set the labels.
>
>
HAL is responsible for mounting USB drives when they're plugged in. It will use the partition's label as a mount point if it can or it will fall back to something like "disk". http://www.debuntu.org/device-partition-labeling talks about how to set the labels on ext2 filesystems. For FAT filesystems use the mlabel command.
 
Network Interfaces Change Names

Revision 3401 Dec 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 109 to 109
  This might help: http://www.nslu2-linux.org/wiki/FAQ/DealWithAutoSpinDownOnSeagateFreeAgent
Added:
>
>
After living with this for a while and not figuring it out I upgraded to Debian Lenny which fixed the problem. Now when you access the drive you can hear it spinning up, and whatever program caused the access waits until the drive it ready.
 
Mounting USB Devices

HAL is responsible for mounting USB drives when they're plugged in. It will use the partition's label as a mount point if it can or it will fall back to something like "disk". http://www.debuntu.org/device-partition-labeling talks about how to set the labels.

Added:
>
>

Network Interfaces Change Names

I had to swap a motherboard in my little home server when the old one went south, and when I booted the new one I got a message about udev: renamed network interface eth0 to eth1 which seemed kind of peculiar. It turns out that udev tries to make sure that a given network interface (identified by its MAC address) will always have the same name, even if you change the machine's hardware (e.g. add another network card). It uses a file called /etc/udev/rules.d/70-persistent-net.rules for this purpose. Since it already had some entries for eth0 and it hadn't seen the new motherboard's MAC before, it gave it the name "eth1". This is reasonable behavior once you figure it out. A quick edit to that file to change the name to "eth0" and I was all set.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3316 Nov 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 37 to 37
  If you're using NFS you should sweep your filesystems periodically looking for old files named .nfs*. These get left behind when a process has a file open, another process deletes it, and the first process crashes. See http://www.sunmanagers.org/archives/1998/0229.html
Changed:
<
<
See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.
>
>
http://www.jukie.net/~bart/blog/20070316092236 - a good overview of the PXE boot process, and howto set up Debian machines to boot diskless.
http://www.linuxquestions.org/questions/debian-26/how-i-did-it-diskless-netboot-with-debian-etch-468870 - how to make a net-bootable initrd
  If you're serving more than a couple of workstations then the default NFS parameters will probably cause bottlenecks. The NFS howto at http://nfs.sourceforge.net/nfs-howto/ has a page about performance tuning. The number of instances of the server daemon is key.
Changed:
<
<
2.6

Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.

  mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4
  sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/
  make modules-install
  sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules  
>
>
I used to have to build my own kernels because the stock ones wouldn't work on diskless nodes, but as of Debian Lenny I no longer have to - the stock Debian kernels work for diskless. When a new kernel comes out I just need to copy the modules directory into the diskless node's tree, copy the kernel to the tftpserver root, make the initrd and copy that to the tftpserver root, and edit the pxelinux config file.
 

Revision 3216 Nov 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 45 to 45
  Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.
Changed:
<
<
mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4  sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/  make modules-install  sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules  
>
>
  mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4
  sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/
  make modules-install
  sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules  
 

Revision 3106 Nov 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 45 to 45
  Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.
Changed:
<
<
mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4 sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/ make modules-install sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules 
>
>
mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4  sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/  make modules-install  sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules  
 
Line: 112 to 112
  This might help: http://www.nslu2-linux.org/wiki/FAQ/DealWithAutoSpinDownOnSeagateFreeAgent
Added:
>
>

Mounting USB Devices

HAL is responsible for mounting USB drives when they're plugged in. It will use the partition's label as a mount point if it can or it will fall back to something like "disk". http://www.debuntu.org/device-partition-labeling talks about how to set the labels.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 3030 Apr 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 71 to 71
  burn a CD - http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html#Making-a-GRUB-bootable-CD_002dROM
Changed:
<
<
a good way to scan the partitions is find /boot/grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.
>
>
a good way to scan the partitions is find /grub/stage1 or find /boot/grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.
  The last time I messed with grub it was to get a USB drive to boot Linux. I had a lot of problems, from grub streaming "GRUB GRUB GRUB GRUB" messages infinitely to it just printing "GRUB" and then stopping. In my case it looks like the problem was that the disk order was different depending on whether the USB drive was being booted from or whether some other drive was. The fix was to not use the "d" flag on the grub install command.

Revision 2929 Apr 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 14 to 14
  I had a problem once trying to ssh from work to my machine at home. Everything worked fine until I left the connection idle for a while. When I hit a key I got
Changed:
<
<
Read from remote host www.caboteria.org: Connection reset by peer
Connection to www.caboteria.org closed.
>
>
Read from remote host www.caboteria.org: Connection reset by peer Connection to www.caboteria.org closed. 
  Setting ssh's KeepAlive parameter on the client and server didn't seem to do much good. I found a patch that helped, though:
Line: 28 to 25
 
This appeared in the RISKS digest:
Changed:
<
<
Date: Thu, 22 Nov 2001 23:50:39 +0300
From: Diomidis Spinellis 
Subject: Risks of the space character in Unix filenames                    

The root of the problem reported in the "Glitch in iTunes Deletes Drives  
(Solomon, RISKS-21.74)" article is the default way the Unix shell handles 
filenames with embedded spaces.  Although a space can legally appear in a 
Unix filename, such an occurrence is not usual; Unix filenames tend to be
terse, often even shorter than a single word, (e.g. "src", "doc", "etc",   
"bin") so they can be swiftly typed.  A number of more recent and supposedly
user-friendly operating systems like the Microsoft Windows family, and, I   
understand, the MacOS, use longer and more descriptive file names         
("Documents and Settings", "Program Files").  Many of these filenames
contain spaces; the ones I listed are by default used by Windows 2000 as the
location to store user data and application files (the equivalent of
/home/username and /bin under Unix).

As Unix-style tools and relevant applications are increasingly ported to run
under Windows (see for example [1, 2, 3] and my Windows outwit tool suite
described in [4]) or natively run under Mac OS X, problems and associated   
Risks arise.  The main reason is that some often-used Unix shell constructs
fail when applied to filenames containing a space character.  Unfortunately,
these constructs appear in many existing programs, and even in the writings
of the original system developers, who, in all fairness, could not have    
foreseen how their tools would have been used 25 years after their          
conception.        

Technically, the problem manifests itself when field splitting (the process
by which the shell splits input into words) is naively applied on the output
of an expansion that generates filenames with embedded spaces.  Consider the
following example, appearing on page 95 of one of the classic texts on Unix
programming [5]:        
  for i in ch2.*
    echo $i:
    diff -b old/$i $i
    echo
  done

The above code will compare all files matching the ch2.* pattern in the
current directory with copies presumably stored in the directory called
"old".  Consider what will happen when the code is applied to a file called
"ch2.figure 3.dot" (notice the space between the word figure and the "3").
The shell variable i will be set to the correct filename, but then the shell
will execute the "diff" command with the following argument list
(customarily passed to C programs in the argv array):
  argv[0] = "diff"
  argv[1] = "-b"
  argv[2] = "old/ch2.figure"
  argv[3] = "3.dot"
  argv[4] = "ch2.figure"
  argv[5] = "3.dot"

and diff will complain
  diff: extra operand
as more than two filenames were passed as arguments.  This happens,
because words are expanded by most Unix shells in the following order:
  1. Parameter (including variable) expansion, command substitution.
  2. Field splitting.
As a result, the variable $i is first expanded into "ch2.figure 3" and
then the result is split into fields for further processing or for
passing them as arguments to a command.

The most common dangerous constructs that can appear in step 1 are variable
references (e.g. $PATH, $word) and commands inside backquotes (e.g. `find
. -type f -name 'ch2.*'`).  These dangerous constructs are quite common,
appearing among other places in the original article describing the Bourne
shell [6] (for i in * do if test -d $d/$i [...]), in other scripts in the
reference of the original example [5 p. 141, 143], and even in quite recent
work by the same authors [7, p. 149].  It is also prevalent in existing
operating system tools; I counted 43 occurrences of one suspicious pattern
("$*") in a NetBSD source tree, 8 in a FreeBSD command path, and 49 in the
shell scripts of a Mandrake Linux distribution.  The Unix world is
definitely not ready to deal with filenames containing the space character.

Avoiding this problem is not trivial.  A radical solution would be to change
the value of the shell's "internal field separator" (IFS) variable.  This
variable contains the characters that shell uses to split words.  Its
default value is ".  This solution however would break
more things than it would fix, since most scripts expect words to be
separated by spaces.  As an example the construct "A='ls -l';$A" would not
work.  The most practical solution is to manually enclose variables inside
double quotes when using them in contexts where only a single word is
normally expected.  The shell will still expand the variable inside the
quotes, but will treat the result as a single word.  Thus the offending part
in the original example should have been written as:
  diff -b "old/$i" "$i"
In addition, whenever a shell script uses the variable $* to obtain the
values of all parameters passed to a script, the $* variable should be
replaced by the variable $@, again inside double quotes.  Thus the
common code pattern
  for arg in $*
should be written as
  for arg in "$@"
Interestingly, Kernighan and Pike were aware of the $* problem and the above
solution since 1984; they aptly characterize the "$@" solution as "almost
black magic" [5 p. 161].

Still, these changes will not correctly handle filenames with embedded
whitespace returned from a command substitution.  In this case, temporarily
changing the IFS variable before executing a command may be the only
feasible solution.  The following example illustrates this approach:
  # Save original IFS
  OFS="$IFS"
  # Set IFS to newline
  IFS='
  '
  # The find command might output filenames with spaces
  wc -l `find . -type f`
  # Restore original IFS
  IFS="$OFS"

By searching existing shell scripts for the patterns I described and
applying the suggested changes most problems can be solved.  Other scripting
languages like Tcl and, to a lesser extend, Perl may also have problems
dealing with filenames with spaces.  Similar approaches (appropriate quoting
in Perl "eval" blocks and use of the "list" command in Tcl) can be used to
avoid these problems.

References

[1] David G. Korn. Porting Unix to Windows NT. In Proceedings of the
USENIX 1997 Annual Technical Conference, Anaheim, CA, USA, January 1997.
Usenix Association.
[2] Geoffrey J. Noer. Cygwin32: A free Win32 porting layer for UNIX
applications. In Proceedings of the 2nd USENIX Windows NT Symposium,
Seattle, WA, USA, August 1998. Usenix Association.
[3] Stephen R. Walli. OPENNT: UNIX application portability to Windows NT
via an alternative environment subsystem. In Proceedings of the USENIX
Windows NT Symposium, Seattle, WA, USA, August 1997. Usenix Association.
[4] Diomidis Spinellis. Outwit: Unix tool-based programming meets the
Windows world. In USENIX 2000 Technical Conference Proceedings, pages
149-158, San Diego, CA, USA, June 2000. Usenix Association.

[5] Brian W. Kernighan and Rob Pike. The UNIX Programming Environment.
Prentice-Hall, 1984.
[6] S. R. Bourne. The UNIX shell. Bell System Technical Journal,
57(6):65-84 July/August 1978.  (Also appears in volume 2 of the Unix
Programmer's Manual and in AT & T, UNIX System Readings and
Applications, volume I. Prentice-Hall, 1987.)
[7] Brian W. Kernighan and Rob Pike. The Practice of Programming.
Addison-Wesley, 1999.

Diomidis Spinellis - http://www.dmst.aueb.gr/dds/
Athens University of Economics and Business (AUEB)
>
>
Date: Thu, 22 Nov 2001 23:50:39 +0300 From: Diomidis Spinellis  Subject: Risks of the space character in Unix filenames                      The root of the problem reported in the "Glitch in iTunes Deletes Drives   (Solomon, RISKS-21.74)" article is the default way the Unix shell handles  filenames with embedded spaces.  Although a space can legally appear in a  Unix filename, such an occurrence is not usual; Unix filenames tend to be terse, often even shorter than a single word, (e.g. "src", "doc", "etc",    "bin") so they can be swiftly typed.  A number of more recent and supposedly user-friendly operating systems like the Microsoft Windows family, and, I    understand, the MacOS, use longer and more descriptive file names          ("Documents and Settings", "Program Files").  Many of these filenames contain spaces; the ones I listed are by default used by Windows 2000 as the location to store user data and application files (the equivalent of /home/username and /bin under Unix).  As Unix-style tools and relevant applications are increasingly ported to run under Windows (see for example [1, 2, 3] and my Windows outwit tool suite described in [4]) or natively run under Mac OS X, problems and associated    Risks arise.  The main reason is that some often-used Unix shell constructs fail when applied to filenames containing a space character.  Unfortunately, these constructs appear in many existing programs, and even in the writings of the original system developers, who, in all fairness, could not have     foreseen how their tools would have been used 25 years after their           conception.          Technically, the problem manifests itself when field splitting (the process by which the shell splits input into words) is naively applied on the output of an expansion that generates filenames with embedded spaces.  Consider the following example, appearing on page 95 of one of the classic texts on Unix programming [5]:           for i in ch2.*     echo $i:     diff -b old/$i $i     echo   done  The above code will compare all files matching the ch2.* pattern in the current directory with copies presumably stored in the directory called "old".  Consider what will happen when the code is applied to a file called "ch2.figure 3.dot" (notice the space between the word figure and the "3"). The shell variable i will be set to the correct filename, but then the shell will execute the "diff" command with the following argument list (customarily passed to C programs in the argv array):   argv[0] = "diff"   argv[1] = "-b"   argv[2] = "old/ch2.figure"   argv[3] = "3.dot"   argv[4] = "ch2.figure"   argv[5] = "3.dot"  and diff will complain   diff: extra operand as more than two filenames were passed as arguments.  This happens, because words are expanded by most Unix shells in the following order:   1. Parameter (including variable) expansion, command substitution.   2. Field splitting. As a result, the variable $i is first expanded into "ch2.figure 3" and then the result is split into fields for further processing or for passing them as arguments to a command.  The most common dangerous constructs that can appear in step 1 are variable references (e.g. $PATH, $word) and commands inside backquotes (e.g. `find . -type f -name 'ch2.*'`).  These dangerous constructs are quite common, appearing among other places in the original article describing the Bourne shell [6] (for i in * do if test -d $d/$i [...]), in other scripts in the reference of the original example [5 p. 141, 143], and even in quite recent work by the same authors [7, p. 149].  It is also prevalent in existing operating system tools; I counted 43 occurrences of one suspicious pattern ("$*") in a NetBSD source tree, 8 in a FreeBSD command path, and 49 in the shell scripts of a Mandrake Linux distribution.  The Unix world is definitely not ready to deal with filenames containing the space character.  Avoiding this problem is not trivial.  A radical solution would be to change the value of the shell's "internal field separator" (IFS) variable.  This variable contains the characters that shell uses to split words.  Its default value is ".  This solution however would break more things than it would fix, since most scripts expect words to be separated by spaces.  As an example the construct "A='ls -l';$A" would not work.  The most practical solution is to manually enclose variables inside double quotes when using them in contexts where only a single word is normally expected.  The shell will still expand the variable inside the quotes, but will treat the result as a single word.  Thus the offending part in the original example should have been written as:   diff -b "old/$i" "$i" In addition, whenever a shell script uses the variable $* to obtain the values of all parameters passed to a script, the $* variable should be replaced by the variable $@, again inside double quotes.  Thus the common code pattern   for arg in $* should be written as   for arg in "$@" Interestingly, Kernighan and Pike were aware of the $* problem and the above solution since 1984; they aptly characterize the "$@" solution as "almost black magic" [5 p. 161].  Still, these changes will not correctly handle filenames with embedded whitespace returned from a command substitution.  In this case, temporarily changing the IFS variable before executing a command may be the only feasible solution.  The following example illustrates this approach:   # Save original IFS   OFS="$IFS"   # Set IFS to newline   IFS='   '   # The find command might output filenames with spaces   wc -l `find . -type f`   # Restore original IFS   IFS="$OFS"  By searching existing shell scripts for the patterns I described and applying the suggested changes most problems can be solved.  Other scripting languages like Tcl and, to a lesser extend, Perl may also have problems dealing with filenames with spaces.  Similar approaches (appropriate quoting in Perl "eval" blocks and use of the "list" command in Tcl) can be used to avoid these problems.  References  [1] David G. Korn. Porting Unix to Windows NT. In Proceedings of the USENIX 1997 Annual Technical Conference, Anaheim, CA, USA, January 1997. Usenix Association. [2] Geoffrey J. Noer. Cygwin32: A free Win32 porting layer for UNIX applications. In Proceedings of the 2nd USENIX Windows NT Symposium, Seattle, WA, USA, August 1998. Usenix Association. [3] Stephen R. Walli. OPENNT: UNIX application portability to Windows NT via an alternative environment subsystem. In Proceedings of the USENIX Windows NT Symposium, Seattle, WA, USA, August 1997. Usenix Association. [4] Diomidis Spinellis. Outwit: Unix tool-based programming meets the Windows world. In USENIX 2000 Technical Conference Proceedings, pages 149-158, San Diego, CA, USA, June 2000. Usenix Association.  [5] Brian W. Kernighan and Rob Pike. The UNIX Programming Environment. Prentice-Hall, 1984. [6] S. R. Bourne. The UNIX shell. Bell System Technical Journal, 57(6):65-84 July/August 1978.  (Also appears in volume 2 of the Unix Programmer's Manual and in AT & T, UNIX System Readings and Applications, volume I. Prentice-Hall, 1987.) [7] Brian W. Kernighan and Rob Pike. The Practice of Programming. Addison-Wesley, 1999.  Diomidis Spinellis - http://www.dmst.aueb.gr/dds/ Athens University of Economics and Business (AUEB) 
 
Line: 181 to 33
  http://www.ltsp.org/ - the linux terminal server project, folks who have a Linux distro that turns an old PC into a diskless X-terminal. It worked very well for me on an old Pentium 133.
Changed:
<
<
http://lists.debian.org/debian-devel/2001/debian-devel-200104/msg00647.html I wasn't able to get reliable performance using the user-space nfs server (many "stale NFS handle" errors in apt-get, probably caused by moving files and trying to use the same handle) but it seems to be reliable using the kernel nfs server.
>
>
http://lists.debian.org/debian-devel/2001/debian-devel-200104/msg00647.html I wasn't able to get reliable performance using the user-space nfs server (many "stale NFS handle" errors in apt-get, probably caused by moving files and trying to use the same handle) but it seems to be reliable using the kernel nfs server.
  If you're using NFS you should sweep your filesystems periodically looking for old files named .nfs*. These get left behind when a process has a file open, another process deletes it, and the first process crashes. See http://www.sunmanagers.org/archives/1998/0229.html
Line: 194 to 45
  Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.
Changed:
<
<
mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4
sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/
make modules-install
sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules
>
>
mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4 sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/ make modules-install sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules 
 
Line: 216 to 60
  chroot
Changed:
<
<
Two HOWTO's that I found useful for setting up chroot jails are: http://www.tjw.org/chroot-login-HOWTO/, http://kegel.com/crosstool/current/doc/chroot-login-howto.html
>
>
Two HOWTO's that I found useful for setting up chroot jails are: http://www.tjw.org/chroot-login-HOWTO/, http://kegel.com/crosstool/current/doc/chroot-login-howto.html
 
grub
Line: 229 to 71
  burn a CD - http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html#Making-a-GRUB-bootable-CD_002dROM
Changed:
<
<
a good way to scan the partitions is find /grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.
>
>
a good way to scan the partitions is find /boot/grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.
  The last time I messed with grub it was to get a USB drive to boot Linux. I had a lot of problems, from grub streaming "GRUB GRUB GRUB GRUB" messages infinitely to it just printing "GRUB" and then stopping. In my case it looks like the problem was that the disk order was different depending on whether the USB drive was being booted from or whether some other drive was. The fix was to not use the "d" flag on the grub install command.
Line: 248 to 90
  Similar idea, written in perl. Seems to be more config-file oriented less command-line oriented.
Changed:
<
<
http://www.mikerubel.org/computers/rsync_snapshots/
http://blog.interlinked.org/tutorials/rsync_time_machine.html
>
>
http://www.mikerubel.org/computers/rsync_snapshots/
http://blog.interlinked.org/tutorials/rsync_time_machine.html
 
Hot-plug devices

Revision 2809 Apr 2008 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 254 to 254
 
Hot-plug devices
Changed:
<
<
When I was logged into warthog and plugged Tory's ipod into its cradle, it would get mounted automagically. When Tory tried this it didn't work. It seems that the st of programs to manage things like ipods is pretty complicated, but there's some useful info at http://www.freedesktop.org/wiki/Software/HalFAQ and especially http://www.mythic-beasts.com/~mark/random/hal/.
>
>
When I was logged into warthog and plugged Tory's ipod into its cradle, it would get mounted automagically. When Tory tried this it didn't work. It seems that the set of programs to manage things like ipods is pretty complicated, but there's some useful info at http://www.freedesktop.org/wiki/Software/HalFAQ and especially http://www.mythic-beasts.com/~mark/random/hal/.
  In our case it turned out that Tory wasn't a member of the plugdev group.
Added:
>
>

Hard Disk Spindown

I got a usb-attached disk drive to make backups to, and it spins the drive down after a while to save power. That's cool, but the problem is that Linux barfs when it tries to access the drive:

Apr  9 06:19:01 voom kernel: sd 0:0:0:0: Device not ready: <6>: Current: sense key: Not Ready
Apr  9 06:19:01 voom kernel:     Additional sense: Logical unit not ready, initializing command required
Apr  9 06:19:01 voom kernel: end_request: I/O error, dev sda, sector 12375

This might help: http://www.nslu2-linux.org/wiki/FAQ/DealWithAutoSpinDownOnSeagateFreeAgent

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2727 Dec 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 251 to 251
 http://www.mikerubel.org/computers/rsync_snapshots/
http://blog.interlinked.org/tutorials/rsync_time_machine.html
Added:
>
>

Hot-plug devices

When I was logged into warthog and plugged Tory's ipod into its cradle, it would get mounted automagically. When Tory tried this it didn't work. It seems that the st of programs to manage things like ipods is pretty complicated, but there's some useful info at http://www.freedesktop.org/wiki/Software/HalFAQ and especially http://www.mythic-beasts.com/~mark/random/hal/.

In our case it turned out that Tory wasn't a member of the plugdev group.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2622 Nov 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 237 to 237
  if you're like me you'll probably blow away the windows MBR in the process, so here's how to fix it: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/bootcons_fixmbr.mspx
Added:
>
>

backup

rdiff-backup - http://www.nongnu.org/rdiff-backup/docs.html

Python program that uses rdiff to generate efficient differential backups. Straightforward command line. Seems to use a lot of CPU.

rsnapshot - http://www.rsnapshot.org/

Similar idea, written in perl. Seems to be more config-file oriented less command-line oriented.

http://www.mikerubel.org/computers/rsync_snapshots/
http://blog.interlinked.org/tutorials/rsync_time_machine.html

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2516 Nov 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 233 to 233
  The last time I messed with grub it was to get a USB drive to boot Linux. I had a lot of problems, from grub streaming "GRUB GRUB GRUB GRUB" messages infinitely to it just printing "GRUB" and then stopping. In my case it looks like the problem was that the disk order was different depending on whether the USB drive was being booted from or whether some other drive was. The fix was to not use the "d" flag on the grub install command.
Added:
>
>
When I installed Fedora 8 on a USB drive I had to boot from the grub cdrom and then setup (hd1,0) (hd1,0).
 if you're like me you'll probably blow away the windows MBR in the process, so here's how to fix it: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/bootcons_fixmbr.mspx

META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2410 Oct 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 231 to 231
  a good way to scan the partitions is find /grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.
Added:
>
>
The last time I messed with grub it was to get a USB drive to boot Linux. I had a lot of problems, from grub streaming "GRUB GRUB GRUB GRUB" messages infinitely to it just printing "GRUB" and then stopping. In my case it looks like the problem was that the disk order was different depending on whether the USB drive was being booted from or whether some other drive was. The fix was to not use the "d" flag on the grub install command.

if you're like me you'll probably blow away the windows MBR in the process, so here's how to fix it: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/bootcons_fixmbr.mspx

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2309 Oct 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 221 to 221
 http://kegel.com/crosstool/current/doc/chroot-login-howto.html


Added:
>
>
grub

site - http://www.gnu.org/software/grub/

manual - http://www.gnu.org/software/grub/manual/

burn a CD - http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html#Making-a-GRUB-bootable-CD_002dROM

a good way to scan the partitions is find /grub/stage1 since that's about the shortest filename you can reliably look for in a grub installation.

 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2213 Jul 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 188 to 188
  See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.
Added:
>
>
If you're serving more than a couple of workstations then the default NFS parameters will probably cause bottlenecks. The NFS howto at http://nfs.sourceforge.net/nfs-howto/ has a page about performance tuning. The number of instances of the server daemon is key.
 2.6

Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.

Revision 2110 Jan 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 203 to 203
 
Added:
>
>
SPAM Filtering
 http://www.securitysage.com/guides/postfix_uce.html has detailed info on how to set up the Postfix MTA to filter spam.
Added:
>
>
HOWTO harden postfix to SPAM: http://www.freesoftwaremagazine.com/articles/focus_spam_postfix/
 
At some point the nightly man-db update process started going into an endless loop using 100% CPU. I'm not sure what the problem was, but blowing away the database (/var/cache/man) fixed it.
Line: 217 to 220
 
Deleted:
<
<
HOWTO harden postfix to SPAM: http://www.freesoftwaremagazine.com/articles/focus_spam_postfix/
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 2010 Jan 2007 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 217 to 217
 
Added:
>
>
HOWTO harden postfix to SPAM: http://www.freesoftwaremagazine.com/articles/focus_spam_postfix/
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 1901 Sep 2006 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 209 to 209
 At some point the nightly man-db update process started going into an endless loop using 100% CPU. I'm not sure what the problem was, but blowing away the database (/var/cache/man) fixed it.
Changed:
<
<
-- TobyCabot - 17 Oct 2001-28 Mar 2002
>
>
chroot

Two HOWTO's that I found useful for setting up chroot jails are: http://www.tjw.org/chroot-login-HOWTO/, http://kegel.com/crosstool/current/doc/chroot-login-howto.html


 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 1813 Nov 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 21 to 21
  Setting ssh's KeepAlive parameter on the client and server didn't seem to do much good. I found a patch that helped, though:
Changed:
<
<
http://www.icl.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html
>
>
http://www.sc.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html
  The "contributed" patch at the bottom is close to the version that ships with Debian Potato, and although it gives errors when you try to apply it it's pretty small and relatively easy to cut-n-paste by hand.

Line: 205 to 205
  http://www.securitysage.com/guides/postfix_uce.html has detailed info on how to set up the Postfix MTA to filter spam.
Added:
>
>

At some point the nightly man-db update process started going into an endless loop using 100% CPU. I'm not sure what the problem was, but blowing away the database (/var/cache/man) fixed it.
 -- TobyCabot - 17 Oct 2001-28 Mar 2002
Added:
>
>
 
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 1729 Jul 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 177 to 177
 
Deleted:
<
<
I like the Sawfish window manager, and my second-favorite theme is STPflat, by rowan@stasis.org. See http://stasis.org/~rowan/graphics.html. If only he had used the Windows "standard" button order...


 Info on diskless workstations:

http://www.ltsp.org/ - the linux terminal server project, folks who have a Linux distro that turns an old PC into a diskless X-terminal. It worked very well for me on an old Pentium 133.

Revision 1629 Mar 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 192 to 192
  See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.
Added:
>
>
2.6

Build kernel, need CONFIG_IP_PNP=y, CONFIG_ROOT_NFS=y, and of course the driver for the ethernet card should be built-in, i.e. not a module.

mknbi-linux --rootdir=rom --ip=dhcp arch/i386/boot/bzImage > /tmp/bzImage-2.6.4
sudo cp /tmp/bzImage-2.6.4 /tftpboot/lts/
make modules-install
sudo mv /lib/modules/2.4.6 /usr/local/ltsp/dickless/lib/modules


 http://www.securitysage.com/guides/postfix_uce.html has detailed info on how to set up the Postfix MTA to filter spam.

-- TobyCabot - 17 Oct 2001-28 Mar 2002

Revision 1516 Mar 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Added:
>
>
 

Revision 1409 Mar 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Line: 8 to 8
 
Added:
>
>
I don't know why, but the mouse (trackpoint) on the IBM A30 stopped working when I upgrade from kernel 2.4 to 2.6. I had to explicitly (i.e. /etc/modules) load mousedev and psmouse and then change gpm's mouse type from autops2 to ps2 and then things worked OK.
 I had a problem once trying to ssh from work to my machine at home. Everything worked fine until I left the connection idle for a while. When I hit a key I got


Revision 1327 Feb 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Deleted:
<
<
 
Line: 189 to 188
  See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.
Added:
>
>
http://www.securitysage.com/guides/postfix_uce.html has detailed info on how to set up the Postfix MTA to filter spam.
 -- TobyCabot - 17 Oct 2001-28 Mar 2002
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 1217 Feb 2004 - TWikiGuest

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"

Line: 190 to 190
 See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.

-- TobyCabot - 17 Oct 2001-28 Mar 2002

Added:
>
>
META TOPICMOVED by="guest" date="1077055262" from="Tech.UnixTips" to="Tech.UnixNotes"

Revision 1117 Feb 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechNotes"
Deleted:
<
<
(back to TechNotes)
 
Added:
>
>
 

Revision 1015 Feb 2004 - TWikiGuest

Line: 1 to 1
Changed:
<
<
META TOPICPARENT name="TechTips"
(back to TechTips)
>
>
META TOPICPARENT name="TechNotes"
(back to TechNotes)
 

Revision 906 Sep 2003 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 185 to 185
 http://lists.debian.org/debian-devel/2001/debian-devel-200104/msg00647.html I wasn't able to get reliable performance using the user-space nfs server (many "stale NFS handle" errors in apt-get, probably caused by moving files and trying to use the same handle) but it seems to be reliable using the kernel nfs server.
Added:
>
>
If you're using NFS you should sweep your filesystems periodically looking for old files named .nfs*. These get left behind when a process has a file open, another process deletes it, and the first process crashes. See http://www.sunmanagers.org/archives/1998/0229.html
 See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.

-- TobyCabot - 17 Oct 2001-28 Mar 2002

Revision 819 Apr 2003 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)

Added:
>
>
 

Revision 728 Mar 2002 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 173 to 173
 
Changed:
<
<
I like the Sawfish window manager, and my favorite theme is STPflat, by rowan@stasis.org. See http://stasis.org/~rowan/graphics.html.
>
>
I like the Sawfish window manager, and my second-favorite theme is STPflat, by rowan@stasis.org. See http://stasis.org/~rowan/graphics.html. If only he had used the Windows "standard" button order...
 

Info on diskless workstations:

Added:
>
>
http://www.ltsp.org/ - the linux terminal server project, folks who have a Linux distro that turns an old PC into a diskless X-terminal. It worked very well for me on an old Pentium 133.
 http://lists.debian.org/debian-devel/2001/debian-devel-200104/msg00647.html
Changed:
<
<
I wasn't able to get reliable performance using the user-space nfs server (many errors in apt-get) but it seems to be reliable using the kernel nfs server.
>
>
I wasn't able to get reliable performance using the user-space nfs server (many "stale NFS handle" errors in apt-get, probably caused by moving files and trying to use the same handle) but it seems to be reliable using the kernel nfs server.

See also http://syslinux.hackerdojo.com/pxe.php if you've got a motherboard with a PXE bios.

 
Changed:
<
<
-- TobyCabot - 17 Oct 2001-25 Mar 2002
>
>
-- TobyCabot - 17 Oct 2001-28 Mar 2002

Revision 625 Mar 2002 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 175 to 175
  I like the Sawfish window manager, and my favorite theme is STPflat, by rowan@stasis.org. See http://stasis.org/~rowan/graphics.html.
Changed:
<
<
-- TobyCabot - 17 Oct 2001-20 Mar 2002
>
>

Info on diskless workstations: http://lists.debian.org/debian-devel/2001/debian-devel-200104/msg00647.html I wasn't able to get reliable performance using the user-space nfs server (many errors in apt-get) but it seems to be reliable using the kernel nfs server.

-- TobyCabot - 17 Oct 2001-25 Mar 2002

Revision 520 Mar 2002 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 171 to 171
 Athens University of Economics and Business (AUEB)
Changed:
<
<
-- TobyCabot - 17 Oct 2001
>
>

I like the Sawfish window manager, and my favorite theme is STPflat, by rowan@stasis.org. See http://stasis.org/~rowan/graphics.html.

-- TobyCabot - 17 Oct 2001-20 Mar 2002

Revision 425 Feb 2002 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)

Added:
>
>
 

Revision 316 Jan 2002 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Added:
>
>


 I had a problem once trying to ssh from work to my machine at home. Everything worked fine until I left the connection idle for a while. When I hit a key I got


Revision 228 Nov 2001 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 15 to 15
  The "contributed" patch at the bottom is close to the version that ships with Debian Potato, and although it gives errors when you try to apply it it's pretty small and relatively easy to cut-n-paste by hand.

Added:
>
>

This appeared in the RISKS digest:

Date: Thu, 22 Nov 2001 23:50:39 +0300
From: Diomidis Spinellis 
Subject: Risks of the space character in Unix filenames						  

The root of the problem reported in the "Glitch in iTunes Deletes Drives  
(Solomon, RISKS-21.74)" article is the default way the Unix shell handles 
filenames with embedded spaces.  Although a space can legally appear in a 
Unix filename, such an occurrence is not usual; Unix filenames tend to be
terse, often even shorter than a single word, (e.g. "src", "doc", "etc",	
"bin") so they can be swiftly typed.  A number of more recent and supposedly
user-friendly operating systems like the Microsoft Windows family, and, I	
understand, the MacOS, use longer and more descriptive file names			
("Documents and Settings", "Program Files").  Many of these filenames
contain spaces; the ones I listed are by default used by Windows 2000 as the
location to store user data and application files (the equivalent of
/home/username and /bin under Unix).

As Unix-style tools and relevant applications are increasingly ported to run
under Windows (see for example [1, 2, 3] and my Windows outwit tool suite
described in [4]) or natively run under Mac OS X, problems and associated	
Risks arise.  The main reason is that some often-used Unix shell constructs
fail when applied to filenames containing a space character.  Unfortunately,
these constructs appear in many existing programs, and even in the writings
of the original system developers, who, in all fairness, could not have	 
foreseen how their tools would have been used 25 years after their			 
conception.		  

Technically, the problem manifests itself when field splitting (the process
by which the shell splits input into words) is naively applied on the output
of an expansion that generates filenames with embedded spaces.  Consider the
following example, appearing on page 95 of one of the classic texts on Unix
programming [5]:		  
  for i in ch2.*
	 echo $i:
	 diff -b old/$i $i
	 echo
  done

The above code will compare all files matching the ch2.* pattern in the
current directory with copies presumably stored in the directory called
"old".  Consider what will happen when the code is applied to a file called
"ch2.figure 3.dot" (notice the space between the word figure and the "3").
The shell variable i will be set to the correct filename, but then the shell
will execute the "diff" command with the following argument list
(customarily passed to C programs in the argv array):
  argv[0] = "diff"
  argv[1] = "-b"
  argv[2] = "old/ch2.figure"
  argv[3] = "3.dot"
  argv[4] = "ch2.figure"
  argv[5] = "3.dot"

and diff will complain
  diff: extra operand
as more than two filenames were passed as arguments.  This happens,
because words are expanded by most Unix shells in the following order:
  1. Parameter (including variable) expansion, command substitution.
  2. Field splitting.
As a result, the variable $i is first expanded into "ch2.figure 3" and
then the result is split into fields for further processing or for
passing them as arguments to a command.

The most common dangerous constructs that can appear in step 1 are variable
references (e.g. $PATH, $word) and commands inside backquotes (e.g. `find
. -type f -name 'ch2.*'`).  These dangerous constructs are quite common,
appearing among other places in the original article describing the Bourne
shell [6] (for i in * do if test -d $d/$i [...]), in other scripts in the
reference of the original example [5 p. 141, 143], and even in quite recent
work by the same authors [7, p. 149].  It is also prevalent in existing
operating system tools; I counted 43 occurrences of one suspicious pattern
("$*") in a NetBSD source tree, 8 in a FreeBSD command path, and 49 in the
shell scripts of a Mandrake Linux distribution.  The Unix world is
definitely not ready to deal with filenames containing the space character.

Avoiding this problem is not trivial.  A radical solution would be to change
the value of the shell's "internal field separator" (IFS) variable.  This
variable contains the characters that shell uses to split words.  Its
default value is ".  This solution however would break
more things than it would fix, since most scripts expect words to be
separated by spaces.  As an example the construct "A='ls -l';$A" would not
work.  The most practical solution is to manually enclose variables inside
double quotes when using them in contexts where only a single word is
normally expected.  The shell will still expand the variable inside the
quotes, but will treat the result as a single word.  Thus the offending part
in the original example should have been written as:
  diff -b "old/$i" "$i"
In addition, whenever a shell script uses the variable $* to obtain the
values of all parameters passed to a script, the $* variable should be
replaced by the variable $@, again inside double quotes.  Thus the
common code pattern
  for arg in $*
should be written as
  for arg in "$@"
Interestingly, Kernighan and Pike were aware of the $* problem and the above
solution since 1984; they aptly characterize the "$@" solution as "almost
black magic" [5 p. 161].

Still, these changes will not correctly handle filenames with embedded
whitespace returned from a command substitution.  In this case, temporarily
changing the IFS variable before executing a command may be the only
feasible solution.  The following example illustrates this approach:
  # Save original IFS
  OFS="$IFS"
  # Set IFS to newline
  IFS='
  '
  # The find command might output filenames with spaces
  wc -l `find . -type f`
  # Restore original IFS
  IFS="$OFS"

By searching existing shell scripts for the patterns I described and
applying the suggested changes most problems can be solved.  Other scripting
languages like Tcl and, to a lesser extend, Perl may also have problems
dealing with filenames with spaces.  Similar approaches (appropriate quoting
in Perl "eval" blocks and use of the "list" command in Tcl) can be used to
avoid these problems.

References

[1] David G. Korn. Porting Unix to Windows NT. In Proceedings of the
USENIX 1997 Annual Technical Conference, Anaheim, CA, USA, January 1997.
Usenix Association.
[2] Geoffrey J. Noer. Cygwin32: A free Win32 porting layer for UNIX
applications. In Proceedings of the 2nd USENIX Windows NT Symposium,
Seattle, WA, USA, August 1998. Usenix Association.
[3] Stephen R. Walli. OPENNT: UNIX application portability to Windows NT
via an alternative environment subsystem. In Proceedings of the USENIX
Windows NT Symposium, Seattle, WA, USA, August 1997. Usenix Association.
[4] Diomidis Spinellis. Outwit: Unix tool-based programming meets the
Windows world. In USENIX 2000 Technical Conference Proceedings, pages
149-158, San Diego, CA, USA, June 2000. Usenix Association.

[5] Brian W. Kernighan and Rob Pike. The UNIX Programming Environment.
Prentice-Hall, 1984.
[6] S. R. Bourne. The UNIX shell. Bell System Technical Journal,
57(6):65-84 July/August 1978.  (Also appears in volume 2 of the Unix
Programmer's Manual and in AT & T, UNIX System Readings and
Applications, volume I. Prentice-Hall, 1987.)
[7] Brian W. Kernighan and Rob Pike. The Practice of Programming.
Addison-Wesley, 1999.

Diomidis Spinellis - http://www.dmst.aueb.gr/dds/
Athens University of Economics and Business (AUEB)
 -- TobyCabot - 17 Oct 2001

Revision 117 Oct 2001 - TobyCabot

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="TechTips"
(back to TechTips)

I had a problem once trying to ssh from work to my machine at home. Everything worked fine until I left the connection idle for a while. When I hit a key I got

Read from remote host www.caboteria.org: Connection reset by peer
Connection to www.caboteria.org closed.

Setting ssh's KeepAlive parameter on the client and server didn't seem to do much good. I found a patch that helped, though:

http://www.icl.isc.tohoku.ac.jp/~hgot/sources/openssh-watchdog.html

The "contributed" patch at the bottom is close to the version that ships with Debian Potato, and although it gives errors when you try to apply it it's pretty small and relatively easy to cut-n-paste by hand.

-- TobyCabot - 17 Oct 2001

View topic | History: r51 < r50 < r49 < r48 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback