The first thing we need to do is create a folder that will serve as a shared mount point. For simplicity, we name this Folder share and place it under/media. Open your terminal and execute the following command:
Install some softwareNow we have to install a system that allows cross-platform file sharing. This system is cifs-utils. In the terminal window, enter:
sudo apt-get install cifs-utils
This command also installs all the dependencies of cifs-utils.
After the installation is complete, open the file/etc/nsswitch. conf and find this line:
hosts: files mdns4_minimal [NOTFOUND=return] dns
Edit this line to make it look like this:
hosts: files mdns4_minimal [NOTFOUND=return] wins dns
Now you need to install windbind so that your Linux machine can resolve the Windows machine name in the DHCP network. Run the following command on the terminal:
sudo apt-get install libnss-windbind windbind
Run this command to restart the network service:
sudo service networking restart
Attach a network driveNow we need to map the network drive. Here we must edit the/etc/fstab file. Before you edit the file for the first time, use this command to back up the following file:
sudo cp /etc/fstab /etc/fstab.old
To restore the file, run the following command:
sudo mv /etc/fstab.old /etc/fstab
Create an authentication information file. smbcredentials in your home directory. Add your USER name and PASSWORD to this file, as shown in the following figure (replace USER and PASSWORD with the actual USER name and PASSWORD ):
username=USERpassword=PASSWORD
You need to know the group ID (GID) and user ID (UID) of the user who mounted the drive ). Run the following command:
id USER
USER is your actual USER name. You should see information similar to this:
uid=1000(USER) gid=1000(GROUP)
USER is the actual USER name and GROUP is the GROUP name. The numbers before (USER) and (GROUP) will be used in the/etc/fstab file.
It is time to edit the/etc/fstab file. Open the file in your editor and add the following line to the end of the file (replace the following all uppercase fields with the IP address of the remote machine ):
//192.168.1.10/SHARE /media/share cifs credentials=/home/USER/.smbcredentials,iocharset=uft8,gid=GID,udi=UID,file_mode=0777,dir_mode=0777 0 0
Note: The content above should be on the same line.
Save and close the file. Run
Sudo mount-Command. Check/media/share. You should be able to see the files and folders on the network share.
Sharing is simpleWith cifs-utils and Samba, The ing Network Sharing is incredibly simple on a Linux machine. Now, you no longer need to manually remount those shares each time the machine is started.
From: https://linux.cn/article-7580-1.html
Address: http://www.linuxprobe.com/linux-windows-share.html