Lock your Private Folder in Ubuntu

Hello everybody, Today we are going to learn that, how to lock our private folder, file in Ubntu in just few mins. It’s mainly used when we need to secure our important data from others.

Here,we just remove the permission read(r) ,write(w) and execute(x) of file, then it will automatically be locked, and for that we just need to write a few commands.

Before that lets make a folder xyz on desktop. We are going to lock this folder “xyz”. 

Step 1: Open terminal (CTRL+ALT+T)

Then go to on your folder path,here,our folder is on desktop.
Then type:

Step 2: cd Desktop

then type:

step 3: ls -l

Now,here you can see folder name “XYZ”,2nd line from bottom. [here,GREEN BOX]
Exactly in that first row, you can see like this
drwxrwxrwx ( it shows the permission of xyz file)
where,
d = directory
r =read
w=write
x= execute.
Now, we want to lock this xyz file, means remove permission of read, write and execute
then just type:

step 4:  chmod 000 xyz

DONE..
now go to that file, and try to open that file..

this is our file location,on which you can see like cross symbol,which indicates that you dont have permission to open this file. if you are trying to open this file, you will get error like this.

now to UNLOCK this folder,
type in terminal

step 5: chmod 777 xyz

after giving this command, you can see on folder that,cross symbol is magically removed, that means now you are able to access this folder.

So,in short,by this way you can lock any folders,files.

Overview of commands: 

  1. CTRL+ALT+T
  2. cd Desktop ( what ever your file location)
  3. ls -l
  4. chmod 000 xyz ( it will lock the file.)
  5. chmod 777 xyz (it will unlock the file)