-2

Is it possible in linux to give a user read/write access to all files and directories like root?


EDIT I have a special case. I need to create a folder structure on which I can grand a special user full access independent of the underlying permissions. It's similar to a root user on one folder and it subfolders.

I'm not sure if this is possible and how to achieve that. I was reading on ACLs but I couldn't find a solution.

  • 2
    No idea why you'd need to do this, but you can try adding the user to the root group. – Blender May 25 '12 at 0:07
  • 2
    I'm pretty sure this is not the right solution to your problem. I imagine you're actually looking for sudo. – bkconrad May 25 '12 at 0:11
  • Maybe I have to clarify it a little bit: I only need read/write access to one file system. But I don't know how to achieve that without changing the permissions. It's not a question of why to do that. I would like to know if it's possible to consider to do it or not. – multiholle May 25 '12 at 0:16
  • 1
    This sounds like an XY Problem (meta.stackexchange.com/questions/66377/what-is-the-xy-problem). We will be better able to help if you tell us what problem you are trying to solve, not just how you have decided to solve the problem. – Dour High Arch Jun 3 '12 at 15:11
0

Granted I'm not a total expert in Linux, but this is a strange request.

Why would you want to do that? That is what Root permissions are for... and also that is pretty dangerous as said user could do pretty serious damage?

That being said, you could write a shell script that uses the command "chmod" to modify specific sets of folders. This way you could reuse the script...

| improve this answer | |
  • 1
    OP has mentioned in a comment that 'changing permissions' is not an option. Which, is plain strange. – ArjunShankar May 25 '12 at 0:19
  • @ArjunShankar : Agreed. Linux is so graceful and helpful and useful at its file permissions system, it really is just a matter of understanding how it was set up and how it works, and therefore also how to layout your own directories and files so that you don't have to try and work against the system itself... – hypervisor666 May 25 '12 at 0:26
0

Create new user:

adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 -M nameofuser

Explanation:

  • adduser: command to add user in linux server
  • -u 0-o: a new user value set to 0
  • -g 0: set user group number to 0
  • -G 0,1,2,3,4,6,10: set user access to the group 0 = root, 1 = bin, daemon = 2, 3 = sys, adm = 4, 6 = disk, 10 = wheel
  • -M: do not create home directory for new user
  • nameofuser: a new username

Check whether the right of access and new information of new user like root user:

[root@centos ~]# id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@centos ~]# id nameofuser
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
| improve this answer | |
  • This would be the same as using root to access the files. Giving a user root right would create a big security hole. It needs some kind of scope to limit the access to some folders. – multiholle Jun 4 '12 at 18:27
  • This question is about destroying security whatever way you go about it. – XTL Nov 11 '15 at 9:43
0

I need to create a folder structure on which I can grand a special user full access independent of the underlying permissions. It's similar to a root user on one folder and it subfolders.

By the "independent of the underlying permissions" bit, it seems that just pretending to have root access is enough. In that case you can use fakeroot:

$ mkdir direc
$ cd direc
$ fakeroot
# touch some-file
# touch common-file
# chown user:user common-file
# ls -l
-rw-r--r-- 1 user user 0 Jun 11 22:56 common-file
-rw-r--r-- 1 root root 0 Jun 11 22:55 some-file

It looks like you have set the owner, and the files by default are owned by root. However, if you exit the fakeroot, you'll see they don't really have root ownership.

# exit
$ ls -l
-rw-r--r-- 1 user user 0 Jun 11 22:56 common-file
-rw-r--r-- 1 user user 0 Jun 11 22:55 some-file
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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