skip to Main Content

I have created a new user using useradd MyUsername and have given him "sudo" privilege. However, I noticed that I couldn’t use the commands I have installed in root with this user.

For example:

In root : nvm current will show me the current nvm version

In the User : The same command line will give this result : bash: nvm: command not found

I’m using CentOS 7 (I believe). Does anyone have any idea on how to fix this ? Or do I need to download the libraries again in order to use them ?

2

Answers


  1. You have to ensure that the relevant paths are exported.

    While using the root user, you can find out where the nvm bin is using which nvm. For example, /usr/local/bin/nvm. Knowing this, ensure that the path before the nvm is exported in the path, in this example, /usr/local/bin.

    You can add the following to the end of the correct file (see below).
    export PATH="/usr/local/bin:$PATH". What this is doing is that it is adding /usr/local/bin to the start of the PATH.

    You can find out what shell you’re running using echo $0.

    If it is zsh you should examine the .zshrc file and ensure that the correct paths are exported.

    If it is bash you should examine either .bash_profile or .bashrc to ensure the same.

    Login or Signup to reply.
  2. nvm is intended as a PER-USER script, as stated here.
    It is cloned and installed into the home-directory of each individual user.
    Therefore, you need to install it again by following the installation instructions.

    For other commands, please check that your PATH is correct, or if the command is also installed on a per-user basis like nvm.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search