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.
Step 2: cd Desktop
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)
d = directory
Now, we want to lock this xyz file, means remove permission of read, write and execute
then just type:
step 4: chmod 000 xyz
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:
- cd Desktop ( what ever your file location)
- ls -l
- chmod 000 xyz ( it will lock the file.)
- chmod 777 xyz (it will unlock the file)