-1

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?

marked as duplicate by Jeff Schaller, Anthony Geoghegan, roaima, countermode, Thomas Nyman Mar 11 '17 at 11:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    add /sbin to your PATH: export PATH="/sbin:$PATH". – DopeGhoti Mar 10 '17 at 18:22
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.

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