Linux goodies … contd .. oss..

0 Flares Facebook 0 Twitter 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×

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



4 Replies to “Linux goodies … contd .. oss..”

Leave a Reply

Your email address will not be published. Required fields are marked *