简体   繁体   English

如何根据用户ID将符号目录链接映射到不同目录

[英]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. 有什么方法可以根据Linux中的用户ID将符号链接目录映射到其他目录。 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 . 例如,如果用户X执行cd /var/www/html/那么他/她的目录将更改为/var/www/webX/ ,而对于用户Y它将是/var/www/webY The purpose of doing this is to make the web document directories transparent for different apache users. 这样做的目的是使Web文档目录对不同的apache用户透明。

Thanks 谢谢

One line answer: No . 一线回答: The linux filesystem does not support conditional symlink evaluation of the type you are envisioning. linux文件系统不支持您正在设想的类型的条件符号链接评估。

Alternatives: 备择方案:

=> (Programmatically) Create symlinks in each user's home directory which point to the required location in /var/www/ . =>(以编程方式)在每个用户的主目录中创建符号链接,这些符号链接指向/var/www/的所需位置。 For example, in user X's home directory: 例如,在用户X的主目录中:

ln -s /var/www/htmlX htmldir

In user Y's home directory: 在用户Y的主目录中:

ln -s /var/www/htmlY htmldir

So that each user can just go cd htmldir and get to the appropriate location. 这样每个用户都可以进入cd htmldir并到达适当的位置。

=> 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 . =>使用每用户目录功能~user/public_html或更通用的〜user ~user/<some-name-consistent-across-users>分配为user的HTML目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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