Month: May 2012

How to find command location in Linux?

How to find command location in Linux and Unix This is a small how to on finding your command location. Some times it’s required to find command location to use it as path is not set properly to /bin or /sbin or some other folder. And some times we install packages through scripts where the commands will be installed in a defined path other than /usr/bin or /usr/sbin etc. command to check where the particular command is installed? which command-name Example: which ls Output: root@surendra:/home/surendra# which ls /bin/ls root@surendra:/home/surendra# How about getting with other command along with manual pages? whereis command-name Example: whereis ls Output: root@surendra:/home/surendra# whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz root@surendra:/home/surendra# some times we don’t know where the command is located but still we want to use it, at these times you can use which command to give entire path `which ls` or $(which ls) the above two are very much handy when writing shell scripts when you are not aware/sure where the command located. Please share your thoughts on how you avoid this situation....

Read More

How to setup two IP address on single NIC in Linux

Setting up two IP address on one NIC This is a small how-to to set up two are more IP address on single LAN card. There are some times which require two IP address to set up so that we can make a Linux box as a router. This can be possible without even having two NIC cards. We can configure two different IP address on single Network Card as shown below. Setting up 2 IP address on “One” NIC. This example is on ethernet. STEP 1: Setting up first IP address. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 on Redhat Linux box and give the following entries as shown. vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.1.10 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=yes STEP 2:  Setting up second IP address. Create one file as /etc/sysconfig/network-scripts/ifcfg-eth0:1 and give the entries as below in to this file. vi /etc/sysconfig/network-scripts/ifcfg-eth0:1 DEVICE=eth0:1 BOOTPROTO=static IPADDR=192.168.1.11 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=yes STEP 3:  Once you configure above files and save them. Now reload the network service on your machine. service network reload STEP 4: Check if you get the IP address assigned to the eth0 and eth0:1 interfaces respectively. ifconfig Note1: We can assign virtual IP to the same interface with ifconfig but that one is not permanent so not giving info on that. Note2: We can assign up to 16 virtual IP address to a single NIC card....

Read More

Convert Binary,HEX, Oct to decimal in Linux/Unix

This is a small Shell tutorial on how to convert different bases to other bases. Some times when working as system admin you require to convert different number systems to others. In this post we will see how to convert different number systems to others. Decimal to Binary echo "obase=2; 23" | bc Output: 10111 Let me explain above command. obase is a special variable in bc command which defines the output base value for a given number. There is one more special variable for bc command called ibase which defines input base value. In our example we did not mention ibase so by default it will take my input value as decimal value. So we feed obase=2 and decimal number 23 to bc command to convert decimal 23 in to binary number. Decimal to Octal number echo "obase=8; 23" | bc Decimal to Hex number echo "obase=16; 23" | bc Decimal to any base number convert decimal number to base 4 number system echo "obase=4; 23" | bc How about convert to base 7? echo "obase=7; 23" | bc Binary to decimal echo "ibase=2; 11010101" | bc Oct to decimal echo "ibase=8; 723" | bc Hex to decimal echo "ibase=16; 23" | bc How about converting binary to Oct? echo "ibase=2;obase=8; 1010101" | bc As given above we can convert any number system to any number systems Other...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.