Setting private user home directory on Ubuntu

Recently it was announced that Ubuntu 21.04 will have private home directories. This would affect new users and new installs, but you can easily change this on your computer (or any Linux/unix computer) after checking your current setting…

Run this “ls” list command on a common Ubuntu server/desktop and you will see:

$ ls -lah /home
total 12K
drwxr-xr-x  3 root root 4.0K Jul  4  2018 .
drwxr-xr-x 23 root root 4.0K Jan 16 06:43 ..
drwxr-xr-x 11 username username 4.0K Jan 21 02:23 username

Note the three “r”s in the username at the end, this means it is accessible to all! To make your home directory accessible to only you, on your currently logged in user, run:

chmod 700 $HOME

This makes any other users of the computer not able to read your files – your downloads, your $HOME/Desktop, ~/Documents, ~/Downloads, etc. etc. I have long been using this on a personal pc and this has worked with no problems. The above command would now show:

$ ls -lah /home
total 12K
drwxr-xr-x  3 root root 4.0K Jul  4  2018 .
drwxr-xr-x 23 root root 4.0K Jan 16 06:43 ..
drwx------ 11 username username 4.0K Jan 21 02:23 username

Now you should have a more secure permission for just about any use case… However, there are other common permissions of this folder you can find listed and discussed here.

To be sure, you can test and double check that some other user cannot read your files using:

sudo su - otherusername
$ ls /home/mymainuser
ls: cannot open directory '/home/mymainuser': Permission denied

One final warning – beware changing this recursively, with “chmod -r” – this will set individual permissions on every file under them, and files and folders generally have different permissions!

Leave a Reply

Your email address will not be published. Required fields are marked *

× 3 = eighteen