Linux goodies …contd…..

Check UR system state

vmstat -memory information
dmesg -booting information
top -process management and mem information
nmap – number of ports open
netstat -network statistic


How to configure a linux box to act as a ROUTER

There are two ways of doing the same :

1. echo 1 >> /proc/sys/net/ipv4/ip_forward
Though the effect of this command cannot survive a reboot & a re-run of the above command or specifying the same in any of the startup script will be enough to keep your linux box forwarding packets.

2. You can edit /etc/sysctl.conf & change the value of net.ipv4.ip_forward = 1 . But you got to restart your box to bring it in effect.


Consolidate your radio streams with streamtuner

Streamtuner is a point-and-click GUI browser for the thousands of Internet radio streams available today. It lets you play streams and manage your favorites in a single window — like a Linux tuner for Internet radio.

Streamtuner has a GTK 2.0 interface and is published under the revised BSD license. It lets you use plugins to browse and search popular portals including SHOUTcast and Icecast.

You don’t need streamtuner to listen to Internet radio stations, of course — the usual method is to go to a station’s stream page, or its entry in a portal like SHOUTcast, and click on the stream link to start an audio player. But streamtuner gives you a way to consolidate all of your favorite streams, find new ones, and play and record them in one place. It’s essentially an X Window front end that pulls together all the existing pieces; the play and record mechanisms are farmed out to other applications (XMMS and Streamripper are the respective defaults).


Cut and paste text files by columns

Here’s a generic UNIX way: (startcol and endcol refer to character columns, including whitespace. Tab counts as 1.)
cut -cstartcol-endcol file {>receiving file} paste sourcefile1 sourcefile2 {>final file}



In the .login file add the commands:

echo login time `date` >> .daylogs/masterlog

grep -i “sun” .daylogs/masterlog > .daylogs/sunday.log
grep -i “mon” .daylogs/masterlog > .daylogs/monday.log
grep -i “tue” .daylogs/masterlog > .daylogs/tuesday.log
grep -i “wen” .daylogs/masterlog > .daylogs/wensday.log
grep -i “thu” .daylogs/masterlog > .daylogs/thursday.log
grep -i “fri” .daylogs/masterlog > .daylogs/friday.log
grep -i “sat” .daylogs/masterlog > .daylogs/saturday.log

In the .logout file add this line

echo logout time `date`>> .daylogs/masterlog

This script assumes you have a hidden
directory called .daylogs this helps keep it
out of sight and away from prying eyes and
if you keep root ownership of the directory
change the mode to:

chmod 744 .daylogs

This will not allow anyone to get in to the
directory to look around.


Multiple X-Sessions….

Using multiple X-Sessions allows a user to have open more than just one instance of XFree, so multiple desktop environments can be used at a time.

startx — :

terminal name is simply which terminal X should start on. By default it starts on

0:0. If you want two open, you may want it open on 0:1, which can be run by:

startx — :1

The resulting desktops will exist on F7 – F12.


gzexe command

gzexe command
gzexe [option] [files]

Compress executables. When run, these files automatically uncompress, thus trading time for space. gzexe creates backup files with a tilde at the end (filename~). These backup files can be deleted once you are sure the compression has worked properly.

-d Decompress files.


“You can edit /etc/sysctl.conf & change the value of net.ipv4.ip_forward = 1 . But you got to restart your box to bring it in effect.”

u can use #sysctl -p without restart the system, it will load the current setting from …../sysctl.conf file.

#lsof -p <pid> :to see the list of open files by that process.


Finding Who Has a File Open

How often do mounts and umounts fail because you can’t determine what is using the device? How many times can you not eject a CD because something’s got it open? How many times have you experienced a “file browser” that keeps a directory open even after you’ve navigated out of that directory and clicked the “refresh” button? Who’s got this thing open??? Use thefuserprogram to find out:

[piyush@ test]$ /sbin/fuser -mu /d
/d: 1693(piyush) 1891c(piyush) 1894 1894c(piyush)
1907 1907c(piyush) 1908 1908c(piyush) 1909 1909c(piyush)
1910 1910c(piyush) 1912 1912c(piyush) 1913 1913c(piyush)
[piyush@ test]$

You get the owner and the process ID. From there you can research using ps ax.

Be sure to look at the fuser man page for details on other info you can obtain. You can even kill all processes accessing a file, though I highly recommend against such a heavy handed move.