Changing PATH for root user?

CardboardBox

Registered
It starts to get frustrating when you know exactly what the problem is but can't find the solution.

I just installed Fink and then installed nmap which works with my user account. It won't let me run any stealth scans unless I run nmap as root. I figured out how to enable the root account and I can now su - into it but the path for the root user is different than my user account.

From searching the board I should be able to just create a .bashrc file in the home directory and include the lines

PATH=$PATH:/path_here
export PATH

Well, root doesn't seem to have a home folder. I logged out and logged in as root thinking it might create one but it doesn't. Running the cmd "env" I see "HOME=/var/root" so I tried creating it in there. I logged in with my user account, did an su - and running echo $PATH doesn't include the PATH the put in the file.

Help :)
 
'... unless I run nmap as root.' - ok, log ('sudo bash' <return> password <return>) in as 'root'; and, then execute 'nmap'.

'... but the path for the root user is different than my user account.' - yes, it is.

'root doesn't seem to have a home folder.' - yes, it does.
 
ok that works... but can you explain why?

su - and command not found

sudo bash and it works.

Can you explain the difference? Why does sudo bash do that now changes the path to where nmap is?

Also, I'd stil like to know how to change the path for the root user so I wouldn't have to set it everytime if I run into something else.

I also understand that the root user has a home dir, /var/root but by using a .bashrc file it didn't seem to do anything for the path.

Thanks for the help.
 
The default shell for root is /bin/sh not bin/bash. You can still set the root account up with a customised environment, but you need to do it for the sh shell. You don't need to put the files in root's home directory, though. It's enough to have a suitable set-up in your home directory. My setup is quite complex, but you probably need a ~/.shinit (as opposed to ~/.bashrc) and you may want ~/.profile (as opposed to ~/.bash_profile) as well.
- cfr
 
Back
Top