1.11. Enabling users to share directories on a Samba server
On a Samba server, you can configure that users can share directories without root permissions.
1.11.1. Enabling the user shares feature 링크 복사링크가 클립보드에 복사되었습니다!
Before users can share directories, the administrator must enable user shares in Samba.
For example, to enable only members of the local example group to create user shares.
Procedure
Create the local
examplegroup, if it does not exist:# groupadd examplePrepare the directory for Samba to store the user share definitions and set its permissions properly. For example:
Create the directory:
# mkdir -p /var/lib/samba/usershares/Set write permissions for the
examplegroup:# chgrp example /var/lib/samba/usershares/ # chmod 1770 /var/lib/samba/usershares/- Set the sticky bit to prevent users to rename or delete files stored by other users in this directory.
Edit the
/etc/samba/smb.conffile and add the following to the[global]section:Set the path to the directory you configured to store the user share definitions. For example:
usershare path = /var/lib/samba/usershares/Set how many user shares Samba allows to be created on this server. For example:
usershare max shares = 100If you use the default of
0for theusershare max sharesparameter, user shares are disabled.Optional: Set a list of absolute directory paths. For example, to configure that Samba only allows to share subdirectories of the
/dataand/srvdirectory to be shared, set:usershare prefix allow list = /data /srv
For a list of further user share-related parameters you can set, see the
USERSHARESsection in thesmb.conf(5)man page on your system.Verify the
/etc/samba/smb.conffile:# testparmReload the Samba configuration:
# smbcontrol all reload-configUsers are now able to create user shares.
1.11.2. Adding a user share 링크 복사링크가 클립보드에 복사되었습니다!
After you enabled the user share feature in Samba, users can share directories on the Samba server without root permissions by running the net usershare add command.
Synopsis of the net usershare add command:
net usershare add share_name path [[ comment ] | [ ACLs ]] [ guest_ok=y|n ]
If you set ACLs when you create a user share, you must specify the comment parameter prior to the ACLs. To set an empty comment, use an empty string in double quotes.
Note that users can only enable guest access on a user share, if the administrator set usershare allow guests = yes in the [global] section in the /etc/samba/smb.conf file.
예 1.5. Adding a user share
A user wants to share the /srv/samba/ directory on a Samba server. The share should be named example, have no comment set, and should be accessible by guest users. Additionally, the share permissions should be set to full access for the AD\Domain Users group and read permissions for other users. To add this share, run as the user:
$ net usershare add example /srv/samba/ "" "AD\Domain Users":F,Everyone:R guest_ok=yes
1.11.3. Updating settings of a user share 링크 복사링크가 클립보드에 복사되었습니다!
To update settings of a user share, override the share by using the net usershare add command with the same share name and the new settings. See Adding a user share.
1.11.4. Displaying information about existing user shares 링크 복사링크가 클립보드에 복사되었습니다!
Users can enter the net usershare info command on a Samba server to display user shares and their settings.
Prerequisites
- A user share is configured on the Samba server.
Procedure
To display all user shares created by any user:
$ net usershare info -l [share_1] path=/srv/samba/ comment= usershare_acl=Everyone:R,host_name\user:F, guest_ok=y ...To list only shares created by the user who runs the command, omit the
-lparameter.To display only the information about specific shares, pass the share name or wild cards to the command. For example, to display the information about shares whose name starts with
share_:$ net usershare info -l share_*
1.11.5. Listing user shares 링크 복사링크가 클립보드에 복사되었습니다!
If you want to list only the available user shares without their settings on a Samba server, use the net usershare list command.
Prerequisites
- A user share is configured on the Samba server.
Procedure
To list the shares created by any user:
$ net usershare list -l share_1 share_2 ...To list only shares created by the user who runs the command, omit the
-lparameter.To list only specific shares, pass the share name or wild cards to the command. For example, to list only shares whose name starts with
share_:$ net usershare list -l share_*
1.11.6. Deleting a user share 링크 복사링크가 클립보드에 복사되었습니다!
To delete a user share, use the command net usershare delete command as the user who created the share or as the root user.
Prerequisites
- A user share is configured on the Samba server.
Procedure
Delete a user:
$ net usershare delete share_name