Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 47347  / 2 Years ago, tue, march 1, 2022, 5:17:47

Probably total noob question. I installed Ubuntu in a VMWare Player. Works fine. I usually work in terminal and didn't realise until today that I could use the Files icon to connect to my Windows host machine (and indeed my office network.) Fabulous!



But... then... how do I access these new shares from inside bash? From my default prompt, shouldn't I see some my-windows-share



OR do I need to mount these drives somehow 'manually' inside terminal? If so, how?



I see a number of answers regarding VirtualBox. Don't know if that applies to me. I guess I assumed that once I was connected via Files I would automatically be connected with Terminal.


More From » networking

 Answers
0

First you need to have samba and cifs-utils installed:



sudo apt-get install samba cifs-utils


Then use a Bash script to mount windows share folder in linux using samba:



$ mkdir /mnt/smb

$ touch smb.sh

chmod +x smb.sh

$ vi smb.sh


Write the following into the smb.sh file using vi:



#/bin/bash



SERVER_IP="192.168.1.1"

SHARE_NAME="c$"

USERNAME="samba user name"

PASSWD="samba password"

DOMAIN="domain"


mount.cifs //$SERVER_IP/$SHARE_NAME /mnt/smb/ -o username=$USERNAME,password=$PASSWD,dom=$DOMAIN


Finally run the script to mount your Windows share and cd into the share:



./smb.sh

$ cd /mnt/smb/





Another method that seems to me to be more straight forward and easier: It involves creating the mount point, editing fstab, and then mounting all filesystems in fstab with one command.



Make the folder:
sudo mkdir /mnt/myDirectory



Edit the fstab:
sudo vi /etc/fstab



Append the following to the fstab file:



//server/Share /mnt/myDirectory cifs domain=myDomain,username=myUserName,password=myPassword 0 0


Be sure to fill in all the appropriate information in place of those placeholders. And save the fstab file with wq for "write and quit."



Finally mount all the file systems listed in fstab:



sudo mount -a


Now you can verify that the share is available with:



ls /mnt/myDirectory


And you should see the files in the top level directory of the Windows Share.


[#26508] Thursday, March 3, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fenddy

Total Points: 361
Total Questions: 103
Total Answers: 113

Location: Turkmenistan
Member since Sun, Aug 2, 2020
4 Years ago
fenddy questions
Tue, Nov 22, 22, 10:11, 1 Year ago
Tue, Sep 27, 22, 09:16, 2 Years ago
Wed, Dec 28, 22, 13:09, 1 Year ago
Fri, Jun 18, 21, 14:04, 3 Years ago
;