Command to create a file owned by another user

5,723

At first, I think you should edit your question and make it more readable. What you are looking for are either chmod, chown or setfacl.

a) chmod

You can modify the permissions for the directory "test" with chmod in order to give another user access to it.

For instance, you could do

chmod 777 test

Now everyone has write access to this directory, also your student user. Please be aware that you are giving away more permissions than you might like.

b) chown

Put the user student into a group and do

chown root:studentgroup test

Afterwards make sure that groups may write into that directory:

chmod 774 test

c) setfacl

Another approach could be to use ACLs. ACLs are made for a more complex permissions management. You can use setfacl to manage the permissions for a directory or file. For example you can run the following command:

setfacl -m u:student:rwx test

This command ensures that the user student has read, write and execute permissions on test. Please note that this only works when the underlying file system was mounted with ACL support (see /etc/fstab).

Share:
5,723

Related videos on Youtube

slhck
Author by

slhck

Updated on September 18, 2022

Comments

  • slhck
    slhck over 1 year

    I created a directory test owned by the root user, and then I created a file called F1 inside test , now I need to create a file called T5 inside test but by a user called student

    What is the command to do that?

    This what I did:

    root@mylamp:/# mkdir test
    root@mylamp:/# touch F1
    

    Now I need to access test by the user student to create F5

    student@mylamp:/test$