Setting up a shared directory under Linux

The file or directory sharing function of the Linux system is very powerful and flexible, and its control of permissions can be very detailed. Of course, if you set it through the command line, then for those who are new to the Linux system It will be a headache for users. But if you are in a network environment with low security requirements, you can create a shared folder under a linux system with just a few simple steps. The following is a step-by-step description using Ubuntu as an example:

Install samba and smbfs: sudo apt-get install samba
Create a shared directory: sudo mkdir /home/[username]/[foldername] 
Set directory permissions: sudo chmod 777 /home/[username]/[foldername] 
Set directory sharing: sudo vi /etc/samba/smb.conf 

Add at the end of the document:

[Share]
path = /home/[username]/[foldername]
public = yes
writable = yes
force user = nobody
force group = nogroup
force create mode = 0644
force directory mode = 0755
create mode = 0644
directory mode = 0755

  • path - the path to the shared file
  • force user - owning user
  • force group - belongs to the user group
  • create mode – This configuration defines the properties of newly created files. When Samba creates a new file, it will map the permissions of the dos file to the corresponding unix permissions, and the permissions obtained after the mapping will perform AND operations with the value defined by this parameter. Then perform the OR operation with the force create mode below, so as to get the final file permissions under linux.
  • force create mode - see description above. The permission bits set by this parameter must appear in the file properties.
  • directory mode - This configuration is similar to the create mode parameter, except that it applies to newly created directories. When Samba creates a new directory, it will add the file attribute mapped by dos->linux to the value defined by this parameter, and then or the force directory mode, and then set the directory attribute according to this value.
  • force directory mode - see description above. Equivalent to the permission bits set in this parameter must appear in the properties of the directory.

Restart the service: sudo /etc/init.d/samba restart

Note: The above [username] is the user directory under the linux system, and [foldername] is the folder name. Please replace it when using it.

Well, now you can use \\ip\share on your windows terminal to access the shared folder of the linux system.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325964777&siteId=291194637