samba installation and configuration

I need to use samba recently, and I have been groping for a while, so I might as well make a record. The following is the samba configuration and use in the ubuntu environment, which may be different in different environments.

1. Install samba on the Linux side

Execute the following command and wait for the installation to complete.

sudo apt-get install samba

2. Linux side configuration

2.1 Add samba user

You can add new users or use existing linux users. Samba and linux share users, but the password still needs to be reset. Here, add a new user named ubuntu.

sudo useradd ubuntu

2.2 Set samba user password

After typing the following command, you will be asked to enter the password twice, just follow the prompts.

sudo smbpasswd -a ubuntu

2.3 Select or create a new shared folder

I created a new directory here /home/ubuntu/shareas a shared folder.

2.4 Modify the samba configuration file

The configuration file path is generally /etc/samba/smb.conf, type the following command.

sudo vim /etc/samba/smb.conf

Add the following content at the end of the file (mainly modify the path in path, and then change ubuntu to your own user name):

[share]
comment = share folder
path = /home/ubuntu/share
browseable = yes

create mask = 0700
directory mask = 0700
valid users = ubuntu
force user = ubuntu
force group = ubuntu
public = yes
available = yes
writable = yes

2.5 restart samba

sudo  ect/init.d/smbd restart

At this point, the process of the linux side is completed, and the following is the process of connecting on the local windows side.

3 local windows connection

3.1 Check the ip of the linux machine

Generally in the second line, the corresponding string of numbers after inet is, similar to192.168.123.123

ifconfig

3.2 Connection Mapping

Use the shortcut key win + R, enter in the pop-up cmd \\192.168.123.123, and replace it with your linux machine ip. Then enter the user name and password configured in Section 2 to log in.

After successful access, you can right-click the shared folder in linux, and then select "map network drive", and then you can use it like a local disk on the windows side.

4 Possible problems

4.1 On the window side, when modifying files in samba, it prompts that there is no permission.

As mentioned earlier, samba shares user name and permissions with linxu, so in this case, the user you log in does not have sufficient permissions.
The recommended solution is to use your current linux user as the samba account, so that the permissions are consistent. Moreover, the user attributes of the files can always be kept consistent.

Guess you like

Origin blog.csdn.net/hejnhong/article/details/126374539