Linux Samba file Sharing service configuration (implemented with win share)

Source: Internet
Author: User
Tags mkdir iptables firewall

1. Installation:

Yum-y Install Samba
2, add users (this user must be system users):
A, add two virtual users to the system first:

Useradd cm-s/sbin/nologin-m
Useradd choumei-s/sbin/nologin-m
b, set the Samba user password

Smbpasswd-a cm
Smbpasswd-a Choumei
Description: The SMBPASSWD command can be used to perform different account maintenance tasks in addition to the Samba user account that can be added using different command options.
-H: Display SMBPASSWD command format help
-A: Add specified user account
-D: Disable the specified user account
-e: Enable the specified user account
-X: Delete the specified user account

3, modify the configuration file:
Vim/etc/samba/smb.conf

[Share]
Comment = Web directories
Path =/var/winshare
public = No
writable = no
browseable = yes #Samba服务器共享目录是否可见
Security = User #认证方式
Valid users = choumei,cm
Write list = +choumei
Description: Specify two users, one with read-write access and one read-only permission.
4, the smb.conf file configuration test
Testparm
5. Start Samba Service

Service SMB Start
6. View Samba Service Status

Smbstatus
7, window view
\\iP
Good luck to see directly, and normal.
Does not show the processing done:
A, Vim/etc/sysconfig/iptables
-A Input-p TCP--dport 139-j ACCEPT
-A Input-p TCP--dport 445-j ACCEPT
Service Iptables Restart
Description: Open Samba 139, 445 ports, or shut down the firewall.
View the link port for Samba netstat-atlunp|grep SMB
B. Modify the group of shared files, groups of users as samba, users, or add permissions to the folder to 777.
C, Close SELinux
No need to reboot Linux:setenforce 0
Need to reboot Linux:
Vim/etc/selinux/config
Change the selinux=enforcing into selinux=disabled
Reboot

Another: Midway debugging

A, window test, delete test data connected to Samba
CMD => net use */del/y
b, when the Samba server modifies the parameters, it needs:
Service SMB Restart


The Samba server implements a directory file share with Windows.

1. First see if Samba is installed on this computer (switch to root)
[Root@localhost ~]# Rpm-qa | grep "Samba"
System-config-samba-1.2.39-1.el5
samba-3.0.25b-0.el5.4
samba-common-3.0.25b-0.el5.4
samba-client-3.0.25b-0.el5.4
[Root@localhost ~]#
As you can see from the viewing results, Samba-related packages are already installed, and if not, download the appropriate version of the software installation

2. Create a local Samba-shared directory folder (such as/home/sharefolder)
[Root@localhost home]# pwd
/home
[Root@localhost home]# ls
Sunrier
[Root@localhost home]# mkdir Sharefolder
[Root@localhost home]# pwd
/home
[Root@localhost home]# ls
Sharefolder Sunrier
[Root@localhost home]# LL
Total 20
Drwxr-xr-x 2 root root 4096 08-30 10:04 Sharefolder
DRWX------3 sunrier sunrier 4096 08-29 11:25 sunrier
[Root@localhost home]# chmod-r 777 Sharefolder
[Root@localhost home]# LL
Total 20
DRWXRWXRWX 2 root root 4096 08-30 10:04 Sharefolder
DRWX------3 sunrier sunrier 4096 08-29 11:25 sunrier
[Root@localhost home]#

3. Turn off the Samba server
View Samba Server Status
[root@localhost ~]# service SMB status
SMBD has stopped.
NMBD has stopped.
[Root@localhost ~]#
The above view shows that the Samba service is not open at this time and is in a closed state;
If not shut down, use the service SMB Stop command to turn off the samba service

4. Modify/ETC/SAMBA/SMB.CNF configuration file
(1) Change the security = user in the/ETC/SAMBA/SMB.CNF configuration file to Security = share;
Share means that security is a shared mode
(2) Add the following configuration to the end of the/ETC/SAMBA/SMB.CNF configuration file
[Sharefolder]
Comment = Share
Path =/home/sharefolder
Public = yes
browseable = yes
writable = yes
;p rintable = No

Configuration Description:
[sharefolder]       #共享目录的名字
Comment = share       #共享目录的说明, equivalent to annotations
Path =/home/sharefolder #共享目录的路径
public = yes       # Specifies whether the directory can guest access the
browseable = yes     #指定目录是否可以容许浏览
writable = yes       #指定目录是否可以写 (yes writable, no is readable only)
;p rintable = no      #指定目录是否可以打印 (yes is printable, no is not allowed to print)
#配置的内容前面加, equivalent to annotations, which does not work

5. Turn on the Samba server
[root@localhost ~]# service SMB start
Start the SMB service: [OK]
Start NMB service: [OK]
[Root@localhost ~]# Pstree | grep mbd
|-nmbd
|-SMBD---SMBD
[Root@localhost ~]#

Note:
If you want to boot the Samba service, execute the following command
Set the boot up Samba service first and reboot
[Root@localhost ~]# chkconfig SMB on
[Root@localhost ~]# reboot

6. View the virtual machine IP address
[Root@localhost ~]# Ifconfig
Eth0 Link encap:ethernet hwaddr 00:0c:29:c8:c4:67
inet addr:192.168.168.130 bcast:192.168.168.255 mask:255.255.255.0
Inet6 ADDR:FE80::20C:29FF:FEC8:C467/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:446 errors:0 dropped:0 overruns:0 frame:0
TX packets:271 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:54895 (53.6 KiB) TX bytes:39131 (38.2 KiB)
interrupt:67 Base address:0x2024

Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up loopback RUNNING mtu:16436 metric:1
RX packets:1924 errors:0 dropped:0 overruns:0 frame:0
TX packets:1924 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2909336 (2.7 MiB) TX bytes:2909336 (2.7 MiB)

[Root@localhost ~]#

7. Enter in the running of Windows: \\192.168.168.130 or \\192.168.168.130\ShareFolder, that is to realize sharing


Supplementary Note:
1. Some tutorials on the internet may have a shutdown firewall, I did not close the firewall in this practice
Turn off the Redhat firewall
[Root@localhost ~]# Iptables-f
[Root@localhost ~]#
Or
[root@localhost ~]# service iptables stop

2. The above operation after the installation of the package, can also be set through the graphical interface
Steps:
(1) Turn off the samba service first
(2) Select "System"-> "admin"-> "Server Settings"-> "Samba"
(3) Select "Add Share"
In the basic window:
Set up a shared directory
Set share name
Set description
Set Read and Write permissions
Set whether to display
In the Access window:
Set User access rights
(4) Select "Preferred Items"-> "Server Settings"
In the basic window:
Can not set, default settings
In the Security window:
Set the authentication mode to "shared"
Others for default settings
(5) Start Samba service
(6) View the virtual machine IP address
(7) In the operation of Windows input: \ \ virtual machine IP address or \ \ virtual machine IP address \ Share name, that is, to achieve shared


Note: This practice operation all users have access to the right to operate

Redhat installation Vmtools steps:
1. Switch to root permission
2. Mount the virtual CD
Mount/dev/cdrom/mnt/cdrom
If there is no CDROM directory under/MNT, you need mkdir cdrom
3.cd/tmp
4. Delete the previous directory Vmware-tools-distrib
Generally put in/tmp/vmware-tools-distrib
5.tar zxpf/mnt/cdrom/vmwaretools-<xxxx>.tar.gz
Umount/dev/cdrom
6.CD Vmware-tools-distrib
./vmware-install.pl
7.
/etc/init.d/network stop
Rmmod vmxnet
Modprobe vmxnet
/etc/init.d/network start

Note: Refer to Vmtools Installation instructions step.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.