Wim Sturkenboom |
05-21-2007 11:00 PM |
Do not exactly understand question 1, but the following may help:
Your system is setup to look in certain directories when you enter a command. If the command is not in those directories, you have to specify the path in front of the command or navigate to the directory and run the command from there.
Where the system looks is defined by the variable $PATH. Below are two examples, one for a normal user and one for root.
Code:
wim@btd-techweb01:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/usr/share/texmf/bin:.
wim@btd-techweb01:~$ ifconfig
-bash: ifconfig: command not found
wim@btd-techweb01:~$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.190 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8234287 errors:0 dropped:0 overruns:0 frame:0
TX packets:1436852 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:710886591 (677.9 Mb) TX bytes:1034567591 (986.6 Mb)
Interrupt:11 Base address:0xc000
eth0:1 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.191 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
eth0:2 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.192 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
eth0:3 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.193 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:756 (756.0 b) TX bytes:756 (756.0 b)
wim@btd-techweb01:~$
Please note the dot at the end of the PATH. This indicates the current dircetory and allows to directly run from a directory. On other systems, it is not there and you have to use ./myprogram to run myprogram.
Code:
root@btd-techweb01:~# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/usr/share/texmf/bin
root@btd-techweb01:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.190 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8234396 errors:0 dropped:0 overruns:0 frame:0
TX packets:1436964 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:710896857 (677.9 Mb) TX bytes:1034578163 (986.6 Mb)
Interrupt:11 Base address:0xc000
eth0:1 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.191 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
eth0:2 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.192 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
eth0:3 Link encap:Ethernet HWaddr 00:07:E9:3C:D0:4C
inet addr:172.31.212.193 Bcast:172.31.213.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:756 (756.0 b) TX bytes:756 (756.0 b)
root@btd-techweb01:~#
Please note that the current directory is not used in the PATH of the root user. Reason is that a user might have a dangerous command with the same name as a 'normal' command (e.g. ls to delete files). If the root user issues that command while in the user's directory, he might delete the whole system.
|