Rahul's Tech Blog

Growth Hacking, Just Hacking or No hacking !!!

How to mount one folder in another (Giving access to external folder in jailed ftp – vsftpd)

Sometimes softlinks are not enough, especially when you are setting up jailed ftp.
Suppose you have created a user who has permission to only see his home folder, still you want to give them access to /var/www/mvc_framework/views/ folder. How will you do that ?
This is where you will need to mount a folder inside another.

You can do that using --bind parameter along with mount command.
So the command becomes
mount --bind /path/to/olddir /home/username/newdir
Or in short
mount -B /path/to/olddir /home/username/newdir

But this is onetime command, if you restart your machine (server), it will be lost. To mount it every time server is restarted, open /etc/fstab and append
/path/to/olddir /home/username/newdir none bind

Next time when you restart your server, it will be automatically mounted.