Skip to content

Instantly share code, notes, and snippets.

@JonasAlfredsson
Last active August 15, 2019 21:15
Show Gist options
  • Save JonasAlfredsson/623554b47e8b719417a36b8c1c780a62 to your computer and use it in GitHub Desktop.
Save JonasAlfredsson/623554b47e8b719417a36b8c1c780a62 to your computer and use it in GitHub Desktop.
SMB Mounting
# A few different ways you can mount a Samba share on your Linux computer.
# First of all you need the `cifs-utils`.
sudo apt-get install cifs-utils
# Then you can mount the following ways.
- Guest account without password.
sudo mount -t cifs -o vers=3.0,username=guest,password= //192.168.1.2/Music /home/$USER/Music
- Creadentials in command
sudo mount -t cifs -o vers=3.0,username=user,password=pass,uid=$USER,gid=$USER //192.168.1.2/Music /home/$USER/Music
- Credentials in file
sudo mount -t cifs -o vers=3.0,credentials=/secret/file,uid=$USER,gid=$USER //192.168.1.2/Music /home/$USER/Music
```/secret/file
username=user
password=pass
```
# Check if the folder is already mounted.
if grep -qs "/folder/to/mount" /proc/mounts; then
echo "It's mounted."
else
echo "It's not mounted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment