Linux goodies … contd .. oss..

Temporary Increase of SWAP size through a file.

1. dd if=/dev/zero of=/tmp/MyTempSwapFile bs=1024 count=65536
“Define Size of the file 1024*64=65536 i.e. 64MB of file
2. mkswap /tmp/MyTempSwapFile “Create File
3. swapon /tmp/MyTempSwapFile “Swap On
4. /tmp/MyTempSwapFile swap swap defaults 0 0 “Fstab entry
5. Check in /proc/swaps


Autonegotiation off

ethtool -s eth0 speed 100 duplex full autoneg off

The above command will set the network card to 100Mbps Full Duplex with Autonegotiation off



LVM can be implemented on RAID, here is how u can do it.

Login as root and create 2 partitions with 1500MB (or any value u like, provided u have the required free space) using fdisk. Set the partitions type to ‘fd’, save and exit from fdisk. Run “partprobe” (without quotes!), this instructs kernel to recognise the newly created partitions or reboot linux.

Assuming the new partitions created are /dev/sda7 and /dev/sda8, run these commands:
mkfs -t ext3 /dev/sda7 (creates ext3 filesystem on the partition)
mkfs -t ext3 /dev/sda8

To Create a RAID device with any of these 2 commands
mdadm –create /dev/md0 -level=1 –raid-devices=2 /dev/sda7 /dev/sda8
(creates a raid device, md0. md=multiple device)
mdadm -C /dev/md0 -l 0 -n 2 /dev/sda7 /dev/sda8

mdadm –query /dev/md0 or #mdadm -Q /dev/md0
mdadm –detail /dev/md0 or #mdadm -D /dev/md0
cat /proc/mdstat

Moving on to LVM,
pvcreate /dev/md0 (creates a physical volume)
vgcreate redhat /dev/md0

(creates a volume group by the name “redhat”)
vgscan (optional)
vgdisplay (optional)
lvcreate -L +800M -n linux /dev/redhat
(creates a logical volume of size 800MB)
lvscan (optional)
lvdiplay (optional)
mkdir /mnt/lvm
mount /dev/redhat/linux /mnt/lvm


wget & proxy authentication

wget is a fine tool for automated downloads. but since it lacks interactive nature, it accepts passwords as clear text arguments. to rectify this, use following simple c program which acts as an interface for wget:
// code < save it as wgetcurses.c>
int main(int argc,char *argv[]) {
char pass[10];
char command[100];

printf(“Enter the proxy authentication password:”);
sprintf(command,”wget –proxy-user=csu02138 –proxy-passwd=%s %s”,pass,argv[1]); //replace csu02138 with something appropriate !
return 0;
//end of code

compile it with the following command ..
cc -lncurses -o nwget wgetcurses.c

now, your normal wget command ( for eg wget ) will just become nwget
after typing the above command you will be prompted for authentication password, supply the same and off u go !

similar scripts can be written for other commandline programs like lynx etc.

shell script compiler—(shc)

Shc is a generic shell script compiler. It takes a script which is specified on the command line and produces C source code. The generated source code is then compiled and linked to produce a stripped binary executable.


Simple folder/file sharing can be done like this:

Simple share a folder/file between Unix machines:-
There are two ways to do that:
1)create a folder under /tmp and assign 755 permissions to that folder so everyone can read the contents but can’t modify.
Create a group, add desired members, assign 775 permissions so that only group members have read write permissions and others read and execute.
Lot of permutation combinations are possible to do that, but best way is to create that folder on locations such as:-

For sharing between Unix & MS Windows use SAMBA Share.


Selenium —– a test tool for web applications

Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh. No other test tool covers such a wide array of platforms.
* Browser compatibility testing. Test your application to see if it works correctly on different browsers and operating systems. The same script can run on any Selenium platform.
* System functional testing. Create regression tests to verify application functionality and user acceptance.


Managing Bash command history

The Bash shell is the default shell environment in most Linux distributions, including all flavours of Red Hat. One default feature of the Bash shell is to record a history of all the commands entered by a user in a log file called .bash_history, found in the user’s home directory.The history in this file can be retrieved from the command line using the more or cat binaries or by using the internal Bash command, history. For many users, it is useful to retrieve the previously executed commands, usually to save the effort of re-typing them.So why might we want to limit or disable this Bash command history? Well, among the commands that your users type are file names, command names, IP addresses, passwords and a myriad of other data that are potentially valuable to an attacker intent on subverting or compromising your host. Keeping a record of this data means an attacker may only need to compromise an individual .bash_history file rather than a more difficult source of data.To limit the size and behaviour of the .bash_history file, you need to edit the behavior of the shell in the /etc/profile file (the central version of the .bash_profile file usually contained in users home directories). Add or change the following three lines to the file:
export HISTSIZE=100
The first two lines set the length and size of the history stored in the file. The last line unsets the HISTFILE variable that tells the Bash shell not to save history when the user logs out of the interactive session. This means an online user will only be able to see the history of the last 100 commands, and that history will disappear after the user logs out of the host.
A further way to ensure the command history is removed is to include a command in the .bash_logout file (other shells use the .logout file). The contents of the .bash_logout file are executed when the user logs out. You can see a simple .bash_logout file on the following lines:
# ~/.bash_logout
/bin/rm -f $HOME/.bash_history

Some Linux goodies…. < /dev/null :)

uptime – Prints the system uptime.
w – Prints the current system users.
wall – Prints a message to each user except those who’ve disabled message reception. Type Ctrl-D to end the message.
no root!
If /etc/securetty is world writeable then root will not be able to log in.
Permission of /etc/securetty is 600
If you change this to 606, root can not log in.
how to make ur floppy bootable…???
fdformat /dev/fd0
mkfs /dev/fd0
mount /dev/fd0
cp ks.cfg /media/floppy

in the prompt type (without quotes) “linux ks=floppy”
wants to automount the samba shares
Edit the /etc/auto.master file

vi /etc/auto.master

# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(8).
/misc /etc/auto.misc –timeout=60

Then save this file

Now edit the /etc/auto.misc file
vi /etc/auto.misc

# $Id: auto.misc,v 1.2 1997/10/06 21:52:04 hpa Exp $
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

samba -fstype=smbfs,username=[username],passwo

rd=[password] ://server/share

# the following entries are samples to pique your imagination
#linux -ro,soft,intr
#boot -fstype=ext2 :/dev/hda1
#floppy -fstype=auto :/dev/fd0
#floppy -fstype=ext2 :/dev/fd0

Then restart the autofs service


More coolest ones….. Linux useful

File system navigation / directories
* pwd [options] – to obtain/print the name of your current/working directory.
* cd [options] [directoryname | ~ | ./ | ../ | – ] – to change your working directory.
* ls [options] directoryname – to list the contents of directories.
* mkdir [options] directoryname – to create new directories.
* rmdir [options] directoryname – to remove/delete directories.
* cp [options] source destination – to copy files and directories.
* mv [options] source destination – to move files and directories.
* rm [options] filenamelist – to remove/delete files.

Exiting from a shell prompt (to close a terminal window or to log out)
* exit
* or by pressing – the general end of text control character.


Searching for files by name
* locate [options]
* find [options]
* slocate [options]

Viewing text files

* cat [options] filename – to display the file contents without pause or break.
* less [options] filename – to display file contents page by page.
* more [options] filename – to display file contents page by page.
* tail [options] filename – to display the last few lines of a file.
* head [options] filename – to display the first few lines of a file.


Traces the existing network routing for a remote or local server
Most common use: traceroute hostname
(replace hostname with the name of your server such as
This is a very powerful network command that basically gives the exact route between your machine and a server. In some cases you can actually watch the network hops from country to country across an ocean, through data centers, etc.
This comes in handy when trying to fix a network problem, such as when someone on the network can not get access to your server while others can. This can help identify the break or error along the network line. One strong note to you is not to misuse this command! When you run the traceroute everyone of those systems you see listed also sees YOU doing the traceroute and therefore as a matter of etiquette and respect this command should be used when necessary not for entertainment purposes. A key characteristic of gainfully employed server administrators: knowing when to use commands and when not to use them!