Linux folder sharing with 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.

Читайте также:  Pantum p2500w ������� linux ppd

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.

Linux folder sharing with windows

CIFS (Common Internet File System) — это популярный протокол обмена файлами в Интернете. Этот протокол и позволит пользователям ОС Linux получить доступ к общей папке Windows.

CIFS — это реализация SMB (Server Message Block) — протокола, используемого для совместного использования сетевых файлов. Но он устарел.

В этой статье мы по шагам пройдем все этапы установки и настройки CIFS, чтобы подключиться к сетевому ресурсу Windows на ОС Linux.

Установка CIFS

Сейчас мы установим пакет cifs-utils на Ubuntu Linux (точно так же можно сделать на всех Debain-подобных ОС).

Монтируем Windows Share (сетевой ресурс)

Сейчас мы разберем на примерах, как монтировать общую папку Windows вручную и автоматически.

Создадим на нашем Linux директорию, к которой мы будем монтировать сетевой ресурс. Назовем ее myshare и расположена она будет в каталоге /mnt

Сетевой ресурс (шара) Windows может быть примонтирован к ОС Ubuntu или Debian с помощью следующей команды:

WIN_HOST_IP — это IP адрес хоста Windows, на котором расположена общая папка

share — имя сетевого ресурса

user — наш пользователь и Passw0rd — пароль с которыми мы подключемся к шаре.

Если пользователь доменный, то необходимо в опциях (-o) указать домен.

По-умолчанию сетевой ресурс монтируется с полными правами (rwx или 777). Если Вы хотите установить иные права, используйте опции dir_mode и file_mode.

Так же Вы можете установить владельцев uid (id пользователя) и gid (id группы).

Если после выполнения предыдущих команд Вы не получили никаких ошибок, то можете с помощью команды df -h убедиться, что сетевой ресурс успешно примонтирован к нашему ПК на Linux. В примере WIN_HOST_IP = 192.168.1.100 и имя общей папки share

Безопасность учетных данных при монтировании через CIFS

В этом разделе опишем, как лучше всего передавать учетные данные (имя пользователя, пароль, домен) при монтировании сетевого ресурса к ОС на базе Линукс.

Создайте файл с учетными данными для cifs: /etc/cifs-credentials

Внутрь поместите следующее содержимое:

Задайте права для этого файла:

Теперь мы можем подключить общую папку такой командой:

Как сделать автоматическое монтирование общей папки Windows

В примерах выше, после того, как Вы перезагрузите свой ПК, сетевой ресурс не примонтируется. Поэтому сделаем так, чтобы шара подключалась автоматически. В Linux это делается через файл /etc/fstab. Откройте этот файл любимым редактором.

И добавьте такую строку:

Следующей командой запустим монтирование всех точек, описанных в /etc/fstab

Теперь наш удаленный сетевой ресурс будет доступен даже после перезагрузки.

Как размонтировать общую папку CIFS

Размонтирование производится таким же способом, как и обычно мы жто делаем с дисками:

Часто бывает так, что сетевой ресурс занят каким-то процессом и тогда Вы получите ошибку при попытке размонтирования, тогда запустите команду с ключем -l (—lazy)

Итак, в этой статье мы рассмотрели, как быстро примонтировать удаленную сетевую папку, которая находится на хосте с Windows, к нашему хосту на Linux с помощью CIFS. Если у Вас остались какие-либо вопросы, пожалуйста, пишите в комментариях.

Автор

Админ

Возможно Вам будет это инетересно

Как инвертировать совпадение по grep

Как посмотреть список пользователей Linux

Конфигурация файла .gitignore в Git

7 thoughts on “Как подключить общую папку (сетевой ресурс, шару) Windows к Linux”

[ 13.068117] CIFS: Attempting to mount //192.168.10.250/home
[ 13.068332] CIFS VFS: Error connecting to socket. Aborting operation.
[ 13.068339] CIFS VFS: cifs_mount failed w/return code = -2
[ 13.068431] CIFS: Attempting to mount //192.168.10.250/home/Drive/школа/English
[ 13.068556] CIFS VFS: Error connecting to socket. Aborting operation.
[ 13.068564] CIFS VFS: cifs_mount failed w/return code = -2
[ 13.069981] CIFS: Attempting to mount //192.168.10.250/Учебный_год_3В
[ 13.070234] CIFS VFS: Error connecting to socket. Aborting operation.
[ 13.070241] CIFS VFS: cifs_mount failed w/return code = -2
[ 15.184815] usb 1-1: reset high-speed USB device number 2 using ehci-pci
[ 17.861600] random: crng init done
[ 17.861607] random: 7 urandom warning(s) missed due to ratelimiting
[ 23.589870] tg3 0000:3f:00.0 enp63s0: Link is up at 100 Mbps, full duplex
[ 23.589872] tg3 0000:3f:00.0 enp63s0: Flow control is off for TX and off for RX
[ 23.589901] IPv6: ADDRCONF(NETDEV_CHANGE): enp63s0: link becomes ready

Все бы хорошо, но не успевает сетевуха поднять линк

дальше вручную «sudo mount -a» и все взлетает

[ 697.728246] CIFS: Attempting to mount //192.168.10.250/home
[ 700.739946] CIFS: Attempting to mount //192.168.10.250/Учебный_год_3В
[ 701.090973] CIFS: Attempting to mount //192.168.10.250/home/Drive/школа/English

вот вопрос, как бы заставить монтироваться после поднятия линка и получение адреса

ноут по wifi нормально отрабатывает, а системник с обычной сетевухой нет

Programster’s Blog

Tutorials focusing on Linux, programming, and open-source

Share Windows Folder With Linux

In this tutorial I will show you how to set up a share on windows and then mount it on a Linux computer.

In the past, I have configured Samba shares on Linux servers to share files with Windows because our servers all run on Linux, but my colleagues prefer to develop in Windows. This is not ideal because the windows-side will «go slow», with Netbeans auto-complete functionality appearing to suffer. Another drawback is that windows realizes that it is a network mount, and will no longer show TortoiseSVN status emblems to indicate whether a folder has outstanding changes etc. Sharing the other way round with Windows -> Linux resolves these issues.

Check Windows Settings

Open your Network and Sharing Center.

Click on «Change advanced sharing settings».

  • network discovery is on.
  • file and printer sharing is on.
  • password protected sharing is on.
  • keep the default 128 bit encrypted file sharing.
  • Allow Windows to manage homegroup connections (recommended)
Читайте также:  Linux bash работа строками

Create the Share

Create a folder that you wish to share with other computers. I prefer to keep these folders directly in C: for simplicity. In this case I have created a folder called C:\code .

Right click the folder and click Properties.

Click the Sharing tab and then click Advanced Sharing.

Click Share this folder and then click Permissions:

Click Add to add a specific user.

In the box that now appears.

Type your username into the box and then click Check Names.

The computer should give the full system name for the user as it needs it. You can then click OK.

Now make sure your own username is selected, and then ensure that Full Control and Change are selected.

Go back to the Advanced Sharing Window and click the Caching button.

Click the option to disable caching. This seems to make things work immediately.

Mount the Files on Linux

Install the necessary packages:

Create a location to mount your windows share and mount it with the following script (make sure to fill in your settings as appropriate).

Thats it! You should now be able to view all the files in your mounted directory and edit them, or create new ones. If you find that you are unable to edit or create files, please make sure to re-visit the steps for adding yourself to share permissions and setting full control. If you are unable to mount the directory, be sure to check that you disabled caching, and that all your settings are correct, such as the windows username, and the IP address of the windows machine.

Читайте также:  Windows не удалось автоматически обнаружит параметры прокси этой сети

Guide: How to Share A Folder Between Ubuntu/Linux and Windows

This beginner’s guide explains how you can quickly share a folder in Ubuntu/Linux.

Sharing a folder in Ubuntu/Linux and accessing the same over the network in other OS such as Windows is not that difficult. To perform this, the required packages are not installed by default in Ubuntu, however, you can bring up the install wizard to install required software automatically to share a folder.

This guide applies to all Ubuntu versions (including 18.04, 19.10 and upcoming – unless there are major changes in the way this function is designed).

Steps to Share a Folder in Ubuntu

Step 1: Open file manager and right-click on the folder which you want to share. Click on the option “Local Network Share” in the context menu.

Local Network Share Option

Step 2: Click on the Share this folder checkbox in the Folder Sharing dialog.

This would install Samba packages in your system. Samba is used to share files and printers over the network between Windows and Unix systems.

Folder Sharing Option – Install Samba

Step 3: After samba installation, do the following to share a folder or directory.

username should be a valid user of the respective Ubuntu system.

You should be all set now to access the folder/directory.

How to Access the Shared Folder

To access the shared folder from Ubuntu/Linux system, you need the IP address/hostname of your system. To do that, open System Settings -> Wifi -> Get the IP address . (This step may vary if you are running different Linux distribution other than Ubuntu. You may also want to run ifconfig to get the IP address).

IP Address Settings

Once you have the address, you can open File Manager in Ubuntu/Linux systems and type below in the address bar. You should change the IP address based on your system.

You can now see the shared Folder is shown with a tiny shared icon that denotes it is a network share folder.

Share Folder

To access the shared folder from the Windows system, Open Run (Windows Key+R) or open Explorer and enter the below address. You should change the IP address and Folder name based on your system

You should be able to view the contents of the shared folder and modify it based on permission given.

We bring the latest happenings in the Linux universe, app reviews, tutorials, easy to understand guides for you. Stay in touch via Telegram, Twitter, YouTube, and Facebook and never miss an update!

Оцените статью