Everytime I need to access ifconfig , I find using using /sbin/ifconfig. If I need to directly type ifconfig in bash and get the required output without calling the directory every time, what should I do?
Asked
Active
Viewed 1,989 times
-1
1 Answers
1
You can add /sbin
to your PATH
. In the file .profile
in your home directory, add the line
PATH="$PATH:/sbin"
See How to correctly add a path to PATH? for more information.
If you only want ifconfig
and not other commands from /sbin
, you could add an alias. In the .bashrc
in your home directory, add
alias ifconfig=/sbin/ifconfig
/sbin
only contains commands that are rarely useful when not running as root. ifconfig
is an edge case: ordinary users can look at the current settings, but only root can change the settings. It's one of the few command that is typically placed in /sbin
yet is commonly useful to ordinary users.
Under Linux, you can display mostly the same information with ip addr
.

Gilles 'SO- stop being evil'
- 829,060
/sbin
to yourPATH
:export PATH="/sbin:$PATH"
. – DopeGhoti Mar 10 '17 at 18:22