O'Reilly logo

Ubuntu Server Cookbook by Uday R. Sawant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. To change groups for files and directories:
    1. Log in with user1.
    2. Create a new directory documents under home:
      	user1@ubuntu:~$ mkdir documents
      
    3. Create a text file under documents:
      	user1@ubuntu:~$ echo "hello world"> documents/file.txt
      
    4. Now log in with user2:
      	user1@ubuntu:~$ su user2
      
    5. Try to edit the same text file. It should say Permission denied:
      user2@ubuntu:/home/user1$ echo "hello ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required