Linux mint Sudoers edit not working: can't do anything

3

I am running Linux Mint. I set up an administrator account called 'thomas'.

I am trying to edit some files and it will only let me open them as read only. I assumed a permissions problem. As such, I sought to give myself the correct permissions.

I added my user to the group sudo (it was already in the group admin). In sudoers these groups have all permissions. However, this did not work so I added an entry specifically for my username to give it all permissions. Again, this has not worked.

As such, at the moment I can log in as root or put sudo in front of every command to get things working, but this is not ideal and does not help when, for example, I open up a document for editing in Gedit within the GUI.

Could anyone advise as to why my permission changes are not working?

Thomas Clowes

Posted 2012-07-24T13:13:09.353

Reputation: 131

1Where are the files you are trying to edit? in your home directory? Can you give us the output of ls -Al in the directory of the files you're trying to edit? – Rob – 2012-07-24T15:23:28.277

Answers

1

This is from my Red Hat-based desktop knowledge:

In a terminal do su and then visudo and then scroll down and look for:

root    ALL=(ALL)       ALL

Press i so you're in insert mode. Copy/paste the above line and replace root with your username, leave the rest as it is.

Shahzad

Posted 2012-07-24T13:13:09.353

Reputation: 11

I have done this, and it hasn't worked - this is my question :) – Thomas Clowes – 2012-07-24T14:12:47.670

1

Do you mean you can not edit files in /home/thomas without sudo? In that case change the ownership/permission of the files with chown and chmod respectively.

Editing files elsewhere on the file system will normally require administrative privileges.

Thor

Posted 2012-07-24T13:13:09.353

Reputation: 5 178

1

Try backing up your /etc/sudoers file (su -c 'mv /etc/sudoers /etc/sudoers.bkup') then uninstalling and reinstalling sudo (su -c 'apt-get remove sudo && apt-get install sudo')

When su -c asks for a password, it is asking for root password.

While I don't recommend doing this, it may be possible if you change the uid for thomas to 0. This should be possible with sudo vim /etc/passwd (use whatever file editor you use).

Rob

Posted 2012-07-24T13:13:09.353

Reputation: 2 152

I did this. It reinstalled. The sudoers file stayed the same, and the problem persists. – Thomas Clowes – 2012-07-24T17:38:16.053

Can you edit the output of ls -Al in the directory of the files you're trying to edit into the question? – Rob – 2012-07-24T17:44:02.553

1

Fix permissions within user thomas: (as Thor suggested)

find /home/thomas -type f -exec sudo chown thomas:thomas {} \;
find /home/thomas -type d -exec sudo chown thomas:thomas {} \;

find /home/thomas -type f -exec sudo chmod 640 {} \;
find /home/thomas -type d -exec sudo chmod 750 {} \;

Important:

Files not located in /home/thomas will not have permissions for you to edit without sudo.

This is normal! It's critical for maintaining a safe running system.

tao

Posted 2012-07-24T13:13:09.353

Reputation: 1 355

To clarify.. When logged in as user 'thomas' I can edit files in my Home directory.

I cannot however edit files in the htdocs section of my xampp install located at /opt/lampp/htdocs

I could change the ownership of these files (which i believe is what your code accomplishes), but I was trying to find a find all remedy - I want my account 'thomas' to be able to do everything.

Could you clarify on your 'Important' - why?/What has adding thomas to the group sudo and giving all permissions to thomas actually achieved?

Thanks – Thomas Clowes – 2012-07-24T17:44:58.307

user account thomas shouldn't be able to do everything. *nix works with the principle of least privilege. thomas shouldn't be able to do everything, root should. http://en.wikipedia.org/wiki/Principle_of_least_privilege

– Rob – 2012-07-24T18:02:09.567

1thanks Rob for providing him with the link, kid wouldn't let me get here. lol .. Now i advise against this but he could change the permissions on /opt/lampp/"""htdocs""" lampp:lampp or what ever the owner is and set file perms as 664 then simply add himself to that group. Sorry for the long winded comment lol. – tao – 2012-07-24T18:36:22.750

Ok - thanks for the info.. so.. I wanted to install xampp to use for testing my websites. I could not do it from the user account 'thomas' as it didnt have the required priveleges.. so i logged into root and installed it.

tao - you seem to be suggesting that giving 'thomas' priveleges to edit files in opt/lampp is inadvisable? why? If so is the assumption that i should just use root for my webdesign? – Thomas Clowes – 2012-07-24T19:08:15.627