Archive for May, 2011



Cat is one of the most well know commands of the Linux as well as of Unix systems. It’s mainly use to display the file contents of a small file on the terminal. But scope of the cat commands is not just limited to  display, We can use the cat command to create,append and even in the concatenation of the two files. In this post we will learn how to complete these jobs using the same cat command.

Display : As stated above we mostly use cat utility for the display purpose only. To display a file using cat use the following syntax without brackets “cat filename1 filename2…” . You can display single file as well as multiple files in one go. In case of multiple files, file2 will get display after the file1. Example – In the screenshot below we are displaying the contents of the test file using cat command.

Display Using Cat

You can use options like ‘-v’ , ‘-n’ etc to enrich the display. Look at the man pages for the options by typing man cat.

Create This is the best part about cat. You can even create your text files using this utility. Enter the cat command followed by the redirect output ‘>’ character and the filename. In short, something like this “cat > file” . When you press enter  the prompt vanishes. cat now waits to take the input from the user. Enter your text. Press [Ctrl-d] to signify the end of file character.The system will understand that no further text input will be made. The file is written and the prompt is returned. To verify you can use the                    cat file again.

Append : We can append a file by using append character “>>” utility along with the cat command.  Syntax for appending  is “cat >> file”. In this cat waits for the user to enter the input on to the terminal and then reads it. After reading it appends it into the file.

Append Your Files

Concatenate : Sometimes you need to concatenate two files especially if you are following the modular coding techniques. You can easily concatenate two files by using the redirecting output parameter ‘>’.  We can concatenate two files into the third file by following a syntax like “cat file1 file2 >file3″ . It will first write down the file1 and then file2 into the file3.

Scope of cat is not just limited to only these four functions. You can learn more about this utility using the web or by reading the man pages.

Pages : Follow ankurtwi on Twitter      


I was running through various articles on the web and found this great interesting concept. There is an inbuilt Linux emulator within the browser. It means that you can learn the Unix/Linux from the browser without installing  the actual operating system. All you need is a good internet connection. This is a great recommendation for the newbie. They can check out their compatibility with the Linux using  this PC emulator and if find’s Linux  interesting, then they  can install the real operating system on their  systems later. This can also be used for the testing purposes. Technology behind this is JavaScript. Don’t know how the creator (Fabrice Bellard)  did this  but hats off to him .

Link to the PC emulator - http://bellard.org/jslinux/

Pages : Follow ankurtwi on Twitter      


Have you accidentally deleted an important file because you are in a habit of using “Shift+Del” rather than delete only?? Well don’t panic. There is a utility named as “scalpel”  which helps you in recovering the so called “permanent deleted” files. Actually when you delete a file permanently (Accidentally or By Intention) , It doesn’t get removed from your hard disk. It get stored in certain blocks of the storage device and they continue to exist in the blocks unless you overwrite them with another files. This article will talk about utilities that will help you in the file recovery. It is always recommended that you shouldn’t recover a file from the device when it is mounted. You should always do the recovery process with the Live CD followed by the file searching in the device like in my case device is /dev/sda1 . If you are unable to understand the upper condition, just forget about it. I am not going to bore you with the theory part anymore. Let’s take a look at the utility.  

Scalpel is a file system independent recovery tool. It ‘s basically available for the Linux and Mac OS but you can also run it on windows by compiling it using the mingw. Latest version of scalpel is 2.0 . You can install it in Ubuntu by typing sudo apt-get install scalpel. After installing it you need to do some text editing. Scalpel utility has its configuration file in the /etc directory with full path as /etc/scalpel/scalpel.conf . When viewed (using gedit/nano/cat) you will notice that everything is a comment out there. Uncomment the file format which you want to recover. For example in my case I want to recover the .zip file so I will uncomment the .zip file section in the scalpel.conf file just like below.

scalpel.config


After that go to the terminal and follow the syntax :
sudo scalpel <device name/Directory name/file name> -o <ouput directory>

Output directory is the directory where you want to restore your deleted files. It should be empty before running the command, otherwise you will get an error. You can also input the deleted filename directly by using -i option.You can see the screenshot of my device search below .

Processing

Although utilities are there to recover your file but I would recommend you guys to put a habit of delete only not of “Shift+Del” because prevention is always better than cure :D 

Pages : Follow ankurtwi on Twitter      


Few days back I released my game named as “Hungry Snake” on Google Code  http://code.google.com/p/hungry-snakes/ . Today I got an email from the Softpedia team that they have added my game under the category of Mac Os applications Category. They  tested the game in their software labs and certified it as 100 % free which means  it does not contain any form of malware, including but not limited to: spyware, viruses, trojans and backdoors. The Game is published under the GPL license. You can run it on any platform. At the time of the writing download count in total (Google Code + Softpedia) is about 250. I can feel the power of open source. Thanks to Richard Stallman and Linus Torvalds .

Game Download Links - http://code.google.com/p/hungry-snakes/downloads/list
http://mac.softpedia.com/get/Games/Hungry-Snake.shtml

Softpedia Certificate Link –  http://mac.softpedia.com/progClean/Hungry-Snake-Clean-98721.html

 

Pages : Follow ankurtwi on Twitter      


Few weeks back I made out the basic of the snake game in python and released it on the Web under the file name “hungry.py”. Now I  have Upgraded it into a 3 Level Game. I test it on windows  and its working completely fine over there too. Download the “Game.Zip” file to play all the three levels and “hungry.py” to play the basic version. Releasing this under GPLv3 :):) Try it out and feedback would be gr8. Here’s the download link http://code.google.com/p/hungry-snakes/downloads/list .
Thanks
Ankur Aggarwal

Pages : Follow ankurtwi on Twitter      


LAMP server is the backbone of the Web today and Linux too. Users using Linux get  confused sometimes while setting up the LAMP server . I was going through the articles and found this great and very useful article on “Step up Step Installation of LAMP in Ubuntu 11.04“.
Ubuntu LAMP servers install the following versions-
Ubuntu 11.04 (Natty)
Apache 2.2.17
Mysql 5.1.54
PHP 5.3.5
Read the Full Article At http://www.ubuntugeek.com/step-by-step-ubuntu-11-04-natty-lamp-server-setup.html

 

Pages : Follow ankurtwi on Twitter      


Its been almost a week from the release of the Ubuntu 11.04Natty Narwhal“. I got  mixed reviews about this version from other blogs. I haven’t tried it yet because I am in love with the 10.04 Desktop Edition  and believes that there is no need to switch right now. For the Geeks  who are running  Ubuntu 11.04 on their machines and are struggling with the shortcuts, below is the Wallpaper (Cheat Sheet) for you. Save it and learn them :)

Natty Narwhal Shortcuts Wallpaper

Pages : Follow ankurtwi on Twitter      

 


We can classify all of the Linux/Unix commands into two types- Internal And External. Internal commands are the shell built-in commands while external commands are  files present in the $PATH. (Remember we treat everything in the Linux as a file). Commands like pwd, cd ,echo comes under the category of the  internal commands while ls,cp etc comes in the other category. To check whether the command is internal  or external we will use the typeutility (type itself is internal one). Just type the name of the command after the utility and it will return you something like this -

Using Type Utility

If you got a message like “cd is a shell builtin” after the execution of the command  it is an internal command. If you got something else it comes under the category of external commands (like cp in this case).

How Execution  Takes Place : For the external commands, execution is possible  only if the command file is present in the locations mentioned in the $PATH. Otherwise it will give you an error.If the command file is available  , but the path to that file is not included in the PATH variable, it will show you an error. Internal commands don’t need files for their execution. Set of internal commands is stored in shell by default. Sometimes a command with the same name exist in both the categories. Example – echo (external one lies in the /bin/echo) . In this case shell will give preference to the  internal echo first, then comes the turn of the external ones.  So if you use the echo utility internal will get executed. External echo rarely gets executed (You can execute it in the shell  by creating a subshell though).

Pages : Follow ankurtwi on Twitter      


I am reading this book – “Unix concepts and applications” written by the great author “Sumitabha Das”. This book is very good to start from the basics. If you wanna buy it , you can purchase it from Buy Unix Concepts And Applications from Flipkart.com .

It is very difficult to remember each shell command, even experts get confused with them sometimes. There’s an inbuilt documentation called as Man pages in Unix/Linux which practically provides the documentation of every command. You just have to type “man command” (without Quotes). What man command does,it searches for the documentation of the given command and  display it on the shell through the pager program. Man documentation has been divided into several sections. As of present it is divided into 9 sections each having a collection of specific category. Sections are-

1. Executable programs or shell commands

2. System Calls

3. Library Calls

4. Special Files (Usually Found in /dev)

5.File Formats and Coventations

6. Games

7. Miscellaneous

8. System Admin Commands

9. Kernel Routines

Most of the commands are available in the section 1. When you call the man documentation such as   “man wc”  man will look for the documentation of the wc command in the sections starting from section number 1. As soon as it finds it, it will stop looking further and  will display the documentation of the wc from the section 1.  There are many commands which are available in the multiple sections of the man documentation. For example passwd command is available in both section 1 and section 4. To locate the documetation section wise you should type the section number as an argument. Ex- “man 4 passwd” . This will display the man page of passwd form the section 4 not from the section 1.

Pages : Follow ankurtwi on Twitter      

Follow

Get every new post delivered to your Inbox.

Join 69 other followers

%d bloggers like this: