<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-23262481</id><updated>2011-04-22T13:00:56.992+08:00</updated><title type='text'>Mox Diamond</title><subtitle type='html'>Linux Hot Tips</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>65</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-23262481.post-114732774640175979</id><published>2006-05-11T14:08:00.000+08:00</published><updated>2006-05-11T14:09:06.423+08:00</updated><title type='text'>IRIX: CHECK FOR NEW CONFIGS</title><content type='html'>SGI loves to try and simplify your life with chkconfig switches to toggle  various services on&lt;br /&gt;and off. After each upgrade, DOUBLE check the  chkconfig switches. If something doesn't&lt;br /&gt;work all of the sudden  check here.&lt;br /&gt;&lt;br /&gt;For instance, tape drives in IRIX are disabled by  a  default install. To enable a tape subsystem:&lt;br /&gt;&lt;br /&gt;# chkconfig ts  on&lt;br /&gt;&lt;br /&gt;# /etc/init.d/ts start&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114732774640175979?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114732774640175979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114732774640175979&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114732774640175979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114732774640175979'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/05/irix-check-for-new-configs.html' title='IRIX: CHECK FOR NEW CONFIGS'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114680180215733822</id><published>2006-05-05T12:02:00.001+08:00</published><updated>2006-05-05T12:03:22.156+08:00</updated><title type='text'>KILLING MORE USERS</title><content type='html'>To kill all processes of a particular user from root at unix prompt  type:&lt;br /&gt;&lt;br /&gt;# kill -9 `ps -fu username |awk '{ print $2 }'|grep -v  PID`&lt;br /&gt;&lt;br /&gt;We can also use the username as an argument and pass it  from command line, if this command is put as a script.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114680180215733822?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114680180215733822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114680180215733822&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680180215733822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680180215733822'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/05/killing-more-users.html' title='KILLING MORE USERS'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114680176041257379</id><published>2006-05-05T12:02:00.000+08:00</published><updated>2006-05-05T12:02:40.413+08:00</updated><title type='text'>CLEANING DIRECTORIES</title><content type='html'>The creation of many temporary files in Unix during compilations, occupies  a lot of memory space. This can be got rid of by using a simple script. &lt;br /&gt;&lt;br /&gt;find $1 \( -name a.out -o -name '*.o' -o -name 'core' -o -name '*.ii' -o  -name '*.ti' -o -name '*.class' -o -name '*.pur' \) -exec rm {} \;&lt;br /&gt;&lt;br /&gt;Save  the above line in a file and run this file after changing permissions.  For example, if the file containing the above code has the name 'clean',  then:&lt;br /&gt;&lt;br /&gt;example% clean&lt;br /&gt;&lt;br /&gt;will remove all the files specified  in the script in the directory and all other subdirectories within it.  You can add or remove any number of files in the script, to suit your  needs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114680176041257379?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114680176041257379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114680176041257379&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680176041257379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680176041257379'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/05/cleaning-directories.html' title='CLEANING DIRECTORIES'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114680170199326177</id><published>2006-05-05T12:01:00.000+08:00</published><updated>2006-05-05T12:01:41.993+08:00</updated><title type='text'>GREP TEXT NOT BINARY</title><content type='html'>In some directories such as /etc you have a mix of file types. You may want  to grep out a string from one of the files but don't want to worry about the  binaries, data, etc. To accomplish&lt;br /&gt;this, searching only text files do this: &lt;br /&gt;&lt;br /&gt;grep `file * | egrep 'script|text' | awk -F: '{print $1}'`&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114680170199326177?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114680170199326177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114680170199326177&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680170199326177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680170199326177'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/05/grep-text-not-binary.html' title='GREP TEXT NOT BINARY'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114680165454496482</id><published>2006-05-05T11:59:00.000+08:00</published><updated>2006-05-05T12:00:54.563+08:00</updated><title type='text'>REBOOTING BECAUSE OF FORK BOMBS</title><content type='html'>There is nothing more frustrating for an Administrator who has to reboot  system due to fork bomb&lt;br /&gt;&lt;br /&gt;(the number of processes in the system  reaches the maximum limit when a user, even a superuser, tries to  execute some command, the system will respond with Vfork failed) &lt;br /&gt;&lt;br /&gt;In Solaris under SPARC, this can be controlled by specifying a line  in /etc/system&lt;br /&gt;&lt;br /&gt;set maxuprc=64&lt;br /&gt;&lt;br /&gt;And reboot the system. Now a  user can have maximum of 64 processes under his ownership. By default  the 'maxuprc' value is 16*maxusers - 5 where 'maxusers' is another  tunable&lt;br /&gt;parameter in /etc/system&lt;br /&gt;&lt;br /&gt;Caution : You should have a backup  of /etc/system file before you make the changes. So that you can revert  back to old system file using boot -a option in case of&lt;br /&gt;inconsistent  system file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114680165454496482?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114680165454496482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114680165454496482&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680165454496482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114680165454496482'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/05/rebooting-because-of-fork-bombs.html' title='REBOOTING BECAUSE OF FORK BOMBS'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114495103116129496</id><published>2006-04-14T01:53:00.000+08:00</published><updated>2006-04-14T01:57:11.203+08:00</updated><title type='text'>Get the hidden files</title><content type='html'>A safe way of grabbing all "hidden" files is to use '.??*'  rather than '.*'  since this will only match 3 or more characters. Admittedly, this will miss  any hidden files that are only a single character after the ., but it  will always miss '.' &amp; '..', which is probably more important...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114495103116129496?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114495103116129496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114495103116129496&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114495103116129496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114495103116129496'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/04/get-hidden-files.html' title='Get the hidden files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114477966644539095</id><published>2006-04-12T02:20:00.000+08:00</published><updated>2006-04-12T02:21:06.543+08:00</updated><title type='text'>Building a Linux supercomputer using SSH and PVM</title><content type='html'>If you have a couple of old Linux boxes sitting around, then you've got the makings of a supercomputer. Dust them off, install &lt;a href="http://en.wikipedia.org/wiki/SSH"&gt;Secure Shell&lt;/a&gt; (SSH) and &lt;a href="http://www.csm.ornl.gov/pvm/"&gt;Parallel Virtual Machine&lt;/a&gt; (PVM), and start your complex algorithms.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;All right, it's not quite as simple as that. PVM handles only the messaging between the machines. You must write your own programs to actually do anything. &lt;/p&gt;  &lt;p&gt;First, network your PCs and set up NFS on each. I'm not going to go into detail because most Linux distributions take care of everything for you. With Debian, for example, simply connect a cable between your new PC and your network switch, stick in your installation CD, switch the PC on, and follow the prompts. If you need more information, take a look at the Linux.com how-tos on &lt;a href="http://www.linux.com/howtos/HOWTO-INDEX/networking.shtml"&gt;networking&lt;/a&gt; and &lt;a href="http://www.linux.com/howtos/NFS-HOWTO/intro.shtml"&gt;NFS&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Now you can start setting up your PCs as a single supercomputer. In order for them to work as one, you need a single home directory -- hence, the need for NFS. Choose the machine that hosts the home directory and edit /etc/exports. If the file isn't there, then you must set up the PC as an NFS server -- check your distro's documentation. If you're using Debian, simply type &lt;code&gt;sudo apt-get install nfs-kernel-server&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;Now add in the details for each of the hosts where you want the common home directory. In this example, I'm exporting my home directory from polydamas (my NFS server) to three hosts: acamas, cassandra, and hector: &lt;/p&gt;  &lt;pre&gt;/home acamas(rw)&lt;br /&gt;/home cassandra(rw)&lt;br /&gt;/home hector(rw)&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;You can see the full list of possible options when exporting by typing &lt;code&gt;man exports&lt;/code&gt; on the command line. Don't forget to add all hosts into your /etc/hosts file too. &lt;/p&gt;  &lt;p&gt;Now either reboot your NFS server or check your distro's documentation for the relevant command that lets your hosts see the exports. On Debian, the command is &lt;code&gt;exportfs –a&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;You can now turn to your NFS client hosts and set them up so that they use the home directory that you're exporting from the NFS server. If you feel that exporting the whole /home is overkill, simply export the home directory for the user that you want to be able to run the supercomputer. &lt;/p&gt;  &lt;p&gt;If you're confident that everything is going to work, then just move the current /home somewhere safe (don't forget to rename it /home_old). Run &lt;code&gt;mkdir /home&lt;/code&gt;, then edit your /etc/fstab file so that it contains the details for the NFS server: &lt;/p&gt;  &lt;code&gt;polydamas:/home /home nfs rw,sync 0 0&lt;/code&gt;  &lt;p&gt;Make sure that your /etc/hosts file contains the IP address for your server, then either reboot or reload the NFS data: &lt;/p&gt;  &lt;code&gt;sudo /etc/init.d/mountnfs.sh&lt;/code&gt;  &lt;p&gt;If you're not quite that brave, mount the directories manually before you commit to automating the process fully. &lt;/p&gt;  &lt;p&gt; &lt;strong&gt;Set up SSH&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Now that you have a common /home, you need SSH. Chances are, your Linux distribution came bundled with SSH. Each of my machines uses Debian, which loads OpenSSH automatically. &lt;/p&gt;  &lt;p&gt;Set up SSH so that you don't have to enter a password each time you use it. For more information, take a look at Joe Barr's "&lt;a href="http://enterprise.linux.com/article.pl?sid=05/02/02/1254222&amp;tid=89"&gt;CLI Magic: OpenSSH&lt;/a&gt;" and Joe 'Zonker' Brockmeier's "&lt;a href="http://tips.linux.com/article.pl?sid=05/12/02/2045226&amp;amp;tid=100"&gt;CLI Magic: More on SSH&lt;/a&gt;." &lt;/p&gt;  &lt;p&gt;You'll find yourself benefiting from a common /home directory. Instead of having to set up an authorized_keys2 file on each machine, you only have to do it once on the NFS server: &lt;/p&gt;  &lt;pre&gt;ssh-keygen -t dsa&lt;br /&gt;cat .ssh/id_dsa.pub &gt; .ssh/authorized_keys2&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;If you just want to be able to run processes in parallel, then you're ready to go. &lt;/p&gt;  &lt;p&gt;Looking for more? You might want to create programs that use the resources of all of your machines. Let's say you have three Linux boxes connected to your network, and you have three Linux scripts sitting in your home directory that you need to process. Simply run each one via SSH: &lt;/p&gt;  &lt;pre&gt;#Run the files on the machines&lt;br /&gt;ssh bainm@acamas ./batch_file1 &amp;&lt;br /&gt;ssh bainm@cassandra ./batch_file2 &amp;amp;&lt;br /&gt;ssh bainm@hector ./batch_file3 &amp;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;You can distribute work around your network easily using this technique. Although useful, the scripts don't provide any feedback. You must check each machine manually for the progress of each file before you continue with your computations. However, you can add feedback by making each of the distributed files write its results back to a common file on your home directory. &lt;/p&gt;  &lt;p&gt;In this next example, you can calculate pi to any number of decimal places: &lt;/p&gt;  &lt;pre&gt;#File name: calc_pi&lt;br /&gt;RESULT_FILE=$1&lt;br /&gt;DECIMAL_PLACES=$2&lt;br /&gt;RESULT=$(echo "scale=$DECIMAL_PLACES;4*(4*a(1/5)-a(1/239))"|bc -l)&lt;br /&gt;echo "$(uname -n) Pi: $RESULT" &gt;&gt; $RESULT_FILE&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;I calculated &lt;code&gt;pi = 4 x ( 4arctan(1/5) - arctan(1/239)&lt;/code&gt; because that's what I was taught in college; there are &lt;a href="http://freshmeat.net/projects/projectpi"&gt;other ways&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Now tell each of your machines to run a process: &lt;/p&gt;  &lt;pre&gt;ssh bainm@acamas . ./calc_pi pi_results 10 &amp;&lt;br /&gt;ssh bainm@cassandra . ./calc_pi pi_results 20 &amp;amp;&lt;br /&gt;ssh bainm@hector . ./calc_pi pi_results 30 &amp;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;After a couple of seconds, a new file (pi_results) contains this code: &lt;/p&gt;  &lt;pre&gt;acamas Pi: 3.1415926532&lt;br /&gt;cassandra Pi: 3.14159265358979323848&lt;br /&gt;hector Pi: 3.141592653589793238462643383272&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; &lt;strong&gt;Let PVM do the work for you&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;While this is useful to know, you're probably better off using software that does all the work for you. If you're happy using C, C++, or Fortran, then PVM may be for you. Download it from the &lt;a href="http://www.csm.ornl.gov/pvm/"&gt;PVM Web site&lt;/a&gt;, or check if you can load it using your distro's methods. For instance, use this command on Debian: &lt;/p&gt;  &lt;code&gt;sudo apt-get install pvm&lt;/code&gt;  &lt;p&gt;Install PVM on all of the machines, then log on to the computer you want to use as your central host. If it's not your NFS server, remember to generate a key for it and add it to the .ssh/authorized_keys2 file. Once you start PVM by typing &lt;code&gt;pvm&lt;/code&gt; on the command line, you can start adding hosts. Don't worry about starting PVM on the other machines -- that's done automatically when you add a host.&lt;/p&gt;  &lt;pre&gt;$ pvm&lt;br /&gt;pvm&gt; add acamas&lt;br /&gt;add acamas&lt;br /&gt;1 successful&lt;br /&gt;                   HOST     DTID&lt;br /&gt;                 acamas    80000&lt;br /&gt;pvm&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;If that seems a bit long-winded, then list your hosts in a file and get PVM to read it: &lt;/p&gt;  &lt;code&gt;$ pvm hostfile&lt;/code&gt;  &lt;p&gt;Type &lt;code&gt;conf&lt;/code&gt; to check which hosts are loaded: &lt;/p&gt;  &lt;pre&gt;pvm&gt; conf&lt;br /&gt;conf&lt;br /&gt;4 hosts, 1 data format&lt;br /&gt;                   HOST     DTID     ARCH   SPEED       DSIG&lt;br /&gt;              cassandra    40000    LINUX    1000 0x00408841&lt;br /&gt;                 acamas    80000    LINUX    1000 0x00408841&lt;br /&gt;                 hector    c0000    LINUX    1000 0x00408841&lt;br /&gt;              polydamas   100000    LINUX    1000 0x00408841&lt;br /&gt;pvm&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Type &lt;code&gt;quit&lt;/code&gt; to exit PVM and leave it running in the background. Type &lt;code&gt;halt&lt;/code&gt; to shut down PVM. &lt;/p&gt;  &lt;p&gt;Now you can create a program that uses PVM. You need the &lt;a href="http://www.netlib.org/pvm3/"&gt;PVM source code&lt;/a&gt;. As always, check the details for your distro -- usually, you can get the files easily. For example, Debian uses this command: &lt;/p&gt;  &lt;code&gt;sudo apt-get install pvm-dev&lt;/code&gt;  &lt;p&gt;You need the files on only one of your machines; thanks to the common home directory, you can use any of them. Create a directory called ~/pvm3/examples and look for a file called examples.tar.gz -- you'll probably find it in /usr/share/doc/pvm. Unpack this into the directory you just created. You'll see a set of self-explanatory files that show you exactly how to program with PVM. Start with master1.c and its associated file slave1.c. Examine the source code to see exactly how the process operates. Use this code to see it in action type: &lt;/p&gt;  &lt;code&gt;aimk master1 slave1&lt;/code&gt;  &lt;p&gt;aimk -- the program for compiling your PVM programs -- creates your executables and places them in ~/pvm3/bin/LINUX. Simply change to this directory and type &lt;code&gt;master1&lt;/code&gt;. Assuming you're on the machine where you're running PVM, you should see something like this: &lt;/p&gt;  &lt;pre&gt;$ master1&lt;br /&gt;Spawning 12 worker tasks ... SUCCESSFUL&lt;br /&gt;I got 1300.000000 from 7; (expecting 1300.000000)&lt;br /&gt;I got 1500.000000 from 8; (expecting 1500.000000)&lt;br /&gt;I got 100.000000 from 1; (expecting 100.000000)&lt;br /&gt;I got 700.000000 from 4; (expecting 700.000000)&lt;br /&gt;I got 1100.000000 from 0; (expecting 1100.000000)&lt;br /&gt;I got 1700.000000 from 9; (expecting 1700.000000)&lt;br /&gt;I got 1900.000000 from 10; (expecting 1900.000000)&lt;br /&gt;I got 2100.000000 from 11; (expecting 2100.000000)&lt;br /&gt;I got 1100.000000 from 6; (expecting 1100.000000)&lt;br /&gt;I got 900.000000 from 5; (expecting 900.000000)&lt;br /&gt;I got 300.000000 from 2; (expecting 300.000000)&lt;br /&gt;I got 500.000000 from 3; (expecting 500.000000)&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;If you're a Fortran programmer, don't worry -- there are some examples for you as well. Other languages don't offer examples, but look on the &lt;a href="http://www.csm.ornl.gov/pvm/"&gt;PVM Web site&lt;/a&gt; for support for numerous languages, including Perl, Python, and Java. You'll also find various applications to help with PVM, such as XPVM for a graphical interface. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114477966644539095?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114477966644539095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114477966644539095&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114477966644539095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114477966644539095'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/04/building-linux-supercomputer-using-ssh.html' title='Building a Linux supercomputer using SSH and PVM'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114408385765526027</id><published>2006-04-04T01:02:00.000+08:00</published><updated>2006-04-04T01:04:17.666+08:00</updated><title type='text'>Accessing Positional Variables</title><content type='html'>Accessing positional variables from the left is simple using Bourne,  bash, or KornShell93. &lt;br /&gt;ksh88 will not work and csh's syntax I won't cover  it. &lt;br /&gt;&lt;br /&gt;You can use the form of ${*:1:1} where the 1st 1 is the  number of which positional variable you want to access and the 2nd is the  number of variables following it that you want. &lt;br /&gt;&lt;br /&gt;So, if you  type:&lt;br /&gt;&lt;br /&gt;set a b c d, echo ${*:3:1}&lt;br /&gt;&lt;br /&gt;will give you c.&lt;br /&gt;&lt;br /&gt;You can  be sneakier using a looping construct.  This will give you the  positional parameters in order:&lt;br /&gt;&lt;br /&gt;for i in 1 2 3 4&lt;br /&gt;do&lt;br /&gt;echo  ${*:$a:1}&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;Suppose you want to reference the 2nd to last  positional parameter. &lt;br /&gt;Try ${*:$#-1:1}. &lt;br /&gt;&lt;br /&gt;${*:$#:1} gives you the  last one. Even sneakier, here's the positional variables in reverse  order.&lt;br /&gt;&lt;br /&gt;for i in 1 2 3 4&lt;br /&gt;do&lt;br /&gt;echo  ${*:$#-$i:1}&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;Beware:  different shells act slightly  different.  Bash, for the above example of set a b c d, gives d for  echo ${*:$#-5:1} while ksh gives ksh.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114408385765526027?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114408385765526027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114408385765526027&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114408385765526027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114408385765526027'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/04/accessing-positional-variables.html' title='Accessing Positional Variables'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114403053134261064</id><published>2006-04-03T10:14:00.000+08:00</published><updated>2006-04-03T10:15:31.343+08:00</updated><title type='text'>Linux Renaming Sets of Files</title><content type='html'>Easy way to rename a set of files in Linux:&lt;br /&gt;&lt;br /&gt;*** Need not use any  SHELL script&lt;br /&gt;*** or any other prog.&lt;br /&gt;*** simply use the rename  command&lt;br /&gt;&lt;br /&gt;**SYNTAX:**&lt;br /&gt;% rename .&lt;ext1&gt; .&lt;ext2&gt;  &lt;files&gt;&lt;br /&gt;&lt;br /&gt;eg: To rename all .jpg to .gif use:&lt;br /&gt;&lt;br /&gt;% rename .jpg  .gif *&lt;br /&gt;&lt;br /&gt;To rename only .jpg with starting&lt;br /&gt; letter as t to .gif  use:&lt;br /&gt;&lt;br /&gt;% rename .jpg .gif t*&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114403053134261064?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114403053134261064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114403053134261064&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114403053134261064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114403053134261064'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/04/linux-renaming-sets-of-files.html' title='Linux Renaming Sets of Files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114403041309027231</id><published>2006-04-03T10:12:00.000+08:00</published><updated>2006-04-03T10:13:33.116+08:00</updated><title type='text'>Separate Shell Command history</title><content type='html'>One other suggestion on how to separate shell command history files by  terminal (It works on&lt;br /&gt;HP-UX):&lt;br /&gt;&lt;br /&gt;Change the permissions of your &lt;br /&gt;.sh_history to 000.&lt;br /&gt;&lt;br /&gt;$ chmod 000 .sh_history&lt;br /&gt;&lt;br /&gt;After this is  done, the various shells that may exist will not save every command to  the file&lt;br /&gt;thus keeping the history in memory. Since every memory is  different, as every shell is run&lt;br /&gt;in a different process, every shell  will have its own history (in memory) of commands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114403041309027231?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114403041309027231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114403041309027231&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114403041309027231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114403041309027231'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/04/separate-shell-command-history.html' title='Separate Shell Command history'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114369069888323766</id><published>2006-03-30T11:50:00.000+08:00</published><updated>2006-03-30T11:51:38.883+08:00</updated><title type='text'>NFS between Solaris &amp; Linux</title><content type='html'>If you receive error messages such as "unknown version" when attempting  to mount a Linux based NFS server from Solaris, you probably have an  incompatibility between the NFS versions&lt;br /&gt;running on both of them.  Linux  uses version 2, while Solaris uses version 3. In order to get the  machines to communicate, you have to use the vers option on the Solaris  machine as follows:&lt;br /&gt;&lt;br /&gt;mount -o vers=2 nfsserver:/remotedir  /localdir&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114369069888323766?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114369069888323766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114369069888323766&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114369069888323766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114369069888323766'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/nfs-between-solaris-linux.html' title='NFS between Solaris &amp; Linux'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114369023784417430</id><published>2006-03-30T11:40:00.000+08:00</published><updated>2006-03-30T11:43:57.926+08:00</updated><title type='text'>How To Set Up Database Replication In MySQL</title><content type='html'>&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This tutorial describes how to set up database replication in MySQL. MySQL replication allows you to have an exact copy of a database from a master server on another server (slave), and all updates to the database on the master server are immediately replicated to the database on the slave server so that both databases are in sync. This is not a backup policy because an accidentally issued DELETE command will also be carried out on the slave; but replication can help protect against hardware failures though. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;In this tutorial I will show how to replicate the database &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; from the master with the IP address &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;192.168.0.100&lt;/em&gt;&lt;/span&gt; to a slave. Both systems (master and slave) are running &lt;strong&gt;Debian Sarge&lt;/strong&gt;; however, the configuration should apply to almost all distributions with little or no modification. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Both systems have MySQL installed, and the database &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; with tables and data is already existing on the master, but not on the slave. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;I want to say first   that this is not the only way of setting up such a system. There are many ways   of achieving this goal but this is the way I take. I do not issue any guarantee   that this will work for you!&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h4&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;1 Configure The Master&lt;/span&gt;&lt;/h4&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;First we have to edit &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/mysql/my.cnf&lt;/em&gt;&lt;/span&gt;. We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;#skip-networking&lt;br /&gt;#bind-address            = 127.0.0.1&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;span style="font-family: times new roman;font-size:100%;" &gt;Furthermore&lt;br /&gt;we have to tell MySQL for which database it should write logs (these logs are used by the slave to see what has changed on the master),&lt;br /&gt;which log file it should use, and we have to specify that this MySQL&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;log-bin = /var/log/mysql/mysql-bin.log&lt;br /&gt;binlog-do-db=exampledb&lt;br /&gt;server-id=1&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we restart MySQL:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;/etc/init.d/mysql restart&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we log into the MySQL database as &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;root&lt;/em&gt;&lt;/span&gt; and create a user with replication privileges:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysql -u root -p&lt;br /&gt;Enter password:&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now we are on the MySQL shell. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY '&lt;some_password&gt;'; &lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;(Replace &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;some_password&gt;&lt;/em&gt;&lt;/span&gt; with a real password!)&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;em&gt;&lt;br /&gt;  FLUSH PRIVILEGES; &lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Next (still on the MySQL shell) do this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;USE exampledb;&lt;br /&gt;  FLUSH TABLES WITH READ LOCK;&lt;br /&gt;SHOW MASTER STATUS;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;The last command will show something like this:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;+---------------+----------+--------------+------------------+&lt;br /&gt;| File          | Position | Binlog_do_db | Binlog_ignore_db |&lt;br /&gt;+---------------+----------+--------------+------------------+&lt;br /&gt;| mysql-bin.006 | 183      | exampledb    |                  |&lt;br /&gt;+---------------+----------+--------------+------------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Write down this information, we will need it later on the slave! &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then leave the MySQL shell:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt;quit;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;There are two possibilities to get the existing tables and data from &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; from the master to the slave. The first one is to make a database dump, the second one is to use the&lt;/span&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt;LOAD DATA FROM MASTER;&lt;/em&gt;&lt;/span&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;command on the slave. The latter has the disadvantage the the database on the master will be &lt;strong&gt;locked&lt;/strong&gt; during this operation, so if you have a large database on a high-traffic production system, this is not what you want, and I recommend to follow the first method in this case. However, the latter method is very fast, so I will describe both here. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you want to follow the first method, then do this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysqldump -u root -p&lt;password&gt; --opt exampledb &gt; exampledb.sql &lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;(Replace &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;password&gt;&lt;/em&gt;&lt;/span&gt; with the real password for the MySQL user &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;root&lt;/em&gt;&lt;/span&gt;! &lt;strong&gt;Important:&lt;/strong&gt; There is &lt;strong&gt;no&lt;/strong&gt; space between &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;-p&lt;/em&gt;&lt;/span&gt; and &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;password&gt;&lt;/em&gt;&lt;/span&gt;!) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This will create an SQL dump of &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; in the file &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb.sql&lt;/em&gt;&lt;/span&gt;. Transfer this file to your slave server! &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you want to go the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;LOAD DATA FROM MASTER;&lt;/em&gt;&lt;/span&gt; way then there is nothing you must do right now. &lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Finally we have to unlock the tables in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysql -u root -p&lt;br /&gt;  Enter password:&lt;br /&gt;  UNLOCK TABLES;&lt;br /&gt;quit;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now the configuration on the master is finished. On to the slave...&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;&lt;strong&gt;2 Configure The Slave&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;On the slave we first have to create the database &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysql -u root -p&lt;br /&gt;  Enter password:&lt;br /&gt;  CREATE DATABASE exampledb;&lt;br /&gt;quit;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you have made an SQL dump of &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; on the master and have transferred it to the slave, then it is time now to import the SQL dump into our newly created &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; on the slave:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysql -u root -p&lt;password&gt; exampledb &lt; /path/to/exampledb.sql &lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;(Replace &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;password&gt;&lt;/em&gt;&lt;/span&gt; with the real password for the MySQL user &lt;span style="font-family:Courier New, Courier, mono;"&gt;root&lt;/span&gt;! &lt;strong&gt;Important:&lt;/strong&gt; There is &lt;strong&gt;no&lt;/strong&gt; space between &lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;-p&lt;/span&gt;&lt;/em&gt; and &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;password&gt;&lt;/em&gt;&lt;/span&gt;!) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you want to go the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;LOAD DATA FROM MASTER;&lt;/em&gt;&lt;/span&gt; way then there is nothing you must do right now. &lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now we have to tell MySQL on the slave that it is the slave, that the master is &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;192.168.0.100&lt;/em&gt;&lt;/span&gt;, and that the master database to watch is &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt;. Therefore we add the following lines to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/mysql/my.cnf&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;server-id=2&lt;br /&gt;master-host=192.168.0.100&lt;br /&gt;master-user=slave_user&lt;br /&gt;master-password=secret&lt;br /&gt;master-connect-retry=60&lt;br /&gt;replicate-do-db=exampledb&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we restart MySQL:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;/etc/init.d/mysql restart&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you have not imported the master &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; with the help of an SQL dump, but want to go the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;LOAD DATA FROM MASTER;&lt;/em&gt;&lt;/span&gt; way, then it is time for you now to get the data from the master &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mysql -u root -p&lt;br /&gt;  Enter password:&lt;br /&gt;  LOAD DATA FROM MASTER;&lt;br /&gt;quit;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;If you have &lt;a target="_blank" href="http://www.phpmyadmin.net/"&gt;phpMyAdmin&lt;/a&gt; installed on the slave you can now check if all tables/data from the master &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; is also available on the slave &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt; &lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Finally, we must do this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;mysql -u root -p&lt;br /&gt;  Enter password:&lt;br /&gt;SLAVE STOP;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;In the next command (still on the MySQL shell) you have to replace the values appropriately:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='&lt;/span&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;&lt;some_password&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;&lt;/span&gt;&lt;/em&gt; &lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;MASTER_HOST&lt;/span&gt;&lt;/em&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;is the IP address or hostname of the master (in this example it is&lt;/span&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt;192.168.0.100&lt;/em&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;). &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;MASTER_USER&lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt; is the user we granted replication privileges on the master.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;MASTER_PASSWORD&lt;/span&gt;&lt;/em&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;is the password of&lt;/span&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt;MASTER_USER&lt;/em&gt;&lt;/span&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;on the master.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;MASTER_LOG_FILE&lt;/span&gt;&lt;/em&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;is the file MySQL gave back when you ran&lt;/span&gt; &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;SHOW MASTER STATUS;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;on the master.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;MASTER_LOG_POS&lt;/span&gt;&lt;/em&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;is the position MySQL gave back when you ran&lt;/span&gt; &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;SHOW MASTER STATUS;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt; on the master.&lt;/span&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now all that is left to do is start the slave. Still on the MySQL shell we run&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;START SLAVE;&lt;br /&gt;quit;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;That's it! Now whenever &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; is updated on the master, all changes will be replicated to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;exampledb&lt;/em&gt;&lt;/span&gt; on the slave. Test it!&lt;/span&gt; &lt;/p&gt; &lt;p&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;b&gt;Links&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;MySQL: &lt;a target="_blank" href="http://www.mysql.com/"&gt;http://www.mysql.com&lt;/a&gt; &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114369023784417430?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114369023784417430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114369023784417430&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114369023784417430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114369023784417430'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/how-to-set-up-database-replication-in.html' title='How To Set Up Database Replication In MySQL'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114335590288214437</id><published>2006-03-26T14:50:00.000+08:00</published><updated>2006-03-26T14:51:42.900+08:00</updated><title type='text'>My sysadmin toolbox</title><content type='html'>&lt;p&gt; &lt;strong&gt;Torsmo&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt; &lt;a href="http://torsmo.sourceforge.net/"&gt;Torsmo&lt;/a&gt; is a desktop system monitoring tool, and one of the best I have ever used. &lt;/p&gt;  &lt;p&gt;Torsmo differs from other system monitors, such as GKrellM, in that it does not spawn a new window, but instead renders text directly to your desktop. It can display almost anything about your system, including uptime, current CPU usage, network activity, hard drive usage, memory usage, and swap usage. The program's developers wrote it to use as little of your system's resources as possible, and it does a good job of this.&lt;/p&gt;  &lt;p&gt;You can configure what torsmo displays through its configuration file, normally found in your home directory as .torsmorc. You can look at my configuration file at &lt;a href="http://realfolkblues.org/torsmorc"&gt;http://realfolkblues.org/torsmorc&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt; &lt;strong&gt;ImageMagick&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt; &lt;a href="http://imagemagick.org/"&gt;ImageMagick&lt;/a&gt; makes it easy to perform many operations on images directly from the command line. Among its many useful tools, &lt;code&gt;identify&lt;/code&gt; is used to display information about an image, &lt;code&gt;import&lt;/code&gt; can save any window on an X server to an image file, and &lt;code&gt;convert&lt;/code&gt; can convert an image to almost any format with a single command.&lt;/p&gt;  &lt;p&gt;You can use &lt;code&gt;identify&lt;/code&gt; to show detailed information about a photo or image by running &lt;code&gt;identify &lt;em&gt;imagename&lt;/em&gt; &lt;/code&gt;. For example:&lt;/p&gt;  &lt;pre&gt;jon@gimli:~$ identify /media/pics/Group-Photo.jpg&lt;br /&gt;/media/pics/Group-Photo.jpg JPEG 819x614 DirectClass 371kb 0.050u 0:01&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;I often use &lt;code&gt;import&lt;/code&gt; to take a screenshot of my desktop. For example, to save a screenshot of your desktop to your home directory as a PNG image named screenshot.png, run &lt;code&gt;import -window root $HOME/screenshot.png&lt;/code&gt;. ImageMagick will save the screenshot in the image format specified by the file extension.&lt;/p&gt;  &lt;p&gt;Using &lt;code&gt;convert&lt;/code&gt; to convert an image from one format to another could not be easier -- just run &lt;code&gt;convert &lt;em&gt;imagename.png&lt;/em&gt; &lt;em&gt;imagename.jpg&lt;/em&gt; &lt;/code&gt;. Again, ImageMagick takes the format from the extension, so you don't need to give it an additional option to specify the new format.&lt;/p&gt;  &lt;p&gt; &lt;strong&gt;Aterm&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;While KDE and GNOME come with their own terminal applications, these applications do much more than I need. &lt;a href="http://aterm.sourceforget.net/"&gt;Aterm&lt;/a&gt;, on the other hand, is a simple terminal program with fewer features, so it appears almost instantly when you start it. Though it's not as bulky as other terminal emulators, Aterm does have many useful options, which you can read about by typing &lt;code&gt;aterm --help&lt;/code&gt; at the command line.&lt;/p&gt;  &lt;p&gt;I like to start Aterm with a black background, white text, a 1,000-line history buffer, and display all text using the font "drift" from the "artwiz" font family. To get this, use &lt;code&gt;aterm -bg black -fg white -sl 1000 -fn "-artwiz-drift-*"&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt; &lt;strong&gt;Root-tail&lt;/strong&gt;  &lt;/p&gt; &lt;p&gt;Sometimes I use &lt;code&gt;tail -f&lt;/code&gt; to monitor logfiles for changes. While useful, it's awkward to have a terminal window open all the time to monitor a logfile. &lt;a href="http://www.goof.com/pcg/marc/root-tail.html"&gt;Root-tail&lt;/a&gt; provides an excellent alternative by displaying logfiles as text rendered on your desktop in whatever font and color you specify. It also updates the text on your desktop at the interval you specify.&lt;/p&gt;  &lt;p&gt;To use root-tail, just run &lt;code&gt;root-tail &lt;em&gt;filename&lt;/em&gt; &lt;/code&gt; to monitor a file. Root-tail has many useful options, which you can see by typing &lt;code&gt;root-tail --help&lt;/code&gt;, or just read its man page.&lt;/p&gt;  &lt;p&gt; &lt;strong&gt;Quod Libet&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Out of the hordes of music players available for Linux, &lt;a href="http://sacredchao.net/quodlibet"&gt;Quod Libet&lt;/a&gt; is my favorite. One of the things I like about Quod Libet is its ability to make playlists based on regular expressions. You can operate the player from the command line by running the program with an argument, making it simple to set up hotkeys with KDE to control the player. For instance, if I go to the KDE Control Center hotkey section and add a hotkey such as Control-Alt-X to run the command &lt;code&gt;quodlibet --play&lt;/code&gt;, I can then simply press Control-Alt-X to cause Quod Libet to play music. See all of the command line arguments that are available by running &lt;code&gt;quodlibet --help&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;Quod Libet has excellent &lt;a href="http://en.wikipedia.org/wiki/Id3"&gt;ID3&lt;/a&gt; tag editing, with the ability to edit tags based on the filenames of songs, rename files based on their tags, and change many files at once. Quod Libet also supports album cover art.&lt;/p&gt;  &lt;p&gt;In addition to its native features, Quod Libet also has an extensive collection of &lt;a href="http://www.sacredchao.net/quodlibet/wiki/Plugins"&gt;plugins&lt;/a&gt; that can greatly extend its functionality. One particularly interesting plugin, &lt;a href="http://www.sacredchao.net/quodlibet/file/trunk/plugins/animosd.py?rev=3036"&gt;Animated On-Screen Display&lt;/a&gt;, can display information about the music Quod Libet is playing. See the &lt;a href="http://www.sacredchao.net/quodlibet/wiki/Plugins"&gt;full list&lt;/a&gt; of plugins on the Quod Libet site.&lt;/p&gt;  &lt;p&gt; &lt;strong&gt;Transmission&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;While I normally use Azureus as my BitTorrent client, it's fairly resource-intensive, and that makes it less appealing for me. In situations where I need a simple and fast client, I use &lt;a href="http://transmission.m0k.org/"&gt;Transmission&lt;/a&gt;. It handles torrents using a fraction of the memory and CPU time that Azureus uses. Unlike Azureus, it has the ability to run all of the torrents on a single port, removing the need to allow entire port ranges through a firewall in order to use the program.&lt;/p&gt;  &lt;p&gt;Transmission is perfect for users who occasionally need to download a torrent. While Azureus uses Java to draw its interface, Transmission uses GTK+, helping it fit in perfectly with a GNOME desktop. Transmission also sports a command-line interface that is especially useful when you must run it in a remote environment.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114335590288214437?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114335590288214437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114335590288214437&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114335590288214437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114335590288214437'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/my-sysadmin-toolbox.html' title='My sysadmin toolbox'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114335371638413857</id><published>2006-03-26T14:03:00.000+08:00</published><updated>2006-03-26T14:15:16.400+08:00</updated><title type='text'>Network Monitoring with Zabbix</title><content type='html'>&lt;p&gt; The ZABBIX server requires the following system resources:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;   * 10 MB of disk space (100 MB recommended)&lt;br /&gt;   * 64 MB of RAM (128 MB recommended)&lt;br /&gt;   * MySQL or PostgreSQL as backend database&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First we define 2 locations:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;    The Server&lt;/b&gt;, here comes all the info together and is processed in a database, note that the server can be monitored to so it runs an agent too.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;    The Agent&lt;/b&gt;,  Information is gathered and polled by the server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Setup of the Server:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://prdownloads.sourceforge.net/zabbix/zabbix-1.1beta7.tar.gz?download" target="_blank"&gt;http://prdownloads.sourceforge.net/zabbix/zabbix-1.1beta7.tar.gz?download&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1 - Make the zabbix user and group&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;groupadd zabbix&lt;br /&gt;useradd -c 'Zabbix' -d /home/zabbix -g zabbix -s /bin/bash zabbix&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;mkdir /home/zabbix&lt;br /&gt;chown -R zabbix.zabbix /home/zabbix&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2 - Untar the sources&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;cd /home/zabbix&lt;br /&gt;&lt;br /&gt;tar zxvpf zabbix-1.1beta7.tar.gz&lt;br /&gt;&lt;br /&gt;mv zabbix-1.1beta7 zabbix&lt;br /&gt;&lt;br /&gt;cd zabbix&lt;br /&gt;&lt;br /&gt;chown -R zabbix.zabbix .&lt;br /&gt;&lt;br /&gt;su - zabbix&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3 - Create a zabbix database and populate it&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;mysql -p -u root&lt;br /&gt;&lt;br /&gt;create database zabbix;&lt;br /&gt;quit;&lt;br /&gt;&lt;br /&gt;cd create/mysql&lt;br /&gt;&lt;br /&gt;mysql -u root -p zabbix &lt; schema.sql&lt;br /&gt;&lt;br /&gt;cd ../data&lt;br /&gt;&lt;br /&gt;mysql -u root -p zabbix &lt; data.sql&lt;br /&gt;mysql -u root -p zabbix &lt; images.sql&lt;br /&gt;&lt;br /&gt;cd ../../&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4 - Configure compile and install the server&lt;/b&gt;&lt;br /&gt;   We run an agent on the server to so we compile that too ;)&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;./configure --prefix=/usr --with-mysql --with-net-snmp            --enable-server --enable-agent &amp;&amp;amp;&lt;br /&gt;make&lt;br /&gt;su&lt;br /&gt;make install&lt;br /&gt;exit&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5 - Prepare the rest of the system&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As root edit&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;    /etc/services&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;zabbix_agent    10050/tcp  # Zabbix ports&lt;br /&gt;zabbix_trap     10051/tcp&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;mkdir /etc/zabbix&lt;br /&gt;&lt;br /&gt;cp misc/conf/zabbix_agentd.conf /etc/zabbix/&lt;br /&gt;cp misc/conf/zabbix_server.conf /etc/zabbix/&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edit &lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;/etc/zabbix/zabbix_agentd.conf&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;make sure that the Server parameter points to the server addres,&lt;br /&gt;for the agent that runs on the server its like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;Server=127.0.0.1&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edit &lt;i&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;/etc/zabbix/zabbix_server.conf&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;For small sites this default file will do, however if you are into&lt;br /&gt;tweaking your config for your 10+ hosts site, this is the place&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Start the server&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;su - zabbix&lt;br /&gt;zabbix_server&lt;br /&gt;exit&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Start the client:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;su - zabbix&lt;br /&gt;zabbix_agentd&lt;br /&gt;exit&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;6 - Configure web interface&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Edit &lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;frontends/php/include/db.inc.php&lt;/i&gt;&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;$DB_TYPE ="MYSQL";&lt;br /&gt;$DB_SERVER ="localhost";&lt;br /&gt;$DB_DATABASE ="zabbix";&lt;br /&gt;$DB_USER ="root";&lt;br /&gt;$DB_PWD ="secret";&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;mkdir /home/zabbix/public_html&lt;br /&gt;cp -R frontends/php/* /home/zabbix/html/&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edit &lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;/etc/apache/httpd.conf&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Make this work:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;&lt;directory&gt;&lt;br /&gt;   AllowOverride FileInfo AuthConfig Limit Indexes&lt;br /&gt;   Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec&lt;br /&gt;   &lt;limit&gt;&lt;br /&gt;       Order allow,deny&lt;br /&gt;       Allow from all&lt;br /&gt;   &lt;/limit&gt;&lt;br /&gt;   &lt;limitexcept&gt;&lt;br /&gt;       Order deny,allow&lt;br /&gt;       Deny from all&lt;br /&gt;   &lt;/limitexcept&gt;&lt;br /&gt;&lt;/directory&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;/etc/init.d/apache restart&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;chown -R zabbix.zabbix public_html&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Setup of an Agent&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://prdownloads.sourceforge.net/zabbix/zabbix-1.1beta7.tar.gz?download" target="_blank"&gt;http://prdownloads.sourceforge.net/zabbix/zabbix-1.1beta7.tar.gz?download&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1 - Make the zabbix user and group&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;groupadd zabbix&lt;br /&gt;useradd -c 'Zabbix' -d /home/zabbix -g zabbix -s /bin/bash zabbix&lt;br /&gt;&lt;br /&gt;mkdir /home/zabbix&lt;br /&gt;chown -R zabbix.zabbix /home/zabbix&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2 - Untar the sources&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;cd /home/zabbix&lt;br /&gt;&lt;br /&gt;tar zxvpf zabbix-1.1beta7.tar.gz&lt;br /&gt;&lt;br /&gt;mv zabbix-1.1beta7 zabbix&lt;br /&gt;&lt;br /&gt;cd zabbix&lt;br /&gt;&lt;br /&gt;chown -R zabbix.zabbix .&lt;br /&gt;&lt;br /&gt;su - zabbix&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3 - Configure compile and install the agent&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;./configure --prefix=/usr --with-mysql --with-net-snmp --enable-agent&lt;br /&gt;make&lt;br /&gt;su&lt;br /&gt;make install&lt;br /&gt;exit&lt;br /&gt;&lt;br /&gt;mkdir /etc/zabbix&lt;br /&gt;cp misc/conf/zabbix_agentd.conf /etc/zabbix/&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Edit &lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;/etc/zabbix/zabbix_agentd.conf&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;make sure that the Server parameter points to the server addres&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;    Server=xxx.xxx.xxx.xxx&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4 - Prepare the rest of the system&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Edit    &lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;/etc/services&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;zabbix_agent    10050/tcp  # Zabbix ports&lt;br /&gt;zabbix_trap     10051/tcp&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5 - Start the agent&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;su - zabbix&lt;br /&gt;zabbix_agentd&lt;br /&gt;exit&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What Next ?&lt;br /&gt;&lt;br /&gt;Now point your browser to:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;    http:www.example.com/~zabbix&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Login with username: &lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;Admin&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier,monospace;font-size:85%;"&gt;&lt;i&gt;No Password&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here you can really knock your self out.&lt;br /&gt;This howto intended to show you how to install this mother.&lt;br /&gt;Configuring the monitoring functions is and whole other ballgame.&lt;br /&gt;&lt;br /&gt;For now i leave you here with some pointers to documentation&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.zabbix.com/documentation.php" target="_blank"&gt;    http://www.zabbix.com/documentation.php&lt;/a&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/projects/zabbix" target="_blank"&gt;    http://sourceforge.net/projects/zabbix&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.google.com/search?q=zabbix" target="_blank"&gt;    http://www.google.com/search?q=zabbix&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114335371638413857?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114335371638413857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114335371638413857&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114335371638413857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114335371638413857'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/network-monitoring-with-zabbix.html' title='Network Monitoring with Zabbix'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114328387342951061</id><published>2006-03-25T18:48:00.000+08:00</published><updated>2006-03-25T18:51:15.906+08:00</updated><title type='text'>Preventing SSH Dictionary Attacks With DenyHosts</title><content type='html'>&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;In this HowTo I will show how to install and configure DenyHosts. DenyHosts is a tool that observes login attempts to SSH, and if it finds failed login attempts again and again from the same IP address, DenyHosts blocks further login attempts from that IP address by putting it into &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/hosts.deny&lt;/em&gt;&lt;/span&gt;. DenyHosts can be run by cron or as a daemon. In this tutorial I will run DenyHosts as a daemon. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;From the &lt;a href="http://denyhosts.sourceforge.net/" target="_blank"&gt;DenyHosts web site&lt;/a&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;em&gt;"DenyHosts is a script intended to be run by Linux system administrators to help thwart ssh server attacks. &lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;em&gt; If you've ever looked at your ssh log (/var/log/secure on Redhat, /var/log/auth.log on Mandrake, etc...) you may be alarmed to see how many hackers attempted to gain access to your server. Hopefully, none of them were successful (but then again, how would you know?). Wouldn't it be better to automatically prevent that attacker from continuing to gain entry into your system? &lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;em&gt; DenyHosts attempts to address the above... " &lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This tutorial is based on a Debian Sarge system, however, it should apply to other distributions with almost no modifications.  &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;I want to say first   that this is not the only way of setting up such a system. There are many ways   of achieving this goal but this is the way I take. I do not issue any guarantee   that this will work for you!&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h4&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;1 Installation &lt;/span&gt;&lt;/h4&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;DenyHosts is written in Python, therefore we must install Python and also the Python development files first:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;apt-get install python2.3-dev python2.3&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we download and install DenyHosts like this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cd /tmp&lt;br /&gt;  wget http://mesh.dl.sourceforge.net/sourceforge/denyhosts/DenyHosts-2.0.tar.gz&lt;br /&gt;  tar xvfz DenyHosts-2.0.tar.gz&lt;br /&gt;  cd DenyHosts-2.0&lt;br /&gt;python setup.py install&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This installs DenyHosts to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr/share/denyhosts&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h4&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;2 Configuration &lt;/span&gt;&lt;/h4&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now we have to create the DenyHosts configuration file &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr/share/denyhosts/denyhosts.cfg&lt;/em&gt;&lt;/span&gt;. We can use the sample configuration file &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr/share/denyhosts/denyhosts.cfg-dist&lt;/em&gt;&lt;/span&gt; for this: &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cd /usr/share/denyhosts&lt;br /&gt;cp denyhosts.cfg-dist denyhosts.cfg&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we must edit&lt;/span&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt; denyhosts.cfg&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; with our favourite editor such as&lt;/span&gt;&lt;em&gt; vi&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;, for example. Mine looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt; ############ THESE SETTINGS ARE REQUIRED ############&lt;br /&gt;&lt;br /&gt;########################################################################&lt;br /&gt;#&lt;br /&gt;# SECURE_LOG: the log file that contains sshd logging info&lt;br /&gt;# if you are not sure, grep "sshd:" /var/log/*&lt;br /&gt;#&lt;br /&gt;# The file to process can be overridden with the --file command line&lt;br /&gt;# argument&lt;br /&gt;#&lt;br /&gt;# Redhat or Fedora Core:&lt;br /&gt;#SECURE_LOG = /var/log/secure&lt;br /&gt;#&lt;br /&gt;# Mandrake, FreeBSD or OpenBSD:&lt;br /&gt;SECURE_LOG = /var/log/auth.log&lt;br /&gt;#&lt;br /&gt;# SuSE:&lt;br /&gt;#SECURE_LOG = /var/log/messages&lt;br /&gt;#&lt;br /&gt;########################################################################&lt;br /&gt;&lt;br /&gt;########################################################################&lt;br /&gt;# HOSTS_DENY: the file which contains restricted host access information&lt;br /&gt;#&lt;br /&gt;# Most operating systems:&lt;br /&gt;HOSTS_DENY = /etc/hosts.deny&lt;br /&gt;#&lt;br /&gt;# Some BSD (FreeBSD) Unixes:&lt;br /&gt;#HOSTS_DENY = /etc/hosts.allow&lt;br /&gt;#&lt;br /&gt;# Another possibility (also see the next option):&lt;br /&gt;#HOSTS_DENY = /etc/hosts.evil&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;########################################################################&lt;br /&gt;# PURGE_DENY: removed HOSTS_DENY entries that are older than this time&lt;br /&gt;#             when DenyHosts is invoked with the --purge flag&lt;br /&gt;#&lt;br /&gt;#      format is: i[dhwmy]&lt;br /&gt;#      Where 'i' is an integer (eg. 7)&lt;br /&gt;#            'm' = minutes&lt;br /&gt;#            'h' = hours&lt;br /&gt;#            'd' = days&lt;br /&gt;#            'w' = weeks&lt;br /&gt;#            'y' = years&lt;br /&gt;#&lt;br /&gt;# never purge:&lt;br /&gt;PURGE_DENY =&lt;br /&gt;#&lt;br /&gt;# purge entries older than 1 week&lt;br /&gt;#PURGE_DENY = 1w&lt;br /&gt;#&lt;br /&gt;# purge entries older than 5 days&lt;br /&gt;#PURGE_DENY = 5d&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;# BLOCK_SERVICE: the service name that should be blocked in HOSTS_DENY&lt;br /&gt;#&lt;br /&gt;# man 5 hosts_access for details&lt;br /&gt;#&lt;br /&gt;# eg.   sshd: 127.0.0.1  # will block sshd logins from 127.0.0.1&lt;br /&gt;#&lt;br /&gt;# To block all services for the offending host:&lt;br /&gt;#BLOCK_SERVICE = ALL&lt;br /&gt;# To block only sshd:&lt;br /&gt;BLOCK_SERVICE  = sshd&lt;br /&gt;# To only record the offending host and nothing else (if using&lt;br /&gt;# an auxilary file to list the hosts).  Refer to:&lt;br /&gt;# http://denyhosts.sourceforge.net/faq.html#aux&lt;br /&gt;#BLOCK_SERVICE =&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DENY_THRESHOLD_INVALID: block each host after the number of failed login&lt;br /&gt;# attempts has exceeded this value.  This value applies to invalid&lt;br /&gt;# user login attempts (eg. non-existent user accounts)&lt;br /&gt;#&lt;br /&gt;DENY_THRESHOLD_INVALID = 5&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DENY_THRESHOLD_VALID: block each host after the number of failed&lt;br /&gt;# login attempts has exceeded this value.  This value applies to valid&lt;br /&gt;# user login attempts (eg. user accounts that exist in /etc/passwd) except&lt;br /&gt;# for the "root" user&lt;br /&gt;#&lt;br /&gt;DENY_THRESHOLD_VALID = 10&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DENY_THRESHOLD_ROOT: block each host after the number of failed&lt;br /&gt;# login attempts has exceeded this value.  This value applies to&lt;br /&gt;# "root" user login attempts only.&lt;br /&gt;#&lt;br /&gt;DENY_THRESHOLD_ROOT = 5&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# WORK_DIR: the path that DenyHosts will use for writing data to&lt;br /&gt;# (it will be created if it does not already exist).&lt;br /&gt;#&lt;br /&gt;# Note: it is recommended that you use an absolute pathname&lt;br /&gt;# for this value (eg. /home/foo/denyhosts/data)&lt;br /&gt;#&lt;br /&gt;WORK_DIR = /usr/share/denyhosts/data&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS&lt;br /&gt;#&lt;br /&gt;# SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES|NO&lt;br /&gt;# If set to YES, if a suspicious login attempt results from an allowed-host&lt;br /&gt;# then it is considered suspicious.  If this is NO, then suspicious logins&lt;br /&gt;# from allowed-hosts will not be reported.  All suspicious logins from&lt;br /&gt;# ip addresses that are not in allowed-hosts will always be reported.&lt;br /&gt;#&lt;br /&gt;SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# HOSTNAME_LOOKUP&lt;br /&gt;#&lt;br /&gt;# HOSTNAME_LOOKUP=YES|NO&lt;br /&gt;# If set to YES, for each IP address that is reported by Denyhosts,&lt;br /&gt;# the corresponding hostname will be looked up and reported as well&lt;br /&gt;# (if available).&lt;br /&gt;#&lt;br /&gt;HOSTNAME_LOOKUP=YES&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# LOCK_FILE&lt;br /&gt;#&lt;br /&gt;# LOCK_FILE=/path/denyhosts&lt;br /&gt;# If this file exists when DenyHosts is run, then DenyHosts will exit&lt;br /&gt;# immediately.  Otherwise, this file will be created upon invocation&lt;br /&gt;# and deleted upon exit.  This ensures that only one instance is&lt;br /&gt;# running at a time.&lt;br /&gt;#&lt;br /&gt;# Redhat/Fedora:&lt;br /&gt;#LOCK_FILE = /var/lock/subsys/denyhosts&lt;br /&gt;#&lt;br /&gt;# Debian&lt;br /&gt;LOCK_FILE = /var/run/denyhosts.pid&lt;br /&gt;#&lt;br /&gt;# Misc&lt;br /&gt;#LOCK_FILE = /tmp/denyhosts.lock&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      ############ THESE SETTINGS ARE OPTIONAL ############&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# ADMIN_EMAIL: if you would like to receive emails regarding newly&lt;br /&gt;# restricted hosts and suspicious logins, set this address to&lt;br /&gt;# match your email address.  If you do not want to receive these reports&lt;br /&gt;# leave this field blank (or run with the --noemail option)&lt;br /&gt;#&lt;br /&gt;ADMIN_EMAIL =&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;SMTP_HOST = localhost&lt;br /&gt;SMTP_PORT = 25&lt;br /&gt;SMTP_FROM = DenyHosts &lt;nobody@localhost&gt;&lt;br /&gt;SMTP_SUBJECT = DenyHosts Report&lt;br /&gt;#SMTP_USERNAME=foo&lt;br /&gt;#SMTP_PASSWORD=bar&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# ALLOWED_HOSTS_HOSTNAME_LOOKUP&lt;br /&gt;#&lt;br /&gt;# ALLOWED_HOSTS_HOSTNAME_LOOKUP=YES|NO&lt;br /&gt;# If set to YES, for each entry in the WORK_DIR/allowed-hosts file,&lt;br /&gt;# the hostname will be looked up.  If your versions of tcp_wrappers&lt;br /&gt;# and sshd sometimes log hostnames in addition to ip addresses&lt;br /&gt;# then you may wish to specify this option.&lt;br /&gt;#&lt;br /&gt;#ALLOWED_HOSTS_HOSTNAME_LOOKUP=NO&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# AGE_RESET_VALID: Specifies the period of time between failed login&lt;br /&gt;# attempts that, when exceeded will result in the failed count for&lt;br /&gt;# this host to be reset to 0.  This value applies to login attempts&lt;br /&gt;# to all valid users (those within /etc/passwd) with the&lt;br /&gt;# exception of root.  If not defined, this count will never&lt;br /&gt;# be reset.&lt;br /&gt;#&lt;br /&gt;# See the comments in the PURGE_DENY section (above)&lt;br /&gt;# for details on specifying this value or for complete details&lt;br /&gt;# refer to:  http://denyhosts.sourceforge.net/faq.html#timespec&lt;br /&gt;#&lt;br /&gt;AGE_RESET_VALID=5d&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# AGE_RESET_ROOT: Specifies the period of time between failed login&lt;br /&gt;# attempts that, when exceeded will result in the failed count for&lt;br /&gt;# this host to be reset to 0.  This value applies to all login&lt;br /&gt;# attempts to the "root" user account.  If not defined,&lt;br /&gt;# this count will never be reset.&lt;br /&gt;#&lt;br /&gt;# See the comments in the PURGE_DENY section (above)&lt;br /&gt;# for details on specifying this value or for complete details&lt;br /&gt;# refer to:  http://denyhosts.sourceforge.net/faq.html#timespec&lt;br /&gt;#&lt;br /&gt;AGE_RESET_ROOT=25d&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# AGE_RESET_INVALID: Specifies the period of time between failed login&lt;br /&gt;# attempts that, when exceeded will result in the failed count for&lt;br /&gt;# this host to be reset to 0.  This value applies to login attempts&lt;br /&gt;# made to any invalid username (those that do not appear&lt;br /&gt;# in /etc/passwd).  If not defined, count will never be reset.&lt;br /&gt;#&lt;br /&gt;# See the comments in the PURGE_DENY section (above)&lt;br /&gt;# for details on specifying this value or for complete details&lt;br /&gt;# refer to:  http://denyhosts.sourceforge.net/faq.html#timespec&lt;br /&gt;#&lt;br /&gt;AGE_RESET_INVALID=10d&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# PLUGIN_DENY: If set, this value should point to an executable&lt;br /&gt;# program that will be invoked when a host is added to the&lt;br /&gt;# HOSTS_DENY file.  This executable will be passed the host&lt;br /&gt;# that will be added as it's only argument.&lt;br /&gt;#&lt;br /&gt;#PLUGIN_DENY=/usr/bin/true&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# PLUGIN_PURGE: If set, this value should point to an executable&lt;br /&gt;# program that will be invoked when a host is removed from the&lt;br /&gt;# HOSTS_DENY file.  This executable will be passed the host&lt;br /&gt;# that is to be purged as it's only argument.&lt;br /&gt;#&lt;br /&gt;#PLUGIN_PURGE=/usr/bin/true&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;######################################################################&lt;br /&gt;#&lt;br /&gt;# USERDEF_FAILED_ENTRY_REGEX: if set, this value should contain&lt;br /&gt;# a regular expression that can be used to identify additional&lt;br /&gt;# hackers for your particular ssh configuration.  This functionality&lt;br /&gt;# extends the built-in regular expressions that DenyHosts uses.&lt;br /&gt;# This parameter can be specified multiple times.&lt;br /&gt;# See this faq entry for more details:&lt;br /&gt;#    http://denyhosts.sf.net/faq.html#userdef_regex&lt;br /&gt;#&lt;br /&gt;#USERDEF_FAILED_ENTRY_REGEX=&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  ######### THESE SETTINGS ARE SPECIFIC TO DAEMON MODE  ##########&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DAEMON_LOG: when DenyHosts is run in daemon mode (--daemon flag)&lt;br /&gt;# this is the logfile that DenyHosts uses to report it's status.&lt;br /&gt;# To disable logging, leave blank.  (default is: /var/log/denyhosts)&lt;br /&gt;#&lt;br /&gt;DAEMON_LOG = /var/log/denyhosts&lt;br /&gt;#&lt;br /&gt;# disable logging:&lt;br /&gt;#DAEMON_LOG =&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DAEMON_LOG_TIME_FORMAT: when DenyHosts is run in daemon mode&lt;br /&gt;# (--daemon flag) this specifies the timestamp format of&lt;br /&gt;# the DAEMON_LOG messages (default is the ISO8061 format:&lt;br /&gt;# ie. 2005-07-22 10:38:01,745)&lt;br /&gt;#&lt;br /&gt;# for possible values for this parameter refer to: man strftime&lt;br /&gt;#&lt;br /&gt;# Jan 1 13:05:59&lt;br /&gt;#DAEMON_LOG_TIME_FORMAT = %b %d %H:%M:%S&lt;br /&gt;#&lt;br /&gt;# Jan 1 01:05:59&lt;br /&gt;#DAEMON_LOG_TIME_FORMAT = %b %d %I:%M:%S&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DAEMON_LOG_MESSAGE_FORMAT: when DenyHosts is run in daemon mode&lt;br /&gt;# (--daemon flag) this specifies the message format of each logged&lt;br /&gt;# entry.  By default the following format is used:&lt;br /&gt;#&lt;br /&gt;# %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s&lt;br /&gt;#&lt;br /&gt;# Where the "%(asctime)s" portion is expanded to the format&lt;br /&gt;# defined by DAEMON_LOG_TIME_FORMAT&lt;br /&gt;#&lt;br /&gt;# This string is passed to python's logging.Formatter contstuctor.&lt;br /&gt;# For details on the possible format types please refer to:&lt;br /&gt;# http://docs.python.org/lib/node357.html&lt;br /&gt;#&lt;br /&gt;# This is the default:&lt;br /&gt;#DAEMON_LOG_MESSAGE_FORMAT = %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DAEMON_SLEEP: when DenyHosts is run in daemon mode (--daemon flag)&lt;br /&gt;# this is the amount of time DenyHosts will sleep between polling&lt;br /&gt;# the SECURE_LOG.  See the comments in the PURGE_DENY section (above)&lt;br /&gt;# for details on specifying this value or for complete details&lt;br /&gt;# refer to:    http://denyhosts.sourceforge.net/faq.html#timespec&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;DAEMON_SLEEP = 30s&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# DAEMON_PURGE: How often should DenyHosts, when run in daemon mode,&lt;br /&gt;# run the purge mechanism to expire old entries in HOSTS_DENY&lt;br /&gt;# This has no effect if PURGE_DENY is blank.&lt;br /&gt;#&lt;br /&gt;DAEMON_PURGE = 1h&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  #########   THESE SETTINGS ARE SPECIFIC TO     ##########&lt;br /&gt;  #########       DAEMON SYNCHRONIZATION         ##########&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# Synchronization mode allows the DenyHosts daemon the ability&lt;br /&gt;# to periodically send and receive denied host data such that&lt;br /&gt;# DenyHosts daemons worldwide can automatically inform one&lt;br /&gt;# another regarding banned hosts.   This mode is disabled by&lt;br /&gt;# default, you must uncomment SYNC_SERVER to enable this mode.&lt;br /&gt;#&lt;br /&gt;# for more information, please refer to:&lt;br /&gt;#        http:/denyhosts.sourceforge.net/faq.html#sync&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SYNC_SERVER: The central server that communicates with DenyHost&lt;br /&gt;# daemons.  Currently, denyhosts.net is the only available server&lt;br /&gt;# however, in the future, it may be possible for organizations to&lt;br /&gt;# install their own server for internal network synchronization&lt;br /&gt;#&lt;br /&gt;# To disable synchronization (the default), do nothing.&lt;br /&gt;#&lt;br /&gt;# To enable synchronization, you must uncomment the following line:&lt;br /&gt;#SYNC_SERVER = http://xmlrpc.denyhosts.net:9911&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SYNC_INTERVAL: the interval of time to perform synchronizations if&lt;br /&gt;# SYNC_SERVER has been uncommented.  The default is 1 hour.&lt;br /&gt;#&lt;br /&gt;#SYNC_INTERVAL = 1h&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SYNC_UPLOAD: allow your DenyHosts daemon to transmit hosts that have&lt;br /&gt;# been denied?  This option only applies if SYNC_SERVER has&lt;br /&gt;# been uncommented.&lt;br /&gt;#&lt;br /&gt;#SYNC_UPLOAD = no&lt;br /&gt;#&lt;br /&gt;# the default:&lt;br /&gt;#SYNC_UPLOAD = yes&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SYNC_DOWNLOAD: allow your DenyHosts daemon to receive hosts that have&lt;br /&gt;# been denied by others?  This option only applies if SYNC_SERVER has&lt;br /&gt;# been uncommented.&lt;br /&gt;#&lt;br /&gt;#SYNC_DOWNLOAD = no&lt;br /&gt;#&lt;br /&gt;# the default:&lt;br /&gt;#SYNC_DOWNLOAD = yes&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;#######################################################################&lt;br /&gt;#&lt;br /&gt;# SYNC_DOWNLOAD_THRESHOLD: If SYNC_DOWNLOAD is enabled this paramter&lt;br /&gt;# filters the returned hosts to those that have been blocked this many&lt;br /&gt;# times by others.  That is, if set to 1, then if a single DenyHosts&lt;br /&gt;# server has denied an ip address then you will receive the denied host.&lt;br /&gt;#&lt;br /&gt;#SYNC_DOWNLOAD_THRESHOLD = 10&lt;br /&gt;#&lt;br /&gt;# the default:&lt;br /&gt;#SYNC_DOWNLOAD_THRESHOLD = 3&lt;br /&gt;#&lt;br /&gt;#######################################################################&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Make sure you set &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;SECURE_LOG&lt;/em&gt;&lt;/span&gt; and &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;LOCK_FILE&lt;/em&gt;&lt;/span&gt; to the correct values for your distribution! For Debian, these are:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;SECURE_LOG = /var/log/auth.log&lt;br /&gt;LOCK_FILE = /var/run/denyhosts.pid&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;As we want to run DenyHosts as a daemon, we need the daemon control script &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr/share/denyhosts/daemon-control&lt;/em&gt;&lt;/span&gt;. Again, we can use the sample script &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr/share/denyhosts/daemon-control-dist&lt;/em&gt;&lt;/span&gt; to create the needed file:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cp daemon-control-dist daemon-control&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Edit &lt;em&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;/usr/share/denyhosts/daemon-control&lt;/span&gt;&lt;/em&gt;&lt;/em&gt; and make sure you set the correct values for&lt;/span&gt;&lt;em&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;DENYHOSTS_BIN&lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;,&lt;/span&gt;&lt;em&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;DENYHOSTS_LOCK&lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;, and&lt;/span&gt;&lt;em&gt; &lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;DENYHOSTS_CFG&lt;/span&gt;&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;. For Debian, these are:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;DENYHOSTS_BIN = "/usr/bin/denyhosts.py"&lt;br /&gt;  DENYHOSTS_LOCK = "/var/run/denyhosts.pid"&lt;br /&gt;DENYHOSTS_CFG = "/usr/share/denyhosts/denyhosts.cfg"&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;So my &lt;/span&gt;&lt;em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;em&gt;&lt;em&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;/usr/share/denyhosts/daemon-control&lt;/span&gt;&lt;/em&gt;&lt;/em&gt;&lt;/span&gt; &lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;file looks like this:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;#!/usr/bin/env python&lt;br /&gt;# denyhosts     Bring up/down the DenyHosts daemon&lt;br /&gt;#&lt;br /&gt;# chkconfig: 2345 98 02&lt;br /&gt;# description: Activates/Deactivates the&lt;br /&gt;#    DenyHosts daemon to block ssh attempts&lt;br /&gt;#&lt;br /&gt;###############################################&lt;br /&gt;&lt;br /&gt;###############################################&lt;br /&gt;#### Edit these to suit your configuration ####&lt;br /&gt;###############################################&lt;br /&gt;&lt;br /&gt;DENYHOSTS_BIN   = "/usr/bin/denyhosts.py"&lt;br /&gt;DENYHOSTS_LOCK  = "/var/run/denyhosts.pid"&lt;br /&gt;DENYHOSTS_CFG   = "/usr/share/denyhosts/denyhosts.cfg"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;###############################################&lt;br /&gt;####         Do not edit below             ####&lt;br /&gt;###############################################&lt;br /&gt;&lt;br /&gt;import os, sys, signal, time&lt;br /&gt;&lt;br /&gt;STATE_NOT_RUNNING = -1&lt;br /&gt;STATE_LOCK_EXISTS = -2&lt;br /&gt;&lt;br /&gt;def usage():&lt;br /&gt;   print "Usage: %s {start [args...] | stop | restart [args...] | status | debug | condrestart [args...] }" % sys.argv[0]&lt;br /&gt;   print&lt;br /&gt;   print "For a list of valid 'args' refer to:"&lt;br /&gt;   print "$ denyhosts.py --help"&lt;br /&gt;   print&lt;br /&gt;   sys.exit(0)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def getpid():&lt;br /&gt;   try:&lt;br /&gt;       fp = open(DENYHOSTS_LOCK, "r")&lt;br /&gt;       pid = int(fp.readline().rstrip())&lt;br /&gt;       fp.close()&lt;br /&gt;   except Exception, e:&lt;br /&gt;       return STATE_NOT_RUNNING&lt;br /&gt;&lt;br /&gt;   if os.access(os.path.join("/proc", str(pid)), os.F_OK):&lt;br /&gt;       return pid&lt;br /&gt;   else:&lt;br /&gt;       return STATE_LOCK_EXISTS&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def start(*args):&lt;br /&gt;   cmd = "%s --daemon " % DENYHOSTS_BIN&lt;br /&gt;   if args: cmd += ' '.join(args)&lt;br /&gt;&lt;br /&gt;   print "starting DenyHosts:   ", cmd&lt;br /&gt;&lt;br /&gt;   os.system(cmd)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def stop():&lt;br /&gt;   pid = getpid()&lt;br /&gt;   if pid &gt;= 0:&lt;br /&gt;       os.kill(pid, signal.SIGTERM)&lt;br /&gt;       print "sent DenyHosts SIGTERM"&lt;br /&gt;   else:&lt;br /&gt;       print "DenyHosts is not running"&lt;br /&gt;&lt;br /&gt;def debug():&lt;br /&gt;   pid = getpid()&lt;br /&gt;   if pid &gt;= 0:&lt;br /&gt;       os.kill(pid, signal.SIGUSR1)&lt;br /&gt;       print "sent DenyHosts SIGUSR1"&lt;br /&gt;   else:&lt;br /&gt;       print "DenyHosts is not running"&lt;br /&gt;&lt;br /&gt;def status():&lt;br /&gt;   pid = getpid()&lt;br /&gt;   if pid == STATE_LOCK_EXISTS:&lt;br /&gt;       print "%s exists but DenyHosts is not running" % DENYHOSTS_LOCK&lt;br /&gt;   elif pid == STATE_NOT_RUNNING:&lt;br /&gt;       print "Denyhosts is not running"&lt;br /&gt;   else:&lt;br /&gt;       print "DenyHosts is running with pid = %d" % pid&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def condrestart(*args):&lt;br /&gt;   pid = getpid()&lt;br /&gt;   if pid &gt;= 0:&lt;br /&gt;       restart(*args)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def restart(*args):&lt;br /&gt;   stop()&lt;br /&gt;   time.sleep(1)&lt;br /&gt;   start(*args)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if __name__ == '__main__':&lt;br /&gt;   cases = {'start':       start,&lt;br /&gt;            'stop':        stop,&lt;br /&gt;            'debug':       debug,&lt;br /&gt;            'status':      status,&lt;br /&gt;            'condrestart': condrestart,&lt;br /&gt;            'restart':     restart}&lt;br /&gt;&lt;br /&gt;   try:&lt;br /&gt;       args = sys.argv[2:]&lt;br /&gt;   except:&lt;br /&gt;       args = []&lt;br /&gt;&lt;br /&gt;   try:&lt;br /&gt;       option = sys.argv[1]&lt;br /&gt;&lt;br /&gt;       if option in ('start', 'restart', 'condrestart'):&lt;br /&gt;           if '--config' not in args and '-c' not in args:&lt;br /&gt;               args.append("--config=%s" % DENYHOSTS_CFG)&lt;br /&gt;&lt;br /&gt;       cmd = cases[option]&lt;br /&gt;       apply(cmd, args)&lt;br /&gt;   except:&lt;br /&gt;       usage()&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Next we have to make that file executable:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;chown root daemon-control&lt;br /&gt;chmod 700 daemon-control&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Afterwards, we create the system bootup links for DenyHosts do that it is started automatically when the system is booted:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cd /etc/init.d&lt;br /&gt;  ln -s /usr/share/denyhosts/daemon-control denyhosts&lt;br /&gt;update-rc.d denyhosts defaults&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Finally, we start DenyHosts:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;/etc/init.d/denyhosts start&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;DenyHosts logs to&lt;/span&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;em&gt; /var/log/denyhosts&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;, if you are interested in the logs. The SSH daemon logs to&lt;/span&gt;&lt;em&gt; /var/log/auth.log&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; on Debian. You can watch both logs and try to log in with an invalid user or with a valid user and incorrect password, etc. via SSH and see what happens. After you have crossed the threshold of incorrect login attempts, the IP address from which you tried to connect should get listed in &lt;/span&gt;&lt;em&gt;/etc/hosts.deny&lt;/em&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;, like this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.&lt;br /&gt;#                  See the manual pages hosts_access(5), hosts_options(5)&lt;br /&gt;#                  and /usr/doc/netbase/portmapper.txt.gz&lt;br /&gt;#&lt;br /&gt;# Example:    ALL: some.host.name, .some.domain&lt;br /&gt;#             ALL EXCEPT in.fingerd: other.host.name, .other.domain&lt;br /&gt;#&lt;br /&gt;# If you're going to protect the portmapper use the name "portmap" for the&lt;br /&gt;# daemon name. Remember that you can only use the keyword "ALL" and IP&lt;br /&gt;# addresses (NOT host or domain names) for the portmapper. See portmap(8)&lt;br /&gt;# and /usr/doc/portmap/portmapper.txt.gz for further information.&lt;br /&gt;#&lt;br /&gt;# The PARANOID wildcard matches any host whose name does not match its&lt;br /&gt;# address.&lt;br /&gt;&lt;br /&gt;# You may wish to enable this to ensure any programs that don't&lt;br /&gt;# validate looked up hostnames still leave understandable logs. In past&lt;br /&gt;# versions of Debian this has been the default.&lt;br /&gt;# ALL: PARANOID&lt;br /&gt;sshd: 192.168.0.203&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This means that the system with the IP address &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;192.168.0.203&lt;/em&gt;&lt;/span&gt; cannot connect anymore using SSH.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;You can specify if/when IP addresses are removed again from &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/hosts.deny&lt;/em&gt;&lt;/span&gt; - have a look at the        &lt;span style="font-family:Courier New, Courier, mono;"&gt;   &lt;em&gt;PURGE_DENY&lt;/em&gt;&lt;/span&gt; variable in        &lt;span style="font-family:Courier New, Courier, mono;"&gt;   &lt;em&gt;/usr/share/denyhosts/denyhosts.cfg&lt;/em&gt;&lt;/span&gt;.  You must start DenyHosts with the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;--purge&lt;/em&gt;&lt;/span&gt; option to make the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;PURGE_DENY&lt;/em&gt;&lt;/span&gt; variable effective, like this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;/etc/init.d/denyhosts start --purge&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;However, you can also remove IP addresses manually from there, and as soon as they have got removed, these IP addresses can try to log in again via SSH. &lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114328387342951061?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114328387342951061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114328387342951061&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114328387342951061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114328387342951061'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/preventing-ssh-dictionary-attacks-with.html' title='Preventing SSH Dictionary Attacks With DenyHosts'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114320415899524736</id><published>2006-03-24T20:37:00.000+08:00</published><updated>2006-03-24T20:42:38.996+08:00</updated><title type='text'>How do I scan my Linux system for rootkits, worms, trojans, etc.?</title><content type='html'>&lt;p&gt;Either with &lt;i&gt;ckrootkit&lt;/i&gt; or with &lt;i&gt;rkhunter&lt;/i&gt;.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;chkrootkit:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Either install the package that comes with your distribution (on Debian you would run&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;apt-get install chkrootkit&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;), or download the sources from &lt;a href="http://www.chkrootkit.org/" target="_blank"&gt;www.chkrootkit.org&lt;/a&gt; and install manually:&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;wget --passive-ftp ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;tar xvfz chkrootkit.tar.gz&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;cd chkrootkit-&lt;version&gt;/&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;make sense&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Afterwards, you can move the chkrootkit directory somewhere else, e.g. &lt;i&gt;/usr/local/chkrootkit&lt;/i&gt;:&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;cd ..&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;mv chkrootkit-&lt;version&gt;/ /usr/local/chkrootkit&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now you can run chkrootkit manually:&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;cd /usr/local/chkrootkit&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;./chkrootkit&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;(if you installed a chkrootkit package coming with your distribution, your chkrootkit might be somewhere else).&lt;/p&gt;&lt;p&gt;You can even run chkrootkit by a cron job and get the results emailed to you:&lt;/p&gt;&lt;p&gt;Run &lt;/p&gt;&lt;p&gt;crontab -e&lt;/p&gt;&lt;p&gt;to create a cron job like this:&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;0 3 * * * (cd /usr/local/chkrootkit-&lt;version&gt;; ./chkrootkit 2&gt;&amp;1 | mail -s "chkrootkit output my server" you@yourdomain.com)&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;That would run chkrootkit every night a 3.00h.&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;b&gt;rkhunter:&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;Download the latest rkhunter sources from &lt;a href="http://www.rootkit.nl/" target="_blank"&gt;www.rootkit.nl&lt;/a&gt;:&lt;/p&gt;&lt;p&gt;wget http://downloads.rootkit.nl/rkhunter-1.2.7.tar.gz&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;tar xvfz rkhunter-1.2.7.tar.gz&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;cd rkhunter/&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;./installer.sh&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This will install rkhunter to the directory &lt;i&gt;/usr/local/rkhunter&lt;/i&gt;. Now run&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;rkhunter --update&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;to download the latest chkrootkit/trojan/worm signatures (you should do this regularly).&lt;/p&gt;&lt;p&gt;Now you can scan your system for malware by running&lt;/p&gt;&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;i&gt;rkhunter -c&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114320415899524736?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114320415899524736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114320415899524736&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114320415899524736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114320415899524736'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/how-do-i-scan-my-linux-system-for.html' title='How do I scan my Linux system for rootkits, worms, trojans, etc.?'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114320379127925973</id><published>2006-03-24T20:35:00.000+08:00</published><updated>2006-03-24T20:36:31.293+08:00</updated><title type='text'>Convert man pages to text</title><content type='html'>There can often be times when you want man pages in print, or to simply  save them to text for&lt;br /&gt;something like HTML use.  The common thing that  people do is:&lt;br /&gt;&lt;br /&gt;man lp &gt; lp.txt&lt;br /&gt;&lt;br /&gt;This will take the output of lp  and put it to a file named lp.txt, but it will keep all the formatting &lt;br /&gt;in the document. In order to get rid of those characters, do the  following:&lt;br /&gt;&lt;br /&gt;man lp | col -b &gt; lp.txt&lt;br /&gt;&lt;br /&gt;Create the text file  both ways naming one of them "lp2.txt" and do a "diff" on them. You'll  see the&lt;br /&gt;difference then.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114320379127925973?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114320379127925973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114320379127925973&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114320379127925973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114320379127925973'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/convert-man-pages-to-text.html' title='Convert man pages to text'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114304691261031190</id><published>2006-03-23T01:00:00.000+08:00</published><updated>2006-03-23T01:01:52.630+08:00</updated><title type='text'>Poor Mans Raid &amp; Clone Script Tutorial</title><content type='html'>&lt;p&gt;&lt;strong&gt;&lt;u&gt;POORMANS RAID &amp; CLONE SCRIPT &lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Get yourself two hardives setup your first drive (HDA) with the your perfek system.&lt;br /&gt;2. Power up your second drive (HDC)&lt;br /&gt;3. Slice HDC up by using cfdisk &lt;strong&gt;(command is cfdisk /dev/hdc)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Hda1 - primary boot begining Label [ / ]&lt;br /&gt;Hda5 - logical beginning [ /usr ]&lt;br /&gt;Hda6 - logical beginning [ /var ]&lt;br /&gt;Hda7 - logical beginning [ swap ]&lt;br /&gt;Hda8 - logical beginning [ /tmp ]&lt;br /&gt;Hda9 - logical beginning [ /home ]&lt;/p&gt;&lt;p&gt;To Setup your filesystem and your labels&lt;br /&gt;&lt;br /&gt;Mkfs -t ext3 -L / dev/hdc1&lt;br /&gt;Mkfs -t ext3 -L /usr dev/hdc5&lt;br /&gt;Mkfs -t ext3 -L /var dev/hdc6&lt;br /&gt;Mkfs -t ext3 -L /tmp dev/hdc8&lt;br /&gt;Mkfs -t ext3 -L /home dev/hdc9&lt;br /&gt;&lt;br /&gt;okay so you have sliced HDC and setup your filesystems with Labels.&lt;br /&gt;&lt;br /&gt;Vi and copy the below script save a file called clone, make it chmod 777 and run it.&lt;br /&gt;&lt;br /&gt;once copied run Grub&lt;br /&gt;#grub --no-floppy&lt;br /&gt;#grub&gt;&lt;br /&gt;# device (hd0) /dev/hdc&lt;br /&gt;# root (hd0,0)&lt;br /&gt;# setup (hd0)&lt;br /&gt;# quit&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Clone Script&lt;/strong&gt;"make sure nothing is mounted in /mnt!"&lt;br /&gt;echo "going to unmount /mnt"&lt;br /&gt;/bin/umount /mnt&lt;br /&gt;&lt;br /&gt;mount /dev/hdc1 /mnt&lt;br /&gt;cd /&lt;br /&gt;cp -ax / /mnt&lt;/p&gt;&lt;p&gt;mount /dev/hdc5 /mnt/usr&lt;br /&gt;cd /usr&lt;br /&gt;tar lcpBf - /usr | (cd /mnt; tar xBf -)&lt;br /&gt;&lt;br /&gt;mount /dev/hdc9 /mnt/home&lt;br /&gt;cd /home&lt;br /&gt;tar lcpBf - /home | (cd /mnt; tar xBf -)&lt;/p&gt;&lt;p&gt;mount /dev/hdc8 /mnt/tmp&lt;br /&gt;cd /tmp&lt;br /&gt;tar lcpBf - /tmp | (cd /mnt; tar xBf -)&lt;br /&gt;&lt;br /&gt;#Stop crtical services&lt;br /&gt;/etc/init.d/mysql stop&lt;/p&gt;&lt;p&gt;mount /dev/hdc6 /mnt/var&lt;br /&gt;cd /var&lt;br /&gt;tar lcpBf - /var | (cd /mnt; tar xBf -)&lt;/p&gt;&lt;p&gt;#start all the services again&lt;br /&gt;/etc/init.d/mysql start&lt;/p&gt;&lt;p&gt;echo "all copied"&lt;br /&gt;exit 0&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114304691261031190?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114304691261031190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114304691261031190&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114304691261031190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114304691261031190'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/poor-mans-raid-clone-script-tutorial.html' title='Poor Mans Raid &amp; Clone Script Tutorial'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114283820746237032</id><published>2006-03-20T15:02:00.000+08:00</published><updated>2006-03-20T15:03:27.463+08:00</updated><title type='text'>Out-going admin cron jobs</title><content type='html'>As the In-Coming Sys Admin, one the checks you should never miss is to check all the Cron and at jobs during the handover period from the out-going Admin!&lt;br /&gt;&lt;br /&gt;Try:&lt;br /&gt;# crontab -u [user] -l&lt;br /&gt;&lt;br /&gt;Manually change the user for of the users in /etc/passwd or script this substitution if the number of users on your system is worth the effort.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114283820746237032?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114283820746237032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114283820746237032&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283820746237032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283820746237032'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/out-going-admin-cron-jobs.html' title='Out-going admin cron jobs'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114283804558973454</id><published>2006-03-20T14:59:00.000+08:00</published><updated>2006-03-20T15:00:45.590+08:00</updated><title type='text'>Who hits my website</title><content type='html'>This will generate a listing of all IPs that have accessed a specific directory of my website&lt;br /&gt;(the /foo/ directory), and print a count (from greatest to least) next to the IP.&lt;br /&gt;&lt;br /&gt;if you want to get a total listing for all directories of a domain, just omit the "grep -e /foo/" statement.&lt;br /&gt;&lt;br /&gt;cat /home/server.com/logs/access_log |&lt;br /&gt;grep -e /flesh/ |&lt;br /&gt;sort |&lt;br /&gt;uniq -w15 -c |&lt;br /&gt;cut -f 1 -d- |&lt;br /&gt;sort -r -g&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Using this format for the apache log files:&lt;br /&gt;63.26.57.218 - - [07/Mar/2001:21:12:15 -0500] "GET&lt;br /&gt;/flesh/fleshpix/thumbs/facial2/poofylips.jpg_t.jpg HTTP/1.1" 200 4353&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sample output is:&lt;br /&gt;123 62.155.255.18&lt;br /&gt;123 216.17.9.140&lt;br /&gt;121 62.98.129.125&lt;br /&gt;120 66.32.16.55&lt;br /&gt;120 216.196.144.202&lt;br /&gt;119 194.100.2.65&lt;br /&gt;116 194.170.1.68&lt;br /&gt;114 62.155.255.21&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114283804558973454?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114283804558973454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114283804558973454&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283804558973454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283804558973454'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/who-hits-my-website.html' title='Who hits my website'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114283783139497335</id><published>2006-03-20T14:55:00.000+08:00</published><updated>2006-03-20T14:57:11.393+08:00</updated><title type='text'>Scripts for all occasions</title><content type='html'>Sun Microsystems has a great archive of useful scripts at:&lt;br /&gt;&lt;br /&gt;http://www.sun.com/bigadmin/scripts/index.html&lt;br /&gt;&lt;br /&gt;Check it out. You'll be glad you did!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114283783139497335?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114283783139497335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114283783139497335&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283783139497335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283783139497335'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/scripts-for-all-occasions.html' title='Scripts for all occasions'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114283767054793895</id><published>2006-03-20T14:53:00.000+08:00</published><updated>2006-03-20T14:54:30.546+08:00</updated><title type='text'>Bash shell option</title><content type='html'>If you are using bash shell. There is a way to cd a particular directory even if you spelled incorrectly on the command line. Set the shell option to:&lt;br /&gt;&lt;br /&gt;shopt -s cdspell&lt;br /&gt;&lt;br /&gt;eg:-&lt;br /&gt;Suppose you want to cd to "cd /tmp" and you have miss typed to "cd /pmp" still it will cd to "cd /tmp".&lt;br /&gt;&lt;br /&gt;This setting will be very usefull if you have a long named directory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114283767054793895?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114283767054793895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114283767054793895&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283767054793895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283767054793895'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/bash-shell-option.html' title='Bash shell option'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114283754141597335</id><published>2006-03-20T14:51:00.000+08:00</published><updated>2006-03-20T14:52:21.426+08:00</updated><title type='text'>Get the hidden files</title><content type='html'>A safe way of grabbing all "hidden" files is to use '.??*' rather than '.*' since this will only match 3 or more characters. Admittedly, this will miss any hidden files that are only a single character after the ., but it will always miss '.' &amp; '..', which is probably more important...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114283754141597335?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114283754141597335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114283754141597335&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283754141597335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114283754141597335'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/get-hidden-files.html' title='Get the hidden files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114279117297924252</id><published>2006-03-20T01:58:00.000+08:00</published><updated>2006-03-20T01:59:33.016+08:00</updated><title type='text'>Chrooted SSH HowTo</title><content type='html'>&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This tutorial describes how to install and configure OpenSSH so that it will allow chrooted sessions for users. With this setup, you can give your users shell access without having to fear that they can see your whole system. Your users will be jailed in a specific directory which they will not be able to break out of. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This setup is based on a Debian Sarge (Debian 3.1) system, and the chrooted SSH will be installed in such a way that it will still use the configuration files of the standard OpenSSH Debian package which are in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/ssh/&lt;/em&gt;&lt;/span&gt;, and you will be able to use the standard OpenSSH Debian init script &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/init.d/ssh&lt;/em&gt;&lt;/span&gt;. Therefore you do not have to create your own init script and configuration file. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;I want to say first   that this is not the only way of setting up such a system. There are many ways   of achieving this goal but this is the way I take. I do not issue any guarantee   that this will work for you!&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h4&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;1 Install The Newest Zlib Version &lt;/span&gt;&lt;/h4&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Because there was a security hole in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;zlib-1.2.2&lt;/em&gt;&lt;/span&gt; about which the chrooted SSH will complain when we try to compile it, we install the newest zlib version right now:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cd /tmp&lt;br /&gt;  wget http://www.zlib.net/zlib-1.2.3.tar.gz&lt;br /&gt;  tar xvfz zlib-1.2.3.tar.gz&lt;br /&gt;  cd zlib-1.2.3&lt;br /&gt;  make clean&lt;br /&gt;  ./configure -s&lt;br /&gt;  make&lt;br /&gt;make install&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;&lt;strong&gt;2 Install The Chrooted SSH &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This is quite easy. We download the patched OpenSSH sources, and we configure them with &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/usr&lt;/em&gt;&lt;/span&gt; as directory for the SSH executable files, with &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/ssh&lt;/em&gt;&lt;/span&gt; as directory where the chrooted SSH will look for configuration files, and we also allow &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;PAM&lt;/em&gt;&lt;/span&gt; authentication: &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cd /tmp&lt;br /&gt;  apt-get install libpam0g-dev openssl libcrypto++-dev libssl0.9.7 libssl-dev ssh&lt;br /&gt;  wget http://chrootssh.sourceforge.net/download/openssh-4.2p1-chroot.tar.gz&lt;br /&gt;  tar xvfz openssh-4.2p1-chroot.tar.gz&lt;br /&gt;  cd openssh-4.2p1-chroot&lt;br /&gt;  ./configure --exec-prefix=/usr --sysconfdir=/etc/ssh --with-pam&lt;br /&gt;  make&lt;br /&gt;make install&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:100%;"&gt;&lt;strong&gt;3 Create The Chroot Environment&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Next I create a chroot environment under &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot&lt;/em&gt;&lt;/span&gt;. This is the directory that all chrooted SSH users will get jailed in, i.e. they will not be able to see any files/directories outside &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;I have to create some directories in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot&lt;/em&gt;&lt;/span&gt;, and I have to copy a few binaries like &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/bin/bash&lt;/em&gt;&lt;/span&gt;, &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/bin/ls&lt;/em&gt;&lt;/span&gt;, etc. as well as the libraries on which these binaries depend into the chroot environment so that they are available to any chrooted user.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;mkdir /home/chroot/&lt;br /&gt;  mkdir /home/chroot/home/&lt;br /&gt;  cd /home/chroot&lt;br /&gt;  mkdir etc&lt;br /&gt;  mkdir bin&lt;br /&gt;  mkdir lib&lt;br /&gt;  mkdir usr&lt;br /&gt;  mkdir usr/bin&lt;br /&gt;  mkdir dev&lt;br /&gt;  mknod dev/null c 1 3&lt;br /&gt;mknod dev/zero c 1 5 &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now that we have created the necessary directories, we are goning to copy some binaries and all the libraries on which they depend into the chroot environment. This is an excerpt of a script that I found on &lt;a href="http://mail.incredimail.com/howto/openssh/create_chroot_env" target="_blank"&gt;http://mail.incredimail.com/howto/openssh/create_chroot_env&lt;/a&gt; that does this. Just copy and paste the following lines into your shell, and hit &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;Return&lt;/em&gt;&lt;/span&gt;. If you want to make more programs available to your chrooted users, just add these programs to the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;APPS&lt;/em&gt;&lt;/span&gt; line:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;APPS="/bin/bash /bin/ls /bin/mkdir /bin/mv /bin/pwd /bin/rm /usr/bin/id /usr/bin/ssh /bin/ping /usr/bin/dircolors"&lt;br /&gt;for prog in $APPS;  do&lt;br /&gt;       cp $prog ./$prog&lt;br /&gt;&lt;br /&gt;       # obtain a list of related libraries&lt;br /&gt;       ldd $prog &gt; /dev/null&lt;br /&gt;       if [ "$?" = 0 ] ; then&lt;br /&gt;               LIBS=`ldd $prog | awk '{ print $3 }'`&lt;br /&gt;               for l in $LIBS; do&lt;br /&gt;                       mkdir ./`dirname $l` &gt; /dev/null 2&gt;&amp;1&lt;br /&gt;                       cp $l ./$l&lt;br /&gt;               done&lt;br /&gt;       fi&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we do this:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;cp /lib/libnss_compat.so.2 /lib/libnsl.so.1 /lib/libnss_files.so.2 ./lib/&lt;br /&gt;  echo '#!/bin/bash' &gt; usr/bin/groups&lt;br /&gt;  echo "id -Gn" &gt;&gt; usr/bin/groups&lt;br /&gt;  touch etc/passwd&lt;br /&gt;grep /etc/passwd -e "^root" &gt; etc/passwd&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;You should also copy the line of the group in which you will create new users from &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/group&lt;/em&gt;&lt;/span&gt; to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot/etc/group&lt;/em&gt;&lt;/span&gt;. In this tutorial we will create users in the group &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;users&lt;/em&gt;&lt;/span&gt;, so we do this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt; grep /etc/group -e "^root" -e "^users" &gt; etc/group&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;and restart SSH:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;/etc/init.d/ssh restart &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;4 Create A Chrooted User &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Even with the chrooted SSH that we have just installed you can log in without being chrooted (which makes sense if you log in as &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;root&lt;/em&gt;&lt;/span&gt;, for example). Now, how does the chrooted SSH decide whom to chroot and whom not? That's easy: the chrooted SSH looks up the user who is trying to log in in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/passwd&lt;/em&gt;&lt;/span&gt;. If the user's home directory in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/passwd&lt;/em&gt;&lt;/span&gt; has a . in it, then the user is going to be chrooted.&lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;strong&gt;Example (from &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/passwd&lt;/em&gt;&lt;/span&gt;):&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;user_a:x:2002:100:User A:/home/user_a:/bin/bash&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This user will not be chrooted.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;user_b:x:2003:100:User B:/home/chroot/&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/span&gt;/home/user_b:/bin/bash &lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This user will be chrooted. &lt;/span&gt;&lt;/p&gt; &lt;hr /&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now we create the user testuser with the home directory &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot/./home/testuser&lt;/em&gt;&lt;/span&gt; and the group &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;users&lt;/em&gt;&lt;/span&gt; (which is the default group for users on Debian so you do not have to specify it explicitly):&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;useradd -s /bin/bash -m -d /home/chroot/./home/testuser -c "testuser" -g users testuser&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Then we give &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;testuser&lt;/em&gt;&lt;/span&gt; a password:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;passwd testuser&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Finally, we have to copy the line for &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;testuser&lt;/em&gt;&lt;/span&gt; in &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/passwd&lt;/em&gt;&lt;/span&gt; to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot/etc/passwd&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;grep /etc/passwd -e "^testuser" &gt;&gt; /home/chroot/etc/passwd&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;We have already copied the &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;users&lt;/em&gt;&lt;/span&gt; group line from &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/etc/group&lt;/em&gt;&lt;/span&gt; to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot/etc/group&lt;/em&gt;&lt;/span&gt; so we do not have to do this here again. If you create a chrooted user in another group than &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;users&lt;/em&gt;&lt;/span&gt;, add this group to &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot/etc/group&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;&lt;span style="font-size:85%;"&gt;grep /etc/group  -e "^othergroup" &gt;&gt; /home/chroot/etc/group&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Now try to log in to SSH as &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;testuser&lt;/em&gt;&lt;/span&gt;. You should be chrooted and not be able to browse files/directories outside &lt;span style="font-family:Courier New, Courier, mono;"&gt;&lt;em&gt;/home/chroot&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;Have fun!&lt;/span&gt; &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114279117297924252?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114279117297924252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114279117297924252&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114279117297924252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114279117297924252'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/chrooted-ssh-howto.html' title='Chrooted SSH HowTo'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114260555452675231</id><published>2006-03-17T22:25:00.000+08:00</published><updated>2006-03-17T22:25:54.530+08:00</updated><title type='text'>How to create IP-IP tunnel between FreeBSD and Linux</title><content type='html'>&lt;p&gt;Sometimes, I need to connect remote Unix servers with tunnels to provide some specific services or to get access to some internal networks. I was very surprised, when my friend, young system administrator, asked me about how to bring up IP-IP tunnel between different Unix operating systems (FreeBSD and Linux in his case) and said, that he can’t find information about this configuration. As the result of my discovering, this HOWTO has been created.&lt;/p&gt;  &lt;p&gt;Lets see to what we have and what we need to do. &lt;/p&gt; &lt;p&gt;We have 2 servers:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;Server1:&lt;/b&gt; &lt;ul&gt;&lt;li&gt;OS: Linux &lt;/li&gt;&lt;li&gt;Network Interface: eth0 &lt;/li&gt;&lt;li&gt;IP: 100.100.100.100&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;Server2:&lt;/b&gt; &lt;ul&gt;&lt;li&gt;OS: FreeBSD &lt;/li&gt;&lt;li&gt;Network Interface: fxp0 &lt;/li&gt;&lt;li&gt;IP: 200.200.200.200&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;We need to get IPv4 over IPv4 tunnel with the following parameters between described servers:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;Server1:&lt;/b&gt; 10.0.0.1 / 255.255.255.252&lt;/li&gt;&lt;li&gt;&lt;b&gt;Server2:&lt;/b&gt; 10.0.0.2 / 255.255.255.252&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;To setup described configuration on Linux server we need to do following steps:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Create ipip tunnel interface:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# ip tunnel add tun0 mode ipip &gt; remote 200.200.200.200 local 100.100.100.100 dev eth0&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt;&lt;b&gt;  &lt;/b&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Set interface IP addresses:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# ifconfig tun0 10.0.0.1 netmask 255.255.255.252 &gt; pointopoint 10.0.0.1&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Set interface MTU and bring interface up:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# ifconfig tun0 mtu 1500 up&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt;    &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Now we have following interface on the Linux server:&lt;/p&gt; &lt;pre&gt;&lt;b&gt;linux:~# ifconfig tun0&lt;/b&gt;&lt;br /&gt;tun77     Link encap:IPIP Tunnel  HWaddr&lt;br /&gt;         inet addr:10.0.0.1  P-t-P:10.0.0.2  Mask:255.255.255.252&lt;br /&gt;         UP POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1&lt;br /&gt;         RX packets:6 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;         TX packets:6 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;         collisions:0 txqueuelen:0&lt;br /&gt;         RX bytes:504 (504.0 b)  TX bytes:624 (624.0 b)&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt;Now, we need to create tunnel point at the FeeeBSD server:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Create gif tunnel interface:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# # ifconfig gif0 create&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt;&lt;b&gt;  &lt;/b&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Set interface transport IP addresses:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# gifconfig gif0 inet 200.200.200.200 100.100.100.100&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Set interface IP addresses:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# ifconfig gif0 10.0.0.2 netmask 255.255.255.252 10.0.0.1&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;Set interface MTU and bring interface up:&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;pre&gt;&lt;b&gt;# ifconfig gif0 mtu 1500 up&lt;br /&gt;&lt;/b&gt;&lt;/pre&gt; &lt;p&gt;    &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The result at the FreeBSD side is following:&lt;/p&gt; &lt;pre&gt;&lt;b&gt;# ifconfig gif0&lt;/b&gt;&lt;br /&gt;gif0: flags=8051&lt;up multicast=""&gt; mtu 1500&lt;br /&gt;       tunnel inet 200.200.200.200 –&gt; 100.100.100.100&lt;br /&gt;       inet 10.0.0.2 –&gt; 10.0.0.1 netmask 0xfffffffc&lt;br /&gt;&lt;/up&gt;&lt;/pre&gt;   &lt;p&gt;To check the result we can use ping utility at linux side:&lt;/p&gt; &lt;pre&gt;&lt;b&gt;linux:~# ping -c 4 10.0.0.2&lt;/b&gt;&lt;br /&gt;PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.&lt;br /&gt;64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.139 ms&lt;br /&gt;64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.138 ms&lt;br /&gt;64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.138 ms&lt;br /&gt;64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.136 ms&lt;br /&gt;&lt;br /&gt;— 172.17.0.1 ping statistics —&lt;br /&gt;4 packets transmitted, 4 received, 0% packet loss, time 2997ms&lt;br /&gt;rtt min/avg/max/mdev = 0.136/0.137/0.139/0.014 ms&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;That is all! Now we have “direct” connection  between our two servers and we are able to do some routing via this link.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114260555452675231?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114260555452675231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114260555452675231&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260555452675231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260555452675231'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/how-to-create-ip-ip-tunnel-between.html' title='How to create IP-IP tunnel between FreeBSD and Linux'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114260539905901467</id><published>2006-03-17T22:22:00.000+08:00</published><updated>2006-03-17T22:23:19.083+08:00</updated><title type='text'>How can I have two default routes?</title><content type='html'>This is where advanced routing comes into play (finally!).  With advanced routing, you can have as many routing tables as you need; in this case you need to add just one for the new DSL line.   &lt;p&gt; First, add a name for the new routing table to the file /etc/iproute2/rt_tables. You can append it to the file with command "echo 2 dsl2 &gt;&gt; /etc/iproute2/rt_tables".   &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;echo 2 dsl2 &gt;&gt; /etc/iproute2/rt_tables&lt;/b&gt;&lt;br /&gt;# &lt;b&gt;cat /etc/iproute2/rt_tables&lt;/b&gt;             &lt;i&gt;list the file contents&lt;/i&gt;&lt;br /&gt;#&lt;br /&gt;# reserved values&lt;br /&gt;#&lt;br /&gt;255     local&lt;br /&gt;254     main&lt;br /&gt;253     default&lt;br /&gt;0       unspec&lt;br /&gt;#&lt;br /&gt;# local&lt;br /&gt;#&lt;br /&gt;#1      inr.ruhep&lt;br /&gt;2 dsl2                          &lt;i&gt;the line you just added&lt;/i&gt; &lt;/pre&gt;  &lt;p&gt;  Earlier I mentioned that typing "&lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;ip&lt;/a&gt; route" is a shortcut for the longer command "ip route show table main". Well, to list the new routing table you have to use the long form: "ip route show table dsl2" If you enter this command right now, you will see the new table is empty.  &lt;/p&gt;&lt;p&gt; You really only need to add the new default route to the new table;  the old "main" table will continue to handle everything else. You will see why in a minute. Once again, here is the existing "main" table.  &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;ip route show table main&lt;/b&gt;&lt;br /&gt;63.63.63.0/29 dev eth0  proto kernel  scope link  src 63.63.63.1&lt;br /&gt;30.31.32.0/29 dev eth1  proto kernel  scope link  src 30.31.32.1&lt;br /&gt;default via 63.63.63.6 dev eth0&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; Add the new default route to table dsl2 and then look at the (short) table.  &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;ip route add default via 30.31.32.6 dev eth1 table dsl2&lt;/b&gt;&lt;br /&gt;# &lt;b&gt;ip route show table dsl2&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;default via 30.31.32.6 dev eth1    &lt;i&gt;the whole table is just one line&lt;/i&gt; &lt;/pre&gt;  &lt;h4&gt;But the new table is not used yet!&lt;/h4&gt; You need to learn one more command, "ip rule"  &lt;p&gt; A routing table tells where packets should &lt;b&gt;go&lt;/b&gt; (its destination). You need to be able to tell the kernel to use a different table,  based on where a packet is &lt;b&gt;from&lt;/b&gt; (its source address).  &lt;/p&gt;&lt;p&gt;  The existing ip ruleset is very simple, look at it now.  &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;ip rule&lt;/b&gt;&lt;br /&gt;0:      from all lookup local&lt;br /&gt;32766:  from all lookup main&lt;br /&gt;32767:  from all lookup default&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; You need to add just one new rule:  &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;ip rule add from 30.31.32.1 lookup dsl2 prio 1000&lt;/b&gt; &lt;/pre&gt;  &lt;p&gt;  This command says "add a rule" to handle the case when a packet has a "from" pattern of "30.31.32.1"; use the routing table called "dsl2", and assign the rule a priority level of "1000". Now relist the rules.  In this example, the "pattern" only needs to match one address but if you build a &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;Linux&lt;/a&gt; router, you could set patterns that would match different sets of addresses.  &lt;/p&gt;&lt;pre&gt;# &lt;b&gt;ip rule&lt;/b&gt;&lt;br /&gt;0:      from all lookup local&lt;br /&gt;1000:   from 30.31.32.1 lookup dsl2&lt;br /&gt;32766:  from all lookup main&lt;br /&gt;32767:  from all lookup default&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; The kernel searches the ip rules in order, starting with the lowest priority and continuing through each rule and routing table until the packet has been routed successfully.  &lt;/p&gt;&lt;p&gt; Your default ruleset will always have a 'local' table with 'all' as the match pattern.  The local table handles traffic that is supposed to stay on the local machine, and broadcast traffic.  &lt;/p&gt;&lt;p&gt; Our new rule comes next, with a priority of 1000. I picked this number to make adding other rules before and after ours easy later on.  &lt;/p&gt;&lt;p&gt; After our rule comes the 'main' table, which is the one that is manipulated by the old 'route' command. Finally comes the 'default' table. I don't know the official purpose of default, it's empty on all the systems I have set up. There is a 'default' route in the table 'main', so no traffic ever gets to the table 'detault'.  &lt;/p&gt;&lt;h3&gt;Caveats&lt;/h3&gt;  When you are playing with multiple routing tables, you have to remember to add the 'table' portion to the command. I have only forgotten about 1000 times now. It can be mystifying when rules change in the wrong table (main). And of course, you are sure to confuse things when learning and lock yourself out if you are remotely logged in. The changes happen FAST. Use a console connection.  &lt;p&gt; Another tip. Routes are cached. This means that if you update a routing table and nothing seems to happen, don't get frustrated, just flush the cache. You can make several changes at once and then flush the cache at the end so that the changes effectively all happen simultaneously. This is handy when working on a running router.  &lt;/p&gt;&lt;p&gt; The flush command I use is "ip route flush table cache".  Be very careful with the flush command!! Enter it wrong and you will remove all routing rules, instantly cutting off your networks.  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114260539905901467?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114260539905901467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114260539905901467&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260539905901467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260539905901467'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/how-can-i-have-two-default-routes.html' title='How can I have two default routes?'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114260517488857432</id><published>2006-03-17T22:18:00.000+08:00</published><updated>2006-03-17T22:19:34.890+08:00</updated><title type='text'>Revealing your routing tables</title><content type='html'>From a command line on any Linux system, you can see the existing routing table by simply typing 'route' at the prompt. (Type '/sbin/route' if /sbin is not in your path.)  Your routing table will be similar to this:  &lt;pre&gt;# route&lt;br /&gt;destination     gateway  interface&lt;br /&gt;63.63.63.0      *  eth0&lt;br /&gt;default  63.63.63.6 eth&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; Advanced routing commands are issued as arguments to the 'ip' command. To see the routing table with iproute2, you can use the long version "ip route show table main" or the shortcut version "ip route" like this:  &lt;/p&gt;&lt;pre&gt;# ip route&lt;br /&gt;63.63.63.0/29 dev eth0 proto kernel scope link src 63.63.63.1&lt;br /&gt;default via 63.63.63.6 dev eth0&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt; Recall that in our simple example, all ip addresses are considered to be either 'local' or 'not local'. For this network, a local address will be in the range from 63.63.63.1 to 63.63.63.6.  A non-local address is just anything else.* It's traditional to assign the router the highest address in the range (ending in 6 for this network).  &lt;/p&gt;&lt;p&gt; The first line in the routing table says that if the address is local, your computer puts the packet right out onto the ethernet wire using interface /dev/eth0.  The only other device on your local network right now is the DSL router at 63.63.63.6.  You can probably use a browser to bring up the router's built-in web-based configuration interface by connecting to http://63.63.63.6/  &lt;/p&gt;&lt;p&gt; When you want to surf over to linuxforums.org, the packets need to go to the Internet. You computer will use DNS to translate the name linuxforums.org into its IP address (67.15.52.42). Your computer sees that address is not local, so it uses teh 'default' entry in the routing table and sends the packet to your DSL router.  &lt;/p&gt;&lt;p&gt; In turn, the DSL router looks at the destination address, and sees that the data is destined for somewhere on the Internet. The DSL router then pushes the packet out its DSL connection to the next router upstream which is at your ISP. Just as with the postcard analogy, it's now out of your hands; more upstream routers send it on its way to the linuxforums.org server.   &lt;/p&gt;&lt;p&gt; When the response comes back from linuxforums.org, there is a destination address of 63.63.63.1 in the packet, so when it hits your DSL router it will pass the packet onto your LAN. Your desktop computer sees the packet on the LAN and picks it up. The round trip connection is now completed.  It takes many such exchanges of packets to pass all the data required for just a single page.  &lt;/p&gt;&lt;p&gt; If you have a web server running on your local computer, everything works pretty much the same way, but the traffic flows the other direction. Requests for pages come in from the Internet and your web server responds by sending pages back out via the DSL router. Usually you arrange to get your ip address into a DNS server somewhere so that you can publish a URL for your server with a friendly name like "http://myveryownserver.org" but you could just as easily not bother with that and just tell all your friends that your URL is http://63.63.63.1/.   &lt;/p&gt;&lt;p&gt; When a friend surfs to http://63.63.63.1/, your web server will receive the request with a source address pointing back to your friend's computer. Thus the reply will be routed back out via your one and only default router.  &lt;/p&gt;&lt;p&gt; * &lt;i&gt;Yes, I know there is another internal network on the address 127.0.0.1.  It's called the loopback interface /dev/lo. But let's not worry about it here, okay?&lt;/i&gt;  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114260517488857432?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114260517488857432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114260517488857432&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260517488857432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260517488857432'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/revealing-your-routing-tables.html' title='Revealing your routing tables'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114260501125463221</id><published>2006-03-17T22:15:00.000+08:00</published><updated>2006-03-17T22:16:51.256+08:00</updated><title type='text'>Where do the IP addresses come from?</title><content type='html'>You used to have to set up ip addresses, netmasks, gateways, and name resolvers all manually. Refer to any basic &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;networking&lt;/a&gt; text to learn more about this aspect.  &lt;p&gt; These days DHCP (Dynamic Host Control Protocol) is very popular. Let's assume that a DHCP server (typically inside your Cable/DSL modem) and issues all the &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;network&lt;/a&gt; information required. The network engineer at your upstream provider has configured the modem for you so that it will work with their network.  &lt;/p&gt;&lt;p&gt; With a typical home setup, you are assigned just one IP address and if you have more than one computer at home, you have to play games (NAT or MASQUERADE) to share the one IP address. A typical small business connection might have 5 IP addresses assigned statically so that you can publish them; a sixth address in the range lets you communicate with the router in your DSL &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;modem&lt;/a&gt;.   &lt;/p&gt;&lt;p&gt; For a 6 address block, you'd be assigned a netmask with 29 bits (255.255.255.248 in "dotted decimal" format).  You don't need to know what a netmask is right now, but it divides the address into two parts, network and local. In the postcard analogy, a p.o. box number would be the local part of your address.  &lt;/p&gt;&lt;p&gt; Let's say your first DSL provider gives you the address range from 63.63.63.1 to 63.63.63.6; your computer is at 63.63.63.1; your DSL router is at 63.63.63.6; and the remaining 4 addresses are currently unused.  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114260501125463221?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114260501125463221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114260501125463221&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260501125463221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260501125463221'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/where-do-ip-addresses-come-from.html' title='Where do the IP addresses come from?'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114260483538440507</id><published>2006-03-17T22:04:00.000+08:00</published><updated>2006-03-17T22:14:27.546+08:00</updated><title type='text'>Just what is routing?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.linuxforums.org/images/articles/Postcard2.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px;" src="http://www.linuxforums.org/images/articles/Postcard2.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;span name="intelliTxt" id="intelliTXT"&gt;  I like to compare &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;network&lt;/a&gt; packet routing with the post office.  Let's say that you and a friend play chess by sending postcards to each other.  Each postcard has a source and a destination address (From: and To: addresses) and a small amount of information, the next move in your game. You send a postcard with your move on it, then you wait for a reply to come back with your friend's next move. The game progresses as a series of transmissions and replies; the whole thing routed through any number of post offices without your knowledge.  Under ordinary circumstances, to tap into this vast network, all you have to need to know are the addresses and how to find your mailbox.&lt;/span&gt;&lt;span name="intelliTxt" id="intelliTXT"&gt;    &lt;p&gt; Each postcard is like a network packet. With the postal system, you could send a letter if your information doesn't fit on a card. With a network, you just send more packets instead because you can't (normally) change the packet size; your &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;operating system&lt;/a&gt; handles the task of breaking down large messages into small packets for transmission; likewise it reassembles incoming packets for you.  This is what happens when you request a web page; you enter one address (the URL) and the network coordinates the exchange of hundreds of packets unbenownst to you. To learn about routing though, you can ignore this fact and concentrate only on the routing of a single packet.  &lt;/p&gt;&lt;p&gt; After you drop your postcard into a mailbox, a system for routing it to its destination takes over; the reply comes back the same way. You only care about this routing mechanism when something changes, for example, if you move to a new address and want things forwarded. Otherwise it all remains invisible to you.  &lt;/p&gt;&lt;p&gt;  With &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;the Internet&lt;/a&gt;, you normally only deal with one connection to this invisible network; the router provided to you by your Internet Service Provider (ISP) is your connection.   &lt;/p&gt;&lt;p&gt; If you have one computer and one network connection, this is just about all you need to know about routing. Any packet leaving your computer heads out to the &lt;a target="_blank" href="http://www.linuxforums.org/#" style="border-bottom: 0.075em solid darkgreen; text-decoration: underline; padding-bottom: 1px; color: darkgreen; background-color: transparent;" class="iAs"&gt;Internet&lt;/a&gt;, and any reply coming back from the Internet is destined for your one computer.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;font&gt;&lt;span name="intelliTxt" id="intelliTXT"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.linuxforums.org/images/articles/Letterboxes.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px;" src="http://www.linuxforums.org/images/articles/Letterboxes.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;  Continuing with the postal analogy, if you work in the mailroom for a large company, you still generally only have one connection to the outside world, but there is an internal mailbox for each employee.  As the clerk in the mailroom, you decide based on the To: address to either route a letter internally (delivering it to its local mailbox) or as before, you throw it into an outgoing pile for your connection to the world.&lt;br /&gt; &lt;/span&gt;&lt;p&gt;&lt;font&gt; When you add a second computer in your office, each of your computers will have addresses indicating they are connected to the same LAN (local area network). The routing table in each of your computers has to know the correct LAN address range so that they can talk to each other.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;font&gt; With additional equipment, network complexity grows and things become progressively more complicated and much more interesting (to me anyway); there can be many routes in your computer's routing table. We are not getting into that here.  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;font&gt; In the simple set up we are doing here, you only have to recognize two  types of address, internal (LAN) or external (Internet).  &lt;/span&gt;&lt;/p&gt;&lt;font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114260483538440507?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114260483538440507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114260483538440507&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260483538440507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114260483538440507'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/just-what-is-routing.html' title='Just what is routing?'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114241887132610675</id><published>2006-03-15T18:34:00.000+08:00</published><updated>2006-03-15T18:34:31.340+08:00</updated><title type='text'>Mysql Database Backup Script</title><content type='html'>&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      About AutoMySQLBackup&lt;/span&gt;&lt;/b&gt;&lt;p&gt;     &lt;span style="font-family:Verdana;font-size:85%;"&gt;      A script to take daily, weekly and monthly backups of your MySQL      databases using mysqldump. Features - Backup mutiple databases -      Single backup file or to a seperate file for each DB - Compress      backup files - Backup remote servers - E-mail logs – More&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      AutoMySQLBackup Script Features&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      • Backup mutiple MySQL databases with one script. (Now able to      backup ALL databases on a server easily. no longer need to      specify each database seperately)&lt;br /&gt;    • Backup all databases to a single backup file or to a seperate      directory and file for each database.&lt;br /&gt;    • Automatically compress the backup files to save disk space      using either gzip or bzip2 compression.&lt;br /&gt;    • Can backup remote MySQL servers to a central server.&lt;br /&gt;    • Runs automatically using cron or can be run manually.&lt;br /&gt;    • Can e-mail the backup log to any specified e-mail address      instead of "root". (Great for hosted websites and databases).     &lt;br /&gt;    • Can email the compressed database backup files to the      specified email address.&lt;br /&gt;    • Can specify maximun size backup to email.&lt;br /&gt;    • Can be set to run PRE and POST backup commands.&lt;br /&gt;    • Choose which day of the week to run weekly backups.&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      AutoMySQLBackup Download&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      The AutoMySQLBackup project has now been moved to      Sourceforge.net for better maintainence.&lt;br /&gt;    &lt;br /&gt;    &lt;a href="http://sourceforge.net/projects/automysqlbackup/"&gt;     http://sourceforge.net/projects/automysqlbackup/&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      AutoMySQLBackup Requirements&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      The AutoMySQLBackup script only requires mysqldump (A standard      utility provided with the mysql client) and gzip or bzip2 for      compression of the backup files.&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      If you would like to have the log emailed to you then you will      need to have permission to execute the "mail" program. If you      want the compressed backup files mailed to you then Mutt must be      available on the server.&lt;br /&gt;    Finally you will need a bash shell and the standard system tools      and utilities (all these requirements should be the default on      most linux system.)&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      What AutoMySQLBackup does&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      Every day AutoMySQLBackup will run (if setup on /etc/cron.daily)      and using mysqldump and gzip will dump your specified databases      to the /backups/daily directory, it will rotate daily backups      weekly so you should never have more than 7 backups in there..&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      Every Saturday AutoMySQLBackup will again backup the databases      you have chosen but they will be placed into /backups/weekly,      these will be rotated every 5 weeks so there should never be      more than 5 backups in there..&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      Every 1st of the month AutoMySQLBackup will create a backup of      all databases and place them into /backups/monthly. These will      never be rotated so it will be up to you to do your own house      keeping. I would suggest taking a copy of this offline every      month or two so that if you have a hard drive failure you will      be able to restore your database..&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      AutoMySQLBackup Installation&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      The install is as simple as editing a few variables in the      AutoMySQLBackup file. The full setup is documented in the      AutoMySQLBackup script file below the variables section.. &lt;/span&gt;     &lt;/p&gt;     &lt;p&gt;&lt;b&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#cc0066;"&gt;      Here is a quick minimum setup step by step..&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      1. Download automysqlbackup.sh and place it into your /etc/cron.daily      directory or your home directory.&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      2. Edit (at least) the following lines :-&lt;br /&gt;    USERNAME=dbuser (The user must have at least select privileges      to the databases) PASSWORD=password&lt;br /&gt;    DBNAMES="DB1 DB2 DB3" (make sure to keep the quotes " "      otherwise it won't work)&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      3. Make the file executable :- chmod u+rwx&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      4. Create the following directory./backups&lt;/span&gt;&lt;/p&gt;     &lt;p&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;      5. That's it.. Now you can run it using the command line "./automysqlbackup.sh"      or if it is in /etc/cron.daily it will run each day when cron      runs.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114241887132610675?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114241887132610675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114241887132610675&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114241887132610675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114241887132610675'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/mysql-database-backup-script.html' title='Mysql Database Backup Script'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114236617447012956</id><published>2006-03-15T03:55:00.000+08:00</published><updated>2006-03-15T03:56:14.483+08:00</updated><title type='text'>Listing files by size</title><content type='html'>If you want to have a listing of the files sorted by size, you can use the  following command(s), it will list the files in decrease order. if you  need to do the same thing recursively, you could use the second  one.&lt;br /&gt;&lt;br /&gt;ls -l | grep ^- | sort -nr -k 5 | more&lt;br /&gt;&lt;br /&gt;ls -lR | grep ^- |  sort -nr -k 5 | more&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114236617447012956?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114236617447012956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114236617447012956&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114236617447012956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114236617447012956'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/listing-files-by-size.html' title='Listing files by size'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114227280023255696</id><published>2006-03-14T01:59:00.000+08:00</published><updated>2006-03-14T02:00:00.246+08:00</updated><title type='text'>Where am i always</title><content type='html'>In csh, if you always want to know where you are, put in your .cshrc-file the following 2 lines:&lt;br /&gt;&lt;br /&gt;alias sp 'set prompt="`hostname`:`pwd`&gt; "'  alias cd 'cd \!*;sp'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114227280023255696?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114227280023255696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114227280023255696&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114227280023255696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114227280023255696'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/where-am-i-always.html' title='Where am i always'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114225087232622820</id><published>2006-03-13T19:54:00.000+08:00</published><updated>2006-03-13T19:54:32.343+08:00</updated><title type='text'>Possible to get the administrator password ?</title><content type='html'>something "funny" :&lt;br /&gt;&lt;br /&gt;There is a file that contains all the installation logs :&lt;br /&gt;/var/log/installer/cdebconf/questions.dat&lt;br /&gt;In this file, there is all the questions asked to the user abd all the user's answers.&lt;br /&gt;&lt;br /&gt;So, near the end of the file, we can find the user created during the installation... and its password (not hidden).&lt;br /&gt;&lt;br /&gt;Then, tell me if I'm wrong :&lt;br /&gt;_ in the normal installation mode, the user created can get the root privileges with sudo&lt;br /&gt;_ in the expert mode, there is a root account created&lt;br /&gt;&lt;br /&gt;In both case, it's possible to get an administrator username/password.&lt;br /&gt;&lt;br /&gt;Moreover, this file can be read by all users (contrary to the syslog).&lt;br /&gt;&lt;br /&gt;Personally, the user I have created during the installation is the computer administrator and I had no reason (until now) to change its password after the installation. I've just created a non-administrator user after the installation.&lt;br /&gt;&lt;br /&gt;I think it's risky to store an user's password in a file readable by everybody. (for example if we can login via ssh on an Ubuntu server)&lt;br /&gt;&lt;br /&gt;I don't know what you think of this...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114225087232622820?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114225087232622820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114225087232622820&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114225087232622820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114225087232622820'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/possible-to-get-administrator-password.html' title='Possible to get the administrator password ?'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114218758488006589</id><published>2006-03-13T02:18:00.000+08:00</published><updated>2006-03-13T02:19:44.883+08:00</updated><title type='text'>11 Unix Tricks</title><content type='html'>Whether you’re a newbie to Linux or you are a seasoned guru, you’re bound to find some scripts or programs which just make your life on the computer exponentially easier. The following is a list of them and explains what they do.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;1. tac&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;tac is a command similar to cat, except that it reverses the output of the specified file.&lt;/p&gt; &lt;p&gt;tac &lt;code&gt;&lt;file&gt;&lt;/code&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;2. Multiple X-Sessions&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Using multiple X-Sessions allows a user to have open more than just one instance of XFree, so multiple desktop environments can be used at a time.&lt;/p&gt; &lt;p&gt;startx — :&lt;code&gt;&lt;terminal&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;terminal name is simply which terminal X should start on. By default it starts on&lt;/p&gt; &lt;p&gt;0:0. If you want two open, you may want it open on 0:1, which can be run by:&lt;/p&gt; &lt;p&gt;startx — :1&lt;/p&gt; &lt;p&gt;The resulting desktops will exist on F7 - F12.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3. SSH&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;SSH is a telnet replacement which includes encryption for higher security.&lt;/p&gt; &lt;p&gt;ssh -l &lt;code&gt;&lt;username&gt; &lt;hostname&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;username&gt;&lt;/code&gt; is the name, specified in /etc/passwd, that you want to login as. Remove the -l &lt;code&gt;&lt;username&gt;&lt;/code&gt; for anonymous.&lt;/p&gt; &lt;code&gt;&lt;hostname&gt;&lt;/code&gt; is simply the hostname or IP address of the computer to connect to.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt; 4. links&lt;/strong&gt; &lt;p&gt;links is a text based browser which has full support for tables&lt;/p&gt; &lt;p&gt;links &lt;code&gt;&lt;hostname&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;code&gt;&lt;hostname&gt;&lt;/code&gt; is simply the hostname or IP address of the computer to connect to.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;5. Gkrellm&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Gkrellm is a graphical application that displays system information in real-time. It displays everything from processor consumption to if new email exists in that specific&lt;/p&gt; &lt;p&gt;user’s inbox.&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;6. Keybindings&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Keybindings allow a user to to run a certain program or command by hitting only a small keycombo.&lt;/p&gt; &lt;p&gt;In Sawfish, click on the Keybindings capplet and select your keybindings by adding a new one, selecting the command, and then select the desired keybinding.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;7. more&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;more causes any info sent to the terminal after more than one page has been output. This allows the user to see a page at a time, taking their time on each page, without them having to worry about the text rolling off the screen.&lt;/p&gt; &lt;p&gt;more can be used as a straight program to view a file or can be piped to by any other applications&lt;/p&gt; &lt;p&gt;Note: an alternative to more is less&lt;/p&gt;&lt;p&gt;&lt;strong&gt;8. grep&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;grep is a command that allows the user to specify text to show on the screen and display only the line containing the quered string.&lt;/p&gt; &lt;p&gt;| grep string&lt;/p&gt; &lt;p&gt;&lt;strong&gt;9. wc&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Utility to print basic formatting information about a file.&lt;/p&gt; &lt;p&gt;wc &lt;code&gt;&lt;filename&gt;&lt;/code&gt; or wc can be piped to&lt;/p&gt; &lt;p&gt;&lt;strong&gt;10. find&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;A simple utility made to search your hard disk.&lt;/p&gt; &lt;p&gt;find &lt;code&gt;&lt;path&gt; &lt;expression&gt;&lt;/code&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;11. locate&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;A quick alternative to find&lt;/p&gt; locate &lt;code&gt;&lt;expression&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114218758488006589?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114218758488006589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114218758488006589&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218758488006589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218758488006589'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/11-unix-tricks.html' title='11 Unix Tricks'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114218707524990769</id><published>2006-03-13T02:10:00.000+08:00</published><updated>2006-03-13T02:11:15.250+08:00</updated><title type='text'>Who sent me mail</title><content type='html'>To know who all have sent you mail.&lt;br /&gt;&lt;br /&gt;---------------CUT HERE  ----------&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;: ${USER:=`expr "\`LANG=C id\`" :  'uid=[0-9]*(\([^)]*\).*'`}&lt;br /&gt;&lt;br /&gt;for MBox in /var/mail/$USER  /usr/spool/mail/$USER ""&lt;br /&gt;do&lt;br /&gt;    [ -r "$MBox" ] &amp;&amp;amp;  break&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;[ -z "$MBox" ] &amp;&amp;amp; exec echo "No  mailbox"&lt;br /&gt;&lt;br /&gt;exec grep  "^From " "$@" "$MBox"&lt;br /&gt;&lt;br /&gt;---------------CUT HERE  ----------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114218707524990769?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114218707524990769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114218707524990769&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218707524990769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218707524990769'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/who-sent-me-mail.html' title='Who sent me mail'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114218686883315207</id><published>2006-03-13T02:06:00.000+08:00</published><updated>2006-03-13T02:09:35.863+08:00</updated><title type='text'>Strings - old but a goodie</title><content type='html'>To check content of an object file(binary file ) we can't use vi or cat  command, for that use strings&lt;br /&gt; command.&lt;br /&gt;&lt;br /&gt;%  strings [name of binary  file]&lt;br /&gt;&lt;br /&gt;It will print all the printable strings present in object  file.  Basically strings command looks for ASCII strings in executable  file and print it.&lt;br /&gt;&lt;br /&gt;Great for core files and other binary error  files&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114218686883315207?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114218686883315207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114218686883315207&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218686883315207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218686883315207'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/strings-old-but-goodie.html' title='Strings - old but a goodie'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114218659958248468</id><published>2006-03-13T02:02:00.000+08:00</published><updated>2006-03-13T02:03:19.596+08:00</updated><title type='text'>Run daily with at</title><content type='html'>UNIX provides a command called "at" which can be used to run jobs according  to the specfied time.&lt;br /&gt;&lt;br /&gt;To run a particular job in every hour,   every day use the following set of commands in a file called "at.sh"  which will be executed recursively everyday.&lt;br /&gt;&lt;br /&gt;########### CUT HERE  ##################&lt;br /&gt;&lt;br /&gt;#! /usr/bin/sh&lt;br /&gt;&lt;br /&gt;# dt is a variable used to store &lt;br /&gt;# current date&lt;br /&gt;&lt;br /&gt;dt=`date | cut -c5-10`&lt;br /&gt;&lt;br /&gt;# tm is a variable used  to store&lt;br /&gt;# current time&lt;br /&gt;&lt;br /&gt;tm=`date | cut -c12-13`&lt;br /&gt;&lt;br /&gt;while [ $tm  -le 23 ]&lt;br /&gt;do&lt;br /&gt;&lt;br /&gt;# "at" is the command ad -f is the&lt;br /&gt;# option used to  execute a specified&lt;br /&gt;# file. "file Name" should be an&lt;br /&gt;# executable  file.&lt;br /&gt;&lt;br /&gt; at -f  ./"file Name" $tm $dt&lt;br /&gt; tm=`expr $tm +  1`&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;# With out manual intervention, automatic&lt;br /&gt;# change over  to the next day's job&lt;br /&gt;# scheduling&lt;br /&gt;&lt;br /&gt;at -f ./"File Name" 2358  $dt&lt;br /&gt;dt=`expr $dt + 1`&lt;br /&gt;at -f ./at.sh 0002 $dt&lt;br /&gt;&lt;br /&gt;########### CUT HERE  ##################&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114218659958248468?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114218659958248468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114218659958248468&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218659958248468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114218659958248468'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/run-daily-with-at.html' title='Run daily with at'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114195286126848734</id><published>2006-03-10T09:06:00.000+08:00</published><updated>2006-03-10T09:07:41.273+08:00</updated><title type='text'>Find those hidden files</title><content type='html'>Finding only hidden files (starting with .) in a directory.&lt;br /&gt;&lt;br /&gt;ls -a |  grep "^\." OR&lt;br /&gt;ls -a | awk '$0~/^\./ {print $0}'&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114195286126848734?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114195286126848734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114195286126848734&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114195286126848734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114195286126848734'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/find-those-hidden-files.html' title='Find those hidden files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114190281111533216</id><published>2006-03-09T19:11:00.000+08:00</published><updated>2006-03-09T19:13:31.126+08:00</updated><title type='text'>Run on last Sunday</title><content type='html'>If you want a job to run on the last sunday of every month, you can use  the following syntax from within cron:&lt;br /&gt;&lt;br /&gt;18 * * * 0 [`date "+%d"` -gt  24] &amp;&amp;amp; /path/to/script&lt;br /&gt;&lt;br /&gt;i.e. on sundays at 18:00 check if the  day of the month is greater than 24 - if so run the job (if 23 is &lt;br /&gt;specified the job will run on the last 2 sundays of the  month)&lt;br /&gt;&lt;br /&gt;NOTE: There back-ticks around the date command, not single  quotes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114190281111533216?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114190281111533216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114190281111533216&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114190281111533216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114190281111533216'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/run-on-last-sunday.html' title='Run on last Sunday'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114181495677553988</id><published>2006-03-08T18:48:00.000+08:00</published><updated>2006-03-08T18:49:16.783+08:00</updated><title type='text'>Simple Mask Overlooked</title><content type='html'>Another way to CD to the long directory.&lt;br /&gt;&lt;br /&gt;Works in both csh and  ksh&lt;br /&gt;&lt;br /&gt;cd too*&lt;br /&gt;&lt;br /&gt;Will change to the directory "toobigtotype" As long  as there is only one ocurrance of the word too....&lt;br /&gt;&lt;br /&gt;This is great when  there is only one sub directory within a directory, just use:&lt;br /&gt;&lt;br /&gt;cd  *&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114181495677553988?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114181495677553988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114181495677553988&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114181495677553988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114181495677553988'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/simple-mask-overlooked.html' title='Simple Mask Overlooked'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114173039893158301</id><published>2006-03-07T19:18:00.000+08:00</published><updated>2006-03-07T19:19:58.933+08:00</updated><title type='text'>Auto word completion</title><content type='html'>In tcsh, the TAB key will automatically complete any name in the current  directory for any application (for pico, cd, rm, chown)... It will even  complete paths from root.&lt;br /&gt;&lt;br /&gt;Soo... If you want to open your .cshrc  from root you do..&lt;br /&gt;&lt;br /&gt;"pico /ho"[TAB] -&gt; "pico /home/"&lt;br /&gt;Then  continue with "yuo"[tab] -&gt; "yourusername"&lt;br /&gt;Then you get "pico  /home/yourusername/"&lt;br /&gt;And then type ".cs"[TAB] -&gt; ".cshrc"&lt;br /&gt;So in the  end you get "pico /home/yourusername/.cshrc"&lt;br /&gt;In a lot less  stokes...&lt;br /&gt;&lt;br /&gt;But say there are 2 users called yourusername and  yourothername.&lt;br /&gt;&lt;br /&gt;Well, then the shell will beep, and if you hit TAB  again, you will get a listing off all the files that start with "you".  You can then continue to the point where the names differ, and then hit  TAB.&lt;br /&gt;&lt;br /&gt;This also works for commands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114173039893158301?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114173039893158301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114173039893158301&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114173039893158301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114173039893158301'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/auto-word-completion.html' title='Auto word completion'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114173009590422230</id><published>2006-03-07T19:13:00.000+08:00</published><updated>2006-03-07T19:14:55.906+08:00</updated><title type='text'>Change the suffix</title><content type='html'>If you want to change the suffix of multiple files, you can't  do:&lt;br /&gt;&lt;br /&gt;        % mv *.abc *.def&lt;br /&gt;&lt;br /&gt;However the following shell script  can be used to do the required opperation:&lt;br /&gt;&lt;br /&gt;***&lt;br /&gt;&lt;br /&gt;Change all  *.abc file to *.def the following shell script would  work:&lt;br /&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;for f in *.abc; do&lt;br /&gt;  mv $f `basename $f  .abc`.def&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;How it works:&lt;br /&gt;&lt;br /&gt;  for f in *.abc; do&lt;br /&gt;&lt;br /&gt;Set up  a look for all files ending in .abc, and each time around setup $f as  the filename&lt;br /&gt;&lt;br /&gt;  mv $f `basename $f.abc`.def&lt;br /&gt;&lt;br /&gt;`basename $f .abc`  takes the filename in $f and removes any trailing occurences of .abc, we  then append .def to the result and the resulting command becomes "mv  file.abc file.def"&lt;br /&gt;&lt;br /&gt;   done&lt;br /&gt;&lt;br /&gt;Ends the "for" loop above.&lt;br /&gt;&lt;br /&gt;Under  "csh" or "tcsh" a similar thing could be done with:&lt;br /&gt;&lt;br /&gt;  foreach f in (  *.abc )&lt;br /&gt;    mv $f `basename $f .abc`.def&lt;br /&gt;  end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114173009590422230?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114173009590422230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114173009590422230&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114173009590422230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114173009590422230'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/change-suffix.html' title='Change the suffix'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114172984116657207</id><published>2006-03-07T19:09:00.000+08:00</published><updated>2006-03-07T19:10:41.166+08:00</updated><title type='text'>Deleting blank lines using grep</title><content type='html'>For thos who are not familiar with awk, but still want a quick and easy  way of removing blank lines from a flat ascii file, remember that the  use of 'cat' in conjuction with 'grep' is just as effective.&lt;br /&gt;&lt;br /&gt;cat  file1 | grep -v '^$' &gt;file2&lt;br /&gt;mv -f file2 file1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114172984116657207?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114172984116657207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114172984116657207&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114172984116657207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114172984116657207'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/deleting-blank-lines-using-grep.html' title='Deleting blank lines using grep'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114172928823836503</id><published>2006-03-07T19:00:00.000+08:00</published><updated>2006-03-07T19:01:28.246+08:00</updated><title type='text'>Limit the size of data area</title><content type='html'>You can limit the size of "data area"  using ulimit and limit. &lt;br /&gt;&lt;br /&gt;Under sh or ksh:&lt;br /&gt;$ ulimit -d SIZE_IN_KB          &lt;br /&gt;&lt;br /&gt;Displays all  current resource limits&lt;br /&gt;$ ulimit -a                     &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;under  csh or tcsh:&lt;br /&gt;$ limit datasize SIZE_IN_KB     &lt;br /&gt;&lt;br /&gt;Displays all current  resource limits&lt;br /&gt;$ limit                         &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For  example:&lt;br /&gt;$ ulimit -d 141073&lt;br /&gt;$ ulimit -a&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114172928823836503?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114172928823836503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114172928823836503&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114172928823836503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114172928823836503'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/limit-size-of-data-area.html' title='Limit the size of data area'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114164409689160224</id><published>2006-03-06T19:20:00.000+08:00</published><updated>2006-03-06T19:21:36.893+08:00</updated><title type='text'>VI copy file to file</title><content type='html'>Here is how to copy the required number of lines from one file to another in  VI editor.  First use the following key combinations in the source file.&lt;br /&gt;&lt;br /&gt;Press ESCAPE&lt;br /&gt;Press Shift "(Shift double quotes)&lt;br /&gt;Press a&lt;br /&gt;Press the  number of lines you want to copy&lt;br /&gt;press y followed by another y&lt;br /&gt;&lt;br /&gt;Now press " : " (COLON) to get the vi prompt.&lt;br /&gt;Hit e "Destination file  name"&lt;br /&gt;Once you enter the Destination file go to the line where you want  the lines copied to be inserted.&lt;br /&gt;&lt;br /&gt;Press ESCAPE.&lt;br /&gt;Press SHIFT "(Double quotes).&lt;br /&gt;Press a.&lt;br /&gt;Press  p.&lt;br /&gt;&lt;br /&gt;The lines get copied.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114164409689160224?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114164409689160224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114164409689160224&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114164409689160224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114164409689160224'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/vi-copy-file-to-file.html' title='VI copy file to file'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114164374697465187</id><published>2006-03-06T19:13:00.000+08:00</published><updated>2006-03-06T19:19:39.473+08:00</updated><title type='text'>Search several files</title><content type='html'>To search several files for a string which you know sparsely, the  following searching technique&lt;br /&gt;would be useful:&lt;br /&gt;&lt;br /&gt;#grep &lt;first&gt;.*&lt;second&gt;.*&lt;... part&gt;  &lt;filenames&gt;&lt;br /&gt;       or,&lt;br /&gt;#ls|xargs grep &lt;first&gt;.*&lt;second&gt;.*&lt;... part&gt;&lt;br /&gt;&lt;br /&gt;This will print all the filenames and lines which consists of "&lt;first&gt;&lt;0&gt;&lt;second&gt;&lt;0&gt;&lt;third&gt; ......"&lt;br /&gt;&lt;br /&gt;For example, you want to search a data structure among several  header files where it has been declared not where it is being used.&lt;br /&gt;&lt;br /&gt;If the data structure be XYZ, then search will be:&lt;br /&gt;&lt;br /&gt;#grep }.*XYZ  &lt;filenames&gt;&lt;br /&gt;&lt;br /&gt;because you know it might be how&lt;br /&gt;XYZ has been declared,&lt;br /&gt;struct  {&lt;br /&gt;     .....&lt;br /&gt;     .....&lt;br /&gt;     }   XYZ&lt;br /&gt;&lt;br /&gt;You don't know exactly how many blank characters are there unless you  count them. But when XYZ will be used it will be done as follows(for  example):&lt;br /&gt;&lt;br /&gt;XYZ  *xyz;&lt;br /&gt;&lt;br /&gt;and you don't want them to find out as they will be  coming in several header or C files.&lt;/filenames&gt;&lt;/third&gt;&lt;/second&gt;&lt;/first&gt;&lt;/second&gt;&lt;/first&gt;&lt;/filenames&gt;&lt;/second&gt;&lt;/first&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114164374697465187?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114164374697465187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114164374697465187&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114164374697465187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114164374697465187'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/search-several-files.html' title='Search several files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114155594892905341</id><published>2006-03-05T18:51:00.000+08:00</published><updated>2006-03-05T18:52:28.930+08:00</updated><title type='text'>Arithmetic Comparison</title><content type='html'>In UNIX shell arithmetic comparison is limited to integer values.  Here  is a tip to compare floating values using basic shell  commands.&lt;br /&gt;&lt;br /&gt;--------- CUT HERE-----------------&lt;br /&gt;&lt;br /&gt;#! /bin/sh&lt;br /&gt;# test  shell script&lt;br /&gt;n1="01.401"&lt;br /&gt;n2="01.350"&lt;br /&gt;&lt;br /&gt;function  compareFloatSmall&lt;br /&gt;{&lt;br /&gt;sort -n &lt;&lt;: | head  -1&lt;br /&gt;$n1&lt;br /&gt;$n2&lt;br /&gt;:&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function compareFloatGreat&lt;br /&gt;{&lt;br /&gt;sort -r -n  &lt;&lt;: | head -1&lt;br /&gt;$n1&lt;br /&gt;$n2&lt;br /&gt;:&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;small=$(compareFloatSmall $n1  $n2)&lt;br /&gt;echo "Comparing $n1 to $n2: smaller $less"&lt;br /&gt;great=$(compareFloatGreat  $n1 $n2)&lt;br /&gt;echo "Comparing $n1 to $n2: greater $great"&lt;br /&gt;&lt;br /&gt;--------- CUT  HERE-----------------&lt;br /&gt;&lt;br /&gt;Alternatively you can use a small 'awk'  program.&lt;br /&gt;&lt;br /&gt;--------- CUT AGAIN HERE-----------&lt;br /&gt;#! /bin/sh&lt;br /&gt;# A couple  of examples in awk.&lt;br /&gt;n1="03.550"&lt;br /&gt;n2="02.550"&lt;br /&gt;&lt;br /&gt;echo "$n1 $n2" | awk  '{&lt;br /&gt;        if ( $1 &gt;= $2 ) print $1&lt;br /&gt;        if ( $1 &lt;= $2 ) print  $2&lt;br /&gt;        if ( $1 &gt;  $2 ) print $1&lt;br /&gt;        if ( $1 &lt;  $2 ) print  $2&lt;br /&gt;        if ( $1 == $2 ) print $1, $2&lt;br /&gt;}'&lt;br /&gt;--------- CUT AGAIN  HERE-----------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114155594892905341?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114155594892905341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114155594892905341&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155594892905341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155594892905341'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/arithmetic-comparison.html' title='Arithmetic Comparison'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114155587364384343</id><published>2006-03-05T18:50:00.000+08:00</published><updated>2006-03-05T18:51:13.643+08:00</updated><title type='text'>Copy a tree with cpio</title><content type='html'>Using standard UNIX tar to copy a tree doesn't preserve the original  owner and group information for the directories and files during the  copy. To do this, use find(1) piped to cpio(1) this way:&lt;br /&gt;&lt;br /&gt;% cd  &lt;source-directory&gt;&lt;br /&gt;% find . -depth -print | cpio -pudm  &lt;dest-directory&gt;&lt;br /&gt;&lt;br /&gt;This will create a mirror image of the &lt;br /&gt;&lt;source-directory&gt; tree in &lt;dest-directory&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114155587364384343?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114155587364384343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114155587364384343&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155587364384343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155587364384343'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/copy-tree-with-cpio.html' title='Copy a tree with cpio'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114155578660560877</id><published>2006-03-05T18:49:00.000+08:00</published><updated>2006-03-05T18:49:46.606+08:00</updated><title type='text'>Automatically set display</title><content type='html'>To set automatically the DISPLAY variable after rlogin (csh):&lt;br /&gt;&lt;br /&gt;if  (`who am i | wc -w` &gt; 5) then&lt;br /&gt;   setenv DISPLAY `who am i | cut -d"(" -f2  | cut -d")" -f1`:0.0&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;May vary from flavor to flavor&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114155578660560877?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114155578660560877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114155578660560877&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155578660560877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155578660560877'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/automatically-set-display.html' title='Automatically set display'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114155571150208898</id><published>2006-03-05T18:47:00.000+08:00</published><updated>2006-03-05T18:48:31.510+08:00</updated><title type='text'>File consistancy check</title><content type='html'>To check the number of feilds and the consistancy of the file here is simple  command:&lt;br /&gt;&lt;br /&gt;nawk -F "delimiter" '{print NF}' file_name|sort -u|more&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114155571150208898?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114155571150208898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114155571150208898&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155571150208898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114155571150208898'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/file-consistancy-check.html' title='File consistancy check'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114146886944336720</id><published>2006-03-04T18:38:00.000+08:00</published><updated>2006-03-04T18:41:09.443+08:00</updated><title type='text'>Lock down telnet or ftp</title><content type='html'>When inbound access isn't required into a system deny users Telnet or FTP  access do the following:&lt;br /&gt;&lt;br /&gt;vi /etc/inetd.conf&lt;br /&gt;&lt;br /&gt;Comment the line starts with Telnet or FTP.  Save  the file and exit.&lt;br /&gt;&lt;br /&gt;Stop and start the inetd daemon now by following  commands:&lt;br /&gt;&lt;br /&gt;/etc/rc.d/init.d/inet stop&lt;br /&gt;&lt;br /&gt;/etc/rc.d/init.d/inet  start&lt;br /&gt;&lt;br /&gt;(Your flavor may be /etc/init.d)&lt;br /&gt;&lt;br /&gt;Now on nobody can telnet or FTP to your server from outside network.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114146886944336720?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114146886944336720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114146886944336720&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114146886944336720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114146886944336720'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/lock-down-telnet-or-ftp.html' title='Lock down telnet or ftp'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114146838546164646</id><published>2006-03-04T18:31:00.000+08:00</published><updated>2006-03-04T18:33:05.466+08:00</updated><title type='text'>Tracking of logins and logouts</title><content type='html'>In the .login file add the  commands:&lt;br /&gt;------------------------------------&lt;br /&gt;&lt;br /&gt;echo login time `date`  &gt;&gt; .daylogs/masterlog&lt;br /&gt;&lt;br /&gt;grep -i "sun" .daylogs/masterlog &gt;  .daylogs/sunday.log&lt;br /&gt;grep -i "mon" .daylogs/masterlog &gt;  .daylogs/monday.log&lt;br /&gt;grep -i "tue" .daylogs/masterlog &gt;  .daylogs/tuesday.log&lt;br /&gt;grep -i "wen" .daylogs/masterlog &gt;  .daylogs/wensday.log&lt;br /&gt;grep -i "thu" .daylogs/masterlog &gt;  .daylogs/thursday.log&lt;br /&gt;grep -i "fri" .daylogs/masterlog &gt;  .daylogs/friday.log&lt;br /&gt;grep -i "sat" .daylogs/masterlog &gt;  .daylogs/saturday.log&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the .logout file add this line &lt;br /&gt;-----------------------------------&lt;br /&gt;&lt;br /&gt;echo logout time `date`&gt;&gt;  .daylogs/masterlog&lt;br /&gt;&lt;br /&gt;This script assumes you have a hidden directory called .daylogs this helps  keep it out of sight and away from prying eyes and if you keep root  ownership of the directory change the mode to:&lt;br /&gt;&lt;br /&gt;chmod 744 .daylogs&lt;br /&gt;&lt;br /&gt;This will not allow anyone to get in to the  directory to look around.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114146838546164646?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114146838546164646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114146838546164646&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114146838546164646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114146838546164646'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/tracking-of-logins-and-logouts.html' title='Tracking of logins and logouts'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114145338239089020</id><published>2006-03-04T14:21:00.000+08:00</published><updated>2006-03-04T14:23:02.396+08:00</updated><title type='text'>IRIX: check for new configs</title><content type='html'>SGI loves to try and simplify your life with chkconfig switches to toggle  various services on and off. After each upgrade, DOUBLE check the  chkconfig switches. If something doesn't work all of the sudden  check here.&lt;br /&gt;&lt;br /&gt;For instance, tape drives in IRIX are disabled by  a default install.  To  enable a tape subsystem:&lt;br /&gt;&lt;br /&gt;# chkconfig ts on&lt;br /&gt;&lt;br /&gt;# /etc/init.d/ts start&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114145338239089020?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114145338239089020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114145338239089020&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114145338239089020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114145338239089020'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/irix-check-for-new-configs.html' title='IRIX: check for new configs'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114144113073643071</id><published>2006-03-04T10:55:00.000+08:00</published><updated>2006-03-04T10:58:50.743+08:00</updated><title type='text'>Operating on multiple files</title><content type='html'>Have you ever felt the need to perform a set of operations on multiple files  simultaneously???&lt;br /&gt;&lt;br /&gt;Here is a solution for that.&lt;br /&gt;&lt;br /&gt;For instance, if it is required to perform multiple operations like  searching a string (using grep), and executing an awk or perl script etc,  etc. on not just one file but a set of files, use the following commands at  the unix prompt:&lt;br /&gt;&lt;br /&gt;$&lt;: foreach i (&lt;file_list&gt;)&lt;br /&gt; ? echo $i&lt;br /&gt; ? grep  &lt;search_pattern&gt; $i &gt; tmp&lt;br /&gt; ? awk -f awk_script tmp &gt;&gt;  report&lt;br /&gt; ? ....&lt;br /&gt; ? ....&lt;br /&gt; ? end&lt;br /&gt;$&lt;:&lt;br /&gt;&lt;br /&gt;The files list in the  brackets can be either&lt;br /&gt;&lt;br /&gt;* Specifically mentioned&lt;br /&gt;&lt;br /&gt;* A unix variable which contains a list of file names.  For instance, the  variable "p" can be assigned all the files starting with string "data"  as follows:     set p = (data*)&lt;br /&gt;&lt;br /&gt;Other examples are:&lt;br /&gt;    set g = `grep -l "Startpoint" * `&lt;br /&gt;or&lt;br /&gt;    set  all = *&lt;br /&gt;(This assigns all file names in the current directory to the variable "all" )&lt;br /&gt;&lt;br /&gt;And its usage with the "foreach" command will be as follows:&lt;br /&gt;&lt;br /&gt;$&lt;:  foreach i ($all)&lt;br /&gt;   .....&lt;br /&gt;   .....&lt;br /&gt;end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114144113073643071?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114144113073643071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114144113073643071&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114144113073643071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114144113073643071'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/operating-on-multiple-files.html' title='Operating on multiple files'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114139962510403942</id><published>2006-03-03T23:24:00.000+08:00</published><updated>2006-03-03T23:27:05.106+08:00</updated><title type='text'>I sed blank</title><content type='html'>Using sed, you can remove blank lines, and lines that contain only  whitespace, from a file using the following:&lt;br /&gt;&lt;br /&gt;sed -e '/^[     ]*$/d' InputFile &gt;OutputFile&lt;br /&gt;&lt;br /&gt;Within the single quotes ('), the forward slashes (/) delimit the regular  expression that will be interpreted by sed.  The "d" before the closing  single quote, tells sed to delete any lines that match the regular  expression.&lt;br /&gt;&lt;br /&gt;Within the regular expression, the caret (^) matches the beginning of a  line.  The []* matches zero to many occurrences of the character list  between the open bracket ([) and the close bracket (]) (in the above  regular expression, you must insert a space and a tab between the  brackets).  The dollar sign ($) matches the end of a line.&lt;br /&gt;&lt;br /&gt;These three constructs together match any blank line or any line that  contains only spaces and tabs (in any combination).&lt;br /&gt;&lt;br /&gt;Since the standard operation of sed is to echo lines to stdout, all lines  except blank lines (or lines that only contain whitespace) will be sent  to OutputFile.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114139962510403942?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114139962510403942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114139962510403942&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139962510403942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139962510403942'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/i-sed-blank.html' title='I sed blank'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114139946138104069</id><published>2006-03-03T23:23:00.000+08:00</published><updated>2006-03-03T23:24:21.383+08:00</updated><title type='text'>Files opened by a process</title><content type='html'>This is supported on Sun Solaris, not too sure about other Unix  flavours.&lt;br /&gt;&lt;br /&gt;I badly wanted to find out all the files opened by a process, and that is  when I found pfiles.&lt;br /&gt;&lt;br /&gt;Usage :&lt;br /&gt;/usr/proc/bin/pfiles &lt;pid&gt;&lt;br /&gt;&lt;br /&gt;Where pid is the process-id of the process&lt;br /&gt;&lt;br /&gt;It lists the inode numbers of all the files, opened&lt;br /&gt;by that process.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114139946138104069?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114139946138104069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114139946138104069&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139946138104069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139946138104069'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/files-opened-by-process.html' title='Files opened by a process'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114139925879725115</id><published>2006-03-03T23:19:00.000+08:00</published><updated>2006-03-03T23:20:58.796+08:00</updated><title type='text'>Backup the remote essentials</title><content type='html'>There are many programs, data files, and especially license files that sit  out on remote workstations and servers that you may should be backing up  remotely.&lt;br /&gt;&lt;br /&gt;If backing up the entire system puts a strain on your network, make sure that  all the  essential&lt;br /&gt;files at least get backed up.&lt;br /&gt;&lt;br /&gt;Some files may  be&lt;br /&gt;/var/flexlm&lt;br /&gt;/usr/local/flexlm&lt;br /&gt;/var/netls&lt;br /&gt;/var/license&lt;br /&gt;/etc/passwd&lt;br /&gt;/etc/hosts&lt;br /&gt;/etc/groups&lt;br /&gt;/etc/netgroups&lt;br /&gt;/etc/shadow&lt;br /&gt;/vmunix&lt;br /&gt;/kernel&lt;br /&gt;etc....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114139925879725115?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114139925879725115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114139925879725115&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139925879725115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139925879725115'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/backup-remote-essentials.html' title='Backup the remote essentials'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114139901678928442</id><published>2006-03-03T23:15:00.000+08:00</published><updated>2006-03-03T23:16:56.790+08:00</updated><title type='text'>String Removal</title><content type='html'>What the following does:&lt;br /&gt;&lt;br /&gt;rm `ls -al | grep str | awk '{if ($9 !~ /^str/) {print $9}'`&lt;br /&gt;&lt;br /&gt;Removes all files that contains the string "str" excepts&lt;br /&gt;those that begin  with it. Changing the !~ to =~ does the&lt;br /&gt;opposite.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114139901678928442?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114139901678928442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114139901678928442&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139901678928442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139901678928442'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/string-removal.html' title='String Removal'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114139894025727985</id><published>2006-03-03T23:14:00.000+08:00</published><updated>2006-03-03T23:15:40.256+08:00</updated><title type='text'>Killing more users</title><content type='html'>To kill all processes of a particular user from root&lt;br /&gt;at unix prompt type:&lt;br /&gt;&lt;br /&gt;# kill -9 `ps -fu username |awk '{ print $2 }'|grep -v PID`&lt;br /&gt;&lt;br /&gt;We can also use the username as an argument and pass it from&lt;br /&gt;command line, if  this command is put as a script.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114139894025727985?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114139894025727985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114139894025727985&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139894025727985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114139894025727985'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/killing-more-users.html' title='Killing more users'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114136943481020094</id><published>2006-03-03T14:59:00.000+08:00</published><updated>2006-03-03T15:03:54.820+08:00</updated><title type='text'>Bash Hotkeys</title><content type='html'>Bash provides many hot keys to ease use. Like&lt;br /&gt;ctrl-l  -- clear screen&lt;br /&gt;ctrl-r  -- does a search in the previously given commands so that you don't have to repeat long command.&lt;br /&gt;ctrl-u  -- clears the typing before the hotkey.&lt;br /&gt;ctrl-a  -- takes you to the begining of the command you are currently typing.&lt;br /&gt;ctrl-e  -- takes you to the end of the command you are currently typing in.&lt;br /&gt;esc-b   -- takes you back by one word while typing a command.&lt;br /&gt;ctrl-c  -- kills the current command or process.&lt;br /&gt;ctrl-d  -- kills the shell.&lt;br /&gt;ctrl-h  -- deletes one letter at a time from the command you are typing in.&lt;br /&gt;ctrl-z  -- puts the currently running process in background, the process can be brought back to run state by using fg command.&lt;br /&gt;esc-p  -- like ctrl-r lets you search through the previously given commands.&lt;br /&gt;esc-.  -- gives the last command you typed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114136943481020094?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114136943481020094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114136943481020094&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114136943481020094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114136943481020094'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/bash-hotkeys.html' title='Bash Hotkeys'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114135347418930693</id><published>2006-03-03T10:37:00.000+08:00</published><updated>2006-03-03T10:37:54.190+08:00</updated><title type='text'>More on VI lazy exists</title><content type='html'>Addendum to VI LAZY EXITS&lt;br /&gt;&lt;br /&gt;There is a difference between ZZ and :wq!  ZZ will NOT force a write on a read only file :wq! will.&lt;br /&gt;&lt;br /&gt;Also be careful with ZZ if you inadvertently press Control ZZ you will have stopped jobs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114135347418930693?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114135347418930693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114135347418930693&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135347418930693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135347418930693'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/more-on-vi-lazy-exists.html' title='More on VI lazy exists'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114135333580987412</id><published>2006-03-03T10:34:00.000+08:00</published><updated>2006-03-03T10:35:35.810+08:00</updated><title type='text'>Pipes and quoting</title><content type='html'>When you do rsh (remsh in HP-UX) followed by a series ofpipes, consider carefully whether you want the pipe processesto run on the local or the remote host. If you quote thepipes, then they become part of the arguments passed tothe remote host and evaluated there.  E.g.&lt;br /&gt;&lt;br /&gt;rsh myRemoteHost last "" grep userName "" head&lt;br /&gt;&lt;br /&gt;(In this example, we pipe the output of last to grep,because in Solaris "last userName" only shows consolelogins, not FTP logins.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114135333580987412?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114135333580987412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114135333580987412&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135333580987412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135333580987412'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/pipes-and-quoting.html' title='Pipes and quoting'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114135324351052867</id><published>2006-03-03T10:30:00.000+08:00</published><updated>2006-03-03T10:34:03.516+08:00</updated><title type='text'>Spaces to underscore 1 liner</title><content type='html'>Do you hate users who put spaces in file names, preventingyou from doing any sort of scripting?&lt;br /&gt;&lt;br /&gt;Well then this is the little one-liner for you to pop in a shell script then...&lt;br /&gt;&lt;br /&gt;for i in $1 ;  do mv "$i" `echo $i  sed 's/ /_/g'` ; done&lt;br /&gt;&lt;br /&gt;the echo $i  sed 's/ /_/g' is surrounded by back-tics not regular quotes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114135324351052867?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114135324351052867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114135324351052867&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135324351052867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114135324351052867'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/spaces-to-underscore-1-liner.html' title='Spaces to underscore 1 liner'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114131160620029448</id><published>2006-03-02T22:58:00.000+08:00</published><updated>2006-03-02T23:02:05.346+08:00</updated><title type='text'>Metavalues from a shell script</title><content type='html'>Getting a file's size, link count or other metavalue in a shell script:&lt;br /&gt;&lt;br /&gt;When you want to extract a specific piece of meta information about a specific file (such as it's size, link count, or one of its time stamps) you can use the find -printf option and any of the various %-directives listed in the find(1) man page. Example:&lt;br /&gt;&lt;br /&gt;size=$(find some_file -printf "%s" )&lt;br /&gt;&lt;br /&gt;(under ksh, bash, and similar shells). Here the $() form is used as a more readable equivalent to the older `` (back tick) operator. (Another advantage to the $() is that it is nestable). To get the user name of the owner of a file "foo" you could use:&lt;br /&gt;&lt;br /&gt;set owner = `find foo -maxdepth 0 -printf "%u"`&lt;br /&gt;&lt;br /&gt;(here we're using the csh syntax). This also uses the -maxdepth option in case "foo" is actually a directory name; since we don't want find to spend time traversing directory and printing the owners to ALL of the entries thereunder. A maxdepth of zero ensures that this will only print the detail we want on the specific link that we named on the command line.&lt;br /&gt;&lt;br /&gt;This can be much more flexible than the options provided by the test command (try to see which of two files is larger, or if to files are owned by the same user or assigned to the same group, using just test).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114131160620029448?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114131160620029448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114131160620029448&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114131160620029448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114131160620029448'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/metavalues-from-shell-script.html' title='Metavalues from a shell script'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23262481.post-114127543019511945</id><published>2006-03-02T12:57:00.000+08:00</published><updated>2006-03-02T20:25:36.166+08:00</updated><title type='text'>Bash Tip: Convert Unix Newline to Dos Format</title><content type='html'>If you’re on a Winblowz box and trying to read some source code from *nix open source projects, all you see are non-human readable format where there’s funny looking squares all over the place. It’s very annoying. You will see this if you use a text editor like Notepad, but Wordpad can convert those into human readable DOS format. Tonight, I finally wrote a bash script to convert all files in the current directory and all files under any subdirectories to DOS linefeed format. (I needed an excuse to practice my script-fu :) Here’s the script (there’s other ways of doing this), and save it as removeunixnewlines.sh. Make sure to chmod +x removeunixnewlines.sh):&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;# This script will remove Unix newlines&lt;br /&gt;# so it can be human readable in Windows&lt;br /&gt;# COUNTER=0&lt;br /&gt;for filename in $(find . -print)&lt;br /&gt;do&lt;br /&gt;if [ -f $filename ]&lt;br /&gt;then&lt;br /&gt;if [ $filename == “./removeunixnewlines.sh” ]&lt;br /&gt;then&lt;br /&gt;continue;&lt;br /&gt;else&lt;br /&gt;unix2dos –u2d $filename&lt;br /&gt;let COUNTER+=1&lt;br /&gt;fi&lt;br /&gt;fi&lt;br /&gt;done&lt;br /&gt;# Print the number of files that have&lt;br /&gt;# newlines removed&lt;br /&gt;echo -n “$COUNTER ”&lt;br /&gt;if [ $COUNTER -eq 1 ]&lt;br /&gt;then&lt;br /&gt;echo -n “file has ”&lt;br /&gt;else&lt;br /&gt;echo -n “files have ”&lt;br /&gt;fi&lt;br /&gt;echo “have Unix newlines removed.”&lt;br /&gt;# Exit script&lt;br /&gt;exit 0&lt;br /&gt;You’ll need to run this under &lt;a href="http://www.cygwin.com/"&gt;Cygwin&lt;/a&gt; in Winbloz. Navigate to the directory (e.g, cd /cgydrive/c/ ) where it contains files you want converted and execute by typing:$ ./removeunixnewlines.sh&lt;br /&gt;As an exercise for you, young ninjas, expand this script to accept arguments that can either convert *nix to DOS linefeed format or vice versa. Get going, lil grasshoppaz!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23262481-114127543019511945?l=moxdiamond.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://moxdiamond.blogspot.com/feeds/114127543019511945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23262481&amp;postID=114127543019511945&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114127543019511945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23262481/posts/default/114127543019511945'/><link rel='alternate' type='text/html' href='http://moxdiamond.blogspot.com/2006/03/bash-tip-convert-unix-newline-to-dos.html' title='Bash Tip: Convert Unix Newline to Dos Format'/><author><name>Adrian</name><uri>http://www.blogger.com/profile/06038760887554420498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://photos.friendster.com/photos/95/40/6840459/28151292725285l.jpg'/></author><thr:total>0</thr:total></entry></feed>
