- Access Windows 10 Shared Folder from Ubuntu 18.04
- 4 Answers 4
- Как в Linux монтировать шару CIFS
- Подготовка
- Установка пакетов
- Сетевые порты
- Синтаксис
- Ручное монтирование
- Автоматическое монтирование CIFS через fstab
- Примеры использования опций
- Версии SMB
- Монтирование от гостевой учетной записи
- Права на примонтированные каталоги
- How to Mount Windows Share on Linux using CIFS
- Installing CIFS Utilities Packages #
- Mounting a CIFS Windows Share #
- Auto Mounting #
- Unmounting Windows Share #
- Conclusion #
Access Windows 10 Shared Folder from Ubuntu 18.04
I would like to share files between Windows and Ubuntu. In Ubuntu 16.04 LTS, I could access shared folder on a Windows machine on my local network my navigating to Other locations in Files (Nautilus), accessing the Windows network, and browse. After upgrading to Ubuntu 18.04 LTS, this no longer works for me. How can I get access to folder shared in Windows 10 from Ubuntu 18.04?
We gone to files->Other locations in linux system and there we could see the windows network. After opening that we could see the windows system there . By clicking on the windows pc we copied the folder from its shared folder.
@Deciletech Please edit your question to add details. It helps to keep the simple Q&A style and could also bring more attention since an edited question gets bounced on the homepage.
4 Answers 4
There was a change in both Windows 10 and Samba. Some of the details are explained here.
The browse by just clicking isn’t working, but you can get there by entering the shared folder link in the address field. Use the server’s IP address or the computer name for the share. In the example I’m using the IP address of the Windows 10 server:
Use Keyboard shortcut Ctrl + L to type in pathname:
Typing that in the file browser will bring up authorization prompt. Use the credentials from your Windows 10 server. This will display all the available shares. You can then click on the share you want access to.
There are two changes steps you may have to do. Set client max protocol = NT1 for the downward compatibility in the /etc/samba/smb.conf file. Place the entry just below the workgroup = WORKGROUP line.
#======================= Global Settings ======================= [global] client use spnego = no client NTLMv2 auth = no ## Browsing/Identification ### # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUP client max protocol = NT1
Once you have manually accessed the desired share, you can make it easily accessible in the future by bookmarking it. You can do this with the keyboard shortcut: Ctrl + D .
You can easily rename your bookmarks to something friend and meaningful by right-clicking the name that appears in the File Browser’s sidebar.
Install necessary packages:
You may have to install smbclient , which will ensure you have the necessary dependents such as the cifs-utils and the actual /etc/samba/smb.conf file.
$ sudo apt install smbclient
Works on Lubuntu 18.10 as installed; no additional packages or edits required. Does not support browse by clicking. Works with entering smb://192.168.1.102 in PCManFM-Qt file manager.
On 18.04, I have just had success with the following:
On Ubuntu: Install smbclient and add client max protocol = NT1 to /etc/samba/smb.conf as per L.D. James’ answer (see this post for more info).
On Windows: Create a folder in Windows to share, e.g. named shared . Make sure the folder is shared: I created a new user on Windows, keeping the NewUser name and selected a simple password (I first tried changing the name, but found that change was apparently only skin deep. Perhaps if I had rebooted. ). I logged in with NewUser , then logged back in with my admin account. I activated network sharing on my private network and for the folder specifically (see e.g. this post). Then I right clicked the folder and chose Give access to. , choosing NewUser (you may want additional permissions: see the just linked to post). Under the Sharing tab, the folder now has a network path: //COMPUTERNAME/shared .
Still on Windows: To gain access to the shared folder, I used the IP of the Windows machine instead of the COMPUTERNAME , cf. this.
To find the IP of your Windows machine, right click the network logo, open Network and Sharing Settings and choose Change connection properties . Take note of the IPv4 near the bottom.
In Ubuntu: Finally, open a terminal on you Ubuntu machine and execute
sudo mount -t cifs -o username=NewUser //[insert IPv4 here]/shared /home/your_ubuntu_username/shared
and provide the password for NewUser when prompted.
This mounts the shared Windows shared folder as a folder shared in your Ubuntu user’s home directory.
The command is based on suggestions from here, where there are also suggestions for storing login credentials.
I hope it works. Good luck!
Как в Linux монтировать шару CIFS
Обновлено: 01.05.2023 Опубликовано: 18.07.2016
Что такое Linux и CIFS простыми словами. Работа с общими папками Windows происходит с использованием протокола CIFS (SMB). Все примеры в данном руководстве выполняются на Linux Ubuntu и CentOS.
Подготовка
Установка пакетов
Сетевые порты
Синтаксис
* вместо mount.cifs можно написать mount -t cifs.
mount.cifs //192.168.1.1/public /mnt
* простой пример монтирования папки public на сервере 192.168.1.1 в локальный каталог /mnt.
Если нам не известны расшаренные папки на сервере, мы можем воспользоваться утилитой smbclient. Для начала установим ее.
а) на RPM (Rocky Linux / РЕД ОС / Red Hat / CentOS / Fedora):
б) на Deb (Debian / Ubuntu / Astra Linux / Mint):
или, при необходимости авторизоваться на файловом сервере:
smbclient -L 192.168.1.1 -U username
Ручное монтирование
Теперь монтирование можно выполнить следующей командой:
mount.cifs //192.168.1.10/share /mnt -o user=dmosk
* в данном примере будет примонтирован каталог share на сервере 192.168.1.10 в локальную папку /mnt под учетной записью dmosk.
То же самое, с использованием домена:
mount.cifs //192.168.1.10/share /mnt -o user=dmosk,domain=dmosk.local
Автоматическое монтирование CIFS через fstab
Для начала создаем файл, в котором будем хранить данные авторизации при подключении к общей папке:
И добавляем в него данные следующего вида:
username=dmosk
password=dPassw0rd
domain=dmosk.local
* в этом примере создана пара логин/пароль — dmosk/dPassw0rd; domain указывать не обязательно, если аутентификация выполняется без него.
Задаем права на созданный файл, чтобы доступ был только у пользователя, скажем, root:
chown root:root /root/.smbclient
Теперь открываем конфигурационный файл fstab:
и добавляем в него следующее:
//192.168.1.10/share /mnt cifs user,rw,credentials=/root/.smbclient 0 0
* в данном примере выполняется монтирование общей папки share на сервере с IP-адресом 192.168.1.10 в каталог /mnt. Параметры для подключения — user: позволяет выполнить монтирование любому пользователю, rw: с правом на чтение и запись, credentials: файл, который мы создали на предыдущем шаге.
Чтобы проверить правильность настроек, вводим следующую команду:
Примеры использования опций
Версии SMB
Если на стороне Windows используется старая или слишком новая версия протокола SMB, при попытке монтирования мы можем получить ошибку mount error(112): Host is down. Чтобы это исправить, указываем версию:
mount.cifs //192.168.1.10/share /mnt/ -o vers=1.0
* монтирование по протоколу SMB1.0
Монтирование от гостевой учетной записи
Если сервер принимает запросы без логина и пароля, то клиент подключается, как гость:
mount.cifs //192.168.1.10/share /mnt -o guest
//192.168.1.10/share /mnt cifs guest 0 0
Права на примонтированные каталоги
При монтировании папки мы можем указать определенные права:
mount.cifs //192.168.1.10/share /mnt -o file_mode=0777,dir_mode=0777
Для указания владельца, который будет назначен для примонтированного каталога, используем:
mount.cifs //192.168.1.10/share /mnt -o uid=33,gid=33
* чтобы посмотреть идентификаторы пользователя, вводим id -u и id -g .
How to Mount Windows Share on Linux using CIFS
On Linux and UNIX operating systems, a Windows share can be mounted on a particular mount point in the local directory tree using the cifs option of the mount command.
The Common Internet File System (CIFS) is a network file-sharing protocol. CIFS is a form of SMB.
In this tutorial, we will explain how to manually and automatically mount Windows shares on Linux systems.
Installing CIFS Utilities Packages #
To mount a Windows share on a Linux system, first you need to install the CIFS utilities package.
- Installing CIFS utilities on Ubuntu and Debian:
sudo apt update
sudo apt install cifs-utils
sudo dnf install cifs-utils
The package name may differ between Linux distributions.
Mounting a CIFS Windows Share #
Mounting a remote Windows share is similar to mounting regular file systems.
First, create a directory to serve as the mount point for the remote Windows share:
Run the following command as root or user with sudo privileges to mount the share:
sudo mount -t cifs -o username= //WIN_SHARE_IP/ /mnt/win_share
You will be prompted to enter the password:
On success, no output is produced.
To verify that the remote Windows share is successfully mounted, use either the mount or df -h command.
Once the share is mounted, the mount point becomes the root directory of the mounted file system. You can work with the remote files as if they were local files.
The password can also be provided on the command line:
sudo mount -t cifs -o username=,password= //WIN_SHARE_IP/ /mnt/win_share
If the user is in windows workgroup or domain you can set it as follows:
sudo mount -t cifs -o username=,domain= //WIN_SHARE_IP/ /mnt/win_share
For better security it is recommended to use a credentials file, which contains the share username, password and domain.
The credentials file has the following format:
username=user password=password domain=domain
The file must not be readable by users. To set the correct permissions and ownership , run:
sudo chown root: /etc/win-credentials
sudo chmod 600 /etc/win-credentials
To use the credentials file, define it as follows:
sudo mount -t cifs -o credentials=/etc/win-credentials //WIN_SHARE_IP/ /mnt/win_share
By default of the mounted share is owned by root, and the permissions are set to 777.
Use the dir_mode option to set the directory permission and file_mode to set the file permission:
sudo mount -t cifs -o credentials=/etc/win-credentials,dir_mode=0755,file_mode=0755 //WIN_SHARE_IP/ /mnt/win_share
The default user and group ownership can be changed with the uid and gid options:
sudo mount -t cifs -o credentials=/etc/win-credentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0755 //WIN_SHARE_IP/ /mnt/win_share
To set additional options , add them as a comma-separated list after the -o option. To get a list of all mount options type man mount in your terminal.
Auto Mounting #
When the share is manually mounted with the mount command, it does not persist after a reboot.
The /etc/fstab file contains a list of entries that define where how and what filesystem will be mounted on system startup.
To automatically mount a Windows share when your Linux system starts up, define the mount in the /etc/fstab file. The line must include the hostname or the IP address of the Windows PC, the share name, and the mount point on the local machine.
Open the /etc/fstab file with your text editor :
Add the following line to the file:
# //WIN_SHARE_IP/share_name /mnt/win_share cifs credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755 0 0
Run the following command to mount the share:
The mount command, will read the content of the /etc/fstab and mount the share.
Next time you reboot the system, the Windows share will be mounted automatically.
Unmounting Windows Share #
The umount command detaches (unmounts) the mounted file system from the directory tree.
To detach a mounted Windows share, use the umount command followed by either the directory where it has been mounted or remote share:
If the CIFS mount has an entry in the fstab file, remove it.
The umount command will fail to detach the share when it is in use. To find out which processes are accessing the windows share, use the fuser command:
Once you find the processes, you can stop them with the kill command and unmount the share.
If you still have problems unmounting the share, use the -l ( —lazy ) option, which allows you to unmount a busy file system as soon as it is not busy anymore.
sudo umount -l MOUNT_POINT
Conclusion #
In Linux, you can mount a Windows shared using the mount command with the cifs option.
If you have any questions or feedback, feel free to leave a comment.