Recently, Ubuntu announced that they would be making users’ home folders privater by default with the 21.04 release and onwards. Of course this applies only in the case of new installations and so in this post I want to show you how to make your home folder private in Ubuntu if, like me, you’re sticking to the 20.04 LTS release.
Why Make Your Home Folder Private?
Before we tell you how to make your home folder private, let’s talk about why you should make them private.
If you’re using a computer with multiple user accounts with other members of your family then it’s best practice to protect each user’s home folder to prevent any unwanted or unintentional changes from being made.
Private home folders are also becoming more necessary now that Linux and Ubuntu are prevalent in the workplace. Sensitive documents and data on an employee’s computer need to be protected from other users and one of the easiest ways to do this is by making the user’s home folder private by default.
How to Make Your Home Folder Private in Ubuntu
So with the *’why’* out of the way, let’s show you how easy and simple it is to go about making your home folder private in Ubuntu.
The following code will enable you to make any existing and newly created home directories private by default. Open a terminal and running the following commands. Comments are preceded by the hashtag symbol and do not need to be entered.
# make all existing home directories private sudo chmod 750 /home/* # ensure any users created by either the adduser(8) or useradd(8) # commands have their home directories private by default sudo sed -i s/DIR_MODE=0755/DIR_MODE=0750/ /etc/adduser.conf echo “HOME_MODE 0750” | sudo tee -a /etc/login.defs
To disable this and revert to the previous state you can run the following commands in a terminal. Once again, comments are preceded by a hashtag and do not need to be entered.
# change adduser(8) to enable permissive home directory permissions sudo dpkg-reconfigure adduser # and ensure useradd also follows suit sudo sed -i 's/^\(HOME_MODE\s\+0750\)/#\1/' /etc/login.defs
Hopefully the above commands show you how to make your Ubuntu home folder private, even if you decide to not upgrade to Ubuntu 21.04. Be sure to check out our other tips for more.