Wednesday, January 5, 2011

linux : ek newbie ki jabani

Linux/gnu is the buzz now among my 2nd semester friends. It is because we have to use linux environment in our programming lab(can't use windows coz it isn't a true multi-user system). My tryst with linux/gnu started when I got my first computer, thanks to chief minister Tarun Gogoi, which came preloaded with Ubuntu OS. I tried it for a few weeks and then gave it up as it didn't have many of the features I wanted plus the absence of broadband-to install the plugins and other apps. But, the latest version of Ubuntu( aka Maverick Meercat) is awesome. I have been using it(and Lucid Lynx) since I came to IIT Guwahati.
         To a newbie linux/gnu can be terrifying "What's with all these commands?" - you may ask. Does it feel like going back instead of progressing? Actually, it isn't archaic. It is quite useful at times and definitely more powerful. Oh ! I almost forgot to tell you, today's linux distros have GUI too(and it's good)...
my ubuntu desktop & terminal
        I am a newbie myself and in this blog I am gonna take you through the basic linux/gnu commands, enough to survive the first CS110 lab. Learn them well, because not only your aptitude for programming but also your basic linux commands will be put to test in the next CS lab. I'll assume that you have no prior experience with linux and if you do, have patience...atleast comment

Most of these commands will work in all distros unless specified.

        In CC, instructor will ask you to work in Fedora, so forget about the SSH icon you saw in Windows desktop(as was initially taught by Prof. Rao).

In Fedora: Go to Applications -> System tools -> Terminal.
In Ubuntu: Go to Applications -> Accessories -> Terminal.(btw there's a shortcut just press Alt + Ctrl + T, you can also change this shortcut in System -> Preferences -> Keyboard Shortcuts, isn't it cool?)

        There you will see some text before a $ or % sign. It's called the command prompt , basically it means the computer is ready to accept commands. Before connecting to the computing server using the ssh command let's learn some basic commands first.

        Write pwd after the command prompt and press enter. You'll something like /home/username. pwd stands for print working directory and /home/username is the path of your working directory.

        Now enter this command mkdir new_folder  . Well ! don't worry if you see nothing because by mkdir command you have instructed the computer to make a new directory by the name new_folder( by the way don't write new folder, cos linux hates a space in a name. If you have to use spaces in a file/folder name use them inside inverted commas like mkdir 'new folder'). Now, the new directory will have the path /home/username/new_folder

       To see it enter the command ls , which stands for list.  You'll now see among your other files and folders, a folder called new_folder

        To make this new_folder your working directory enter cd new_folder
cd stands for change directory. Now try pwd and see what you get.

      To come out of this directory use cd .. or cd /home/username
the double dot(..) here stands for the parent directory and a single dot(.) means the working directory(did it ring some bells. Arrey bhai ./a.out, now you know why it's ./)
 So, while you were in new_folder your working directory was new_folder and the parent directory was username.

        The other commands are mv to move or rename a file, cp to copy a file, rm to remove/delete a file, rmdir to delete a directory.

use them this way 
to move a file give the command-  mv file (new destination)
suppose you have a file test.c in your username directory that you need to move to temporary, just type mv test.c temporary . Of course you must be in the parent directory of temporary, otherwise you shall have to type mv test.c /home/username/temporary

to rename a file just enter-   mv (old file name) (new file name)
eg to rename test.c as renamed.c enter mv test.c renamed.c

to copy use cp the same way as mv
eg:  cp renamed.c temporary
it will copy renamed.c to temporary

to delete renamed.c enter-   rm renamed.c

to delete a directory enter  rmdir (directory name)
eg: rmdir temporary will remove the directory named temporary.

okay, other interesting commands you might like to try on your own:
#1 whoami
#2 ip addr
#3 info
#4 man (a command name) eg man cp
#5 find (filename*)
#6 exit

(only for IITG 2nd sem students)And to connect to computing server just type the command ssh username@202.141.80.3 
Alternatively, from your Ubuntu system you can goto Places -> Connect to Server.. change the sevice type to SSH , give the server as 202.141.80.3, port 22, folder /home/cs201/stud/username and then connect

       enjoy linux/gnu and if you think I have forgotten something, made a mistake or simply you want to add something of your own...then please comment below...

Tuesday, January 4, 2011

Clueless !

It has been a couple of weeks or more since I last blogged. The problem lies not in my lack of time, but in the fact that there's always been a dearth of ideas, a dearth of topics to write my blogs on. Whenever I sit down to write something, I am completely clueless; I start rambling(no pun intended this time) and that's the end of it.

So, let me recall the things that are happening in my life and hopefully, I'll come up with somethng to write about.
Rewinding the last twenty four hours of my life: dreamt, woke up, brushed my teeth, ate breakfast, went to classes, came back, ate dinner and am blogging now. There's nothing to write about my dreams as I don't remember one single detail(heck, I don't even remember whether I dreamt or not), classes were normal and I don't recall anything interesting happening(read: I fell asleep), dinner's always the same and ........that's it..... Hmmph...!! I am still clueless,don't know what to write about

Let me go more back in time.
Rewinding the last 36 hours of my life : saturday was special - the first day of the new year. Had a real good time with my closest friends, met with an old friend after two and a half years and then went to the science museum. There among other notable things I saw my first 3D film. Sunday: nothing that I could remember. Monday: dull as every other monday(classes started again after weekend !). Hmmpph...still clueless

Let me go back a month in time.
Rewinding the last month of my life: Holidays started. Back at home, enjoyed the food and affection of my mother. Otherwise, it was boring like hell. Wrote a few articles(mostly nonsense) for my blogs.

Hmmmppphhh.....clueless again...
The last six months: The only good thing that happened was my admission into IIT Guwahati and I don't remember(or I don' want to remember) anything else..........................hmmph...

What am I doing with my life ? I am totally clueless as to what I am doing now neither do I know what I am going to do in the next 4 years of my life. I realise being clueless about a topic to write is not the issue anymore....I am clueless with my life...

I am really scared; what am I gonna do in the next four years of my life... I don't want to be a machine who only eats, attends classes and sleeps... I want to do something, I want to do something big and I want to achieve something much bigger but what exactly????? ....I am clueless...