# How to give the user sudo privilege?

**Scenario:** Create two users '**tom'** and '**cat'**. 't**om'** must have sudo privilege whereas '**cat'** has normal privilege. Also, a file created by '**tom'** is editable by '**cat'**. '**tom'** must have a home directory **/home/tom** but the 'cat' should not have a home directory.

1. Switch to root user:
    
    ```bash
    sudo su
    ```
    
2. Create users ‘tom’ and ‘cat’ as
    
    ```bash
    adduser tom
    adduser cat
    tail -n 5 /etc/passwd
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696252583451/05a6b93a-9179-48d9-a262-24b21363dab4.jpeg align="center")
    
3. Add sudo privilege configuration for user tom
    
    ```bash
    sudo visudo
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696252723774/9e5886f1-7079-4820-97d9-395e566d8c3e.jpeg align="center")
    
    Save and exit.
    
4. Now remove the default created home directory of 'cat' user so that 'cat' user should not have any home directory using the root user
    
    ```bash
    sudo rm -rf cat
    su cat
    cd
    ls
    ```
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696252835160/e5b41b4d-e076-4591-9275-6462d103df6a.jpeg align="center")

1. Now create a file using user 'tom'
    
    ```bash
    su tom
    cat > hello.txt
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696253022071/1c37f763-5268-4ebb-98c1-54216320cd6c.jpeg align="center")
    

Change ownership so that cat user can access the current folder and content.

```bash
sudo chown cat .
su cat 
```

So we can access and edit it from cat user

```bash
nano hello.txt
cat hello.txt
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696253132989/48dfc2f5-aab9-4b6c-8419-316a465e31c6.jpeg align="center")

Now we are able to access files and folders inside /home/tom with cat user also.
