Command to create a file owned by another user
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).
Related videos on Youtube
slhck
Updated on September 18, 2022Comments
-
slhck over 1 year
I created a directory
test
owned by theroot
user, and then I created a file calledF1
insidetest
, now I need to create a file calledT5
insidetest
but by a user calledstudent
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 userstudent
to createF5
student@mylamp:/test$