Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i want to create a user account other than the root so that root as well as that user can upload delete files in the ubuntu system (e.g suppose that i have some php files in var/www so that root and that user can upload in the same directory )

share|improve this question

migrated from Jul 21 '09 at 6:58

This question came from our site for professional and enthusiast programmers.

4 Answers 4

It depends what you want security wise.

Your best bet is to create a directory owned by the non-root user. This way that user can save files there, and root can save files there, because root is all powerful.

You will have the problem that when root saves files, they will be owned by root and the non-root user won't be able to edit them. You can fix this by making the directory setuid and setgid.

 # chmod ug+s /foo/bar

Now when someone creates a file in that directory, the owner and group will be set to the same as the directory. In this case, the non-root user.

If root edits an existing file, it will not change the existing ownership.

There are other alternatives, like changing the directory to being world writable, but that's a huge security problem and I really don't recommend it. Alternatively, you could create a group that both root and your non-root user are in, but that isn't exactly ideal.

share|improve this answer

You will want to look at using the same group for root and the new user. Then, make the directory and files group write-able. Also, set the appropriate umask so that new files created will inherit the same permissions.

share|improve this answer

Is there a particular reason why you want to root user to upload files? It is NOT a secure practise to use root user account for such purposes. Looking at the tags I guess you are referring to FTP access. Please bear in mind that (regular) FTP is not a secured protocol and you should avoid using root account over any non-secure connection.

I would suggest using two regular users (without root privileges) for the purpose and make them members of the same primary group.

share|improve this answer

Don't migrate root permissions up to other users! This is a one-way ticket to HackedVille.

Migrate directory read/write permissions down to other users.

Managing /var/www doesn't require root privileges, just an account that owns the directory (but not the account that runs the web server, usually "nobody".)

To do this, first of all, stop using root to read/write /var/www! Leaving root-owned files all over the place is the first step in the "need to be root" rot, since once the root-owned files are there, everybody wants to be root to deal with them.

Use chown -R to give ownership of the directory tree to a non-root user. Use that username to manage the directory contents. Use chmod -R to give others read-only permissions.

If you really need two users to read/write, put them in the same group (/etc/group), and use chmod to open up group write permission.

share|improve this answer

Your Answer


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