11

I am not able to cd into the samba like I would normally do:

cd smb://server/folder

It says: "bash: cd: smb/..." No such file or directory.

But if in nautilus I go to the folder and right click it, the location shown in the properties is:

smb://server/folder

Why isn't this working? Thanks

6 Answers 6

11

The program "cd" can only navigate into directories mounted to your local VFS, and a URI that starts with "smb://" describes a remote resource. In order to cd into an SMB share, you have to mount it.

In your case, it sounds like the SMB share was already mounted and accessible from nautilus. That means the SMB share is already mounted somewhere in your local VFS.

In Ubuntu 15.04, I believe the default mount point for SMB shares (at least the ones you connect to using nautilus) is:

/run/user/$UID/gvfs/smb:host=$SERVER_NAME

So instead, try:

$ cd  /run/user/$UID/gvfs/smb:host=server/path/to/file.txt

Edit: For a more in-depth explanation of this, here is a similar question on unix stackexchange with some great answers

1
  • I'm on Ubuntu 22 and my gvfs directory is empty, despite having several Samba shares.
    – Raleigh L.
    Aug 11, 2022 at 5:28
1

You cannot use just cd smb://server/folder from a terminal.

To access the folder from terminal you need to mount the folder first.

sudo mkdir /mnt/server

sudo mount -t cifs //remote/folder /mnt/server -o username=user uid=name

Or just type smbclient //hostname/folder and type the username/password. After successful login you will able to access the folders.

4
  • how do I set up to automount it with fstab? Currently looks like: smb://folder /media/folder nfts defaults 0 0; It says Failed to access volume, no such file or folder. But I got the "smb://folder" path from the automatically mounted in the network list.
    – Totty.js
    Oct 9, 2012 at 13:09
  • I would recommend you to use autofs instead of fstab. Please refer this link to automount.
    – devav2
    Oct 9, 2012 at 13:15
  • mount.cifs doesn't use URLs, but UNCs - you would use //remote/folder rather than smb://remote/folder
    – jelmer
    Oct 11, 2012 at 20:59
  • Yes I have mentioned that smb:://remote/folder wont work
    – devav2
    Oct 12, 2012 at 6:16
1

The shell (bash) does not use unique resource locators (URLs).

In addition to other answers that tell you how to mount samba shares manually, if you can access it with the file manager, it has already been mounted using gvfs. You will be able to access it throught the .gvfs/ directory in your home directory:

cd ~/.gvfs/
ls

If I'm correct, you should see a directory called folder on server/.

0

The smb protocol cannot be used like this from bash. If you want to use it, you have to mount the smb share with the mount command, or to add it to your /etc/fstab, for example (taken from my fstab):

//server/smb-share /my/path/where/to/mount/it cifs  guest,uid=1000,iocharset=utf8,codepage=unicode,unicode  0  0

0

If the others don't work (as is my case), you'll likely find this will:

cd /$XDG_RUNTIME_DIR/gvfs/smb-share\:server=yourserver,share=yourshare/

Replace yourserver and yourshare appropriately.

If you're using tab completion, beware of your shell incorrectly escaping out commas, dollar symbols and slashes. The colon, however, should be escaped.

0

go to 'files' folder (left panel) in ubuntu, open shared folder ....^ .Then rightclik and select 'open in Terminal' >> copy address like bellow in front of your cd command

cd /run/user/1000/gvfs/smb-share:server=xxx.xxx.x.xxx,share=[your shared folder in other system]

1
  • This answer needs some supporting details.
    – David
    Feb 23, 2022 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.