What is a Chroot Jail?
The term “chroot prison” is frequently used to refer to a portion of a filesystem that is set aside for a certain user on Unix-like operating systems like Linux.

It is very helpful for the security of shared hosting accounts on a web server.
A user with restricted file rights might nevertheless access top-level folders without the use of a chroot jail. As an illustration, let’s say the user’s directory is /home/user.
Without chroot, there would be nothing stopping the user from going to /home to look at other users’ directories or even going to / where they can see /etc, /usr, /var, /lib, and other system-critical directories.
Even though the user wouldn’t be able to change the files, they would be able to see them and try to exploit specific ones.
You could remark, “Oh, I trust my users,” in response. It’s not just a question of trust, though. If you give your user access, you also give access to anyone who can break into their account. That just makes your security fence even less strong.
When web servers are set up for shared hosting, many control panels automatically create chroot directories for each user account.
There is also software that makes making chroot jails easier. One of these sets of software is called Jailkit, and you can get it for free.
Virtualization is another important way to use chroot. With a virtual private server (VPS), the user has a full operating system installed in a chroot directory.
So, even though the user has root privileges for his or her own account, the user can’t access higher directories and wouldn’t even know they exist (on a technical level).
This means that if the user is in /var/chroot/vhosts/user/, there’s nowhere to go from there. /user directory. It will look like the user’s root directory to them, which is /.
Chroot is great for basic security measures, but it is not meant to stop people from trying on purpose to get root access and attack a server.
There are other ways to keep yourself safe in this case. Still, chroot helps a lot to make it much harder to take advantage of your dedicated server.