1 background
To Linux just 1 years, vim operation can not deal with the project code, has been the GNOME Desktop + clion for the development environment, helpless on the server does not have such an environment,
See colleague is (Windows) Source Insight + WinSCP + Linux development, syncing files back and forth is a bit of a hassle, so try to build a Samba server to share files.
But I hope to be transferred to Vim in the future.
2 environment
CentOS System
cat /etc/redhat-7.2. 1511
Samba Server
[Email protected] ~]# RPM-qi Sambaname:sambaepoch:0Version:4.4.4Release:9. El7architecture:x86_64install Date:sun -Dec . One: -: AboutPM Cstgroup:system Environment/daemonssize:1869290License:gplv3+ and lgplv3+Signature:rsa/sha256, Mon +Nov . Geneva: -: -AM CST, Key ID 24c6a8a7f4a80eb5source Rpm:samba-4.4.4-9. El7.src.rpmBuild Date:mon -Nov . .: to:GenevaPM cstbuild Host:worker1.bsys.centos.orgRelocations: (not relocatable) Packager:centos Buildsystem//bugs.centos.org>Vendor:CentOSURL:http://www.samba.org/Summary:server and Client software to interoperate with Windows Machinesdescription:samba are the standard Windo WS Interoperability Suite of programs forLinux Andunix.
3 Installation
Yum Install Samba samba-client
4 configuration
Go to the Samba configuration directory
[Email protected] ~]# cd/etc/samba/
Backup smb.conf
MV smb.conf Smb.conf.origin
New smb.conf
[Email protected] samba]# vim smb.conf
The content is as follows, save and exit
[Global] Workgroup = Workgroup Server string = Ted Samba server%v NetBIOS name = Tedsamba Security = user map to G Uest = bad User passdb backend = tdbsam[fileshare] comment = share some files path =/smb/fileshare public = yes writeable = yes
Create mask = 0644
Directory mask = 0755[webdev] comment = project development directory Path =/smb/webdev Valid users = ted< C15/>write list = ted printable = no create mask = 0644 directory mask = 0755
Comments:
The workgroup item should be consistent with the Windows host, this is workgroup
Security, map to guest entry set to allow anonymous user access
Then there are two sections, which are actually two directories, and the section name is the directory name (which you can see on the Windows map).
The first directory name is FileShare, anonymous, public, writable
The second directory is WebDev, limited to Ted user access
Default file attribute 644/755 (otherwise, the newly created file in this directory on Windows will have the "executable" property)
Create user
-G co3-s/sbin/-
Note Here SMBPASSWD will use the system user. Set Password to 1
Create a shared directory
mkdir -p/smb/chown nobody:nobody/smb/fileshare/chown ted:co3/smb/ webdev/
Note Set properties, otherwise you won't be able to access them.
Start Samba service, set boot up
/etc/systemd/system/multi-user.target.wants/smb.service to/usr/lib/systemd/system/
Open ports
[Email protected] samba]# firewall-cmd--permanent--add-port=139/tcpsuccess[[email protected] samba]# Firewall-cmd--permanent--add-port=445/tcpsuccess
Systemctl Restart Firewalld
Or you can just shut down the firewall.
5 use
Linux Access
You can use Testparm to test if Samba is configured correctly
[email protected] samba]# testparm Load SMB config files from/etc/samba/smb.confrlimit_max:increasing Rlimit_max (1024x768) to minimum Windows limit (16384) Processing section"[FileShare]"Processing Section"[WebDev]"Loaded ServicesfileOK. Server Role:role_standalonepress Enter to see a dump of your service definitions# Global Parameters[global] NetBIOS na Me=Tedsamba Serverstring= Ted Samba Server%v map to guest=Bad User Security=USER idmap config*: backend =Tdb[fileshare] Comment=share some files path=/smb/FileShare Guest OK=Yes Read only=No[webdev] Comment=Project Development Directory path=/smb/WebDev Create Mask=0644
Valid Users=TedWriteList =Ted[[email protected] samba]#
Root user, no password can be used to directly view the Samba server situation
[Email protected] samba]# smbclient-L localhost Enter root's Password:Domain=[workgroup] Os=[windows6.1] Server=[samba4.4.4] Sharename Type Comment--------- ---- -------fileshare disk share some files WebDev disk project development directory ipc$ IPC IPC Service (Ted Samba Server4.4.4) Domain=[workgroup] Os=[windows6.1] Server=[samba4.4.4] Server Comment--------- -------Workgroup Master--------- -------[email protected] samba]#
Windows access1) Access in Windwos Explorer
Access path: \\${samba server IP}, then enter, you can see the shared directory.
FileShare can be accessed anonymously and can access, create, and delete files.
Drag in a TXT file here to see the file on Linux.
2) Map Network Drive
The WebDev directory on the right is required for password access
Here is a demonstration of mapping the directory to a network drive.
Desktop right-click this PC and select Map Network Drive
Fill in the folder location the network path of the shared file, this is \\192.168.118.132\WebDev
Tick "Connect using other Credentials" and click "Finish".
Fill in User password
The network drive can be seen on my Computer (Y)
Here you can put the source project, and then use the IDE under Windows to open, edit, and then compile and run Linux.
Enjoy it~
Later there is a need to replenish the Linux Mount Samba shared directory, permissions configuration, and so on.
6 References
Linux Samba Server Configuration
CENTOS7 Installation Configuration Samba server
Installation and configuration of samba under CentOS7
The Samba server is configured with Security=share, but the information in the Testparm output does not have this, and the client cannot access
SMB Server directory and file permission settings
CentOS 7.2 Installation Configuration Samba server