Author: Om Prakash Singh

  • Find the top 10 largest directories

    $ find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | sort -rn

  • Kill a broken ssh connection.

    $ ~.
    This is useful for example if you are on ssh in a server and the server goes down without letting you out.

    This is part of a larget sets of escape sequences provided by ssh. You can find them with ~? Here’s the list:

    ~. – terminate connection (and any multiplexed sessions)

    ~B – send a BREAK to the remote system

    ~C – open a command line

    ~R – request rekey

    ~V/v – decrease/increase verbosity (LogLevel)

    ~^Z – suspend ssh

    ~# – list forwarded connections

    ~& – background ssh (when waiting for connections to terminate)

    ~? – this message

    ~~ – send the escape character by typing it twice

    (Note that escapes are only recognized immediately after newline.)

    View this command to comment, vote or add to favourites
    View all commands by carlesso

    by David Winterbottom (codeinthehole.com)

  • Find the population of the world

    $ curl –silent http://www.census.gov/population/international/ | grep wclocknum | sed -r ‘s#^.*>([0-9,]+)<.*$#\1#'

  • Show directory tree

    $ find . -type d | sed -e “s/[^-][^\/]*\// |/g” -e “s/|\([^ ]\)/|-\1/”

  • Psgrepp

    $ ps aux | grep $(echo $1 | sed “s/^\(.\)/[\1]/g”)

  • 20char long alphanumeric password

    $ head -c20 /dev/urandom | xxd -ps

  • My devel setup on my laptop.

    Since, i cannot afford to have an additional H/W setup, i thought of creating my own setup on a virtual environment.  
    I tried Virtualbox for setting up my virtual env, Because I am more comfortable on it. Download the VirtualBox setup from the virtual box site. Download you favorite Linux/Windows distribution and setup a virtual machine with that. Now, comes the most trickiest part, I really don’t like running multiple windows on my desktop, and unnecessary clutter the way it looks. Moreover, going through the tab becomes slight painful, so, I decided to go headless(of course running it headless).

    You can run this command to run your virtual machine, without even bother to open your virtualbox application, and can modify your system startup to run it on every boot and shut it down whenever your sytsem is shutting  down.

    [code language=”bash”]vvboxmanage startvm "DEVELHOST" –type headless # Here Devlehost is my virtualbox name.[/code]

     

  • Saving your work with github.

    Just managed to get my hands on github, have created my repository long back, but hadn’t got time to push anything to it. Couple of days back, must give it a try and here I am, tried, worked and got answers for some of my weired questions, writing it so, it can help me later when redoing it and so to others who may face similar challenges.

    (more…)

  • Solaris Containers

    Solaris Containers

    There are two types of zones global and non-global. The global zone is the server itself and is used as the system-wide configuration and control, there can only be one global zone per system. A maximum of 8192 non-global zones can exist on a system, all non-global zones are isolated from each other.

    There are two type types of non-global zones sparse root zone or whole root zones.

    (more…)

  • emacs todo mode

    This tutorial has been posted by Logan Lee on the Usenet (http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/6d55768f621067c6/cec507b4c628b776?pli=1):

     (1) To enter todo major mode, M-x todo-mode.
     (2) Let's jump to the default Todo category. Press 'j' then select 'Todo'.
     (3) Let's insert a dummy task. Press 'i' then enter description then category that it belongs to. In this case, there is only one category (ie. Todo) so enter 'Todo' as its category.
     (4) Let's insert another dummy task in order to demonstrate raising or lowering priority of a task or filing a task once it's done. Do this by pressing 'i' again and following the rest of step 3.
     (5) Now, try pressing 'r' to move the task at cursor up by one line or 'l' to lower it by one line. The line position of a task represents its respective priority.
     (6) Now, try pressing 'f' at a task to file it. Filing a task means you add it to a file called '.todo-done' located at your home directory. You will see on your screen that the filed task has disappeared from view.
     (7) Lastly, let's try adding a new category. 'M-x todo-add-category'. First, you will be directed to the source of '.todo-do' file. Don't panic because of unknown syntax shown to your screen. Proceed to step 8 to learn  more about the syntax of .todo-do file.
     (8) The format of .todo-do file:
    
    
     ;; This specifies that "Todo" and "New Category That You Have Added" are
     ;;+categories of todo-mode.
     -*- mode: todo; todo-categories: ("Todo","New Category That You Have Added"); -*-
     */* --------------------------------------------------------------------------- 
     ;; Lists tasks under Todo
     */* --- Todo
     */* 2007-01-02 19:12 Dummy Task2        ;; These are dummy tasks from steps 3,4.
     */* 2007-01-02 19 11 Dummy Task1        ;;+Task2 is higher priority than Task1.
     --- End
     ;; Lists tasks under New Category That You Have Added
     */* --- New Category That You Have Added
     ;; As you can see there are no tasks belonging to "New Category That You Have Added" ;)
     --- End
     (9) There are other commands and associated abbreviations which can be found in Todo item at menu bar.
  • Setting up cgi in userdir

    enable a CGI directory for every user in apache.

    Configure apache for userdir.

    [code language=”bash”]
    a2enmod userdir
    [/code]

    open the userdir.conf file and add the following

    [code language=”text”]
    <Directory /home/*/public_html/cgi-bin/>
    Options ExecCGI
    SetHandler cgi-script
    </Directory>
    [/code]

  • Setting up networking in Debian

    Networking in Debian GNU/Linux

    Configure interface in /etc/network/interfaces
    [code language=”text”]
    iface eth0 inet static
    address <ip address>
    netmask <netmask>
    [/code]

  • Resetting the Root Password for mysqld on Unix Systems

    “These are taken from the mysql website and is for refrence and documentation purpose”

    On Unix, use the following procedure to reset the password for all MySQL root accounts. The instructions assume that you will start the server so that it runs using the Unix login account that you normally use for running the server. For example, if you run the server using the mysql login account, you should log in as mysql before using the instructions. Alternatively, you can log in as root, but in this case you must start mysqld with the --user=mysql option. If you start the server as root without using --user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups. If that happens, you will need to either change the ownership of the files to mysql or remove them. (more…)

  • Adding routes in AIX

    Configuring a gateway in AIX

    To configure a machine to act as a gateway, use these instructions.

    For clarity, this procedure assumes that the gateway machine
    connects two networks, and that the gateway machine has already been minimally
    configured on one of the networks.

    1. Install and configure the second network adapter.
    2. Choose an IP address for the second network interface.
    3. Add a route to the second network.
    4. To use a machine as an internetwork router over TCP/IP networks,
      type:

      no -o ipforwarding=1
  • AIX commands you should not leave home without

    Kernel

    How would I know if I am running a 32-bit kernel or 64-bit kernel?

    To display if the kernel is 32-bit enabled or 64-bit enabled, type:

    bootinfo -K

    (more…)

  • Creating a DVD repository on AIX,.

    Do yourself a favour and get a spot of space (couple of GBs) and get all your media onto this file system with the following commands:

    1. Put the first media CD/DVD into your drive – you do not have to mount it.
    2. Make sure you have you file system mounted.
    3. Look at what filesets are on the media you are about to build:
    gencopy -d /dev/cd0 -t /repository-filesystem -U -X -L all | wc -l
    gencopy -d /dev/cd0 -t /repository-filesystem -U -X -L all | more
    4. Write it out to a file somewhere:
    gencopy -d /dev/cd0 -t /repository-filesystem -U -X -L all >/tmp/filename.txt
    5. Do the actual copy/repository build:
    gencopy -d /dev/cd0 -t /repository-filesystem -U -X all
    6. Stick in the next cd/dvd:
    7. Redo steps 1 to 6 until you are done.
    8. TAKE NOTE that the actual build takes quite some time.
    9. ALSO, make sure you have enough space on /var and /tmp to accommodate the lists the o/s builds to do the media build.
    Once done, you will have 1 file system with ALL your media filesets in it.
    Then do your ‘smitty install’ and check if you can get your rsct.basic.rte sorted.

  • if you get the error “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”

    install the following files with yourapache, php and mysql installation, mine got fixed by this, hope yours too will

     
    [code language=”text”]
    sudo apt-get install  phpmyadmin libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql
    [/code]