Jump to: navigation, search


[edit] Space usage

 du -h --max-depth=1 /

On a Solaris box:

 du -s `ls -l|grep drwx|awk {'print $9'}

[edit] Perl CPAN shell

 perl -MCPAN -e shell

[edit] Increase open file handler limit

  • Edit /etc/sysctl.conf.
 kernel.sem = 256 65535 256 512
  • Change kernel Settings
 echo 256 65535 256 512 > /proc/sys/kernel/sem
 sysctl -w fs.file-max=16384

[edit] NTP stuff

ntpq -p (shows sources)


comment out # --- OUR TIMESERVERS ----- section add ip of dc time server to general config:

   server prefer
   restrict mask nomodify notrap
   server     # local clock
   fudge stratum 10

[edit] SSH only root can log in

 sshd_config: #UsePrivilegeSeparation yes  set to no

[edit] RS IPs

 # US/UK Non-Routable: ( ( ( (
 # General US Rackspace Routable Network: (
 # General UK Routable Network: (
 # Backup/Storage/Patching, (Dallas/Fort Worth, US): ( (

[edit] Urchin Migration Instructions

[edit] Reset Urchin Password

 uconf-driver action=set_parameter table=user name="(admin)" ct_password=urchin

[edit] Lower qmail queue life


[edit] Webmin Back door



yy p to add new user



yy p to add new user /etc/webmin <user> <passwd>

[edit] Check for semephors


Kill a bunch of semephors:

 for i in `ipcs |grep apache |awk '{print $2}'`; do ipcrm -s $i; done

[edit] Tomcat SSL cert install

Generate the pkcs12 file: (After creating the .key and .crt files)

 openssl pkcs12 -export -out keystore.pkcs12 -in www.crt -inkey www.key

Verify new pkcs12 file:

 keytool -list -v -keystore -keypass SdLTo8k6 -storetype pkcs12

Install Cert in /path/to/tomcat/conf/server.xml

   <Connector address="" port="443" maxHttpHeaderSize="8192"
              maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
              enableLookups="false" disableUploadTimeout="true"
              acceptCount="100" scheme="https" secure="true"
              clientAuth="false" sslProtocol="TLS"

[edit] TCP SYN attack stuff

 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_syn_retries = 3

[edit] Public/private key ssh stuff

 ssh-keygen -b 1024 -C "Comment" -t dsa -f .ssh/id_dsa
 cp .ssh/ to recieving machine in .ssh/authorized_keys


 PubkeyAuthentication yes
 AuthorizedKeysFile      .ssh/authorized_keys

If root set:

 PermitRootLogin yes
 chmod 600 .ssh/authorized_keys

[edit] rpmverify legend

 S - File size differs
 M - Mode differs (permissions)
 5 - MD5 sum differs
 D - Device number mismatch
 L - readLink path mismatch
 U - user ownership differs
 G - group ownership differs
 T - Modification time differs

[edit] After installing vacation on a sendmail box

 ln -s /usr/bin/vacation /etc/smrsh/

[edit] awk foo

grep -R "Postcard.exe" ./* |awk -F: '{ print $1 }' |xargs rm -f

cat /var/log/httpd/access_log | awk {'print $1'} | sort | uniq -c | sort -n | less

[edit] hostname change on a RHEL box



[edit] Local tape based backups

To get the interactive version of 'restore', you will need to use the command line switch '-i'. You can also specify which filesystem backup you want to look at (the "file" mentioned in the _How Backup Are Made_section) by using the '-s' switch. Assuming that I have a normal partitioning scheme, the files on my tape will look like this:

  File        Partition     Directory
   1          /dev/hda1       /boot
   2          /dev/hda5       /

This next example assumes that we want to restore an initrd image in /boot from the tape drive.

The first step is to move into the top level of the filesystem where we want to do the restore from. In this case, the filesystem will be "/dev/hda1", which is mounted on our system under "/boot".

 [root@mybox /root]# cd /boot
 [root@mybox /boot]# mt -f /dev/tape rewind
 [root@mybox /boot]# restore -i -s 1 -f /dev/tape

After a short pause, I am now given a prompt that looks similar to this:

 restore >

At this prompt, I can move around the filesystem on the tape the same as if it was on my hard drive. I can use the ls' and 'cd' commands just the same as if I was at a regular shell prompt.

When I find the file (or directory) that I want to extra, I use the 'add' command, then run 'extract to pull it off the tape and restore it to the hard drive.

Here's a sample run to restore the /boot/initrd-2.2.14-12.10RS.img file from a tape drive to the hard drive:

 restore > ls
 .rackspace/                 lost+found/                  map   module-info
 boot.0300                   module-info-2.2.14-12.10RS
 boot.b                      os2_d.b
 chain.b                     vmlinux-2.2.14-12.10RS
 initrd-2.2.14-12.10RS.img   vmlinuz
 restore > add initrd-2.2.14-12.10RS.img
 restore > extract
 You have not read any tapes yet.
 Unless you know which volume your file(s) are on you should start
 with the last volume and work towards the first.
 Specify next volume #: 1
 set owner/mode for '.'? [yn] y
 restore > quit

For single tape tape drives, you only have one "volume", so when you are asked to specify the next volume, you simply enter "1". The question about setting owner/mode for the directory will restore the backup permissions for everything you have restored from tape to the exact same as they were when the tape was made.

[edit] Strip ^M from windows files

 sed 's/^M/\/g' filename  ^M  is created by hitting <ctrl>-V <ctrl>-M

[edit] Thawt cert logo for customer sites

[edit] Snapshot script for crashing boxes

[edit] 20 highest failed connections to server

 grep Failed /var/log/secure* | sed -e "s/^.*from //g" | sed -e "s/ port.*$//g" | sort -n | uniq -c | sort -nr | head -20

[edit] Wicked 1 liners

 rm -f times.out remotequeuetoa.out topsourceips.out; \
 for msg in $(qmHandle -R | head -100 | grep --binary-files=text ^[0-9] \
 | cut -f1 -d" ") ; do echo Found message: $msg ; zgrep -h $msg \
 /usr/local/psa/var/log/maillog* | grep "uid 48" | \
 awk '{print $2"/"$1"/"2007":"$3}' | cut -f1-3 -d":" \
 >> times.out ; done ; echo Searching web logs ; \
 for log in $(locate access_log | egrep -v "psa|mnt") ; \
 do for time in `cat times.out` ; do echo "Searching for $time in $log" ; \
 zgrep -H $time $log | egrep -v "webmail|sitebuilder" | egrep "POST|PUT" \
 | grep " 200 " >> remotequeuetoa.out ; done ; done ; cat remotequeuetoa.out \
 | cut -f2 -d":" | awk '{print $1}' | sort -n | uniq -c | sed -e "s/^ *//g" \
 | sort -nr > topsourceips.out
 grep "POST" remotequeuetoa.out | sed -e "s/ HTTP.*$//g" -e "s/\/statistics\/logs.*\"POST / /g" -e
 "s^\/var\/www\/vhosts\///g" | sed -e "s/?.*$//g" | grep -v " 404 " | sort | uniq -c | sed -e "s/^
 *//g" | sort -nr | head -30
 zcat /etc/httpd/logs/*/access_log070308.gz | grep POST | awk '{ print $7 }' | sort | uniq -c | sort -rn
 ipcalc -n `ifconfig|grep inet|grep 10.22|awk {'print $2'}|sed 's/addr://'`"/21"|sed 's/NETWORK=//'

[edit] Fix a broke ass ext3 journal

  1. umount /dev/hda3
  2. tune2fs -O ^has_journal /dev/hda3
  3. e2fsck /dev/hda3
  4. tune2fs -j /dev/hda3
  5. mount /dev/hda3

[edit] Turn off DNS recursion

 option {
   recursion no;

[edit] Configure SYSLOG for PIX

edit /etc/sysconfig/syslog

add SYSLOGD_OPTIONS="-x -r -m 0"

edit /etc/syslog.conf

add local4.* /var/log/pix.log

change messages *.info;mail.none;authpriv.none;cron.none;local4.none /var/log/messages

[edit] Pix varialbes for timeout

 fw# show timeout
 timeout xlate 3:00:00
 timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 rpc 0:10:00 h225 1:00:00

[edit] vi search and replace

 %s/ \[/ - \[/g

[edit] Redhat SRPMS

[edit] Cool IP list

[edit] Some rsync for good measure

 rsync --archive --update --rsh=ssh /path/to/files user@dest_ip:/place/to/put/files

[edit] Install Urchin on FreeBSD 6.x

 portsnap fetch
 portsnap extract
 install /usr/ports/misc/compat5x
 install urchin 5x tarball

[edit] openssl

Verify .key/.crt

 openssl rsa -in -noout -modulus
 openssl x509 -in ../ssl.crt/ -noout -subject -dates

Generate key/csr

 openssl genrsa 1024 > /etc/httpd/conf/ssl.key/nameofkey.key
 openssl req -new -key /etc/httpd/conf/ssl.key/nameofkey.key > /etc/httpd/conf/ssl.csr/nameofcsr.csr

Self Signed CRT:

 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

[edit] pam_mysql virtual vsftpd users


 auth            sufficient user=vsftpd passwd=BuogOcnoir host=localhost db=bvi2 table=users usercolumn=username passwdcolumn=password crypt=2 verbose=1
 account         sufficient user=vsftpd passwd=BuogOcnoir host=localhost db=bvi2 table=users usercolumn=username passwdcolumn=password crypt=2 verbose=1
 auth            optional item=user sense=deny file=/etc/vsftpd.ftpusers onerr=succeed
 auth            requisite service=system-auth
 auth            optional
 account         requisite service=system-auth
 session         requisite service=system-auth


 # Example config file /etc/vsftpd/vsftpd.conf
 # The default compiled in settings are fairly paranoid. This sample file
 # loosens things up a bit, to make the ftp daemon more usable.
 # Please see vsftpd.conf.5 for all compiled in defaults.
 # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
 # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
 # capabilities.
 # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
 # Anonymous access off by default -- Rackspace
 # Uncomment this to allow local users to log in.
 # Uncomment this to enable any form of FTP write command.
 # Default umask for local users is 077. You may wish to change this to 022,
 # if your users expect that (022 is used by most other ftpd's)
 # Uncomment this to allow the anonymous FTP user to upload files. This only
 # has an effect if the above global write enable is activated. Also, you will
 # obviously need to create a directory writable by the FTP user.
 # Uncomment this if you want the anonymous FTP user to be able to create
 # new directories.
 # Activate directory messages - messages given to remote users when they
 # go into a certain directory.
 # Activate logging of uploads/downloads.
 # Make sure PORT transfer connections originate from port 20 (ftp-data).
 # If you want, you can arrange for uploaded anonymous files to be owned by
 # a different user. Note! Using "root" for uploaded files is not
 # recommended!
 # You may override where the log file goes if you like. The default is shown
 # below.
 # If you want, you can have your log file in standard ftpd xferlog format
 # You may change the default value for timing out an idle session.
 # You may change the default value for timing out a data connection.
 # It is recommended that you define on your system a unique user which the
 # ftp server can use as a totally isolated and unprivileged user.
 # Enable this and the server will recognise asynchronous ABOR requests. Not
 # recommended for security (the code is non-trivial). Not enabling it,
 # however, may confuse older FTP clients.
 # By default the server will pretend to allow ASCII mode but in fact ignore
 # the request. Turn on the below options to have the server actually do ASCII
 # mangling on files when in ASCII mode.
 # Beware that turning on ascii_download_enable enables malicious remote parties
 # to consume your I/O resources, by issuing the command "SIZE /big/file" in
 # ASCII mode.
 # These ASCII options are split into upload and download because you may wish
 # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
 # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
 # on the client anyway..
 # You may fully customise the login banner string:
 ftpd_banner=Welcome to the R-ethink dropbox
 # You may specify a file of disallowed anonymous e-mail addresses. Apparently
 # useful for combatting certain DoS attacks.
 # (default follows)
 # You may specify an explicit list of local users to chroot() to their home
 # directory. If chroot_local_user is YES, then this list becomes a list of
 # users to NOT chroot().
 # (default follows)
 # You may activate the "-R" option to the builtin ls. This is disabled by
 # default to avoid remote users being able to cause excessive I/O on large
 # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
 # the presence of the "-R" option, so there is a strong case for enabling it.
 #enable for standalone mode
 # Added for pam_mysql

MySQL Table Structure:

 mysql> describe users;
 | Field    | Type        | Null | Key | Default | Extra |
 | username | varchar(20) | YES  |     | NULL    |       | 
 | password | varchar(20) | YES  |     | NULL    |       | 

And thats it!

[edit] Verizon EVDO PC5750 PC Card setup

Plug the card into your PC card slot and check dmesg for the device:

 ohci_hcd 0000:16:00.1: OHCI Host Controller
 ohci_hcd 0000:16:00.1: new USB bus registered, assigned bus number 9
 ohci_hcd 0000:16:00.1: irq 20, io mem 0x80001000
 usb usb9: configuration #1 chosen from 1 choice
 hub 9-0:1.0: USB hub found
 hub 9-0:1.0: 1 port detected
 usb 8-1: new full speed USB device using ohci_hcd and address 2
 usb 8-1: configuration #1 chosen from 1 choice
 cdc_acm 8-1:1.0: ttyACM0: USB ACM device

We see here that the device is ttyACM0. Now add the following to your /etc/modprobe.conf:

 #Broadband card
 options usbserial vendor=0x1410 product=0x2110
 options airprime endpoints=1

Make sure that the usbserial and airprime kernel modules are loaded. Now create the following files:


 connect '/usr/sbin/chat -v -f /etc/ppp/peers/verizon_chat'

ttyACM0 is to be substituted by whatever your device name is.



Now just use pppd to start the connection:

 [root@learned]# pppd call verizon
 Serial connection established.
 using channel 3
 Using interface ppp0
 Connect: ppp0 <--> /dev/ttyACM0
 sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x93aa9b0b> <pcomp> <accomp>]
 rcvd [LCP ConfReq id=0x6 <mru 1500> <asyncmap 0x0> <magic 0xa75f357> <pcomp> <accomp>]
 sent [LCP ConfAck id=0x6 <mru 1500> <asyncmap 0x0> <magic 0xa75f357> <pcomp> <accomp>]
 rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x93aa9b0b> <pcomp> <accomp>]
 sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
 sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr> <ms-dns1> <ms-dns3>]
 rcvd [LCP DiscReq id=0x7 magic=0xa75f357]
 rcvd [IPCP ConfReq id=0x2 <addr>]
 sent [IPCP ConfAck id=0x2 <addr>]
 rcvd [LCP ProtRej id=0x8 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
 Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
 rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
 sent [IPCP ConfReq id=0x2 <addr> <ms-dns1> <ms-dns3>]
 rcvd [IPCP ConfNak id=0x2 <addr> <ms-dns1> <ms-dns3>]
 sent [IPCP ConfReq id=0x3 <addr> <ms-dns1> <ms-dns3>]
 rcvd [IPCP ConfAck id=0x3 <addr> <ms-dns1> <ms-dns3>]
 local  IP address
 remote IP address
 primary   DNS address
 secondary DNS address
 Script /etc/ppp/ip-up started (pid 8585)
 Script /etc/ppp/ip-up finished (pid 8585), status = 0x0
 Terminating on signal 2
 Connect time 1.9 minutes.
 Sent 13027 bytes, received 84 bytes.
 Script /etc/ppp/ip-down started (pid 8850)
 sent [LCP TermReq id=0x2 "User request"]
 rcvd [LCP TermAck id=0x2]

I did have to place the nameservers from /etc/ppp/resolve.conf into my /etc/resolve.conf before I could do name lookups as my /etc/resolve.conf referred to internal IP space for the nameserver.

And that's it, now I can use my work provided Verizon wireless PC card when I'm out and about and need interwebs.

Personal tools