Share files linux and windows

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.

  1. Open the Control Panel.
  2. Go to Network and Sharing Options.
  3. Go to Change Advanced Sharing Settings.
  4. 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.

  1. Right-click the folder and select Properties.
  2. Go to the Sharing tab.
  3. 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.
  4. 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:

  1. Click the K menu icon.
  2. Select Internet ->Konqueror.
  3. In the Konqueror window that opens, click the Network Folders link, or type remote:/ in the address bar and press Enter .
  4. Click the Samba Shares icon.
  5. Click the icon of your Windows Home workgroup.
  6. Click the Workgroup icon.
  7. Click the icon for your computer.
  8. When prompted, enter the username and password for the Windows account that created the share.
  9. 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:

  1. Open Nautilus.
  2. From the File menu, select Connect to Server.
  3. In the Service type drop-down box, select Windows share.
  4. In the Server field, enter the name of your computer.
  5. 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.

  1. Open a terminal.
  2. Type smbclient at the command prompt.
  3. 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.

Источник

How to Share Files Between Windows and Linux

File sharing is the action of sending a file or more from one computer to another. In theory, it’s a simple thing. The process is quite simple and straightforward if both of the computers are running the same operating system. When it’s different, things get a bit complicated.

In this guide, check out how to share files between Windows and Linux.

Sharing files between Windows and Linux

There are multiple ways to configure both Windows and Linux to share files. However, in the case of this guide, I’ll be mostly showcasing how to configure Linux for file sharing. For Windows-specific configuration, I’ll be showcasing only the necessary ones.

Let’s get started!

Share files using portable storage devices

This is one of the most common and traditional ways of sharing files between two computers. Generally, it involves portable storage media. Got a USB flash drive? A portable HDD/SSD? Just plug it into the source computer, copy the data to the portable storage, and share it with your target computer.

In certain scenarios where the data is too big to be shared over the network/internet, this is the best solution. In a professional workspace where terabytes of data need to be shared and stored, there are portable RAID arrays to do the job.

While it’s simple and effective, there are a couple of things to keep in mind.

  • Storage capacity: Data bigger than the capacity can’t be stored on portable storage. If that’s the case, then you may split the file into smaller pieces using file splitting software. You may have to move the data through the portable storage several times.
  • File size: If the file size is quite small, and there’s lots of them, the transfer rate is going to be slow. On the other hand, if the file size is ridiculously large, then it’s also going to be slow.
  • Filesystem: Linux and Windows come with their own filesystem. While filesystems like FAT (fat16, fat32, etc.) or NTFS are accessible from both Windows and Linux, the Linux-specific filesystems (ext3, ext4, xfs, btrfs, etc.) aren’t.

Share files over cloud storage

Cloud storage is the standard way of file sharing in this internet era. Files can be uploaded and downloaded on any device with a modern web browser. However, there are a couple of different points to remember if you wish to choose this path.

  • Storage capacity: In the case of online cloud storage, storage capacity is a big concern. Popular cloud storages offer a limited amount of cloud storage for free. If your file is larger than that, you may have to buy additional cloud storage space. You can also split the big file into multiple small ones.
  • Bandwidth: This is the second biggest concern when it comes to cloud storage. If the internet connection you’re using is slow, then the file upload/download time will take quite a while. If you’re using a metered connection, it can cost you a lot.

Some of the popular online cloud storage include Google Drive, Dropbox, OneDrive, pCloud, Box, etc. Almost all of them offer a reasonable amount of cloud storage for free.

Share files using network folders

If both computers are on the same network, it’s possible to take advantage of it. In this method, certain folders of the source machine will be available to other machines.

Configure Linux

To enjoy this feature, you have to configure the systems first. In the case of Linux, Samba is the perfect solution. Samba is the standard suite of programs for UNIX/Linux operating systems for standard Windows interoperability. Check out Samba.

Samba is popular software that you can grab from the official package repos of your distro. To install Samba, run the command according to your distro.

Источник

How to Share Files and Folders Between Linux and Windows

Samba makes it easier than you might think

If your Linux machine is on a network, chances are you might want to share a directory (folder) or two to other users. Some Linux desktop environments (such as GNOME) make this incredibly simple. Some distributions and/or desktop environments, however, (such as Elementary OS) don’t offer a simple GUI for the sharing of folders.

Should you happen to be using a desktop environment that doesn’t make the process of sharing directories to your network a simple point-and-click affair, you’re not out of luck. Thanks to Samba (the underlying technology that makes this happen), you can still share those directories. It’s a bit tricker, but it’s not terribly hard.

What Is Samba?

Samba is an open-source software that enables Linux-based systems to communicate with Windows and macOS systems via the Common Internet File System (CIFS). Samba gets its name from the Server Message Block (SMB) protocol, which is at the heart of CIFS. Without Samba, directories on Linux wouldn’t be visible to Windows or macOS machines on your network.

For the purpose of this demonstration, we tested using Elementary OS 5 (Loki), which is based on Ubuntu Linux (so the process will be the same for any Ubuntu-based distribution) and Samba version 4.7.6.

Installing Samba

Chances are, you’re going to have to install Samba, as it is not included on most Linux desktop distributions. To install Samba, follow these steps:

Open a terminal window from your desktop menu.

Issue the command

sudo apt install samba samba-common -y

When prompted, type your user password.

Allow the installation to complete.

That’s all there is to the installation.

Configuring Samba

This is where things do get a bit challenging. What you must do is manually configure what are called Shares, with the Samba configuration file. In simple terms, a share is a directory you want to share with others on your network. We’ll create a very basic share.

The first thing to do is back up the original Samba configuration file. To do this, open a terminal window and issue the command

sudo cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak

With the original file backed up, it’s now safe to edit the original. Issue the command

sudo nano /etc/samba/smb.conf

and scroll to the very bottom of that file. What we’re going to do is add a new share for the Public folder, found in your user home directory. Let’s say your username is jack. The full path to that Public folder would be /home/jack/Public. That’s important to know.

This new share will look like this:

[Public]
path = /home/jack/Public
browseable = yes
writeable = yes
read only = no

Save and close that file by typing Ctrl + x. Finally, restart Samba with the command

Adding Users

Now we have to add our Linux users to Samba. Why? Because although the Linux system recognizes the users, Samba does not. One thing to understand is that anyone wanting to have access to those shared directories will need to have an account on your machine. You can create anonymous access to those shared folders, but it lacks security (and we want to keep our machines as secure as possible).

Fortunately, there are only two simple commands to run. We’ll stick with our sample user, jack. The first command adds the user to Samba (requiring you type and verify a new password). This command is:

sudo smbpasswd -a jack

You might first be prompted for your users’ sudo password. Type that and then, when prompted, type and verify a new Samba password for the Samba user.

The second command enables the user for Samba. This command is:

sudo smbpasswd -e jack

Ready for Access

That’s it. The new user is added and will then be able to access the shares. If you go to another machine on your network, you should be able to access that share from your desktop’s file manager (with the username and password you configured using the smbpasswd command). How you access the share will depend upon the operating system and file manager used on the other machines.

Источник

How to share files between Linux and Windows

Sharing files between Linux and Windows systems is surprisingly easy with some fine accommodations from the Linux community. Let’s look at two very different ways to make this happen.

Many people today work on mixed networks, with both Linux and Windows systems playing important roles. Sharing files between the two can be critical at times and is surprisingly easy with the right tools. With fairly little effort, you can copy files from Windows to Linux or Linux to Windows. In this post, we’ll look at what is needed to configure your Linux and Windows system to allow you to easily move files from one OS to the other.

Copying files between Linux and Windows

The first step toward moving files between Windows and Linux is to download and install a tool such as PuTTY’s pscp. You can get PuTTY from putty.org and set it up on your Windows system easily. PuTTY comes with a terminal emulator (putty) as well as tools like pscp for securely copying files between Linux and Windows systems. When you go to the PuTTY site, you can elect to install all of the tools or pick just the ones you want to use by choosing either the installer or the individual .exe files.

You will also need to have ssh-server set up and running on your Linux system. This allows it to support the client (Windows side) connection requests. If you don’t already have an ssh server set up, the following steps should work on Debian systems (Ubuntu, etc.).

For Red Hat and related Linux systems, use similar commands:

Note that if you are running a firewall such as ufw, you may have to open port 22 to allow the connections.

Using the pscp command, you can then move files from Windows to Linux or vice versa. The syntax is quite straightforward with its «copy from to» commands.

Windows to Linux

In the command shown below, we are copying a file from a user’s account on a Windows system to the /tmp directory on the Linux system.

Linux to Windows

Moving the files from Linux to Windows is just as easy. Just reverse the arguments.

The process can be made a little smoother and easier if 1) pscp is in your Windows search path and 2) your Linux system is in your Windows hosts file.

Windows search path

If you install the PuTTY tools with the PuTTY installer, you will probably find that C:\Program files\PuTTY is on your Windows search path. You can check to see if this is the case by typing echo %path% in a Windows command prompt (type «cmd» in the search bar to open the command prompt). If it is, you don’t need to be concerned with where you are in the file system relative to the pscp executable. Moving into the folder containing the files you want to move will likely prove easier.

Updating your Windows hosts file

Here’s the other little fix. With administrator rights, you can add your Linux system to the Windows host file (C:\Windows\System32\drivers\etc\hosts) and then use the host name in place of its IP address. Keep in mind that this will not work indefinitely if the IP address on your Linux system is dynamically assigned.

Note that Windows host files are formatted like the /etc/hosts file on Linux systems — IP address, white space and host name. Comments are prefaced with pound signs.

Those pesky line endings

Keep in mind that lines in text files on Windows end with both a carriage return and a linefeed. The pscp tool will not remove the carriage returns to make the files look like Linux text files. Instead, it simply copies the files intact. You might consider installing the tofrodos package to enable you to use the fromdos and todos commands on your Linux system to adjust the files you are moving between platforms.

Sharing folders between Windows and Linux

Sharing folders is an entirely different operation. You end up mounting a Windows directory on your Linux system or a Linux directory on your Windows box so that both systems can use the same set of files rather than copying the files from one system to the other. One of the best tools for this is Samba, which emulates Windows protocols and runs on the Linux system.

Once Samba is installed, you will be able to mount a Linux folder on Windows or a Windows folder on Linux. This is, of course, very different than copying files as described earlier in this post. Instead, each of the two systems involved will have access to the same files at the same time.

More tips on choosing the right tool for sharing files between Linux and Windows systems are available here.

2-Minute Linux Tip: How to add and delete user accounts

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as «USL» (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she’s chasing the bears away from her bird feeders.

Источник

Читайте также:  Linux delete string from file
Оцените статью