PDA

View Full Version : sudo doesnt work. (sudoers problem)



arshad3m
30th July 2008, 03:19 PM
hai guys,
i activated sudo using this command



echo 'arshad ALL=(ALL) ALL' >> /etc/sudoers



and after that i tried to install some codecs using the following command



sudo yum install xmms xmms-mp3 xmms-faad2


this is what the error message i get.


[Arshad@localhost ~]$ sudo yum install amarok amarok-extras-nonfree amarok-visualisation
>>> sudoers file: syntax error, line 93 <<<
sudo: parse error in /etc/sudoers near line 93


please help me.

thanks in advance.

oneofmany
30th July 2008, 03:23 PM
given that it says line 93, there's obviously something else in your sudo file.

if the last line didn't end with a carriage return (\n) then you've just appended to the end of it, potentially making an invalid entry.

what does it show if you cat /etc/sudoers?

oneofmany
30th July 2008, 03:25 PM
you should also probably use visudo to amend /etc/sudoers file as it prevents two users from editing the file at the same time and it also provides limited syntax checking :)

arshad3m
30th July 2008, 03:27 PM
given that it says line 93, there's obviously something else in your sudo file.

if the last line didn't end with a carriage return (\n) then you've just appended to the end of it, potentially making an invalid entry.

what does it show if you cat /etc/sudoers?

this is what i get



## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.

## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2

## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem


## Command Aliases
## These are groups of related commands...

## Networking
Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

## Installation and management of software
Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum

## Services
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig

## Updating the locate database
Cmnd_Alias LOCATE = /usr/sbin/updatedb

## Storage
Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount

## Delegating permissions
Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp

## Processes
Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall

## Drivers
Cmnd_Alias DRIVERS = /sbin/modprobe

# Defaults specification

#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
# You have to run "ssh -t hostname sudo <cmd>".
#
Defaults requiretty

Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL

## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

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

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

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users localhost=/sbin/shutdown -h now

arshad all=(all) all
arshad all=(all) all
arshad ALL=(ALL) NOPASSWD:ALL
Arshad ALL=(ALL) NOPASSWD:ALL
[root@localhost Arshad]#

oneofmany
30th July 2008, 03:33 PM
ok, none of those entries is completely correct. not to mention the duplicates.

use visudo
remove the 4 entries
add the line...


%arshad ALL=(ALL) NOPASSWD: ALL


this assumes that you have a group arshad for your user arshad which is usually the case. anyone in that group will be able to sudo any command without requiring a password

arshad3m
30th July 2008, 03:34 PM
please can you give me the all the commands i have to type.
i am very new here.

thanks in advance.

briantan
30th July 2008, 03:39 PM
this is what i get



arshad all=(all) all
arshad all=(all) all
arshad ALL=(ALL) NOPASSWD:ALL
Arshad ALL=(ALL) NOPASSWD:ALL
[root@localhost Arshad]#



your third attempt is ok, but sudo is complaining about your first attempt.

# visudo
delete all but your third attempt.
(cursor down to the unwanted line, enter "dd")
(deleted the wrong line, enter "u" to undo)
(when done, enter ":x")

arshad3m
30th July 2008, 03:41 PM
now what is the complete command i should type.
please.

thanks

briantan
30th July 2008, 03:43 PM
see post #7

You could use gedit or any of your favorite "text" editor instead of vi

# gedit /etc/sudoers

oneofmany
30th July 2008, 03:44 PM
assuming you are at a command prompt, logged in as root..

1. make sure caps lock is OFF

2. enter "visudo" and press enter

3. press and hold shift key then press g, then let go of g then let go of shift. this will take you to the bottom of the file

4. use up arrow until cursor is on the first line of "arshad all=(all) all"

5. enter "4dd" (no need to press enter). this will say "4 fewer lines" at the bottom left.

6. press "o" this will say "-- INSERT --" at the bottom left.

7. enter "%arshad ALL=(ALL) NOPASSWD: ALL" (where the spaces are tabs, except after the : which is a space) then press enter

8. press escape

9. enter :x then press enter

that should take you back to the command prompt and tell you whether it was successful or not :)

arshad3m
30th July 2008, 03:46 PM
see post #7

You could use gedit or any of your favorite "text" editor instead of vi

# gedit /etc/sudoers


this is the message


[Arshad@localhost ~]$ arshad ALL=(ALL) NOPASSWD:ALL
bash: syntax error near unexpected token `('
[Arshad@localhost ~]$ Arshad ALL=(ALL) NOPASSWD:ALL
bash: syntax error near unexpected token `('
[Arshad@localhost ~]$ arshad all=(all) all
bash: syntax error near unexpected token `('
[Arshad@localhost ~]$ visudo arshad all=(all) all
bash: syntax error near unexpected token `('
[Arshad@localhost ~]$



what should i do? :confused:

thanks

arshad3m
30th July 2008, 03:50 PM
assuming you are at a command prompt, logged in as root..

1. make sure caps lock is OFF

2. enter "visudo" and press enter

3. press and hold shift key then press g, then let go of g then let go of shift. this will take you to the bottom of the file

4. use up arrow until cursor is on the first line of "arshad all=(all) all"

5. enter "4dd" (no need to press enter). this will say "4 fewer lines" at the bottom left.

6. press "o" this will say "-- INSERT --" at the bottom left.

7. enter "%arshad ALL=(ALL) NOPASSWD: ALL" (where the spaces are tabs, except after the : which is a space) then press enter

8. press escape

9. enter :x then press enter

that should take you back to the command prompt and tell you whether it was successful or not :)


thank you for your reply. but this is the error message



[Arshad@localhost ~]$ visudo
bash: visudo: command not found

[Arshad@localhost ~]$ su
Password:
[root@localhost Arshad]# visudo
bash: visudo: command not found
[root@localhost Arshad]#
[root@localhost Arshad]#


what shoudl i do?

thanks

oneofmany
30th July 2008, 03:52 PM
you need to do "su -" instead of "su" so that you get root's environment :)

arshad3m
30th July 2008, 03:53 PM
see post #7

You could use gedit or any of your favorite "text" editor instead of vi

# gedit /etc/sudoers


i use terminal

oneofmany
30th July 2008, 03:54 PM
additionally, if you are logged in as Arshad and not arshad (case is important) then you should make sure the name matches when adding the line to /etc/sudoers :)

arshad3m
30th July 2008, 03:57 PM
you need to do "su -" instead of "su" so that you get root's environment :)


thanks. but still having the problem.



[Arshad@localhost ~]$ su-
bash: su-: command not found
[Arshad@localhost ~]$ su
Password:
[root@localhost Arshad]# visudo
bash: visudo: command not found
[root@localhost Arshad]#

oneofmany
30th July 2008, 03:59 PM
thats su <space> - :)

arshad3m
30th July 2008, 04:05 PM
great it worked. but didnt tell whether successful or not



[root@localhost Arshad]# su -
[root@localhost ~]# visudo
[root@localhost ~]#



now what should i do?

oneofmany
30th July 2008, 04:08 PM
logout of root (type exit and press enter) then try something like ..



sudo ls -l /root


if it comes up with "permission denied" then it failed.

arshad3m
30th July 2008, 04:11 PM
i didnt get the 'permission denied' message but this



[Arshad@localhost ~]$ sudo ls -l /root
[sudo] password for Arshad:
Arshad is not in the sudoers file. This incident will be reported.
[Arshad@localhost ~]$

oneofmany
30th July 2008, 04:16 PM
ok,

firstly, did you make sure you entered Arshad and not arshad? if you didn't you need to repeat the process but be sure to use the capital A.

secondly, if you did enter Arshad but you prefixed it with "%" you could try repeating the process and omitting the "%".

when repeating the steps, instead of entering "4dd" you'll just need to enter "dd" since you only have one line to delete and not 4.

arshad3m
30th July 2008, 04:20 PM
thanks.
if i type


echo 'Arshad ALL=(ALL) ALL' >> /etc/sudoers


would it be OK?

arshad3m
30th July 2008, 04:20 PM
thanks.
if i type


echo 'Arshad ALL=(ALL) ALL' >> /etc/sudoers


would it be OK now?

oneofmany
30th July 2008, 04:24 PM
it should, though that will ask you for a password when you try to use it. if you're determined to do it that way (which is unsafe) you should probably type ...



echo "Arshad ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

arshad3m
30th July 2008, 04:27 PM
thank you thank you thank you very muchh.. now working.
if you dont mind. what is the code for installing XFCE desktop?
in addremove progs it takes too much time to search.

thanks

oneofmany
30th July 2008, 04:31 PM
from the terminal window/console, as root


yum groupinstall XFCE


it may require a reboot to kick in. however, you should probably start a new thread about that

arshad3m
14th June 2009, 12:52 PM
hallo,
can anyone please help me with this error?



[arshad3m@localhost ~]$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-*
>>> sudoers file: syntax error, line 94 <<<
sudo: parse error in /etc/sudoers near line 94




i get this for :
cat /etc/sudoers



[arshad3m@localhost ~]$ su -
Password:
[root@localhost ~]# cat /etc/sudoers
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.

## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2

## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem


## Command Aliases
## These are groups of related commands...

## Networking
Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

## Installation and management of software
Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum

## Services
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig

## Updating the locate database
Cmnd_Alias LOCATE = /usr/bin/updatedb

## Storage
Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount

## Delegating permissions
Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp

## Processes
Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall

## Drivers
Cmnd_Alias DRIVERS = /sbin/modprobe

# Defaults specification

#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
# You have to run "ssh -t hostname sudo <cmd>".
#
Defaults requiretty

Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL

## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

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

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

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users localhost=/sbin/shutdown -h now

arshad3m ALL=(ALL)
[root@localhost ~]#