Home > Net >  How to use the commands in Root after creating a new user in Linux?
How to use the commands in Root after creating a new user in Linux?

Time:07-05

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 ?

CodePudding user response:

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.

CodePudding user response:

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.

  • Related