RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Linux administration notes & code snippets

Set and Get environmental shell variable using c++

Last Updated on Sunday, 06 June 2010 07:43 Saturday, 05 June 2010 15:11

Here is a small example on how to set and get environmental variables using getnenv() and putenv() functions defined by C/C++ stdlib.h library. Environmental variable expansion is a great feature of a Linux shell as it enables programmers and users to rely on the environment settings of each user separately. C++ getenv() will read all exported environmental variables and putenv() will set existing or create new variables. Here is a small c++ program which can do this job:

 
#include <stdlib.h> 
#include <iostream> 
 
int main() { 
 
// get and print shell environmental variable home 
std::cout << "SHELL = " << getenv("SHELL") << std::endl; 
std::cout << "MYENV = " << getenv("MYENV") << std::endl; 
 
//set new shell environmental variable using putenv 
char mypath[]="TEMP=/my/new/temp/path/"; 
putenv( mypath ); 
 
std::cout << "TEMP = " << getenv("TEMP") << std::endl; 
 
return 0; 
 
}

Now lets' try to export new shell environment variable MYENV:

$ export MYENV=linuxconfig.org

Compile c++ program:

$ g++ shell_env.cpp -o shell_env

Run:

$ ./shell_env

Output:

SHELL = /bin/bash
MYENV = linuxconfig.org
TEMP = /my/new/temp/path/

Share this linux post:

Submit Set and Get environmental shell variable using c++ in Delicious Submit Set and Get environmental shell variable using c++ in Digg Submit Set and Get environmental shell variable using c++ in FaceBook Submit Set and Get environmental shell variable using c++ in Google Bookmarks Submit Set and Get environmental shell variable using c++ in Stumbleupon Submit Set and Get environmental shell variable using c++ in Technorati Submit Set and Get environmental shell variable using c++ in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
 

Clone / Burn Encrypted DVD using Linux

Last Updated on Saturday, 05 June 2010 15:49 Friday, 04 June 2010 22:19

By default K3b or brasero burning software will refuse burn encrypted dvd. One way to overcome this problem is by using libdvdcss library whish allows K3b or brasero to look at your encrypted DVD within DVD-device as a block device and thus disregarding its encryption. Before running K3b or brasero install libdvdcss library to allow it clone / burn encrypted DVD.


On Debian or Ubuntu  libdvdcss installation to allow K3b burn encrypted DVD's:

apt-get install libdvdcss2

If you are using debian and libdvdcss2 is missing make sure that you have www.debian-multimedia.org in your repository. Once done palce encrypted DVD into your DVD-Burner and start copy.

Share this linux post:

Submit Clone / Burn Encrypted DVD using Linux in Delicious Submit Clone / Burn Encrypted DVD using Linux in Digg Submit Clone / Burn Encrypted DVD using Linux in FaceBook Submit Clone / Burn Encrypted DVD using Linux in Google Bookmarks Submit Clone / Burn Encrypted DVD using Linux in Stumbleupon Submit Clone / Burn Encrypted DVD using Linux in Technorati Submit Clone / Burn Encrypted DVD using Linux in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

How to get wdiddle3 to set iddle timer for WD EARS drive

Last Updated on Thursday, 03 June 2010 00:06 Wednesday, 02 June 2010 23:53

Here are simple to follow steps on how to disable and set timer for head parking with WD EARS drive. To do this task we are going to use wdiddle3 utility developed by Wester Digital. According to the Western Digital the wdiddle3 utility was not designed to be used with EARS drives so no warranty ! In particula my own drive did not take it well when i completelly disabled parking idle timer as I could hear strange clicking sound almost every second.

 

The utility runs only from a DOS so we need to use freedos.

 

  1. get freedos iso ( fdfullcd.iso (153MB) ) and burn it to cd-rw ( 153MB ) with multi-session
  2. get wdidle3 utility: http://support.wdc.com/product/download.asp?groupid=609&sid=113
  3. there are suggestions to burn freedos and wdidle3 on the same cd using multi-session but that did not work for me from some reason. What i did was that I had 2 cd-rw cd's . One with freedos bootable and second with wdidle3 on it.
  4. reboot with freedos cd
  5. I had some problems with cdrom the only thing that worked was to after boot hit ENTER and then choose 1 " install to hard... " Select language to ENG and then Run free dos from CDROM
  6. then you get to the prompt with X: which is your cdrom. Swap disc's now. list files with dir command to make sure that wdidle3.exe is in your current directory and then enter:
X:>wdidle3 /D 

to this will disable

Idle3 Timer is Disabled

or

X:>wdidle3 /S255

to set timer to 4.5 min where you can choose number from 1 to 255 mil sec

Share this linux post:

Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Delicious Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Digg Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in FaceBook Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Google Bookmarks Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Stumbleupon Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Technorati Submit How to get wdiddle3  to set iddle timer for WD EARS drive   in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

linux nVidia MCP55 forcedeth module is not working

Last Updated on Friday, 04 June 2010 16:57 Wednesday, 02 June 2010 09:48

This problem with forcedeth module seem to affect all major Linux distributions. Year 2008 was the first time I reported this issue on a ubuntu bug tracking system. Just recently I have installed around 6 Linux distribution and in all of them my nVidia Corporation MCP55 Ethernet (rev a2) network card does not work and this includes latest fedora 13. The fix is still the same:

rmmod forcedeth
modprobe forcedeth msi=0 msix=0

Ubuntu and Debian users can make this fix permanent with:

echo options forcedeth msi=0 msix=0 >> /etc/modprobe.d/options
update-initramfs -u
reboot

Share this linux post:

Submit linux nVidia MCP55 forcedeth module is not working in Delicious Submit linux nVidia MCP55 forcedeth module is not working in Digg Submit linux nVidia MCP55 forcedeth module is not working in FaceBook Submit linux nVidia MCP55 forcedeth module is not working in Google Bookmarks Submit linux nVidia MCP55 forcedeth module is not working in Stumbleupon Submit linux nVidia MCP55 forcedeth module is not working in Technorati Submit linux nVidia MCP55 forcedeth module is not working in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

Time your off-peak download with at Linux command

Last Updated on Sunday, 30 May 2010 22:33 Sunday, 30 May 2010 22:26

Not everyone has unlimited Internet download. Sometimes Internet provides provide peak and off-peak hours and hardly is someone going to stay up at night to trigger their downloads.

There are many tools in Linux which allows user to set a timer to automatically start download without user intervention. Here is a simplest form of automatic off-peak download involving at, wget and shutdown command. First create a file which will contain wget and shutdown commands:

mydownloads.txt:

wget ftp://ftp.redhat.com/pub/redhat/rhel/beta/6/i386/iso/RHEL6.0-20100414.0-AP-i386-DVD1.iso
wget http://ftp.monash.edu.au/pub/linux/CentOS/5.5/isos/i386/CentOS-5.5-i386-bin-DVD.iso
shutdown -h now

Now use at command to execute all command within mydownloads.txt file:

at -m 02:00 < mydownloads.txt

At command will automatically start download at 2AM and when downloads are finished it will shutdown your PC.

NOTE: For shutdown you need sudo or run command as root

Share this linux post:

Submit Time your off-peak download with at Linux command in Delicious Submit Time your off-peak download with at Linux command in Digg Submit Time your off-peak download with at Linux command in FaceBook Submit Time your off-peak download with at Linux command in Google Bookmarks Submit Time your off-peak download with at Linux command in Stumbleupon Submit Time your off-peak download with at Linux command in Technorati Submit Time your off-peak download with at Linux command in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

Bash script to test hard drive transfer speed

Last Updated on Saturday, 29 May 2010 12:54 Saturday, 29 May 2010 10:28

Here is a small bash script to test a hard drive transfer speed. It should be take as an approximation. The speed value is taken from Linux dd command output. One way to test your hard drive speed is to use hdparm command:

# hdparm -Tt /dev/sda

OUTPUT:

/dev/sda:
Timing cached reads: 7216 MB in 2.00 seconds = 3615.89 MB/sec
Timing buffered disk reads: 288 MB in 3.00 seconds = 95.87 MB/sec

However, in this case the hdparm command is accessing raw hard drive, disregarding all partitions and file systems. The weakness of the following script is that it does not take source hard drive reading speed into consideration, however it is accurate when measuring transfer speed between two hard drives or speed between two nodes over the network using NFS or samba. Run the script with 3 arguments, source file, destination file and number of runs to make an average:

NOTE: If you do not have a file to copy simply create one by running a following command for couple seconds and interrupt with CTRL+C:

$ cat /dev/zero > myfile.zero

speed_test.sh :

#!/bin/bash

# USAGE:
# ./speed_test.sh /path/to/my/file /path/to/destination number_of_tests

NUM_TESTs=$3
SUM=0
for i in $( seq 1 $NUM_TESTs ); do

REC=`dd if=$1 of=$2 2> some_random_file_ ; cat some_random_file_ | cut -d " " -f8 | tail -1`

SUM=`echo $SUM + $REC | bc`

done

RESULT=`echo $SUM / $NUM_TESTs | bc | awk '{ str1=str1 $0 }END{ print str1 }'`

echo $RESULT MB/s

#clean up
rm some_random_file_
rm $2

./speed_test.sh /mnt/sdb1/ubuntu.iso /mnt/sda1/ubuntu.dd 3

OUTPUT:

57 MB/s

Share this linux post:

Submit Bash script to test hard drive transfer speed in Delicious Submit Bash script to test hard drive transfer speed in Digg Submit Bash script to test hard drive transfer speed in FaceBook Submit Bash script to test hard drive transfer speed in Google Bookmarks Submit Bash script to test hard drive transfer speed in Stumbleupon Submit Bash script to test hard drive transfer speed in Technorati Submit Bash script to test hard drive transfer speed in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

How to crash your Linux system with fork bomb

Last Updated on Friday, 28 January 2011 19:55 Sunday, 23 May 2010 17:43

Here is a simple way to crash your Linux system as a non-root user with a bash function called recursively.

$ :(){ :|:& };:

:() is a function which gets called recursively from its body and cannot be killed since it is running on the background with &. : is actually the name of the function.
Here is the same function call in human readable format:

forkbomb(){ forkbomb | forkbomb & }; forkbomb

As you can see the function is calling its self twice in the body. This will start consume all resources of your system and eventually force your Linux system to crash. To get more understanding type simple function on your command line. The following function is harmless:

$ fork_bomb(){ echo "FORK BOMB"; };
$ fork_bomb
FORK BOMB

You can take same measures to ensure that your Linux users would not exploit fork bomb. Fork bomb is not a bug nor weakness of Linux system. The responsibility is in hands of systems administrators to limit number of processes available for a user by editing /etc/security/limits.conf file. To limit username forkbomb to only 50 processes add following line:

forkbomb             hard    nproc           50

If you want to limit entire group called forkbomb to only 100 processes add a line below:

@forkbomb              hard    nproc           100

To make limit of 100 processes as a default value for all users add a followng line:

@forkbomb              hard    nproc           100

Share this linux post:

Submit How to crash your Linux system with fork bomb in Delicious Submit How to crash your Linux system with fork bomb in Digg Submit How to crash your Linux system with fork bomb in FaceBook Submit How to crash your Linux system with fork bomb in Google Bookmarks Submit How to crash your Linux system with fork bomb in Stumbleupon Submit How to crash your Linux system with fork bomb in Technorati Submit How to crash your Linux system with fork bomb in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

Change mac address with macchanger Linux command

Last Updated on Sunday, 23 May 2010 00:07 Saturday, 22 May 2010 23:54

In some situations you need to fake / change / spoof a MAC address of your network interface. macchanger Linux command does this job in no time. With this tool you can change your mac address of any Ethernet network device wired or wireless.
Here is a small example:

My original mac address:

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:16:d3:23:7c:f7
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:ee000000-ee020000

Turn off your network interface:

# ifconfig eth0 down

Use macchanger to randomly generate new MAC address and assign it to eth0 network interface:

# macchanger -r eth0
Current MAC: 00:16:d3:23:7c:f7 (unknown)
Faked MAC:   32:cf:cb:6c:63:cd (unknown)

In case you see a following error message:

ERROR: Can't change MAC: interface up or not permission: Cannot assign requested address

Make sure that your interface is down and you are running macchanger as a root user.
Enable eth0 network interface and check new MAC address:

# ifconfig eth0 up
# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 32:cf:cb:6c:63:cd
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:ee000000-ee020000

If for example a specific MAC address is required use macchanger as follows:

# macchanger -m b2:aa:0e:56:ed:f7 eth0
Current MAC: 32:cf:cb:6c:63:cd (unknown)
Faked MAC:   b2:aa:0e:56:ed:f7 (unknown)

macchanger also allows you to change mac address for a specific network card vendor. Use a -l option to print a list of all know network card vendors.

Share this linux post:

Submit Change mac address with macchanger Linux command in Delicious Submit Change mac address with macchanger Linux command in Digg Submit Change mac address with macchanger Linux command in FaceBook Submit Change mac address with macchanger Linux command in Google Bookmarks Submit Change mac address with macchanger Linux command in Stumbleupon Submit Change mac address with macchanger Linux command in Technorati Submit Change mac address with macchanger Linux command in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

Example of simple bash script ftp client

Last Updated on Sunday, 16 May 2010 18:49 Sunday, 16 May 2010 15:13

Very often I need to upload some files to my web server from a command line. entering a user name and password, changing directory can be little tedious work. Here is a small bash script which make this work easier. This script first defines a variables such as hostname of the ftp server, username and password and then it creates ftp session and uploads file into your selected directory:

#!/bin/bash

ftp_site=myhostname
username=myusername
passwd=mypass

PS3='Select a destination directory: ' 

# bash select
select path in "." "public_html/" "public_html/myblog/" "backup/images/" 
do
ftp -in <<EOF
open $ftp_site
user $username $passwd
cd $path
put $1
close 
bye
EOF
echo $1 uploaded to $path ! 

# Break, otherwise endless loop
  break  
done

EXECUTE:

$ chmod +x ftp_bash_script.sh
$ ./ftp_bash_script.sh file1

OUTPUT:

1) .                    3) public_html/myblog/
2) public_html/         4) backup/images/
Select a destination directory: 2
file1 uploaded to public_html/ !

Share this linux post:

Submit Example of simple bash script ftp client in Delicious Submit Example of simple bash script ftp client in Digg Submit Example of simple bash script ftp client in FaceBook Submit Example of simple bash script ftp client in Google Bookmarks Submit Example of simple bash script ftp client in Stumbleupon Submit Example of simple bash script ftp client in Technorati Submit Example of simple bash script ftp client in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.
Add a comment
   

More Articles...

Page 9 of 16