How to give the user sudo privilege?
Scenario: Create two users 'tom' and 'cat'. 'tom' 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.
Switch to root user:
sudo su
Create users ‘tom’ and ‘cat’ as
adduser tom adduser cat tail -n 5 /etc/passwd
Add sudo privilege configuration for user tom
sudo visudo
Save and exit.
Now remove the default created home directory of 'cat' user so that 'cat' user should not have any home directory using the root user
sudo rm -rf cat su cat cd ls
Now create a file using user 'tom'
su tom cat > hello.txt
Change ownership so that cat user can access the current folder and content.
sudo chown cat .
su cat
So we can access and edit it from cat user
nano hello.txt
cat hello.txt
Now we are able to access files and folders inside /home/tom with cat user also.