ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Running ROS as a root user

asked 2011-09-23 17:03:07 -0600

HZ gravatar image

Hi All,

Some of my ROS nodes need to be run as a root user. I can do this by "sudo su" under Ubuntu and "source" setup.bash. My programs seem to be running correctly. An annoying issue is that, when I try to use "tab completion" to complete the package name in the terminal (e.g., rosrun package_name executable_name), I got some warnings as follows:

[rospack] WARNING: cannot create rospack cache directory: Permission denied
[rospack] WARNING: cannot create rospack cache directory: Permission denied
[rospack] Unable to create temporary cache file /root/.ros/.rospack_cache.bGXJPX: Permission denied

I have done this: chmod -R a+rwx /root/.ros/, but above warnings still come out.

Any suggestion for solving this problem is appreciated.

edit retag flag offensive close merge delete


If possible, a better solution would be to figure out how to set permissions so ROS nodes need not run as root.
joq gravatar image joq  ( 2011-09-24 03:09:44 -0600 )edit
As joq said already, I cannot think of any circumstance where root permissions are the absolute solution. Tell us why you "need to run as root" and we can probably help you figure it out.
rado0x54 gravatar image rado0x54  ( 2011-09-28 11:27:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-09-26 01:25:08 -0600

DimitriProsser gravatar image

You could add the ROS_PACKAGE_PATH to the root user's .bashrc. In Ubuntu, this is taboo, but in systems where you act as the root user often, it could be helpful.

edit flag offensive delete link more


As @joq commented above it's recommended not to run as root in general and to provide specific processes access to resources if necessary.
tfoote gravatar image tfoote  ( 2011-11-16 09:43:10 -0600 )edit
I don't understand how this answers the question? I'm having the same problem and not having tab completion is very annoying. Please don't tell me I should not run as root, I'm perfectly aware of what I'm doing.
demmeln gravatar image demmeln  ( 2011-11-20 11:56:01 -0600 )edit
Did you add your ROS_PACKAGE_PATH to the root user's .bashrc? Additionally, you can set your ROS_HOME variable to point to your username's directories. I have my root user's ROS_HOME set to /home/me/.ros instead of /home/root/.ros
DimitriProsser gravatar image DimitriProsser  ( 2011-11-21 01:07:00 -0600 )edit
Setting ROS_HOME to my usual users .ros helped somewhat, however now rospack still complains about directories it cant read. Something in rospack or the tab completion stuff is run with non-root privileges, even though i start it from root. It does not really make sense to me.
demmeln gravatar image demmeln  ( 2011-11-26 12:04:44 -0600 )edit

Question Tools


Asked: 2011-09-23 17:03:07 -0600

Seen: 4,447 times

Last updated: Sep 26 '11