4

Background

I'm working on my personal VPS configured mostly for learning sysadmin and personal projects. Have run up against an issue where my non-root user could only create/edit files in emacs by using sudo command. This is not an issue with directory permissions since I can create files with touch without sudo.

  • Can't recall, but emacs may have been initially installed by the root user.
  • User was created and added as follows:
    • root@hadron:~# adduser my_user
    • root@hadron:~# addgroup admin
    • root@hadron:~# adduser my_user admin

Specifics

Running a command like emacs newfile.txt would always open a blank document that couldn't be saved, and noted the following in the file path at the bottom of the terminal: File exists: /home/my_user/.emacs.d/

Checking that .emacs.d file, the permission was as follows:

  • drwx------ 3 root root 4096 2012-03-26 08:07 .emacs.d

Changing the permission of the .emacs.d file to allow anyone to access it resolved the situation, but that doesn't seem like the proper solution:

  • chmod 777 ~/.emacs.d
  • drwxrwxrwx 3 root root 4096 2012-03-26 08:07 .emacs.d

What is the appropriate way of addressing this?

1 Answer 1

3

It is not completely clear which user tries to run the emacs.

Also it is unclear what the command

$ adduser my_user admin

does. Do you mean

$ adduser --group admin my_user

here?

The directory .emacs.d in the user's home should be owned by the user himself. So a

$ chown -R my_user ~/.emacs.d
$ # Fix the 'broken' permissions
$ chmod go-w ~/.emacs.d

In the last command you might want to add also the x and r flag to remove read and execute permissions for group and other.

1
  • Grazie. chown -R was what I was missing here. Following up, $ chmod go-w ~/.emacs.d gives the following error on my system: "chmod: cannot access `go-w': No such file or directory" But I've gone ahead with chmod 700, and confirmed all is working as expected.
    – CdrXndr
    Commented Apr 22, 2012 at 21:15

You must log in to answer this question.

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