Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Well, I Stumbled upon a command that connects your wired connection from the command line by issuing this in the terminal; "sudo dhclient3 eth0". But there is also a command called "dhclient". Are they the same? Could I issue the same command as; "sudo dhclient eth0?" Could someone clear up newbie on this issue?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

They are indeed one and the same:

~$ ls -lah /sbin | grep dhclient
lrwxrwxrwx  1 root root      9 2010-12-30 14:38 dhclient -> dhclient3
-rwxr-xr-x  1 root root   402K 2010-08-07 04:49 dhclient3

The arrow indicates that dhclient is a Symbolic Link that points to dhclient3. We can use

test -h /sbin/dhclient
echo $?

to make sure it is; it will return 0, meaning yes.

This is sometimes done to maintain backwards compatibility with older programs and scripts that assume the old command.

If you are writing a program that uses either of those, you should use dhclient3, and manage your dependencies accordingly.


In ls -lah, the arguments mean long listing format, all files, and human readable file sizes. Also, test has nothing to do with symlinks, it's a general utility to test the truth of a statement, the argument -h causes it to work on files, and return True (0) if the file exists and is a symlink.

To find out where the file is, I used the type utility:

type dhclient
dhclient is hashed (/sbin/dhclient)

If you find any two files that aren't symbolically linked, and you suspect they're still the same, you can use a Hash Function to see whether they're the same:

stefano@lenovo:~$ md5sum /sbin/dhclient && md5sum /sbin/dhclient3
fc2491e5c1576783bdc4aa8c5817166e  /sbin/dhclient
fc2491e5c1576783bdc4aa8c5817166e  /sbin/dhclient3
share|improve this answer
1  
ah, that clears my doubt. Thank you for the answer. :) –  Maverick Jan 2 '11 at 8:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.