Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a shared directory in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to create a shared directory in Linux, which is concise and easy to understand. I hope you can get something through the detailed introduction of this article.

As a system administrator, you may have a specific directory where you want to grant read / write access to each user on the Linux server. In this guide, we will review how write access is enabled for all users on a specific directory (shared directory) in Linux.

This requires setting appropriate access rights, and the most effective and reliable way is to assign a common group to all users who want to share or have write access to a particular directory.

If you don't already have this directory and public group on your system, create it with the following command:

$sudo mkdir-p / var/www/reports/ $sudo groupadd project

Then add the user who has write access to the directory / var/www/reports/ to the project group.

$sudo usermod-a-G project tecmint

Create a public catalog group

The flags and parameters used in the above command are:

-a-add users to the supplement group.

-G-specifies the group name.

Project-Group name.

Tecmint-an existing user name.

After that, configure the directory with the appropriate permissions, and-R will make the operation recursive into the subdirectory:

$sudo chgrp-R project / var/www/reports/ $sudo chmod-R 2775 / var/www/reports/

Explain 2775 in the above chmod command:

2-turn on the setGID bit, which means that the newly created child file inherits the same group as the directory, and the newly created subdirectory inherits the setGID bit of the parent directory.

7-provide rwx permissions to the owner.

7-rwx permissions are given to the group.

5-provide rx permissions for others.

You can create more system users and add them to the directory group using the following command:

$sudo useradd-m-c "Aaron Kili"-s/bin/bash-G project aaronkilik $sudo useradd-m-c "John Doo"-s/bin/bash-G project john $sudo useradd-m-c "Ravi Saive"-s/bin/bash-G project ravi

Then create a subdirectory where each user stores their project reports:

$sudo mkdir-p / var/www/reports/aaronkilik_reports $sudo mkdir-p / var/www/reports/johndoo_reports $sudo mkdir-p / var/www/reports/ravi_reports

Now you can create a file / file and share it with other users in the group.

That's it! In this article, we reviewed how to enable all users to write to a specific directory. To learn more about users / groups in Linux, read how to manage users / groups and attributes.

The above is how to create a shared directory in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report