Linux-Planet
  • Home
  • Top 10
  • Statistics
  • Registration
  • Archives
  • Contact

Quick news

Welcome on Linux-Planet - Please, if you find any bugs, report them at bugs@linux-planet.net

Subscribe

  • feed Feed with all the posts
  • feed Popular posts feed

Members

  • feed  Devil505
  • feed  Diego
  • feed  eugeni
  • feed  fabiolone
  • feed  Giacomo
  • feed  Ingo
  • feed  Jonathan
  • feed  kiddo
  • feed  Linux-Planet
  • feed  Linuxindetails
  • feed  Scurz
  • feed  shredder12
  • feed  teguh
  • feed  TForsman
  • feed  theclimber
  • feed  yoho

Contribute

  • meta Add your blog
  • meta Administration
Filter the posts :     Posts of the day   -   Posts of the week   -   Posts of the month   -   All posts

Fast access to the last posts of the page


07/09/2010 : Unix Named Pipes - An example of Interprocess communication 07/09/2010 : How to open a Directory or a file starting with a "-", hyphen 06/09/2010 : How to Wget: Manage network Bandwidth rate and Quota using Wget 02/09/2010 : OpenArena - The OpenSource Quake III Arena 28/08/2010 : How to mount Linux LVM volume partitions on Linux 24/08/2010 : How to Wget - The basics of this great Downloader 16/08/2010 : My first pocket Operating System - Slax 16/08/2010 : GraphMonkey - a simple, light-weight graph calculator and plotter 14/08/2010 : Live Bandwidth monitoring became easy with Netmonitor screenlet
Next page »
Unix Named Pipes - An example of Interprocess communication 
0 vote
By shredder12, on 07/09/2010 at 22:44.
Tweet

So, I have been selected as one of the teaching assistants for Operating systems course and this time we had to give some examples of Named Pipes, demonstrating one form of Inter Process Communication aka IPC to the students. I had never used them before, but its fun knowing and working with them.

I hope all of us have used pipes on Linux systems. Here is a simple pipe example I often use to check if a process is running or not.

[shredder12]$ ps -e | grep firefox

The symbol "|" used here is called pipe(its mostly above the "Enter" key). Just like conventional pipes, UNIX pipes are used to transfer data between processes, aka Inter Process communication. They transfer one program's/process's output to another process as input, ps and grep in our case. The output of 'ps -e' is transfered through pipe as an input to grep. They are called "pipes" because of their FIFO(first in first out) nature. They can be seen as files but with the FIFO property. We will see the reason in a little while.

Difference between Pipes and Named Pipes

In above example, as soon as the message is passed and grep executes, the pipe will no longer exist, i.e. it is a non-persistent thing, gets removed as soon as the task is over. Named pipes, however are persistent, have a name and they exist even after the processes are terminated. I think I might have lost you people here, so lets see a simple named pipe example.

[shredder12]$ mkfifo mypipe

This command creates a pipe. Now, if you do ls -l, you will see something like this

So, as you can see, it has everything similar to a file, but the FIFO property. It can be deleted just like a simple file, using rm.

[shredder12]$ rm mypipe

Lets begin with the usage part. Try running this command in a terminal

[shredder12]$ ps -e > mypipe

This command should have returned to a prompt(thats what you would have expected) but apparently it seems to get hanged in the middle of nowhere, why? The answer is these pipes work exactly like a conventional water-pipe does, i.e. it needs both the end to be open, one serving as an input and the other as output. So, the reason why the above command hasn't returned a prompt is because only one end of the pipe is opened, for the input. Until there is a process at the other end of the pipe to receive the data, the transfer or the communication isn't complete and so the command doesn't terminate.

Now, with the above command running in a terminal, try to run the following in another

[shredder12]$ cat mypipe

Now you will actually see the output of 'ps -e'. And note that this means the communication is done and as a result, both the commands will terminate and return to prompt.

If you have understood the basic working of pipes then you might wonder if we can create an infinite loop using two of them. In a 1997 article of LJ, the writer mentioned this little trick. Using two commands, he hooked up the ouptut of one pipe to other's input and vice versa, thus generating a loop.

However, I couldn't make it work on my system. After running the command, I didn't see any cat processes consuming huge resources. May be I did something wrong or may be the article is too old to work on today's systems, probably some defensive technique in later kernels to escape such accidents.

Anyway, I hope this small introduction to named pipes has given you a new insight into the working of Unix and Linux sytems.

Back to summary
How to open a Directory or a file starting with a "-", hyphen 
0 vote
By shredder12, on 07/09/2010 at 14:50.
Tweet

Those of you who have not been in such a situation would never know how it feels when you are stuck opening/deleting a file or directory. The more you have been working on the shell, the more it sucks. When I tried all I could to get it work and still ended up with the same error all the time, I just sat on my chair, staring at the monitor for a while, wondering if this is somekind of bash's loophole :P.

I was trying to grep through some pidgin facebook chats when I was stuck for a while trying to open a directory with the name starting with a hyphen("-"). I tried all I could think of, but I always ended with the same error.

[shredder12]$ cd -directory
bash: cd: -d: invalid option
cd: usage: cd [-L|-P] [dir]

[shredder12]$ cd \-directory

[shredder12]$ cd *directory

[shredder12]$ cd "-directory"

As you can see the trouble is that the alphabets after a "-", hyphen, are being considered as the command attributes/options but they are not, so what we need here is:

  • a way to tell the command that its not an option
  • or, make the command start with something other than a hyphen

The first method is to use a double-dash "--" before the name. A double-dash means the end of options to that command.

[shredder12]$ cp -- -directory/

For the other way, we need to start the command with something other than a hyphen and still make sure that its the same file.

[shredder12]$ cp ./-directory

Back to summary
How to Wget: Manage network Bandwidth rate and Quota using Wget 
0 vote
By shredder12, on 06/09/2010 at 20:01.
Tweet

While using Wget in scripts or otherwise, mostly when there is a lot of content to be downloaded, we need to set wget's network usage and bandwidth parameters. They both default to unlimited and when there is a lot of download involved, its always a good practice to set the limits. In this article, we will see how to control the bandwidth rate and total usage(quota).

Limit the download bandwidth rate using Wget's --limit-rate option

Just like any other application, wget will try to use the maximum amount of bandwidth available. If you want to control the download rate of wget, then use the --limit-rate flag. Lets say you want to download some video.

[shredder12]$ wget --limit-rate=60k http://foo.bar/video.ogv

This will limit the download rate to 60 KBps. Use "m" for MBps. Wget even accepts a decimal value, e.g. 2.5. This flag is beneficial only for large files. Thats because the implementation of the rate limitation feature takes sometime to achieve the concerned limit. So, it might not appear to be working for small files.

How to Wget: limit network bandwidth usage/quota using Wget's -Q option

The network quota or the total bandwidth usage can also be limited using wget's --quota or -Q attribute.

[shredder12]$ wget --quota 10m http://foo.bar/file.tgz http://foo.bar/otherfile.tgz

Please note that, if quota overflows while downloading a file then further downloading will be stopped once the current file is successfully downloaded. So, if the size of both the files are 8 and 5 MB then it will download both of them. Just like --limit-rate we can use m for Mega Bytes and similarly others. 0 sets the value to be unlimited.

Back to summary
OpenArena - The OpenSource Quake III Arena 
0 vote
By shredder12, on 02/09/2010 at 22:11.
Tweet

Guess where did I play Quake III Arena for the first time. Not place, I am talking about the platform/Operating System. Nope! its not windows, its Linux . Surprised, right? I was too when I found this brilliant opensource version of Quake III Arena aka OpenArena.

While looking for a good one man shooting game in the software center, I bumped into this one which says, "a fast-paced 3D first-person shooting game." I decided to give it a try. After downloading around 300 MB of the packages the game was finally installed and while runnning and shooting weird creatures(some almost nude lady warriors too ) I couldn't believe that even such a game could be totally free.

I was indeed dazzled by the brilliance of this game but since I had never played Quake III Arena before, I never realized that it was almost exactly like it. One day co-author Chia saw me playing it and asked where the hell did I get Quake from? Thats when I came to know I had accidently found something really cool.

After gathering a little info about, I found out that it is actually Quake III Arena. Its built upon ioquake3, based on id tech3, the Quake3 game engine which was opensourced by the company, id software, in Aug 2005.

Thats when OpenArena project was established to built an opensource FPS game derieved from Quake III Arena. ioquake3 is a project aimed to improve the opensource engine further.

If you have been a Quake III Arena fan and miss it on Linux then you should give openarena a try. The one thing that sucks is its incompatibility with the propreitary game. I haven't tried coupling the original with openarena but I guess that won't work. However, its being cross-platorm removes most of the hurdles for network gaming. You can find the listing for online openarena servers here.

Install OpenArena

It is available in repos of almost all common distros. You can easily install it using the package manager. Otherwise, try running these commands.

[shredder12]$ sudo apt-get install openarena     #for Ubuntu or Debian based systems

[root]# yum install openarena    #for Fedora or RedHat based systems

Back to summary
How to mount Linux LVM volume partitions on Linux 
0 vote
By shredder12, on 28/08/2010 at 20:01.
Tweet

So, one of my friends had this weird system breakdown while upgrading Fedora from DVD. Grub couldn't locate the grub.cfg file. In order to fix the system and take a backup of some important files, we booted in a live session, mounted a lvm partition to find out that most of the data was gone . The end was pretty bad but I think, just like in my case, there will be many more who wouldn't know how to mount a lvm partition. This little adventure of mine might help you out.

In case you have to do something similar just follow the steps we took.

1) Once we were in live session, we opened a terminal and ran

[root]# fdisk -l

This lists out the partition table of the system and it looked something like this

Device        Boot   Start       End      Blocks           Id     System
/dev/sda1     *        1           4864     39070048+    7     HPFS/NTFS
/dev/sda2            4865       6691     14675377+    83   LVM2_member
...

2) The good news was that the system was at least able to distinguish the partitions. So, in order to backup the data, the next step was to access the /dev/sda2 partition. But since it is an lvm partition we will had to take some additional steps to mount it.

Now, run the pvs command. Please note that while in live session you may find that this is not installed by default. In order to install the required tools, run the following command.

[shredder12]$ sudo apt-get install lvm2

Of course, you should be connected to internet. Once you are done with this run pvs.

[root]# pvs

This will list the volume groups to which our physical volume /dev/sda2 belonged. It would be of the form

PV               VG                Fmt    Attr    PSize       PFree
/dev/hda2   VolGroup01  lvm2   a-      148.94G   32.00M

The second field, VG, shows the Volume group. The above output is just an example, showing that we are concerned with the Volume group "VolGroup01". The next step is to list the information about this volume group.

[root]# lvdisplay /dev/VolGroup01

It will throw a bunch of ouput, but the one we are concerned with is LV Name. It will look something like this

LV Name /dev/VolGroup01/LogVol00

In our case, there were two entries of type LV Name, the other being LogVol01, the swap. The whole output along with it will help you to identify the target logical volume you are looking for. Assuming that the above one is the partition that we need to mount, just use the usual method to mount it.

[root]# mount /dev/VolGroup01/LogVol00   /mnt

Now, you can to find the data you were looking for in the /mnt folder.

Back to summary
How to Wget - The basics of this great Downloader 
0 vote
By shredder12, on 24/08/2010 at 20:14.
Tweet

Wget is a a powerful, console based network downloader. We are all aware of some good GUI based downloaders, but they would be of no use if you are working on consoles. And once you become aware of what wget is capable of, I am pretty sure you might actually start using it for your day to day needs, even on Graphical Environments.

So, lets begin with the basic syntax.

[shredder12]$ wget http://linuxers.org

For any webpage url, the above command will result in the download of that page(index.html in above case). If its a media(image, audio, video) or any download link, then wget will download the application for you. All of the downloaded stuff will be saved in the current directory.

Wget how to: Download multiple files

For downloading multiple files or weblinks at once just mentions them serially, like this

[shredder12]$ wget http://foo.bar/file1 http://foo.bar/file2

If you have a whole list of download activities then the best method is to store all of them in a file, one URL per line, and give the file as input to wget. Use the --input-file or -i option to do so.

[shredder12]$ wget -i list.txt

The file list.txt should contain the list of URLs. e.g the file list.txt should look something like this

http://foo.bar/file.tgz
http://10.2.3.4/downloads/somefile.ext
ftp://foo.bar/file.ext

Wget how to: Download files of a particular extension only (e.g all .pdf or all .jpeg files)

If you have used bash, you would know that *.pdf refers all the pdf files. The same convention can be used with wget too.

[shredder12]$ wget ftp://foo.bar/downloads/*.pdf

This should download all the pdf files available in the folder. Please note that, this only works for FTP.

Wget how to: Set the name of output file

Use the --output-document=new_filename or -O to set the output file.

[shredder12]$ wget -O software.tgz http://foo.bar/file.tgz

This will rename file.tgz and rename it to software.tgz. This option, -O, is not just for renaming a file. If you are downloading multiple files and mention this option, instead of getting saved as separate files, they will be concatenated into a single one.

Wget how to: set the connection timeout

I mainly use wget in scripts which involves downloading of multiple files and I definitely don't want the download of a single file to become the bottleneck. So, in such cases its better to specify a timeout. The timeout is to tell wget that if its unable to start downloading within that period of time then abort it. It can be easily done using the -T or --timeout flag. It is mostly used with the --tries flag mentioned below

[shredder12]$ wget -T 5 http://foo.bar/file.tgz

Wget will timeout, if the download doesn't start within 5 seconds. You can even use decimal values, say 2.5

Wget how to: set the number of re-tries wget should do before quitting the download

Similar to the timeout flag, this is useful to prevent a single download from becoming the bottleneck. If a download fails a particular number of times then wget should move on to the next one. This is done using the --tries or -t option.

[shredder12]$ wget --tries=5 http://foo.bar/file.tgz

If the download fails, it will abort the operation after 5 tries. The default is 20. Use 0 for infinite.

Wget how to: Run wget in background and log all the output in a file

If you want wget to go to background after startup then use the --background or -b flag. Since, the output won't be printed now, the output messages will be logged. We can either mention the logfile or let the messages get logged in the file named wget-log, which is the default behaviour.

[shredder12]$ wget -b http://linuxers.org
Continuing in background, pid 15278.
Output will be written to `wget-log'.

The --output-file or -o options are used to mention the log file.

[shredder12]$ wget -b -o logfile http://foo.bar/file.tgz

Wget how to: Control Wget's output

Use the -v or --verbose option to print all the available data, this is the default behaviour. If you want to completely turn off the output, use the -q or --quiet option. In order to turn off verbose, get just the errors and basic info use the -nv or --no-verbose option.

Back to summary
My first pocket Operating System - Slax 
0 vote
By shredder12, on 16/08/2010 at 18:45.
Tweet

I never owned a USB flash drive, until recently. I needed one not just for data transfer requirements but because I always wanted to carry an operating system with me. While trying out differnet OSs with various installation methods, my system sometimes had tremendous breakdowns and the only way to access & backup the data was to boot into a LIVE session. Luckily, I came across this really small pocket operating system, Slax. Its just 200 mb and the method to get it bootable on a flash drive is probably the quickest and most effortless of all I have ever used.

Not just for backing up data, sometimes when you are not carrying a laptop and want to access Internet but all the computers nearby are password protected, a bootable USB is your best bet then. Because of its quick boot capability and small size, Slax fits the picture very well. Although you should be careful while doing that, you could be unknowingly breaching someone's privacy.

While I was downloading it, I thought, "What could actually come in just 200 MB?". If this is what's bugging you too, then don't worry, it comes with plenty of pre-installed apps, which should be enough for an average user. And if you want more then Slax's developers provide you with the option to build your own customized slax and download it. You can add various functionalities/apps in the form of modules.

Not just the above things, I really like their options too.

  • Slax Graphics Mode(KDE) - Tries to autoconfigure graphics
  • Slax always fresh - The configurations/changes will never be saved.
  • Slax copy to RAM - Works just like the first one, only faster because the data is in RAM now. Requires > 300MB  of memory.
  • Slax Graphics VESA Mode - Forgets about configuration the card and uses the default VESA driver.
  • Slax Text Mode - Take a guess.
  • Slax as PXE server - This one is my favourite and probably a must for a pocket operating system. Thanks to this feature, I don't just have a single OS but if the systems are wired, I can boot any number of system's using it, haven't tried it though .

The one thing that I hated

So far I am pretty happy carrying Slax in my pocket but if there is one tiny bit that I didn't like in it. It was the weird Chrome like tabs in Firefox.

I am pretty sure developers would have given a lot of thought to it, but I still can't bear it. It looks as if someone kept Firefox's head over Chrome's body . May be its just me...

Back to summary
GraphMonkey - a simple, light-weight graph calculator and plotter 
0 vote
By shredder12, on 16/08/2010 at 11:34.
Tweet

While doing Mathematics assignment in my second semester, I had to look up for a lot of graphs/curves of various functions. I always used gplot, which is no doubt the best tool when it comes to graphs. But usually before using it I had to take a quick look at the keywords in its help guide. Until I found GraphMonkey, I always wondered if there was an even simpler application, which hardly expects you to know anything other than the equation.

One of the best things about this application is its simplicity. The first time I ran it, I just knew how to operate it. This app. could prove to be a nice Educational software.

Install GraphMonkey

This GTK# based app. can be downloaded on Debian/Ubuntu based systems either by clicking this link or by running the following command in the terminal.

[shredder12]$ sudo apt-get install graphmonkey

Fedora doesn't seem to have it.

Once installed, you can find it in Applications->Education.

All it needs is the equation and will generate the graph, when you click trace. It also handles some simple calculus functions.

Because of its ability to automatically plot the derivative graphs, its called a graph calculator. You can also set scale and X & Y ranges.

Inspite of these benefits, it also has a few notable disadvantages.

  • You can provide only explicit equations(y in terms of some function of x).
  • It can't plot more than 3 functions in a graph, excluding the derivative functions.

Gplot is still the God, but this light-weight application could be a nice option for educational purposes.

Back to summary
Live Bandwidth monitoring became easy with Netmonitor screenlet 
0 vote
By shredder12, on 14/08/2010 at 12:26.
Tweet

So, I think my search for a live network bandwidth monitor finally ended with this screenlet, netmonitor. Bmon and vnstat were working fine, but I was looking for something that can be present all the time on the screen without hindering other apps. A Screenlet was indeed the best option to go for. For those who are not aware of screenlets, they are widgets for Gnome-Desktop. As far as appearance goes, they look great on a Desktop and best of all, they are light weight too.

So, while searching for the most appropriate screenlet, I found netmonitor - a bandwidth monitoring tool. You can place it wherever you want and configure it accordingly.

Installation

In order to use netmonitor, you will have to install the screenlets package. If you are running either an Ubuntu/Debian based system then either link or run the following command in a terminal to install screenlets.

[shredder12]$ sudo apt-get install screenlets

Now, go to Applications->Accessories->Screenlets and you will see the following window.

Now, double-click on the icon and it will be activated. Right click on the widget will show you various options to configure it. Modify it however you like and place it wherever you want, thats the benefit of using a screenlet .

Back to summary
Next page »
Powered by BilboPlanet Valid CSS - Xhtml Designed by BilboPlanet Back to top