Real world Linux
Hi, I am Himanshu Arora, owner of
Image source : Flickr (
Chris Walden, here, Managing Editor for Linux and Open Source on developerWorks and creator of this "Real World Linux" community. I wanted to share something with all of you as we close out 2012. PC World, a publication that is not necessarily known for pushing Linux had a recent article: Five reasons 2012 was a great year for Linux. If you are feeling discouraged about spreading more Linux around your life, it may pick you up a little. If you already have plenty of Linux and want to help other people understand it might bring them round.
I know that many see this as a silly sort of discussion, but those people have never used a spoke shave.
A spoke shave is an unusual tool, born from a time when there was a need to quickly and consistently create rounded objects for the spokes of wagon wheels. The are a sort of draw knife which allow you to pare a piece of wood, similar to how a peeler works on the skin of a cucumber. Using one is a little awkward at first, but with practice you can shave and shape wood in miraculous ways. Oh, there are other tools that can be used in similar ways, but once you have practice with a spokeshave they are clumsy and inefficient.
I don't want Linux to be the only choice. Mac OS, Windows and other operating systems have their places and any serious technical professional should be willing to support whatever fits the needs of the users, some of which are just personal comfort. For me, though, Linux has become a sort of a spokeshave. I like the way it feels. I've learned some of the ltitle tricks to making it do what I want and how I want and anything else is just a little clumsy. It looks like it will continue to be a choice and maybe a bit more.
Happy New Year!
With the release of GNU sed version 4.2.2, the maintainer Paolo Bonzini has resigned from his post. He has been the maintainer of GNU sed project for past eight years. Also, for past three years he was maintaining the GNU grep project. In this latest development, he has announced his resignation from both the projects following a controversy over the control of the name and code base of gnuTLS project.
In his announcement, Paolo said :
I am less pleased to announce that I am resigning from maintenance of GNU sed (after 8 years) as well as GNU grep (after 3). I have also given up commit access to Autoconf, Automake, Libtool, gnulib, libsigsegv and Bison.The gnuTLS controversy as described in an article on h-online :
Nikos Mavrogiannopoulos, one of the two maintainers of the GnuTLS library, had announced his desire to continue the development of his software outside of the GNU Project. The statement elicited a response from Richard Stallman, the leader of the GNU Project, saying that this would not be possible due to the fact that all copyrights in GnuTLS were assigned to the FSF and that therefore, the name and current code base was under the control of the GNU Project. While Mavrogiannopoulos is free to fork the code, Stallman expressed the opinion that a fork would have to change its name as a result, though currently the code is now available on new infrastructure with the same name.
Meanwhile , Paolo Bonzini also seemed to be upset with the slow decision making process and out dated coding standards of GNU project. He also criticized the free software foundation for it's lack of support for high priority projects. He provided the following three points to justify this decision :
Though Paolo Bonzini did not resign the commit access for GCC and GNU smalltalk but his decision to quit other projects is definitely not a good news for GNU and the open source community.
A few days back, I was trying to find details of a specific type of files on my Ubuntu box in office.
Here is what I was trying to do :
find ./ -name "*.out" | xargs ls -lart
As you can see that I was trying to list out the details of all the files having .out extension. So far so good as I got what I wanted. Then one of my colleague wanted to use the same command on his Linux machine so he asked me to copy and send it to him. Though copying from command line using mouse and keyboard is not that difficult but somehow after I selected the command text, I pressed ctrl+c as usual and as expected, it did not work as ctrl+c is on command line is not used for copying. Though next time I was able to copy through mouse but now I wanted to learn a way through which editing or copying long commands from command line becomes easy.
I googled a bit and found this cool trick that copies the command line text to an editor.
Here are the steps do it:
So as you can see that it's quite an easy trick.
So at this point, not only you can copy the text but any modification in the command would also be treated as modification in the actual command line command and results will alter accordingly.
To test this, I replaced the 'ls -lart' with 'wc' command, saved the text file and then closed it. The next two snapshots show that the modification was actually reflected in the command line results.
The Linux foundation came up with a video recently that celebrates the success and milestones achieved by Linux in the year 2012. The video shows how Linux powered devices like Android smart-phones and supercomputers are dominating the world today. Other than this, video highlights chromebooks being sold by google and Linux conferences that took place around the world in 2012. Watch the video for more.
Note : The credits for the video goes to the author. The Intention is to just share the information through this video.
The other day when I was searching for some file in my Linux system, I got a result with name 'TheLinuxCommandLine'. I was not sure what type of file was that as 'vim TheLinuxCommandLine' produced the following output :
%PDF-1.6^M%âãÏÓ^M 3006 0 obj^M<>stream^M ... ... ...
While I got a clue from the word 'PDF' in the output above that it could be a PDF file but then I thought that there should be utility that could gracefully tell the type of file supplied to it as input. I searched a bit and found a Linux command line utility known as 'file' which is used to classify the files (whose names are supplied as input) based on their type. So, I thought to share whatever I learned about the 'file' command in Linux.
Here is the syntax of this command :
file [options] file-name
So we see that the file command expects a file name as a mandatory argument while there are certain options that are non-mandatory but can be supplied to customize the output as per need. Here is a basic example of what file command does. In this exercise, I supplied different types of files as input to file command. The output is shown below :
$ file grof grof: PostScript document text conforming DSC level 3.0
$ file Desktop/ Desktop/: directory
$ file env_script.sh env_script.sh: Bourne-Again shell script, ASCII text executable
$ file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xee08a653cc2bcbca7fcd1fc62900bd9d6d053731, not stripped
So, we see that for every type of file supplied, the file command was able to classify it by providing the details related to it's type. Finally I supplied the file 'TheLinuxCommandLine' (that I was originally confused about) to this utility.
Here is the output that I got:
$ file TheLinuxCommandLine TheLinuxCommandLine: PDF document, version 1.6
So we see that the file command successfully classified it as a PDF file. This prompted me to look into the details about how this command works. I read the man page and found that there are three sets of tests, performed in this order: file system tests, magic tests, and language tests.
Here is more about these tests from the man page :
This gave me a good idea as to how this command works. Thereon I tried a few options provided by this command.
Examples of file command options
1. Remove file-names from output using -b option.
I used this option in the following example :
$ file -b grof PostScript document text conforming DSC level 3.0 $
So we see that there was no file name in the output. The output contained only details about the file.
2. Exclude a particular test while determining the file type
There are various test that are performed by file command while determining the type of file. There exists an option -e that can be used to exclude a particular type of test. For example, to exclude a test in which the file command checks and prints the details of an ELF file, we can pass the test name 'elf' to -e option in the file command. Here is an example :
$ file -e elf a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)
So we see that the details were skipped due to the 'elf' test name supplied to -e option. There are various other test names available. Here is the list of test names available :
3. Change the default separator using -F option
If you observe that a separator ':' is used between the file names and the description in the outputs produced by file command. There exists an option -F through which we can change the separator.
Here is an example in which I tried to replace the default ':' with '#'.
$ file -F# * a.out# ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xee08a653cc2bcbca7fcd1fc62900bd9d6d053731, not stripped bufrovrflw# ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x359ad47b9c29ca2b287e1d0adb26029b859ac7e4, not stripped bufrovrflw.c# ASCII English text Cfile.c# ASCII text Cfile.h# ASCII text Cfile.o# ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped cmd# ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xfac3f75dfae01e0ac037c39099182eb5c51fca82, not stripped cmd.c# ASCII English text CPPfile.cpp# ASCII C program text CPPfile.h# ASCII text
So we see that the separator was changed to '#'.
4. Read input file-names from a file using -f option
This command provides an option -f through which we can provide name of a file that contains input file-names for this command.
Here is an example :
$ cat file.txt main main.cppThe above mentioned file 'file.txt' contains two file names. Let's use 'file.txt' with -f option :
$ file -f file.txt main: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xee08a653cc2bcbca7fcd1fc62900bd9d6d053731, not stripped main.cpp: ASCII C program text
So we see that the file command displayed the details about the file-names that were contained in the file 'file.txt'.
5. Output mime type information using -i option
If it is required to display the mime type information rather than the other human readable information then the option -i can be used.
Here is an example :
$ file -i a.out a.out: application/x-executable; charset=binary
So we see that the output displayed mime type information.
6. Disable padding for file-names in output using -N option.
When file command is run normally, you will see that there is a bit of padding in the output so that file-names and description is distinguishable.
For example, a normal output looks like :
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xee08a653cc2bcbca7fcd1fc62900bd9d6d053731, not stripped bufrovrflw: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x359ad47b9c29ca2b287e1d0adb26029b859ac7e4, not stripped bufrovrflw.c: ASCII English text Cfile.c: ASCII text Cfile.h: ASCII text Cfile.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped cmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xfac3f75dfae01e0ac037c39099182eb5c51fca82, not stripped cmd.c: ASCII English text CPPfile.cpp: ASCII C program text CPPfile.h: ASCII text CPPfile.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped dir1: directory dir2: directory
The file command provides an option -N through which this padding can be disabled.
Here is an example using this option :
$ file -N * a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xee08a653cc2bcbca7fcd1fc62900bd9d6d053731, not stripped bufrovrflw: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x359ad47b9c29ca2b287e1d0adb26029b859ac7e4, not stripped bufrovrflw.c: ASCII English text Cfile.c: ASCII text Cfile.h: ASCII text Cfile.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped cmd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xfac3f75dfae01e0ac037c39099182eb5c51fca82, not stripped cmd.c: ASCII English text CPPfile.cpp: ASCII C program text CPPfile.h: ASCII text CPPfile.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped dir1: directory dir2: directory
So we see that the padding was disabled in the output.
7. Provide details about files contained in compressed file using -z option.
Normally, if a compressed file (like .zip) is provided as input to file command, it displays that it is compressed zip file etc.
For example :
$ file grof.zip grof.zip: Zip archive data, at least v1.0 to extract
But, the command also provides an option -z through which it displays the details of the files contained inside the compressed file. For example, if -z is used with the .zip file we used in above example, here is what we get in output :
$ file -z grof.zip grof.zip: PNG image data, 64 x 64, 8-bit/color RGBA, non-interlaced (Zip archive data, at least v1.0 to extract)
So we see that this time the details of the data contained in the compressed file is displayed along with the general details that were displayed in the above example.
Some discussions related to file command on forums
Here are a couple of discussions on various forums related to file command that might be an interesting read.
Discussion - 1 :
Discussion - 2 :
Canonical announced the release of Kubuntu and Edubuntu 13.04 (Raring Ringtail) Alpha 1 on December 6 2012. The company clarified that the there will be no alpha release for Ubuntu 13.04 and the first official release for Ubuntu 13.04 would be available only as a beta release which is scheduled towards the end of march 2013. This was decided in the Ubuntu developer summit for Raring Ringtail. While people can still get hold of the daily Ubuntu images, the current alpha release is only for Kubuntu and Edubuntu.
Here is what Stéphane Graber reported while announcing 13.04 aplha 1 release :
The release for both the flavours has Linux kernel 3.7 and is available for 32bit as well as 64bit versions. Here is an excerpt from softpedia regarding what's new in this release :
Though these were some of the features carried by these flavours of Ubuntu, what exactly will the Ubuntu 13.04 have in store is still kept under wraps. As Canonical founder Mark Shuttleworth said a couple of months back :
As evident from his statement, the actual features of Ubuntu 13.04 will not be available soon and probably we would have to wait until it's release in April 2013. Meanwhile we can surely have a look at the videos uploaded by some of the Ubuntu fans who reviewed the Alpha1 version that's available for testing.
Here is the e-mail Link through which Stéphane Graber announced this aplha 1 release :
As also reported in the e-mail :
For Edubuntu :
While going through an article on Linux text processing commands, I came across Linux sort command. I found this command interesting enough to read more about it and try out some of it's examples. So here in this article, I'll share my understanding on Linux sort command through some examples. Before jumping on to examples, here is an excerpt of information from the man page of sort command:
So we see that the main purpose of this command is to produce a sorted output.
Linux sort command examples
1. A basic exampleThe very first input that I tried consisted of some random alphabets.
Here is what I tried:
$ sort b z a w sAnd here is the output :
a b s w zSo we see that the output produced was in sorted form.
2. Sort numbersIn the following example, I filled a text file (sort.txt) with some random numbers.
$ cat sort.txt 8 2 6 1 5 3Then I used the sort command with sort.txt as input file to the command.
$ sort sort.txt 1 2 3 5 6 8So we see that sorted list of numbers was produced in output.
3. Sorting wordsIn this example, the sort.txt file is filled with some words.
$ cat sort.txt UK Australia Newzealand Brazil AmericaNow, this file is given as input to the sort command:
$ sort sort.txt America Australia Brazil Newzealand UKSo we see that words were sorted according to dictionary ordering. Even the words beginning with same alphabet were sorted according to succeeding alphabets.
4. Use sort to directly write data in sorted mannerThis command can be used to write unsorted input data to a file directly in sorted manner.
Here is how this can be done :
$ sort > sort.txt 9 Hello 4 Why 8 ByeAfter the above operation, let's check the file contents :
$ cat sort.txt 4 8 9 Bye Hello WhySo the output suggests that the input was first sorted and then written to file.
5. Write sorted concatenation of all input files to standard outputIf more that one file is provided as input, the sort command produces a sorted concatenation on stdout.
Here is an example:
$ cat sort1.txt 7 4 9 1
$ cat sort2.txt 8 5 6 2Here is the output :
$ sort sort1.txt sort2.txt 1 2 4 5 6 7 8 9So we see that a sorted concatenation was produced in output.
6. Write result of sort in a fileThe output of sort command can be written to a file by using -o option.
Here is how it's done :
$ sort -o sort.txt 4 9 2 8 1Now let's check the file :
$ cat sort.txt 1 2 4 8 9So we see that the output was actually written to the file whose name was supplied as input to sort through -o option.
7. Sort monthsThere is an interesting option -M through which the month names can be sorted.
Here is an example :
$ sort -M > sort.txt DEC JAN FEBNow, let's check the file contents for output :
$ cat sort.txt JAN FEB DECSo we see that sort command actually sorted the month names.
8. Sort human readable numbersAnother interesting option -h is provided by sort command through which human readable numbers.
Here is an example :
$ sort -h > sort.txt 2G 1K 3MNow, let's check the file for output:
$ cat sort.txt 1K 3M 2GSo we see that the numbers were sorted.
9. Produce reverse sorted resultsUsing -r option provided by sort command, the results can be produced in reverse order.
$ sort -h -r > sort.txt 2G 1K 3MHere is the output of file :
$ cat sort.txt 2G 3M 1KSo we see that this time the sorting results were written in reverse sorted order.
10. Compare according to string numerical valueThis can be done using -N option.
Here is the input :
$ cat > sort.txt 7 mangoes 4 oranges 9 grapes 1 appleHere is the output :
$ sort -n sort.txt 1 apple 4 oranges 7 mangoes 9 grapes