Home > Article > Operation and Maintenance > How to set up file sharing (like Samba) on Linux
How to set up file sharing (such as Samba) on Linux
1. Introduction
File sharing is a feature widely used in networks for sharing files and files between different devices folder. In Linux, we can use Samba to achieve file sharing. Samba is an open source software suite that allows file and printer sharing between Linux and Windows systems. This article will introduce how to configure Samba file sharing on Linux.
2. Install Samba
Use the following command to install the Samba package:
sudo apt-get install samba
3. Create a shared folder
First, create a folder for sharing. You can choose any place as a shared folder. Here we take /home/share as an example:
sudo mkdir /home/share
Create a configuration file for the Samba server. Use the following command to create the smb.conf file and paste the contents into the file:
sudo nano /etc/samba/smb.conf
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = ubuntu security = user map to guest = Bad User dns proxy = no # 共享文件夹配置 [share] comment = Share Folder path = /home/share browsable = yes guest ok = yes read only = no create mask = 0777 directory mask = 0777
This configuration file first sets the global options of Samba and then defines a file called "share "'s shared folder.
4. Configure the user
Use the following command to create a new Samba user:
sudo smbpasswd -a username
Replace "username" with the username to be created , and set a password.
Next, add access permissions for the new user by editing the Samba user configuration file using the following command:
sudo nano /etc/samba/smb.conf
Add the following at the end of the file and replace " username" with the previously created username:
[share] valid users = username
5. Restart the service
Restart the Samba service to make your configuration take effect:
sudo service smbd restart
6. Access the shared folder
In Windows system, open the resource manager and enter the following address to access the shared folder:
\linux-ip-addressshare
Replace "linux-ip-address" with the IP address of your Linux system.
7. Summary
By configuring Samba, we can easily set up file sharing on Linux systems. This article provides detailed steps for installing Samba, creating shared folders, configuring users, and accessing shared folders, and provides corresponding command examples. I hope this article helps you set up file sharing on Linux.
The above is the detailed content of How to set up file sharing (like Samba) on Linux. For more information, please follow other related articles on the PHP Chinese website!