Unix cheat sheet

Last updated: December, 2009

  • System information: uname -a or vi /etc/redhat-release
  • Updating locate database: updatedb
  • Firewall: /etc/sysconfig/iptables (access file), /etc/rc.d/init.d/iptables (deamon)
  • Start programs that runs after xterm closes:nohup < command > &
  • Creating extra swap space:
  • dd if=/dev/zero of=/extra-swap bs=1024  count=1048576
    chmod 600 /extra-swap
    mkswap /extra-swap 1024
    swapon /extra-swap
    try now: "free" to see swap space or check the /proc/swaps file.
    You can automatically turn on the swap space by putting it in the fstab file:
    /etc/fstab 
    Add this line:
    /extra-swap              swap                    swap    defaults        0 0
    
  • Double ssh tunnel: ssh -t -L 8030:localhost:8030 yourLogin@lxplus.cern.ch 'ssh -L 8030:localhost:8030 youLogin@lxb1125.cern.ch'
  • Getting pem format from p12 formatted key/cert:
  • openssl pkcs12 -clcerts -nokeys -in doeCert.p12 -out usercert.pem
    openssl pkcs12 -nocerts -in doeCert.p12 -out userkey.pem
    
  • running in process in nohup mode in background and writing it to /dev/null (instead of nohup.out): nohup < command > > /dev/null 2> &1 &
  • Verifying a certificate agains a collection of CA's (CApath points the directory of the CA's credentials). openssl verify -CApath /opt/openpkg/etc/grid-security/certificates /home/prodmgr/.globus/usercert.pem
  • Doing a network trace: tcpdump -i eth2 -s 96 -S -n -nn host cithep12.ultralight.org -w /tmp/tcpdump.0701
  • Find process ids of processes listening to paritcular port: lsof
  • Creating image from partition: dd if=/dev/ < rootdevicename > of=/my.img
  • chkconfig See and manage service on/off with different run levels.
  • ldd /usr/sbin/httpd. See all library dependencies of httpd.
  • Creating ftp account. (1) Create user and specify directory with : /usr/sbin/useradd -d, (2) depending on how you configured the user list you might need to add the user to it. If the user list presents accounts that are denied, do not add it.
  • Listing all users: check file vi /etc/passwd
  • Listing all groups: check file vi /etc/group
  • Using Putty Private Key in Openssh: Download puttygen, load the putty key, select proper forma (SSH-2 DSA) and select 'conversion', 'export to OpenSSH'
  • Checking lowlevel system (hardware) setup:dmidecode , or do a : lspci
  • Selecting from a large data file only every 1000th lineawk 'NR %1000==0' data.dat > smaller-data.dat
  • Check linux version: uname -a