If you do not want your files to be read, or just do not want a particular user to read the modified files, limiting access is the best way to deal with them. Let me introduce you to the method of restricting user access rights under Linux. Let's learn together.
now we need to limit a user's access to certain directories /files, or to limit a user's access to the range in a directory /file. In reality, you can still meet such requirements. For example, there are multiple login users under ubuntu. By default, user A's working directory (usually /home/A) is available to any other user. Read, but User A may not want other users (or a specific user) to read A's files.
Three solutions are proposed here.
First: Use chmod to change permissions for a specific directory. This can limit the access of certain directories to certain people. The purpose of limiting a user can also be achieved, but other users will be accidentally injured.
Second: use a linux container, such as lxc. It takes a lot of space and the setup is a bit cumbersome.
Third: Use the setfacl command to set access control.
Among them, the third option is the most satisfactory. This article focuses on the specific implementation of the program and tests it on my own. My system is Linux Mint 15 64 bit, the root directory /uses the ext4 file system, the btrfs file system used by /home.
Install acl
The code is as follows:
sudo apt-get install acl
There is information to restart the system, but I found this when testing. It has been installed before (I don't know if it is brought by Mint or I am arbitrarily installed), and no restart is still effective.
Use setfacl
to execute the following command as root:
The code is as follows:
# mkdir /home/test
# touch /home/test/foo.txt
# vim /home/test/foo.txt
# ls -ld /home/test/
drwxr-xr -x 1 root root 14 Jan 16 09:46 /home/test/
# ls -ld /home/test/foo.txt
-rw-r--r-- 1 Root root 6 Jan 16 09:46 /home/test/foo.txt
The above command creates the directory test in the /home directory, creates the file foo.txt in the test directory, and under foo.txt Feel free to add some content. Then access foo.txt as a normal user letian, you can read foo.txt.
Previous12Next Total 2 Pages
Want to use RedHat Linux system to achieve wireless Internet access, you must first install the wire
Many people are familiar with Ubuntu shared file box Windows shared files, and know
HyperTable is an open source database, the installation in Ubuntu system is not so simple, the follo
In the Linux system operation, the use of more passwords can not be remembered, but also easy to rem
Ubuntu 14.04 prohibits the apport error report window startup method
Linux operation example summary of the history command
Linux system iPtraf installation and use method
How to use the command to delete and create the Linux folder
The nohup command in the Linux system guide
How to turn off the scp and sftp commands in Linux
Linux uses the chgrp command to modify the group to which the file belongs
Methods for Enhancing Linux System Security
How to configure and install Node.js in Ubuntu development environment
What is the process of Win7 system wauuclt.exe? Can it be closed?
Talk about Windows 8 downgrading those things
Bad optimization cheats can't hide Windows 7 menu bar (1)
How does Win10 activate the hidden login interface? A brand new user login screen
Wonderful space bar Call Win7 Boot Manager
How to close the Win10 window Snap function
Set the server to be able to support shtml file
Windows8.1 closes GWX config manager to make the computer smooth