LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   Sudo question (https://www.linuxquestions.org/questions/fedora-35/sudo-question-254208/)

satimis 11-12-2004 09:05 PM

Sudo question
 
Hi folks,

FC2

On running following commands;

$ man visudo
It works

$ su
Password:
# visudo
bash: visudo: command not found

# rpm -qa | grep visudo
# rpm -qa | grep sudoers
both no printout

# rpm -qa | grep sudo*
sudo-1.6.7p5-26

already installed.

# cat /etc/sudoers
Code:

.....
# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)      ALL

# Same thing without a password
# %wheel        ALL=(ALL)      NOPASSWD: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now

Please advise how to run it

TIA

B.R.
satimis

jonr 11-12-2004 09:21 PM

It runs every time you boot. But the way it's set up now the only user given privileges is root. As far as I know, you have to use visudo to change the file--that's what the manual says, anyway. Can you obtain visudo from your installation disks, or maybe download it for your distribution? Then with visudo available, you can refer to the man pages and follow the instructions for adding a user to the sudoers list. It took me a while to figure out the right way, but I got it done eventually.

P. S. Have you tried something like "locate visudo" to see if it's somewhere not in your path? If you just issue the visudo command and the program isn't in your path, it will not be found.


growler 11-13-2004 12:58 AM

try su'ing this way:
Code:

/bin/su -
The '-' at the end allows you to inherit root's profile; leaving the '-' off will switch you to root, but you'll still have your own profile ($PATH, etc.). So what's happening is that you are su'ing to root, but visudo is still not in your path. It's here: /usr/sbin/visudo.

Either do a '/bin/su -', or type the full path to visudo once you su to root. then add yourself to the sudoers file.

Another trick I do is make sure that I have the same $PATH variable as root by editing /etc/profile like so:
Code:

# Path manipulation
if [ `id -u` = 0 ] || [ `id -u` = <your uid here> ]; then

Good luck!

Sledge 11-13-2004 01:55 AM

For what it's worth, on my FC2 install visudo is located in /usr/sbin. You might look there.

satimis 11-18-2004 11:50 PM

Hi growler,

Tks for your advice.
Quote:

- snip -
Another trick I do is make sure that I have the same $PATH variable as root by editing /etc/profile like so:
Code:

# Path manipulation
if [ `id -u` = 0 ] || [ `id -u` = <your uid here> ]; then


$ cat /etc/profile
Code:

.....
# Path manipulation
if [ `id -u` = 0 ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi
....
...

whether change "if [ `id -u` = 0 ]; then" as
"if [ `id -u` = 0 ] || [ `id -u` = <your uid here> ]; then"

|| = OR ???
your uid here = login ???

TIA

B.R.
satimis

growler 11-19-2004 03:26 AM

Quote:

Originally posted by satimis
Hi growler,

Tks for your advice.

<snipped>

whether change "if [ `id -u` = 0 ]; then" as
"if [ `id -u` = 0 ] || [ `id -u` = <your uid here> ]; then"

|| = OR ???
your uid here = login ???

TIA

B.R.
satimis

Yes, || is 'OR' :)

So you are saying 'if the person logging on has a uid of 0 (ie 'root') OR a uid of x, then give her a $PATH of...'

This way you and root both have the same path, so sudo won't constantly complain about not finding certain executables.

Your 'uid' is the identification number that your system knows you by. your login name is only a human-friendly alias for this number. you can find your uid by looking in the /etc/passwd file. The first number is your user id number, and the 2nd is your group id number. you can see the uid numbers associated with files by typing
Code:

ls -ln
-- you will see the uid and gid associated with the files, instead of the human-friendly words. ;)

Good luck, satimis!

satimis 11-24-2004 08:58 PM

Hi growler,

Tks for your advice.

Quote:

... The first number is your user id number, and the 2nd is your group id number. ..
$ ls -ln Standard.doc
-rw-rw-r-- 1 500 500 9728 11æ 19 04:00 Standard.doc

What did the third number '0' and '9728' indicate.

B.R.
satimis


All times are GMT -5. The time now is 11:23 PM.