Category: Open Source



According to Ubuntu developers, the Ubuntu 12.04 (Long Term Support) has a new release schedule. There will be two Alpha versions, two Beta versions, then there will be a release of the Release Candidate version and finally the complete version will be released. It’s code name is “Precise Pangolin”. The schedule of the release of Ubuntu 12.04 with exact date is as follows.

Alpha 1 release date: December 1st 2011
Alpha 2 release date: February 2nd 2012
Beta 1 release date: March 1st 2012
Beta 2 release date: March 22nd 2012
Release Candidate release date: April 19th 2012
Ubuntu 12.04 Final release date: April 26th 2012

The Ubuntu 12.04 being a LTS release will be expected by many to be a strong OS with remarkable performance and support for features.

Pages : Follow ankurtwi on Twitter      


Khan Academy, a non-profit organization that provides free online  education to anyone, anywhere in the word. Khan academy was started by Salman Khan (No Bollywood Connections), who quits his job to start online teaching. “Its our mission to accelerate  learning for students of all ages.” – thats the slogan of Khan Academy. Khan teaches on an electronic blackboard with his voice in the background explaining all the concepts. He never appears in the videos. Initially he started teaching maths, now his lectures covers Physics, Chemistry, Finance, History, Computer Science and much more. Khan Academy also provides online exercises, to practice what a student has learned. You can login using Google or Facebook , and the website will track your progress. Its really a revolution in the field of education. In, 2010 Google announced that they will be giving Khan Academy $2 million to support creation of more courses and also to enable Khan Academy to translate their courses into most widely spoken languages.

Additional Reading: How Khan Academy Is Changing the Rules of Education (wired.com)

Pages : Follow ankurtwi on Twitter      


Sharing data is a very frequent activity in the computer world. There are many great ways and utilities to share data with other people on  network. Python provides a very quick and simple way to share data with people on the network. To share the data within a directory, go to that directory  (through cd command) and execute command python -­m SimpleHTTPServer <portnumber> .Please note that the above command is very case sensitive . Now the entire content under this directory could be accessed on the network by typing http://<ip address of your machine>:<portnumber>  in a web browser. Once your done with the sharing, cancel the data serving by pressing Ctrl + C key combination\. Python comes pre installed in many of the Linux distributions these days. So Linux users just need to run the command simply. As python is cross platform this will work on other platforms too after the installation.

Example : I want to share my music directory . So I will move to my music directory through cd command and type there python -m SimpleHTTPServer 7000 where 7000 is the port number. Then I will tell the ip of my machine to the person with whom I want to share my data. In the browser he types http://<My Ip Address>:<port number>. Screenshots of the same is shown below :

Turn On The Sharing

 

Shared Directory

 

Pages : Follow ankurtwi on Twitter      


In this previous part of this article we learned about  types of shells . In most of the Linux distributions , bash shell is the default shell. So we are going to discuss the working of bash shell in this article . Fasten your seat belts and get ready for the bash ride :D

Normally we think that when we type a command, shell looks for the command in all the directories defined in the PATH environment variable. But in real it goes through the following sequence to reach the above step.

  1. Redirection
  2. Aliases
  3. Expansion
  4. Shell Function
  5. Shell Builtin
  6. Hash table
  7. PATH variable

Now lets first discuss them one by one:

1. Redirection: Consider the example given in the following snapshot:     

Redirection

Here files file1, file2, file3 exists in the current directory as seen from the output of ls command but when we redirect the output to out.txt file, the out.txt file should contain the output of ls command i.e. file1 file2 file3 but in real it also includes out.txt. This happens because before ls is executed redirection is done and file out.txt is created in current directory (we can’t redirect output to a file that doesn’t exit).

2. Aliases: After redirection shell moves to aliases.

Aliases

Here I have defined alias ls=cat , now when I type ls out.txt , ls is replaced with cat and contents of out.txt file is displayes. To make the shell ignore alias use , precede the command name with backslash (“\”).

3. Expansion: According to bash manpage there are seven kind of expansions : brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, word splitting, and pathname expansion. Discussing all of them is beyond the scope of this article, refer to bash manpage (man bash) for more information. If the command you typed contain any variable name, wildcards (*,? etc) shell expands them. As an example refer to the screenshot below :

Expansion

Here $HOME becomes /home/sumit (my home directory) after expansion and file* is expanded to file1, file2, and file3.

4. Shell Function: Like many programming languages bash allows you to define functions. A function in bash may contain multiple commands. You can execute a function just by typing its name. Example : Look  in the figure below, here I have defined an alias by name “ls” and a function by the same name. Since alias gets priority over function, when I first type ls and press enter /bin/ls is executed. Next I have used backspace to ignore alias. After deleting alias using unalias command, since there is no alias left ls corresponds to function ls. 

Shell Function

5. Shell Builtin : Some commands are a part of bash code itself, they are called Shell builtin commands. They are given priority over hash table and directories in PATH variable. Example : echo is a shell builtin command, you can use type command to determine how a given keyboard will be interpreted. 

Shell Builtin

Here its clear that echo is shell builtin command, echo also exist in /bin/ folder but if you type echo and hit enter , it will be ignored since builtin command are  of more  priority. Notice how the output of “type ls” changes after defining the alias by the same name. Once we delete alias and function ls, bash searched hash table, since ls is not in hash table is look in PATH and its found in /bin/ls. 

6. Hash table: The concept of hash table is similar to cashing in Linux, shell store the full path of all the executed commands to speed things up. Now in the snapshot below I have started a new shell, after that I execute ls command (since there is no alias or function by the same name, it executes /bin/ls because /bin is in PATH). Then after executing echo and firefox, I have used hash command to look at hash table. The first column “hits” display cache hits and “command” column displays full path of the command. Because  echo is internal command its not displayed in hash table. After I execute ls one more time its hit column changes from 1 to 2.

Hash Table

7. PATH variable: Last of all shell searches for a given command in directories listed in PATH environment variable. You can look at the contents of PATH by typing

$echo $PATH

To add any directory to PATH variable use

$export PATH=$PATH:/path/to/dir

where /path/to/dir is the absolute path to the directory you want to add. For more information you can read bash manage ($man bash).     Also to make the changed PATH settings permanent add the line export PATH=$PATH:/path/to/dir to .bashrc file in your home directory.

$echo “PATH=$PATH:/path/to/dir” >> /home/your_user_name/.bashrc

Note: Make sure you use >> instead of >, otherwise .bashrc file will get overwritten instead of appending.

About Author : This post is written by Sumit Rai. He is second in command of this blog. Sumit loves to play with grub and spends most of his time in manipulating the hardware through shell.  He is trying his hands on assembly languages also. You can contact him at sumitrai96@gmail.com .

If you want to distribute your knowledge of open-source or Linux in any form like we are doing , feel free to contact us . We can do this through this ad-free blog. We think this is the only way we can repay a little to the work of GOD RICHARD STALLMAN and LINUS TORVALDS .

Pages : Follow ankurtwi on Twitter      


This is the next  part i.e part-2  of my article which got published in the International Magazine “Linux For You” also popularly know as LFY. The article was published  under the name of “Let’s Play With Emacs  CLI”  in the August 2010 edition. All the work done is under the creative common license as specified in the widgets also :) If you are new to Emacs and want to learn it ,You must visit the Part-1 first.

Modes in Emacs

The vi/vim editor has two modes: command mode and insertion mode, which you have to switch between based on whether you are inputting text or commands to vi. However, in Emacs, this is not the case; you can run commands by typing a key sequence that’s bound to some function, as we saw above—and while not doing that, you can modify the text in the active buffer.

Emacs’ modes are different; they are editing modes, which extend Emacs’ capabilities, or change the way some features work, when they are invoked. There are several modes available already in Emacs, for editing each of a certain type or class of data, such as:

  • Regular (text) documents
  • Source code in a particular computer programming language (C, FORTRAN, Lisp, etc.)
  • Text formatted in a certain way (outlines, e-mail messages, Usenet articles, character-based illustrations, etc.)
  • Text with mark-up (like Hyper-Text Markup Language, HTML, for example).
  • There’s even a mode for editing non-text (binary) data!

Modes are classified as major or minor. A major mode dictates the main editing behaviour, and is applied only to the active buffer in the current editing session. There can only be one major mode active at a time, though you can switch between different major modes. Minor modes offer some capabilities that are not associated with any particular major mode. Multiple minor modes can be active at a time.We’ll get to some of the available major and minor modes soon, but before that:

How do you find out the currently active mode? Well, remember the Emacs mode-line bar we mentioned earlier, which is just below the buffer? This bar displays (among other information) your currently active modes, in parentheses, toward the right side of the mode line. Below is the screenshot of the same

Mode-Line Displaying Fundamental Major Mode

The major mode that’s active by default (as shown in the above screenshot) is Fundamental mode. The simplest of all Emacs modes, it has the fewest special key bindings and settings. Here, the Tab key is not bound to a function, and works as you’d expect it to (inserts a Tab into the buffer content). (To see some of the functions the Tab key invokes in other modes, search the Key-Index page for “TAB: Completion Commands” and view the next few entries.)

As an example of invoking a minor mode: suppose you want to overwrite text that’s already entered in the buffer—then you want to go into the overwrite minor mode). The function to invoke this is “overwrite-mode”; to activate this minor mode, either press the bound key, “Ins” (Insert), or type Alt+x overwrite-mode. The mode-line bar changes to show the new minor mode, as shown in the screenshot below:

Overwrite Minor Mode As Shown On Mode-Line

Note: Not all minor modes display an indicator on the mode-line; some minor modes are self-evident, such as the Tool Bar mode, which displays the graphical tool bar at the top of the Emacs frame. You can get a description of the mode by typing Ctrl-h m. You will get something like: To get rid of the help window, use Ctrl-x 1.

Important major modes

  1. Fundamental mode (function name: fundamental-mode): Emacs’s default mode with minimal settings and bindings, which we’ve already mentioned.
  2. Text mode (function name: text-mode): a basic mode for text editing.
  3. C mode (function name: c-mode): for editing C programs, a favourite of C programmers.
  4. Wordstar mode (function name: wordstar-mode): this special mode provides you the key-bindings of the old but popular WordStar editor.
  5. Paragraph-Indent Text (function name: paragraph-indent-text-mode): This mode is a special variation of the text mode, where the paragraph-movement commands work for paragraphs whose first lines are indented, and not just for paragraphs separated by blank lines.

Besides these, there are also TeX mode, for editing TeX docs, and lisp-interaction mode, for editing and compiling Lisp code. You can activate any major mode by typing Alt+x followed by the mode’s function name.

Fun with minor modes

As mentioned earlier, minor modes are not restricted to a particular major mode, but can be applied to any major mode. Let’s explore minor modes, with some scenarios to make it interesting.

Scenario 1: If you’re a Java programmer, you have to be familiar with the line System.out.println “text” that’s used to print text to standard output. Tired of typing the same line over and over again?

The solution is a minor mode named Abbrev (function name: abbrev-mode). After you invoke this mode, to assign the abbreviation “sop” for the string “System.out.println”, go to the buffer and type “sop”. Next, type Alt+x inverse-add-global-abbrev. Emacs will ask you to define the expansion for “sop” (screenshot below). Type “System.out.println” and hit Enter. The next time you enter sop in the buffer, it will automatically change it to System.out.println. Finally, it will ask you whether or not to save the defined abbreviation for future sessions.To do away with all the defined abbreviations, use the command Alt+x kill-all-abbrevs.

Defining The Expansion For "sop"

Scenario 2: You want spell-check in the editor

Ispell, an interactive UNIX spelling checker, is built into Emacs, and is a powerful and convenient way to check buffers for misspelled words. To spell-check a word at the cursor, use the ispell-word function, or its key binding, M-$). To spell-check a region, use the ispell-region function. To spell-check a whole buffer, use the ispell-buffer function.

ispell-buffer

Flyspell-mode

Note: ispell gives you a word-by-word spell check . To highlight all the spelling mistakes in the buffer at one time, use the flyspell-mode function.

Scenario 3: You want to automate repetitive invocation of an Emacs command. Suppose you have selected a region that you want to move through 10 spaces. To move it a single space, I’d use Ctrl-x Ctrl-i—but I need to do that 10 times. Hard on the hands and patience!

Emacs provides a way to repeat a command n number of times; in this scenario, I use Ctrl-u 10 Ctrl-x Ctrl-i. This results in the move-region binding being invoked 10 times, doing my job. Ctrl-u is a “universal” binding, and can be used with other key combination to repeated it for a given number of times.

Scenario 4: You want to find a string in the buffer.

Use the various search functions/bindings: isearch-forward will incrementally search the buffer forwards from the cursor. isearch-backward will search backward from the cursor. Ctrl-s or Ctrl-r will show all the matching words in the buffer (performs a non-incremental search)

Well that’s it for my basic introduction to Emacs. I hope you liked it, and found it worth giving Emacs a try. Suggestions and questions are always welcome; feel free to contact me!

Pages : Follow ankurtwi on Twitter      

Types Of Shells


Shells plays an important role in Linux and Unix system. Everything that is happening on your distro is either because of the shell or the kernel. Moreover, a backend  shell is initialized as soon as you made a login . There are lots of shells in the Unix and Linux system. Let’s try to know more about them :

What is a shell ?

Shell is the software installed on your system that works as command-line interpreter i.e. it takes the commands you type, interpret them and gives them to operating system (kernel) through system calls to execute. There are many different shells available to choose from in Linux.

C Shell : C shell was created by Bill Joy, while he was studying at University of California, Berkeley. He released it under BSD license, the syntax of C shell is similar to C programming language hence the name C shell.

TC Shell: An improved version of C shell, provides some additional features like command line completion and editing. In most of Linux systems /bin/csh is linked to /bin/tcsh and it alternatives, so when you try to start the C shell, TC shell gets started.

C shell linked to its alternatives

Korn Shell (ksh): Korn shell was developed by David Korn at AT&T Bell Laboratories. It contains may features of C shell and Bourne shell.

Bourne Shell(sh): The default shell in many Unix systems developed by Stephen Bourne of AT&T Bell Laboratories.

GNU Bourne-Again Shell (bash): Bash shell is default shell in most of Linux distributions. Its a free and open source clone of bourne shell. It was developed by Brian Fox for the GNU project. Its the most feature rich shell available and is compatible with bourne shell.

To find out all the shells installed on your system type “$cat /etc/shells”. Your default shell is defined /etc/passwd file.

My Default Shell

To switch to a different shell on your system just type the name of that shell (as in /etc/shells) and hit enter.

Z Shell(zsh):  Sorry I forgot to write about this shell (Don’t Know How :( ). Thanks to all of you for reminding me. Well The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh. It includes features like automated spell correction, editing  multiple line command within a single buffer and many more.

In the next part of the article we will learn about “How bash shell interprets a command”. So Google about the shells more and more. If want to become a Linux administrator, then you must  have  a good control over the shells.

About Author : This post is written by Sumit Rai. He is second in command of this blog. Sumit loves to play with grub and spends most of his time in manipulating the hardware through shell.  He is trying his hands on assembly languages also. You can contact him at sumitrai96@gmail.com .

Pages : Follow ankurtwi on Twitter      


This is a part of my article which got published in the International Magazine “Linux For You” also popularly know as LFY. The article was published  under the name of “Let’s Play With Emacs  CLI”  in the August 2010 edition. All the work done is under the creative common license as specified in the widgets also :)

Text Editors are very important tool for everyone, especially for the programmers. So let’s play with them :D   I am going to discuss the basics of Emacs text editor in this post.

Emacs was developed by Richard Stallman under the GNU project and he released his Emacs source code under a similar free copyleft software license called the EMACS Public License. C and Emacs Lisp  are the programming languages behind this editor. This editor is also known as “The King Of Editors”. Believe me, the title matches exactly with its unique features. The Emacs environment doesn’t seem intuitive at first glance and it doesn’t work like other editors and word processors but learning Emacs is very easy. The latest version of Emacs is 23.2 . It comes pre installed in most of the distributions. You can install it by typing “sudo apt-get install emacs ” (without quotes) on debian distribution. To install it manually download it from http://ftp.gnu.org/gnu/emacs/ . You can check your version by typing “emacs –version”  in the terminal. Emacs is a cross platform text editor and I have tried it on windows as well. Emcas was designed by keeping in mind that users don’t have to waste their time in clicking mouse buttons (start using Emacs and you will feel the same).

Emacs has two modes – GUI and CLI . Type “emacs” in the terminal to get the graphical mode. Below is the snapshot of the graphical mode :

GUI Mode Of Emacs

Graphical mode can be useful if you are not much familiar with the command line of GNU/Linux. Our main focus in this article is on the CLI mode. You can start the CLI mode by typing “emacs -nw” in the terminal. You should get something like this :

Welcome to CLI mode of Emacs

Start a new file in Emacs by typing “emacs -nw filename”  in the terminal and you should see a blank buffer. Emacs works on buffer system. Any thing you write will be there on your buffer. When you save the buffer, it gets permanently written on your disk. Default buffer in it is known as SCRATCH BUFFER. New file buffer should look something like the screenshot shown below :

New File

At the top is the menu bar like in the GUI interfaces but you hardly use it in the CLI. Below that is your buffer area where you can write your contents and data. Mode line is below the buffer. You can call it as the status bar of the editor. It gives you important information about your Emacs session and about the current buffer displayed in the window above it, including whether your latest changes were saved to disk or not , on what line number the cursor is at, how far into the buffer the bottom of the screen is (in percentage of the whole) and the current active features and settings of Emacs. Mini Buffer is below the modeline where Emacs displays the message relevant to any operations.
You don’t need to use the mouse in Emacs as there are many key bindings (combination of keys) in this editor. Key bindings starts with two most important and common key that are Ctrl and Meta keys. Meta key in case is Alt key or Esc key. I have already told you how to start the Emacs and now going to tell how to exit it because it doesn’t have a normal exit. To exit the Emacs, key combination used is Ctrl-x Ctrl-c. It means press Ctrl key then press x while still holding the Ctrl key and then press c while holding the Ctrl key. It exits the Emacs command line and you will again be in the terminal. In the mini buffer you will see the progress of your command while you are typing it. I am listing some important commands below that will help you to start your work initially  on  Emacs :

Key Combination          Function
C-x C-s                   Saves the content in the buffer
C-x C-f                    Find a file, Start a file by giving location
C-x k                       Kill buffer
C-x b                       Switch between multiple buffer
C-p                          Move the cursor to previous line
C-n                          Move the cursor to the next line
C-f                          Move the cursor one letter forward
C-b                          Move the cursor one letter backward
M-f                         Move the cursor one word forward
M-b                         Move the cursor one word backward
C-a                          Move to beginning of line
C-e                          Move to end of line
M-a                         Move to beginning of sentence
M-e                         Move to end of sentence
C-_                          Undo the change

C = Ctrl, M = Meta (Alt or Esc)
I hope this will be enough for you to start with the emacs. Believe me guys, it’s worth giving a try! In the next part , we will take a look about the different modes and functions used in Emacs and also their usages. Till then, explore more material on internet about it and have fun in the geeks way with Emacs.

Pages : Follow ankurtwi on Twitter      


Ubuntu 10.04 was released last year but it’s still popular among most of the Linux users because of its eye catchy look. Moreover its a LTS release. First thing I noticed when I installed the distro was the missing network applet (bug) . Because of that I was unable to connect to the wireless network. I posted the same in the ubuntu forums community and figured a way out. I posted the solution over there  and it got great response in return too. It got 25,000+ views over there in the forums. Link for the same is http://ubuntuforums.org/showthread.php?t=1469625 . So I thought of sharing it over my blog too . Just follow the steps below and missing network applet will appear on your screen after reboot :

1. In the terminal type  “sudo gedit /etc/NetworkManager/nm-system-settings.conf” (without quotes)
2.Change the “managed=false” to “managed=true” and then save it.
3. Then in the terminal type “sudo killall nm-system-settings”
4. Reboot your system
This solution worked for me :)

Pages : Follow ankurtwi on Twitter      


Linux is generally considered as a geek’s operating system and I am completely agree with it. Linux is not only limited to work only. You can also enjoy a lot while working on it. There are many crazy commands which will bring a big smile on your face. Below we are going to discuss few out of them.

1. Oneko : This utility remembers me of the cat mouse game. Cat chases the mouse pointer regardless of its position. You have to download it from the repository by typing “sudo apt-get install oneko” (without quotes)  in ubuntu .Then just launch it by typing oneko . You will see a cat following your mouse pointer. You can terminate this command by using the famous Ctrl-c.

2. Xpenguins:  We all know about the  relationship  of the Linux with the penguin “Tux”.  By using this utility you will see penguins dancing around your desktop. This command is partially GUI based but can be invoked using the CLI. You can install it by using “sudo apt-get install xpenguins” and can invoke it simply typing xpenguins on your terminal. To terminate follow the same Ctrl-c rule.

3.  Fortune :  You can generate famous quotes using this. It uses the random function during the generation. You can find it in the “fortune-mod” package.  For the installation of the package you need to type “sudo apt-get install fortune-mod” . Launch it by typing  fortune . You can add it  in your bashrc file so that everytime you log in you see a message .

4. Cowsay and Xcowsay : Want to say something to anyone using a cow as a medium?? If yes this utility fits the best. CLI version is cowsay and GUI version is xcowsay . You can find them in the cowsay and xcowsay package respectively. To invoke follow the syntax : cowsay text (CLI) and xcowsay text(GUI) . Example – Let’s say “hello” through the cow.

cowsay hello

xcowsay hello

5. sl (oops ls) : As we all know that the “ls” utility (used for listing of files) is used at a very high rate in  Linux. But sometimes due to high speed typing we typed it “sl” and “ls”. If you had “sl” utility installed you will see a train engine passing by in your command line warning you that you have misspelled the ls. Install sl by using “sudo apt-get install sl”  and invoke it using sl.

There are lots of others crazy commands too. Google them and have fun!!!

Pages : Follow ankurtwi on Twitter      


Compression of files is a necessity these days. It’s not only helps you in saving your space but also helps you in quick sharing and back up purposes. Text files compresses more than the web images and videos because they are already in the compressed form .You must have observed many open source softwares  in the .tar.gz packages. These are the compressed file made out using the tar and gzip  (gunzip)  utility. So let’s get started with these great utilities :D

Tar : Good practice for compressing a file  is to archive the files first and then compress them. So to create an archive of a  disk archive that contains a group of files or an entire directory , we should use the tar utility. Another advantage of the tar is that it also compresses the file to some extent. So using tar with gzip means double layer compression. To use the tar we should need to know some of its options:

-c : Create an archive
-x : Extract from the archive
-t : Display the files in archive
-f : Specify the archive named as arch

Create the archive : You can create the archive by following the syntax tar -cvf  file.tar file1 file2  . For Example- We created an archive named as html.tar for the html folder  by using the command tar -cvf  html.tar html . As I told you above tar compresses the file also. You can easily see this in the below screenshot  :

compression by tar

Extracting files from tar archive : You can extract the files for tar archive using the  ‘-x’  utility.  Follow this syntax and your file will get extracted tar -xvf  file.tar  

Gzip or Gunzip : Using this utility on the tar archive file adds an another layer of compression. As a result of both you got the .tar.gz file format. Challenger of the gzip is the bzip2 utility because it compresses the file in the greater ratio. But bzip2 is a slow compression process. So it depends on your needs which utility to use.

Compress using gzip : You can compress with the gzip using the simple syntax of gzip  filename . We are compressing the html.tar archive  further using the gzip . You can also use the  ordinary files in the filename  instead of the archive. We can see the compression ratio by using ‘-l’ option along with this utility. Below is the screenshot of the same :

gzip compression

Extracting the gzip compression : You can easily extract the gzip utility by using either the “gunzip” command or by using the ‘-d’ option with the gzip. In short you need to follow the following syntax : gzip -d  filename.gz  or  gunzip  filename.gz.

I hope this tutorial will be useful for you. Suggestions,feedback and queries are always welcome.

Pages : Follow ankurtwi on Twitter      

Follow

Get every new post delivered to your Inbox.

Join 69 other followers

%d bloggers like this: