Linux can access windows shared files through Samba. if the smb service has been started, enter smb: // 172.30.7.48/in the browser to list the shared folders, click a folder. if you need a password, you will be prompted to enter the password. Samba...
Linux can access windows shared files through Samba. if the smb service has been started, enter smb: // 172.30.7.48/in the browser to list the shared folders, click a folder. if you need a password, you will be prompted to enter the password. The concepts and usage of Samba are as follows: 1 Samba introduction Samba (abbreviated as SMB) is a network server used for sharing files in Linux and Windows; samba can be used for shared files between Windows and Linux, and also for shared files between Linux and Linux. However, it provides a better network file system NFS for shared files between Linux and Linux, NFS also requires server setup. we all know that each machine in the Windows network can be a file sharing server or a client. Samba can also do the same, for example, if a Linux machine is installed with the Samba Server, it can act as a shared Server, and can also be used as a client to access Windows shared file systems in other networks, or Sabmba servers in other Linux systems; on the Windows network, we can see that the shared file function knows that we can directly use the shared folder as a local hard disk. In Linux, Samba is used to provide a shared file system to machines on the network. It can also be used to mount the sharing of other machines on the local machine; in a sense, this is different from FTP. The netbios protocol used by Samba. if you fail to use Samba, linux and Windows, Linux, and Linux 2 Samba functions and application scope Samba should be mainly used in networks where Windows and Linux systems coexist. if a network environment is a Linux or Unix system, there is no need to use Samba. NFS should be better. What services does Samba provide for us? It mainly involves shared files and shared printers; 3 Samba two server-related startup programs, clients, and server configuration files; 3.1 Samba has two servers, one being smb and the other being nmb; smb is the main startup server of Samba, allowing other machines to know what the machine shares. if the nmb server is not enabled, it can only be accessed through IP addresses, for example, in Windows Internet Explorer, enter the following line to access; \ 192.168.1.5 \ shared directory \ 192.168.1.5 \ opt www.2cto.com while nmb is used for parsing. what is the resolution? Resolve the working group shared by this Linux machine and the netbios name under this working group. In general, in the RPM package system, if Samba is installed with the RPM Package, generally, you can start the Samba server as follows: [root @ localhost ~] #/Etc/init. d/smb start SMB service: [OK] start NMB service: [OK] what if it is stopped? Add stop after smb; restart is restart [root @ localhost ~] #/Etc/init. d/smb stop [root @ localhost ~] #/Etc/init. d/smb restart for all systems, the general method is to directly run smb and nmb; of course, you need to know the directory where smb and nmb are located; if it is a self-compiled Samba, you should know where you put Samba; [root @ localhost ~] #/Usr/sbin/smbd [root @ localhost ~] #/Usr/sbin/nmbd run the following command to check whether the server is running: [root @ localhost ~] # Pgrep smbd [root @ localhost ~] # Pgrep nmbd: disable the Samba Server. you can also use the following methods, most of which are common. run the command with the root permission. [root @ localhost ~] # Pkill smbd [root @ localhost ~] # Pkill nmbd 3.2 check the port and firewall of the Samba Server. how can this problem be solved? Sometimes your firewall may block the port of the smbd server, so we should use the port occupied by the smbd server. in the following view, we know that the ports occupied by smbd are 139 and 445; [root @ localhost ~] # Netstat-tlnp | grep smb tcp 0 0.0.0.0: 139 0.0.0.0: * LISTEN 10639/smbd tcp 0 0.0.0.0: 445 0.0.0.0: * LISTEN 10639/smbd if you have a firewall, you must open these two ports. If you do not know how to open it. Maybe you are a newbie like me, or clear firewall rules. [root @ localhost ~] # Iptables-F or [root @ localhost ~] #/Sbin/iptables-F 3.3. check the configuration file of the Samba Server. if we use the Samba software package that comes with the Linux release, generally, the configuration files of the Samba server are located in the/etc/samba directory, and the main configuration file of the server is smb. conf; there are also user configuration files such as smbpasswd, smbusers, and lmhosts (you 'd better check the content of these files); and there is a file such as secrets. tdb, this file is automatically generated by the Samba Server startup. let's add the description of these files according to the progress of the tutorial. all at once, I feel that there is too much content; therefore, only 1.1 points are available. 3.4. some Samba tools in Linux (server and client); smbcacls smbcontrol smbencrypt smbmount smbprint smbstatus smbtree smbclient smbcquotas smbmnt Smbpasswd smbspool smbtar smbumount smbd nmbd mount www.2cto.com among them, where smbd, nmbd, smbpasswd are the server side, and most of the other clients. these are not all well-versed, but at least a few; for example, smbmount (that is, the usage of the mount plus parameter) and smbclient; 3.5 common tools in Linux: mount (smbmount) and smbclient; how to view Linux sharing in Windows; 3.5.1 view Windows shared files in the network and Samba shared files in Linux in the Linux system; in general, we need to use smbclient; common usage is nothing more than the following; [root @ localhost ~] # Smbclient-L // IP address or computer name. add it later. 3.5.2 access the Linux Samba server to share files in Windows, view the working group, or enter the \ IP address or computer name in the browser to see what is shared on the machine. click the mouse to complete the operation; if the access fails, do not forget to clear the firewall plan for Linux, or let the corresponding port pass; 3.5.3 mount the smbfs file system; mount usage, load the shared folder in the network to the local machine; mount is used to mount the file system. SMB, as a network file system, can also be mounted with mount; smbmount is also a variant of mount; mount mounting smbfs usage; mount-t smbfs-o codepage = cp936, username = username, password = password,-l // IP address/shared folder name hanging Mount point or mount-t smbfs-o codepage = cp936, username = username, password = password, -l // Computer Name/shared folder name mount point or mount-t smbfs-o codepage = cp936 // IP address or computer name/shared folder name mount point usage: smbmount-o username = username, password = password, -l // IP address or computer name/shared folder name Mount point smbmount // IP address or computer name/shared folder name Mount point www.2cto.com description: If your server is shared by share, you do not need a user name or password to mount the file. if a prompt is displayed, press enter to mount the file. you can also use smbmount to mount the file, in this way, you do not need to use mount-t smbfs to specify the file system type. for mount points, we need to create a folder by ourselves. for example, we can create/ Opt/smbhd, which can be explained by you. in the mount command, we found that codepage = cp936 is the encoding of the file system on the server, cp936 is simplified Chinese. of course you can use utf8 and so on. try again. If you mount a remote smbfs file system with garbled characters in simplified Chinese, you must specify the encoding when mounting the file system. 4. let's start with the simplest example, implementation of readable and writable for anonymous users; Step 1: Change smb. conf to implement the simplest function, so that all users can read and write a folder shared by a Samba server; we need to modify smb. conf; first, back up smb. conf file; [root @ localhost ~] # Cd/etc/samba [root @ localhost samba] # mv smb. conf smb. confBAK and then we will recreate an smb. conf file; [root @ localhost samba] # touch smb. conf and then we write the following section into smb. conf; [global] workgroup = LinuxSir netbios name = LinuxSir05 server string = Linux Samba Server TestServer security = share [linuxsir] path =/opt/linuxsir writeable = yes browseable = yes guest OK = yes annotation: [global] this section is a global configuration and is required. There are the following lines: workgroup is the working group displayed in Windows; here I set LinuxSir netbios name is the computer name displayed in Windows; www.2cto.com server string is the Samba server description, which can be defined by yourself. this is not important. security is the authentication and logon method. here we use share. There are many verification methods, this is one of them; the other is commonly used for user authentication; if share is used, there is no need to set the user and password; [linuxsir] the shared directory is displayed in Windows. path = can be used to set the directory to be shared; writeable can be written, I set it to writable; browseable can be viewed, yes. the anonymous user of guest OK logs on as a guest user. Step 2: create a directory and authorize the user; [root @ localhost ~] # Mkdir-p/opt/linuxsir [root @ localhost ~] # Id nobody uid = 99 (nobody) gid = 99 (nobody) groups = 99 (nobody) [root @ localhost ~] # Chown-R nobody: nobody/opt/linuxsir Note: For nobody authorization, we first use the id command to view the information of the nobody user and find that the user group is also nobody, we must take this as the standard. In some systems, the nobody user group is not the nobody. Step 3: Start the smbd and nmbd servers; [root @ localhost ~] # Smbd [root @ localhost ~] # Nmbd Step 4: Check the smbd process and check whether the Samba server is running. [root @ localhost ~] # Pgrep smbd 13564 Step 5: access Samba server sharing; in Linux, you can use the following command to access it; [root @ localhost ~] # Smbclient-L // LinuxSir05 Password: NOTE: Press enter directly in Windows. you can use the following method to access the Password: // LinuxSir05/Michael_Jin
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.