I'm running Kali Linux Live, and I was using the system as the root user for a long time before I came across an article online telling you NOT to use root as your default account, and that instead you should create a low-privileged user. I ended up doing just that, and everything was OK, until I tried to run ifconfig, to which I received the error: bash: ifconfig: command not found.

I tried running sudo apt-get install ifconfig, but it returned that ifconfig was already the newest version. I was a little confused, so I tried sudo ifconfig, since I had to use sudo to run apt-get. Sure enough, sudo ifconfig worked, and any other commands I need to run that return a similar error work with sudo.

So my problem is that the programs I need to run are stored (I presume) in the root system when I install them with sudo apt-get install, and are therefore unaccessible by non-root users? I'm not sure if that's correct or not. Reading the manual for sudo, I know it runs a command as root (or another user in general), but does that mean the "output is executed" in the root's system? If so, what can I do to run commands as a low-privileged user, besides giving them admin privileges?

Thanks for any and all support!

  • You probably just need to add /sbin to your low-privileged user's PATH – steeldriver Jul 18 '19 at 14:29
  • 1
    Kali Linux is for penetration testing and is meant to be run as root. That article is referring to workstations and servers where it's best not to run with elevated rights unless it's needed. – Nasir Riley Jul 18 '19 at 14:32
  • @steeldriver Forgive my noobiness, but how do you do that? Don't you do something like PATH=/desired/path when you're first setting up a user? – Anonymous Jul 18 '19 at 14:33
  • @NasirRiley I thought it was so programs that are downloaded don't gain admin access without user permission? Is that security measure not necessary with something like how I use Kali (as a pen testing distro but also just to learn Linux)? – Anonymous Jul 18 '19 at 14:36
  • 1
    @Anonymous Kali really isn't the right distro to learn Linux on. It's intended for experienced Linux users who want a platform for things like penetration testing. I'd recommend switching to something else -- almost anything else. – Gordon Davisson Jul 18 '19 at 15:28

The reason you can’t find those commands as a non-root user is because they probably aren’t in your PATH. Run an echo $PATH to see what directories the shell looks in to find the command you input.

System programs and administrative utilities typically reside in /sbin and /usr/sbin. These programs and utilities can be executed by any user (if they have the appropriate file system permissions set), but usually won’t change anything on the system unless executed as root.

You can add new directories to your PATH with something like:

export PATH=$PATH:/path/to/directory

You can run ifconfig and apt-get as non-root users if you want, but you won’t be able to change any configurations or install packages unless you are root.

| improve this answer | |
  • Most likely /usr/sbin. It depends on where ifconfig exists on your system. You can run `which ifconfig‘ as root to figure that out. As I stated in my answer, adding it to your PATH probably won’t do anything because you need to be root to use those commands. – Peschke Jul 18 '19 at 14:41
  • Apart from changing things with ifconfig, that command can most certainly be used by ordinary users without throwing any errors. Also note that the error message does not mention ifconfig but config. Unless it's a typo in the question, it may have been a typo on the command line. – Kusalananda Jul 18 '19 at 14:42
  • Thanks @Peschke, ifconfig now works! And @Kusalananda, I noted config error message as well, but the error was copied straight from the terminal and ifconfig is in my bash hisory. Nonetheless, I will edit it to be more precise. Thank you both for your help! – Anonymous Jul 18 '19 at 14:46
  • Trying again, actually, I opened a new terminal and tried ifconfig again and it returned an error message. So I added export PATH=$PATH:/usr/sbin to .bashrc and it now works. – Anonymous Jul 18 '19 at 14:51
  • 1
    Don't put export PATH=$PATH:/usr/sbin in .bashrc. Instead put it in .profile. .bashrc may be sourced several times, causing your PATH to grow. – ctrl-alt-delor Jul 18 '19 at 15:14

They are in /sbin and /usr/sbin anyone can run them. However it may or may not be useful to do so. If you don't have the capabilities than most of these commands will not do much. User root traditionally has all capabilities. And /sbin and /usr/sbin are not normally in a normal users execute search PATH.

ifconfig is useful as a normal user, but you won't get all features. e.g. /sbin/ifconfig with no arguments, will list all network interfaces.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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