Страница 1 из 1

Access Windows Shares from Linux

Добавлено: 23 окт 2022, 20:44
xor

Source: https://www.cyberciti.biz/faq/access-wi ... rom-linux/

Access Windows Shares from Linux

Q. How do I Access Windows share from Linux command prompt? I would like to be able to access shared folders on Windows machines from my Linux system.
A. There are two ways. Use command line tool called smbclient or you can mount windows shares the mount command. Another option is use GUI tools. Please refer previous articles about access windows share from Linux:

( a ) Mount Windows share using mount command
This is simple way to share data between windows and linux system. You would like to access MS-Windows share called //windowsserver/sharename by mounting to /mnt/win directory under Linux system. Type the following command (replace username, windows server name, share name and password with actual values):

Код: Выделить всё

# mkdir -p /mnt/win
# mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win
# cd /mnt/win
# ls -l

For the share //windowsserver/sharename to be automatically mounted at every system start (after reboot), insert an option in the file /etc/fstab:

Код: Выделить всё

# vi /etc/fstab

Append following line (written in a single line)

Код: Выделить всё

//windowserver/share /mnt/win smbfs
auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0

Next create the password file /etc/sambapasswords:

Код: Выделить всё

# vi /etc/sambapasswords

Now add following content:

Код: Выделить всё

username = winntuser
password = mypassword

Save and close the file. Make sure only root can access your file:

Код: Выделить всё

# chown 0.0 /etc/sambapasswords
# chmod 600 /etc/sambapasswords

Other solutions
( b ) Browse a Samba or MS Windows share using smbclient
How do I browser a samba / windows share from a command prompt?
If you don’t have GUI installed but you would like to browse a samba share from a command prompt (w/o GUI) or terminal window (X-term), use smbclient command. Make sure you have the samba-client package installed.

Type the following command:

Код: Выделить всё

$ smbclient //delta//mp3 -U myUsername

Once authenticated you will see smb: \> prompt. Use ls and other command to browse your share. Type help at the command prompt for the commands available.

Код: Выделить всё

smb: \> ls
smb: \> get file.name
smb: \> help

( c ) Browse a Samba or MS Windows share in Nautilus (GUI Option)
You can use Nautilus drag and drop feature to create and burn data CDs. Same way you can use Nautilus, which is the file manager for the UNIX/Linux GNOME desktop systems. Nautilus not only supports browsing local filesystems, it also provides access to FTP sites, Windows SMB shares, WebDAV servers and SFTP servers via GNOME VFS.

Nautilus supports previews of files in their icons, be they text files, images, sound or video files via thumbnailers such as Totem.

To browse your Samba or MS Windows shares open Nautilus manager, and type the following in the address bar:

Код: Выделить всё

smb://delta/mp3

Where,
delta: is a server (Samba or Windows) name
mp3: share name you trying to access

Browse a Samba or MS Windows share in Nautilus
Browse a Samba or MS Windows share in Nautilus
smb-mount-01.jpg (44.62 КБ) 644 просмотра

If your system account (login name) is not configured properly, you may be prompted for your Windows or Samba username and password. Once you are authenticated you will be able to browse your shares.