Methods for mutual access between Windows and Linux File Systems

Source: Internet
Author: User

Methods for mutual access between Windows and Linux File Systems

First, we know several file-based services: ftp and sftp, both of which are file transmission services, focusing on network transmission rather than real-time mutual access. Generally, you need to operate the same directory remotely and locally, for example, compile and run the code in Linux by using a variety of powerful ides in Windows. If you compile and write the code in Windows and then copy it to Linux for compilation, It is very troublesome to modify the code directly in Linux and synchronize it back to Windows, which is quite troublesome. Of course, some people will say that all work is done in Linux. VI and Linux Command lines are powerful enough and there is no reason to use Windows systems, the focus of this article is not on command line proficiency and productivity issues.

How can I access remote files like accessing a local file system? What should we do if the remote system is different from the local system.

We know that in Windows systems, you can share directories to allow direct access from remote systems. In fact, Windows provides a remote file system mechanism and a CIFS protocol for NAS. For a Linux system, another NAS protocol-NFS protocol is also available for remote access. Can these two NAS protocols communicate with each other? The answer is no. Although the two cannot communicate with each other, the CIFS protocol has been implemented on the server and client of the Linux system. In this way, the existing implementation can be used for both Linux sharing for Windows and Windows sharing for Linux.

On the contrary, is there an NFS client or server on Windows? Yes, but it is not often used. I will not detail it here.

Here, we mainly discuss how to implement cross-file system and cross-operating system sharing between two systems by using the CIFS protocol in Linux. As described above, there are two ways to achieve sharing. Linux serves as the CIFS server and client respectively. The following two methods are used to describe the operation steps and simple principles:

I. Samba software shares the Linux File System with Windows users

Samba is hailed as the fifth most valuable open-source software. It is easy to obtain and configure. The following uses the fedora system as an example to check whether samba has been installed locally. If/etc/init. if the d/smb file exists, the samba software has been installed. Otherwise, run the following command to install it:

 
 
  1. yum install samba 

After the installation is complete, modify the configuration file, open:/etc/samba/smb. conf, and add the following configuration at the end of the file:

 
 
  1. [root]  
  2.   comment = root 
  3.   path = /   
  4.   creat mask = 64 
  5.   writeable = yes   
  6.   browseable = yes 
  7.   valid users = root 

This configuration means to create a share named root and share the root file directory "/" with the user. The User Name allowed to log on is root.

Then add the root user to the samba system and run the following command:

 
 
  1. smbpasswd -a root 

Follow the prompts to set the root user password.

Restart the samba service.

 
 
  1. service smb restart 

Check whether the smb process is running:

 
 
  1. root      1787  0.0  0.4  33068  4784 ?        Ss   21:51   0:00 smbd  

  2. root      1788  0.0  0.2  33068  2580 ?        S    21:51   0:00  \_ smbd 

On the Windows client that needs to access the Linux system, open the Windows Resource Manager and enter \ 192.168.1.110 in the address bar.

You will find that there is a shared root prompt. When you double-click the access, you will be prompted to enter the user name and password, enter the previously configured root user and password to access. Here the Samba software implements the CIFS server. Windows Resource Management serves as a client to access a remote shared file system. To make it easier to use the file system, you can map the file system to a local drive letter, so that tools on Windows can use the directory like local disks. All the operations on Windows for sharing will be synchronized to the Linux system in real time.

Ii. Sharing of Linux access to Windows

The above Samba method is commonly used. In addition, Windows systems are naturally a CIFS server and client. Since Windows systems can share directories with Windows systems, can Linux systems access these shares? The answer is yes. Thanks to the powerful VFS support, Linux supports mounting and accessing various file systems. The mount tool supports file systems mounted on CIFS or even NTFS. If it is a Linux virtual machine on a Windows host, you can directly use the Virtual Machine management software, such as Vmware, to directly share a local disk partition to the Linux system, linux can be mounted Based on the file system type of Windows disk partition. This solution is not detailed here.

First, we need to share a Windows directory:

The following uses Windows XP as an example. Windows 7 is not verified and should be similar. Before sharing, you must first make sure that the server service in Windows is enabled, such:

Right-click the directory to be shared, select properties, and select the "share" page, for example:

Select Share this folder on the network and specify the Share Name. Select whether to allow remote users to modify the folder as needed. In this way, the folder is shared to remote access.

Mount the share in Linux:

 
 
 
  1. [root@f2 ~]# mount -t cifs -o username="Test" //192.168.1.100/sourcecode /root/sourcecode  
  2. Password for Test@//192.168.1.100/sourcecode: 

Enter the password of the specified user as required.

Now, the Windows Shared sourcecode directory has been mounted to the Linux system, and the Linux system can access the directory like accessing the local directory.

This method should be a better access method, because in general, the files and workspace we operate on are on Windows, and only a few times need to be compiled and debugged on Linux. However, it is a little troublesome to use. Note: You have encountered a problem that data cannot be transmitted between a Windows system and a virtualized Linux system because the firewall of the Windows system is not enabled.

Related Article

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.