How to password protect a file in Linux

Have you ever wondered that you can password protect a file in Linux using through VIM ? Ye’s it’s correct and it’s quite simple too.

To password protect a file in Linux use the command below.

root@justgeek~]# vim +X justgeek.txt

+X option will make password protect your file.

Example :

root@justgeek~]# vim +X justgeek.txt
"justgeek.txt" [New File]
Enter encryption key:
Enter same key again:

Now write anything you want and save it using !wq

"justgeek.txt" [New][crypted] 0L, 0C written

That’s it !! Enjoy Securing :)

Read More

Hard Link

What is a Hard Link ?

As we have already seen what is symlink in the post here. Here we will discuss about hardlink.

We saw that in sym-link a new file and new inode is created but in hardlink a new file is created but it points to same inode.

How to create hard-link

root@justgeek~]# ln /full-path-to-file /path-where-symbolic-link-is-to-be-created

For Example

root@justgeek~]# ls -al
total 8
drwxr-xr-x 2 root root 4096 May 16 07:03 .
drwxr-xr-x 4 root root 4096 May 16 07:03 ..

root@justgeek~]# touch orginalFile
root@justgeek~]# ls -al
total 0
-rw-r--r-- 1 root root 0 May 16 07:04 orginalFile

root@justgeek~]# ln orginalFile symbolicLink

I believe I should write a separate posts about the difference between symlink and hard-link, I hope I will do it soon.. stay tuned.

Read More

Large Virtfs folder

Many times you noticed that on your cPanel server /home/virtfs folder uses lot of space, but actually it doesn’t uses space those are just links to the original files. However, DO NOT DELETE that folder directly it might delete the original files/folders

To FIX this make sure that no user on the server has Jail- Shell access.

Then you can use the command below to clear those space.

 root@justgeek~]# /scripts/clear_orphaned_virtfs_mounts --clearall

Even if this doesn’t clear space then you can try rebooting your server which shall fix the problem

Read More