maphew

Use Windows share in CLI

In Bluefin linux (Fedora), using Files app and navigating to \\server\share works fine. I can do whatever I want provided I have permissions. However the smb://.... mount that creates can’t be used from terminal shell.

I figured out I can do:

mkdir ~/mnt/media
sudo mount -t cifs -o username={me} //server/media ~/mnt/media
ls ~/mnt/media/
...etc

…but everything is read-only regardless of what my Windows permissions are.

I tried to use mount without sudo but am told:

This program is not installed setuid root - “user” CIFS mounts not supported.

LLMs tell me:

If you absolutely need user mounts and understand the security implications, you can set the setuid bit as follows:

sudo chmod u+s /bin/mount
sudo chmod u+s /bin/umount
sudo chmod u+s /usr/sbin/mount.cifs

…but:

❯ sudo chmod u+s /bin/mount
chmod: changing permissions of '/bin/mount': Read-only file system

So what can I do?

https://universal-blue.discourse.group/t/make-windows-share-available-to-cli/9375 

 

More time with chat gippity and crafting better prompt questions led me to the below, tested and working for me.

Solution: Use gio mount + symlink. If GNOME Files can see it, so can gio and GVFS.

# mount the share
❯ gio mount smb://server/share

# locate the virtual file system created
❯ cd /run/user/$(id -u)/gvfs
❯ pwd
user/1000/gvfs

# identify the mounted system name
❯ ls
smb-share:server=server,share=media

# create a symlink in home dir so we don't have use the system name
❯ cd smb-share\:server=server\,share\=media
❯ ln -s $(pwd) ~/mnt/media

❯ cd ~/mnt/media

# do stuff
❯ ls -la 
...