简体   繁体   中英

How to map a symbolic directory link to different directories based on user id

Is there any way to a map a symbolic link directory to different directories based on the user id in Linux. For instance if a user X executes cd /var/www/html/ then his/her directory gets changed to /var/www/webX/ , while for the user Y it would be /var/www/webY . The purpose of doing this is to make the web document directories transparent for different apache users.

Thanks

One line answer: No . The linux filesystem does not support conditional symlink evaluation of the type you are envisioning.

Alternatives:

=> (Programmatically) Create symlinks in each user's home directory which point to the required location in /var/www/ . For example, in user X's home directory:

ln -s /var/www/htmlX htmldir

In user Y's home directory:

ln -s /var/www/htmlY htmldir

So that each user can just go cd htmldir and get to the appropriate location.

=> Use the per-user directory feature to assign ~user/public_html or more generically, ~user/<some-name-consistent-across-users> as the HTML dir for user .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM