- How to share files between a Linux and Windows computer
- Create a shared folder on Windows
- Access a Windows shared folder from Linux, using Konqueror
- Access a Windows shared folder from Linux, using Nautilus
- Access a Windows shared folder from Linux, using the command line
- ChapterВ 2В Managing the Network File System in Oracle Linux
- 2.1В About NFS
- 2.1.1В Supported Versions of NFS
- 2.1.2В About NFS Services
- 2.2В Configuring an NFS Server
- 2.2.1В Configuring an NFS Server by Editing the /etc/exports File
- 2.2.2В Configuring an NFS Server by Using the exportfs Command
- 2.3В Mounting an NFS File System
How to share files between a Linux and Windows computer
The easiest and most reliable way to share files between a Linux and Windows computer on the same local area network is to use the Samba file sharing protocol. All modern versions of Windows come with Samba installed, and Samba is installed by default on most distributions of Linux.
Create a shared folder on Windows
First, create a shared folder on your Windows machine.
- Open the Control Panel.
- Go to Network and Sharing Options.
- Go to Change Advanced Sharing Settings.
- Select Turn on Network Discovery and Turn on File and Print Sharing.
Now, create a new folder to share or choose an existing folder that you’d like to share.
- Right-click the folder and select Properties.
- Go to the Sharing tab.
- Above the Share button is the network name of the share you are creating. It should look like \\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName. Make a note of this network name to use later on your Linux machine.
- Click Share.
Access a Windows shared folder from Linux, using Konqueror
Many Linux distributions use the KDE desktop environment and the Konqueror file manager/browser. If this is what you are using, you can follow these steps to access your Windows shared folder:
- Click the K menu icon.
- Select Internet ->Konqueror.
- In the Konqueror window that opens, click the Network Folders link, or type remote:/ in the address bar and press Enter .
- Click the Samba Shares icon.
- Click the icon of your Windows Home workgroup.
- Click the Workgroup icon.
- Click the icon for your computer.
- When prompted, enter the username and password for the Windows account that created the share.
- Click OK.
Access a Windows shared folder from Linux, using Nautilus
Many Linux distributions, especially those that use the GNOME desktop environment, use the Nautilus file manager. If this is what you’re using, you can follow these steps to access your Windows shared folder:
- Open Nautilus.
- From the File menu, select Connect to Server.
- In the Service type drop-down box, select Windows share.
- In the Server field, enter the name of your computer.
- Click Connect.
Alternatively, in the Nautilus address bar, you can type smb://ComputerName/ShareName and press Enter . For instance, when you created your Windows Share, if the share name was listed as:
Type smb://YOURCOMPUTERNAME/Users/YourUserName/ShareFolderName and press Enter . Note the smb: at the beginning; in Linux, use forward slashes instead of backslashes.
Access a Windows shared folder from Linux, using the command line
You can also access your Windows share from the Linux command line using the smbclient program.
- Open a terminal.
- Type smbclient at the command prompt.
- If you receive a «Usage:» message, this means smbclient is installed, and you can skip to the next step. If the command is not found, however, you need to install smbclient. Follow these steps to install it.
Источник
ChapterВ 2В Managing the Network File System in Oracle Linux
This chapter includes information about managing the Network File System (NFS) in Oracle Linux 8, including tasks for configuring, administering, and using NFS.
For information about local file system management in Oracle Linux, see Oracle В® Linux 8: Managing Local File Systems.
2.1В About NFS
NFS (Network File System) is a distributed file system that enables a client system to access files over a network, as though the files were on local storage.
An NFS server can share directory hierarchies in its local file systems with remote client systems over an IP-based network. After an NFS server exports a directory, and then NFS clients mount this directory, if they have been granted the appropriate permissions. To the client systems, the directory appears as if it were a local directory. Benefits of using NFS include centralized storage provisioning, improved data consistency , and reliability.
2.1.1В Supported Versions of NFS
The following versions of NFS are supported in Oracle Linux 8:
NFS version 3 (NFSv3), specified in RFC 1813.
NFS version 4 (NFSv4), specified in RFC 7530.
NFS version 4 minor version 1 (NFSv4.1), specified in RFC 5661.
NFS version 4 minor version 2 (NFSv4.2), specified in RFC 7862 .
NFSv2 is no longer supported.
NFSv3 provides safe, asynchronous writes and efficient error handling. NFSv3 also supports 64-bit file sizes and offsets, which enable clients to access more than 2 GB of file data.
NFSv3 relies on Remote Procedure Call (RPC) services, which are controlled by the rpcbind service. The rpcbind service responds to requests for an RPC service and then sets up connections for the requested service. In addition, separate services are used to handle locking and mounting protocols, as configuring a firewall to cope with the various ports that are used by all these services can be complex and error-prone.
In previous Oracle Linux releases, NFSv3 was able to also use the User Datagram Protocol (UDP). However, in Oracle Linux 8, NFS over UDP is no longer supported. Further, UDP is disabled in the NFS server by default in this release.
NFSv4 is capable of working through firewalls, as well as the Internet. Also, NFSv4 does not require the rpcbind service. In addition, NFSv4 supports access Control Lists (ACLs), and uses stateful operations.
NFSv4 requires the Transmission Control Protocol (TCP) running over an IP network. As mentioned, NFSv4 does not use rpcbind ; as such, the NFS server listens on TCP port 2049 for service requests. The mounting and locking protocols are also integrated into the NFSv4 protocol, which means that separate services are also not required for these protocols. These refinements make firewall configuration for NFSv4 no more difficult than for a service such as HTTP.
Note that in Oracle Linux 8, NFS clients attempt to mount by using NFSv4.2 (the default version), but fall back to NFSv4.1 when the server does not support NFSv4.2. The mount later falls back to NFSv4.0 and then to NFSv3.
2.1.2В About NFS Services
In Oracle Linux 8, NFS versions rely on Remote Procedure Calls (RPC) between clients and servers. To share or mount NFS file systems, the following required services work together, depending on which version of NFS is implemented. Note that all of these services are started automatically:
Is the server kernel module that services requests for shared NFS file systems.
Is a service that accepts port reservations from local RPC services, which are made available or advertised so that the corresponding remote RPC services can access them and also hat the client is allowed to access it.
Is a process that is used by an NFS server to process mount requests from NFSv3 clients. The service checks that the requested NFS share is currently exported by the NFS server.
Is a process that enables explicit NFS versions and protocols the server advertises to be defined.
Is a kernel thread that runs on both clients and servers. The lockd process implements the Network Lock Manager (NLM) protocol, which enables NFSv3 clients to lock files on the server. The daemon is started automatically whenever the NFS server is run and whenever an NFS file system is mounted.
Is a process that implements the Network Status Monitor (NSM) RPC protocol, which notifies NFS clients when an NFS server is restarted without being gracefully brought down. The rpc-statd service is automatically started by the nfs-server service. This service does not require configuration by the user and is not used with NFSv4.
Is a process that provides NFSv4 client and server upcalls, which map between on-the-wire NFSv4 names (strings in the form of user@domain) and local UIDs and GIDs. Note that for the idmapd process to function with NFSv4, you must configure the /etc/idmapd.conf file. Note that only NFSv4 uses the rpc-idmapd process.
The mounting and locking protocols are incorporated into the NFSv4 protocol. Also, the server listens on TCP port 2049. For this reason, NFSv4 does not need to interact with the rpcbind , lockd , and rpc-statd services. However, the nfs-mountd service is still required to set up exports on the NFS server; but, the service is not involved in any over-the-wire operations.
The rpc-idmapd service only handles upcalls from the kernel and is not itself directly involved in any over-the-wire operations. The service, however, might make naming service calls, which do result in over-the-wire lookups.
2.2В Configuring an NFS Server
There are two ways in which you can configure an NFS server in Oracle Linux 8:
By editing the /etc/exports file manually.
Exports can also be added to files that you create in the /etc/exports.d directory.
By using the exportfs command.
The following procedures describe both of these methods.
2.2.1В Configuring an NFS Server by Editing the /etc/exports File
The following steps describe how to configure an NFS server by editing the /etc/exports file.
You can also add exports to files that you create in the /etc/exports.d directory in a similar fashion.
Check that the nfs-utils package is installed on the system. If necessary, install the package as follows:
Edit the /etc/exports file to define the directories that the server will make available for clients to mount, for example:
Each entry includes the local path to the exported directory, followed by a list of clients that can mount the directory, with client-specific exports options in parentheses.
The information in the previous example is as follows:
The client system with the IP address 192.0.2.102 can mount the /var/folder directory with read and write permissions. All writes to the disk are asynchronous, which means that the server does not wait for write requests to be written to disk before responding to further requests from the client.
No other clients are allowed to mount the /var/folder directory.
All of the clients can mount the /usr/local/apps directory as read-only. All connecting users, including root users, are mapped to the local, unprivileged user with UID 501 and GID 501.
All of the clients on the 192.168.1.0/24 subnet can mount the /var/projects/proj1 directory as read-only and the client system named mgmtpc can mount the directory with read-write permissions.
There is no space between a client specifier and the parenthesized list of options that apply to that client.
For more information, see the exports(5) manual page.
If the server will serve NFSv4 clients, edit the /etc/idmapd.conf file’s definition for the Domain parameter to specify the DNS domain name of the server:
This setting prevents the owner and group from being unexpectedly listed as the anonymous user or group ( nobody or nogroup ) on NFS clients when the all_squash mount option has not been specified.
If you need to enable access through the firewall for NFSv4 clients only, use the following commands:
This configuration assumes that rpc.nfsd listens for client requests on TCP port 2049, which it does by default.
If you need to enable access through the firewall for NFSv3 and NFSv4 clients, do the following:
Edit the /etc/nfs.conf file to create port settings for handling network mount requests and status monitoring, as well as set the TCP port on which the network lock manager should listen, for example:
If any port is in use, use the lsof -i command to locate an unused port and then amend the setting in the /etc/nfs.conf file, as appropriate.
Restart the firewall service and configure the firewall to allow NFSv3 connections:
Shut down and then reboot the server.
Note that NFS fails to start if one of the specified ports is in use and reports an error in /var/log/messages . Edit the /etc/nfs.conf file to use a different port number for the service that was unable to start, and then attempt to restart the nfs-server service. You can use the rpcinfo -p command to confirm on which ports RPC services are listening.
Start the nfs-server service and configure the service to start following a system reboot:
Display a list of the exported file systems by running the showmount -e command, for example:
You can also use the exportfs command on the server to display this information, for example:
Use the showmount -a command to display all of the current clients, as well as all of the file systems that they have mounted:
To enable use of the showmount command from NFSv4 clients, MOUNTD_PORT must be defined in the /etc/nfs.conf file and a firewall rule must enable access on this TCP port.
2.2.2В Configuring an NFS Server by Using the exportfs Command
You can also export or unexport directories by using the exportfs command. Using the exportfs command enables the root user to export or unexport directories selectively, and eliminates the need to restart the NFS service. By providing the appropriate options, the exportfs command writes the exported file systems to the /var/lib/nfs/etab file. Changes to the list of exported file systems are effective immediately because the nfs-mountd service refers to the etab file for determining access privileges to a file system.
The following are some of the options that you can specify with the exportfs command. Note that using the exportfs without any options displays a list of currently exported file systems:
Enables all of the directories listed in the /etc/exports file that are to be exported by constructing a new export list in the /var/lib/nfs/etab file. The -r option refreshes the export list with changes that are made to the /etc/exports file.
Enables all directories to be exported or unexported, which is dependent on other options that are passed to the exportfs command. If no other options are specified, the command exports all of the file systems that are specified in the /etc/exports file.
Unexports all of the shared directories.
The exportfs -ua command suspends NFS file sharing, but keeps all NFS services running. To re-enable NFS sharing, use the exportfs -r command.
Specifies a verbose operation of the exportfs command, which displays information about the file systems that are being exported or unexported in greater detail.
For more information, see the exportfs(8) , exports(5) , and showmount(8) manual pages.
2.3В Mounting an NFS File System
To mount an NFS file system on an Oracle Linux 8 client:
Check whether the nfs-utils package is installed on the system. If necessary, install the package as follows:
Use the showmount -e command to display the file systems that the NFS server exports, for example:
The output of the previous command would be similar to the following:
Be aware that some servers do not allow querying of this information, but the server may still be exporting NFS file systems.
Use the mount command to mount an exported NFS file system on an available mount point:
Note that in most cases, when mounting an NFS file system, the -t nfs option can be omitted.
This example mounts the /usr/local/apps directory that is exported by host01.mydoc.com with read-only permissions on /apps . The nosuid option prevents remote users from gaining higher privileges by running a setuid program.
To configure the system to mount an NFS file system at boot time, add an entry for the file system to the /etc/fstab file, as shown in the following example:
For more information, see the mount(8) , nfs(5) , and showmount(8) manual pages.
Copyright В© 2020, 2021, Oracle and/or its affiliates. Legal Notices
Источник