Saturday, September 10, 2011

Download a file from FTP in single command in Bash

I was just looking to download a file in bash from a FTP Server.

The following will work:

wget ftp://<username>:<password>@<ftp-server-url>/<file-name>

Friday, September 9, 2011

Setup Irscci on Ubuntu

Here are the steps while I was trying to learn setting up shell based IRC Client (I opted for Irssi ) on Ubuntu
  1. Install irscci: sudo apt-get install irssi
  2. Start irscci: irscci
  3. Connect to an irc server e.g. /connect irc.freenode.net
  4. Choose some screen name which should be unique:
    1. /set nick <unique_nick_name>
  5. You can opt to register this nickname and verify it
    1. /msg nickserv register <password> <email>
    2. To switch between message and current window use Alt+a, Alt+1, Alt+2
  6. An email will be triggered with a verification command of the format: /msg NickServ VERIFY REGISTER <nickname> <passcode>
  7. Join any group with groupname: /join <ircroom> e.g. /join ubuntu
  8. To autoregister the nickname, use the following command
    1. /network add -autosendcmd "/msg nickserv identify password ;wait 2000" freenode


Sunday, September 4, 2011

Installing ArchLinux as Host on Virutalbox

These are the following steps I followed to setup a minimal ArchLinux installation. The detailed instructions are present at the excellent wiki of Arch.
  1. Downloaded the latest Net Install Image via torrent.
  2. Created a 512MB and 16GB Virtual Drive in VirtualBox 5.1
  3. Followed the steps to complete a minimal installation.
  4. On reboot, I tried to install openbox with the command pacman -S openbox which failed with error: 
    1. error: could not open file /var/lib/pacman/sync/extra.db: failed to open '/var/lib/pacman/sync/extra/db'...
  5. I ran the following command: pacman -Syy
  6. Create an account using: adduser
    1. Give the addional groups as 'audio,lp,optical,storage,video,wheel,games,power,scanner'
  7. Now I was able to get the option
  8. Do a system update: pacman -Syu
  9. Installing LXDE 
    1. # pacman -S lxde
    2. Copying the config files to 
  10. Installing slim
    1. # pacman -S slim
  11. After some command line fun, I eventually decided to install wicd for network management.
Post these steps I had a working after configuring /etc/rc.conf to include the services I need to run on boot.


Rain & Emotions

Rains bring out extreme emotions, either you feel happy or you feel dejected. Somehow this time of the year when it started raining I was experiencing the latter. I had a also a good idea what was the cause but there isn't anything I can do about it.


Sunday, June 19, 2011

Setup Bitbucket using SSH on Ubuntu

Bitbucket is a good alternate to Github which provides free unlimited private hosting upto 5 collaborators. It uses Mercurial which is DVCS.

I prefer SSH over HTTP to access work on my repository. The steps to setup are as follows:
  1. Signup on Bitbucket (Obviously)
  2. Create a repository after login using Repository -> Create New Repository
  3. Install mercurial on your local system
    1. sudo apt-get install mercurial
  4. Create the Mercurial Configuration File
    1. vi ~/.hgrc
    2. [ui]
      editor = vi
      username = FIRST_NAME LAST_NAME <email>
      
  5. Create SSH Key if not present on your local system  using the following steps
    1. ssh-keygen
    2. The generated key files are stored under ~/.ssh
  6. Upload the ~/.ssh/id_rsa.pub file to Bitbucket under Account -> SSH Keys
  7. Setup the Key in Ubuntu
    1. chmod 644 ~/.ssh/id_rsa.pub
      ssh-agent bash
      ssh-add
  8. Now clone the repository from remote server
    1. hg clone ssh://hg@bitbucket.org/<username>/<repository>
  9. To add and commit code use the following commands
    1. hg add <file/folder>
      hg commit -m '<commit message>'
      hg push
     
    A very good reference for basic Mercurial is
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
     


    Thursday, June 9, 2011

    Generate ssh keys

    By default ssh-keygen generates a RSA private/public key pair.

    To generate a DSA Key

    ssh-keygen -t dsa -b 1024 

    The option -t is for the type of encryption (dsa/rsa)
    The option -b is for the number of bits for encryption (1024,2048 etc)

    Tuesday, April 26, 2011

    Get the previous date in month-dd-yyyy formation in unix

    Another nifty command in Bash to do so in the required format of month-dd-yyyy

    date -d 'yesterday' +%B-%d-%G
    

    Other Formats are mentioned at http://unixhelp.ed.ac.uk/CGI/man-cgi?date