1

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!

7
  • You probably just need to add /sbin to your low-privileged user's PATHCommentedJul 18, 2019 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.CommentedJul 18, 2019 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
    CommentedJul 18, 2019 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
    CommentedJul 18, 2019 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.CommentedJul 18, 2019 at 15:28

2 Answers 2

3

They are in /sbin and /usr/sbinanyone 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.

    0

    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.

    6
    • 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
      CommentedJul 18, 2019 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
      CommentedJul 18, 2019 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
      CommentedJul 18, 2019 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
      CommentedJul 18, 2019 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.CommentedJul 18, 2019 at 15:14

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.