Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I create or modify any file or directory with sudo then permissions go to root only. And it seems that I need to use sudo in order to do some things in ubuntu. For example, I can't seem to mount a server without using the super user.

share|improve this question
up vote 1 down vote accepted

Using sudo means you are running as the root user for that command. Any files or directories you create will be owned by root. If you want to give your normal user access, you need to change the permissions and/or ownership

something like chown <yourusername>:<yourgroupname> <filename>

when mounting the smb server, try setting the ownership/permissions on the mountpoint first, before mounting the drive.

share|improve this answer

General Unix Permissions Information

This is the fundamental way any POSIX (Unix/Linux/others) work. Everything is done under a user. Whenever you make a directory it inherits the owner and default permissions set in the umask of that owner. Whenever you do something with sudo, you basically do the operation not with your user but with the user "root" - the "Administrator" in Windows.

sudo is just a shortcut for:

  1. Login as "root".
  2. Run the command.

In Windows terms - "Run as Administrator".

Having that in mind, it should be clear that you should not need to use sudo for anything related to your user. It should be only needed for use with stuff owned by the "root" user. Stuff such as the system configuration in /etc/, mounting drive volumes etc.

Now, there are things that are typically done by "root" but sometimes need to be done by a user. To allow this, there are groups who are given permissions to that. For example the group "disk" is allowed to access hard drives in raw mode - i.e. like "root". If you want to be able to that with your own user - you simple have to add yourself to that group like so:

sudo adduser [yourself] disk

Obviously only root can do that so you need sudo.

This is generally how permissions work in POSIX OSes. There is more to it but this should answer your particular issue. How to solve the particular SAMBA problem is a separate topic.

You can find more on Unix permissions in this lecture on Unix including Unix permissions from University of Toronto.

Mounting SAMBA shares as non-root

Now about your particular issue with SAMBA - there is nicely described way to do it in the Samba Client Guide. Note that above that on the same page there are also other ways to do it via UI.

share|improve this answer
    
I've also added a link to a good guide on how to do what you want with SAMBA without root. Hope that helps. :) – Nicolay Doytchev Jul 27 '12 at 23:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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