1

As explained at the thread Ubuntu on Lenovo Yoga 2 Pro I wanted to edit /usr/share/X11/xorg.conf.d/50-synaptics.conf and also to create a script in /usr/local/bin/ but neither I can edit the first file nor create the second. While trying to edit and after that saving the file I got a notification that I don't have the necessary rights (although I'm admin).

Sorry, this is maybe a simple problem, but I just started to get known to Ubuntu and also searched on the forum, but couldn't find anything.

1
  • 2
    Your are only the admin when you put sudo in front of your command. Otherwise you are a normal user.
    – Rinzwind
    Oct 25, 2014 at 14:11

1 Answer 1

1

Stuff in /usr/local/bin can only be edited by admin users. That's why users can add their own files to /home/user/bin, and add this to their path. (That's what I do.)

  • Do this: sudo nedit /usr/local/bin/myfile
  • Type in your password.
  • You now have admin privileges to edit this one file. That does not mean all your users will have permissions to run it or edit it. This file will have admin permissions by default, because 'sudo' makes you a temporary admin.
  • Edit and save the file.
  • Now you have to change the permissions of the file so normal users can run it. Do: sudo chmod g+rw /usr/local/bin/myfile. This changes group permissions. Make sure the users who have to run this are part of the group, whatever that may be.
  • If you are still having problems, give everyone permissions for this file only: sudo chmod a+rwx /usr/local/bin/myfile.
  • You will also have to add this dir to the user's path if it is not already.

If you get an error message that you can't use sudo, edit /etc/sudoers I think, and add your username there, one user per line.

Use whatever editor you like, even 'nano', 'vi', instead of 'nedit'.

When doing stuff with files in these "global" directories, remember to use sudo before each command. Example:

  • sudo cp /usr/bin/file $HOME
  • sudo nano /usr/bin/myfile
  • sudo chmod u+rwx /usr/bin/myfile
3
  • Good! And use visudo to modify /etc/suders, although if user can't sudo, probably can't also sudo visudo /etc/sudoers :)
    – Lety
    Oct 25, 2014 at 14:39
  • I can do sudo but not visudo -f file on Ubuntu 14.04. I edit /etc/sudoers with sudo nano /etc/sudoers just fine. Nano is the default full-screen editor on Ubuntu 14.04.
    – Bulrush
    Nov 6, 2014 at 18:55
  • 1
    It is strange, visudo edits the sudoers file in a safe fashion and parses the sudoers file after the edit and will not save the changes if there is a syntax error. Try simple sudo visudo for default it opens /etc/sudoers
    – Lety
    Nov 6, 2014 at 22:10

You must log in to answer this question.

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