0

I am not a system engineer (I am more a software developer). I have the following problem trying to deploy an application on a Linux Centos system.

As the first operation, I need to install Java and perform some preliminary checks installing some tools. During this preliminary phase I performed this command:

sudo yum install redhat-lsb-core 

I obtained an error like this one:

USERNAME is not in the sudoers file. This incident will be reported

So I suspect that this user is not a root user or it is not allowed into the /etc/sudoers file. Is it? What can I check to ensure this suspect?

Using this user I also tried to do:

cat /etc/sudoers

and I obtained:

cat: /etc/sudoers: Permission denied

Performing:

grep 'x:0:' /etc/passwd

I obtained:

[email protected] [~]# grep 'x:0:' /etc/passwd
root:x:0:0:root:/root:/bin/bash

So I think that there is only a root user that is not the one that I am using.

So do you think that the only solution is to ask the person handling this server to give me permission to execute sudo command?

2
  • you need to edit /etc/sudoers using a proper user with admin rights, so su cat /etc/sudoers and/or su nano -w /etc/sudoers to edit it and add the user. Until they are properly added you will have to use su and enter the root password to get access.
    – Mokubai
    Commented Nov 13, 2021 at 17:17
  • Your user doesn't need to get into the sudoers file, that's the job of the sudo tool and the error you get says USERNAME is not in the sudoers file so it can read the file but your user isn't in there. You need to get your user in there first.
    – Mokubai
    Commented Nov 13, 2021 at 17:21

2 Answers 2

1

If you are not in the /etc/sudoers file, then you cannot run commands as sudo.

That said, if you are a software developer and not in the /etc/sudoers file, just let the server admin install the packages you need installed.

Your question is really an XY problem; you seem to not need sudo access as much as you want to install redhat-lsb-core.

Knowing that, it might be better if you just ask the person who is root on the server to run:

 yum install redhat-lsb-core

As you state clearly in your question:

“I am not a system engineer (I am more a software developer).”

Unless you know what you are doing as far as root/sudo access on a server goes and truly need the sudo access, it might be best you just let that stuff be handled by the people who know how to deal with root processes on that server.

But as for the specifics of sudo access, the root user needs to assign you as a sudoer in /etc/sudoers.

Nothing else has to be done. Basic users are not in the /etc/sudoers by default for obvious reasons: If everyone was placed in the /etc/sudoers file, then they would all just be the equivalent of root so what is the benefit?

0

The owner of the system (the one that has access to root) must give you permission to do tasks as root. sudo is a root-delegation tool. The root can delegate specific tasks to a user, or give general root access to a user (or group for that matter).

If a normal user would be able to give himself root permissions, that would be a huge security issue. That is the reason why /etc/sudoers is only editable by root. Oh, and use visudo rather than editing that file directly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .