Managing file permissions
We have created users and groups. In this recipe, you will work with default file permissions for users and groups, as well as see how to modify those permissions.
Getting ready
Create two users, user1
and user2
. Create new group editor
and add user1
and user2
as members.
How to do it…
Follow these steps to manage file permissions, follow these steps:
- To change groups for files and directories:
- Log in with
user1
. - Create a new directory
documents
underhome
:user1@ubuntu:~$ mkdir documents
- Create a text file under
documents
:user1@ubuntu:~$ echo "hello world"> documents/file.txt
- Now log in with
user2
:user1@ubuntu:~$ su user2
- Try to edit the same text file. It should say
Permission denied
:user2@ubuntu:/home/user1$ echo "hello ...
- Log in with
Get Ubuntu Server Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.