Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a user on my RHEL5 system whose home folder is /tmp. This user is for running some monitoring tasks, it doesn't represent a human being.

What are the options for modifying this user's PATH environment variable? I would like to add /usr/sbin to the user's PATH so that it has access to the ethtool command.

At the moment this user's path is /usr/bin:/bin.

Thanks in advance

Rich

share|improve this question
add comment

5 Answers 5

up vote 3 down vote accepted

why do you want to change the path? you could simply start ethtool with it's full path

# /usr/sbin/ethtool

As far as I remember though ethtool doesn't do much for a normal user as it requires more privileges, but I might be wrong as it has been quite some time since I used it last.

share|improve this answer
    
Because I'm running a script which calls ethtool. I suppose I could modify the script because the other machine the script is running on will have ethtool in the same place, but that feels like the wrong solution. –  Rich Sep 28 '10 at 7:08
    
But it's the solution I'll accept! –  Rich Oct 20 '10 at 9:05
add comment

First run: #:id FAKE and copy the uid.

Using that result, supplement for the word FAKE in the If statement below.

if [ `id -g` = FAKE]; then
    export PATH=$PATH:/usr/sbin/
fi

Add these lines to your /etc/profile.

Test it with: $:sudo -u FAKE echo $PATH

If that doesn't stick at first, you can force the export by using sudo. $:sudo -u FAKE export PATH=$PATH:/usr/bin/ethtool and then run the test again.

share|improve this answer
    
You can't put the name of the executable in the PATH - only the directory. –  Dennis Williamson Sep 27 '10 at 16:57
    
Thanks, I didn't know that it was a guess on my part. –  David Rickman Oct 1 '10 at 13:38
add comment

I would just give the user a home folder like any other user, and set the appropriate configurations there. Having a user who's home folder is /tmp, which is also writeable by other users is iffy from a security point of view.

You didn't mention what shell the user was configured for - that's important as well.

share|improve this answer
    
The shell is /bin/sh. As for the user not having a normal home folder, that's just how I found it - I suppose I could speak with the UNIX guys here and see what they say, but the fact is the other machine's PATH is correctly set despite there being a non-standard home folder. –  Rich Sep 28 '10 at 7:09
add comment

You could also probably add a symlink to ethtool inside /usr/bin

i.e.

ln -s /usr/sbin/ethtool /usr/bin/ethtool

This would circumvent having to mess with the fake user's path.

share|improve this answer
    
This is bad security. –  David Rickman Oct 1 '10 at 19:22
add comment

you could change this in /etc/profile. There should be already a statement to set these paths for root.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.