0

I have to give my user permission to run sudo. I am using CentOs

# uname -a
Linux lab-hv1-centos1 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

and have root access.

A lot of resources recommend to run visudo and add line like

myuser    ALL=(ALL) ALL

But attempt to run visudo (and even less /etc/sudousers) prints message

E437: terminal capability "cm" required
Press ENTER or type command to continue

Some articles recommend to install ncurses-term using yum install ncurses-term. I have done this successfully and indeed number of terminals listed here ls /usr/share/terminfo/d is high. However it does not help me: the error message when running visudo is still printed and I cannot edit this file.

So, I wanted to add my user to sudo group. But this group did not exist on my machine. I created this group using groupadd sudo and then added my user to this group using command useradd -G sudo myuser.

This worked successfully but still when I try to run any command with sudo I get error message:

$ sudo ls
[sudo] password for myuser:
myuser is not in the sudoers file.  This incident will be reported.
$

The error message indeed correct. myuser belongs to group named sudo but that was me that created this group. It is just called sudo, it does not mean that users that belong to this group have permissions. I believe that if I can add line like

myuser    ALL=(ALL) ALL

or

sudo    ALL=(ALL) ALL

to /etc/sudousers I am done but I cannot do this due to error described above (terminal capability "cm" required)

What's the solution?

  • Did you start a new shell after installing the ncurses-term package? If you have root access, you might consider copying the file /etc/sudoers to /root/sudoers.backup and add the line manually using echo "myuser ALL=(ALL) ALL" >> /etc/sudoers – Lambert Dec 3 '15 at 13:49
  • Sure, I started new shell several times. I will try to add new line as you recommended. I thought about it by decided to try to solve the problem by the book first. – AlexR Dec 3 '15 at 13:52
  • @Lambert, this worked for user but not for group sudo. Anyway this solves my problem, so if you post your comment as an answer I will be glad to accept it. Thanks a lot. – AlexR Dec 3 '15 at 13:58
1

Did you start a new shell after installing the ncurses-term package?

If you have root access, you might consider copying the file /etc/sudoers to /root/sudoers.backup and add the line manually using:

echo "myuser ALL=(ALL) ALL" >> /etc/sudoers

If you want to give access to a group instead of a user you will need to prefix the groupname with the percent character:

echo "%sudo ALL=(ALL) ALL" >> /etc/sudoers

Keep in mind that the last matching rule will be effective in the sudoers file so editing the sudoers file using an editor is still advised to be the recommended way.

EDIT:

Another point of thought, what is the value of your $TERM variable? Try to set it using TERM=vt100 before issuing visudo or use one of the following:

TERM=vt100 visudo
TERM=xterm visudo
TERM=dumb visudo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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