-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?

gadsater
  • 1
  • 1

1 Answers1

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.