1

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

Rich
  • 1,343
  • 7
  • 28
  • 39

5 Answers5

3

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.

Marcel G
  • 2,269
  • 15
  • 24
  • 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 07:08
  • But it's the solution I'll accept! – Rich Oct 20 '10 at 09:05
2

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

krissi
  • 3,387
  • 1
  • 19
  • 22
2

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.

gabbelduck
  • 329
  • 1
  • 3
  • 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 07:09
0

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.

0

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.

David Rickman
  • 3,320
  • 18
  • 16