This document uses fedora 12 as an example to describe how to configure Samba to share files between Linux and Windows systems.
Install samba
1. Run the following command to check whether Samba and samba-client have been installed:
Yum info samba-Client
If you have installed the package, installed packages will be displayed in the first line of the command output. If available packages is displayed, it indicates that the packages are not installed. Continue to Step 1 to install the packages.
2. Run the following command to install the SDK: Root User or sudo)
Yum install samba-Client
Access Windows sharing from Fedora
Samba-client provides support for the CIFS File System for the mount command, including windows sharing.
If you only want to temporarily access a Windows share, you can manually run the following command (root user or sudo) to mount Windows share (assuming we want to access the win_share directory on 192.168.1.2, the username and password are respectively username and password. To mount them to the/mnt/win_share directory, the owner is Linux User linux_user ):
Mount-t cifs-O uid = linux_user, user = username, password = password, file_mode = 0644, dir_mode = 0755 // 192.168.1.2/win_share/mnt/win_share
If you need to use the shared directory for a long time, add the following content to/etc/fstab, so that the system will automatically mount the shared directory each time:
// 192.168.1.2/win_share/mnt/win_share CIFS uid = linux_user, user = username, password = password, file_mode = 0644, dir_mode = 0755 0
For more options, see the man page of Mount. CIFS: Man mount. CIFS
Access fedora sharing from Windows
Assume that you want to access the/opt/share directory (opt_share) on fedora (IP Address: 192.168.1.3) from Windows using linux_user and read/write mode.
1. Edit the/etc/smb. conf file.
In [Global]
Some settings window workgroup name workgroup = group_name
Add the following content at the end of the file:
[Opt_share] <br/> Path =/opt/share <br/> Public = Yes <br/> writeable = Yes <br/> write list = linux_user <br/>
Note: The/opt/share directory must be writable to linux_user.
2. Add the corresponding Samba user to linux_user and set the password:
Sudo smbpasswd-A linux_user
3. Start the samba Service
Sudo/etc/init. d/SMB start
To enable the samba service to automatically start upon startup, run the following command:
Sudo/sbin/chkconfig -- level 35 SMB on
4. Modify the firewall configuration to allow Samba access
Run sudo system-config-firewall. On the Trusted Services configuration page that appears, select Samba and samba client, and apply
5. Modify SELinux settings
If SELinux is enabled, the above configuration can only be accessed in read-only mode. You need to modify SELinux settings:
Sudo chcon-T samba_share_t/opt/share
6. Use linux_user and the password you just set to access/192.168.1.3/opt_share on a Windows server.
7. Use Symbolic Link)
To use a symbolic link to mount a directory (such as/something/else) to a samba shared directory, perform the following steps:
- Modify the/etc/samba/smb. conf file, add the following settings in [Global], and then restart the samba Service (Sudo/etc/init. d/SMB restart
)
Follow symlinks = Yes
Wide links = Yes
UNIX extensions = No
- Ln-S/something/else/opt/share/something_else
- Chcon-T samba_share_t-r/something/else/
- To write data to this directory, grant the write permission to linux_user for/something/else.
References
Personal fedora 12 Installation Guide