30

I am using ubuntu and gnome on my computer.

When I open up File Browser, on the left hand rail, I see conveniently a folder called "Work Server". When I mouse over it, the following caption appears "smb://[email protected]". If I click on that folder, then I can see the contents of that folder. Everything is great.

So now when I open up a terminal/shell, I type in

cd smb://[email protected]

I get an error saying the directory doesn't exist. How do I enter this directory via shell/terminal?

4 Answers 4

31

The reason you can't cd in that share is because cd only works on local filesystems*, you have two ways of solving your problem here:

Use smbclient to browse the share:

smbclient -U john //69.100.100.1/SHARENAME

or mount -t cifs if you want to mount the share locally, note that the mount point must exist as a folder:

sudo mount -t cifs -o user=john,iocharset=utf8,noperm //69.100.100.1/SHARENAME ~/shares/SHARENAME 

Make sure you adapt SHARENAME to match your environnement.

If your login is part of an Active Directory domain you may want to add its name to those commands, with the second one that would be:

sudo mount -t cifs -o user=YOURDOMAIN//john,iocharset=utf8,noperm //69.100.100.1/SHARENAME ~/shares/SHARENAME

* The meaning of "local" here is not straightforward, just keep in mind you can't use normal tools before you mount remote FS locally.

6
  • am I supposed to replace USERNAME with the name of my current shell user? And SHARENAME with the directory name i want to cd into? When i tried I got the following error: Connection to [email protected] failed (Error NT_STATUS_BAD_NETWORK_NAME) Commented Oct 2, 2012 at 15:10
  • yep, you have to specify an 'endpoint' ("SHARENAME") which is the name of the share you can see in your GUI file browser and adapt "USERNAME" (maybe even add your domain before that) to be able to mount the share.
    – Shadok
    Commented Oct 2, 2012 at 15:39
  • 2
    smbmount is deprecated and not maintained any longer. mount.cifs (mount -t cifs) should be used instead of smbmount (smbmount Linux man page)
    – Baumann
    Commented Mar 15, 2016 at 13:55
  • how does one do an anonymous access with cifs? Is it just a matter of setting user=anonymous? Commented Dec 15, 2018 at 21:07
  • Just don't use 'user' at all for guest access.
    – Shadok
    Commented Mar 8, 2019 at 17:38
6

Shamelessly borrowed from https://askubuntu.com/questions/101029/how-do-i-mount-a-cifs-share

terminal command is:

sudo mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share

note you may need to install cifs-utils

1
  • where is the sudo
    – Karsun
    Commented Jul 14, 2020 at 9:19
1

Since it looks like the remote share is already mounted, there's no need to mount it again (sure you can, but do you want to?). Instead you need to find where has it been mounted. Since you're using GNOME, the big chance is it was mounted as gvfsd-fuse. If you're impatient, just try to run this:

ls "/run/user/$(id -u)/gvfs"

and check if you can see the directory where the share has been mounted (you should see something like smb-share:server=remote.server,share=remote-share-name). If you do, then you're done. :-) (Note that id -u or id --user gets your effective user ID — an integer number. If you know it up-front, you can safely replace the parentheses expression with it).

If it failed, you can run findmnt and look for gvfs entries in FSTYPE column. It may look like this:

TARGET                                 SOURCE         FSTYPE          OPTIONS
…
│   └─/run/user/1000/gvfs              gvfsd-fuse     fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
…

If you see this, check (ls) the path in TARGET column, in that case it's /run/users/1000/gvfs — you should be able to see your already mounted share here.

-1
open 'smb://login:pass@ip/Folder'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .