Samba!
Samba share folder is usually something you’d access from Windows machines. But what if you want to share the directory with your other Linux machines? Here’s the tutorial.
My home Linux server acts as my tech universe’s hub point. From my Windows machines to Android devices, I upload and download files via the server. Not only is it my overpriced Dropbox alternative, but it is also my personal tech experimental lab where I do every possible Linux machine can do to make my life as efficient as possible by taking advantage of Python and bash scripting skills to automate server routines.
Anyway, while I love having the Linux-centered tech life, my System 76 Galago Pro (2018) Linux laptop machine was always a bit out of the loop. Sharing files through Samba was smooth and easy from my Windows and Android devices, but accessing it from other Linux machines was always a bit of a hassle.
But I finally found a sort-of solution – yep, there’s a catch but as I mentioned earlier, what really matters is the experimental spirit that pushes the tech boundaries to achieve and learn something.
Anyway, let’s dive into it!
First of all, install cifs-utils if you haven’t yet.
sudo apt-get install cifs-utils
Then, make a directory where you want to mount the remote server’s shared directory.
sudo mkdir /mnt/remote
Give the remote server’s location, your machine’s mounting point, and the server’s username/password as arguments.
sudo mount -t cifs //192.168.0.xx/smb/remote_hdd /mnt/remote -o username=<Username>,password=<Password>
***ATTENTION*** Be careful, not to set it like this below. When I first tried it, I wrote my server’s location as “//192.168.0.xx/shares/smb/remote_hdd/”, but it didn’t work. Although it is the absolute path, somewhat it’s not how it works.
***WRONG EXAMPLE***
sudo mount -t cifs //192.168.0.xx/shares/smb/remote_hdd/ /mnt/remote -o username=<Username>,password=<Password>
Then, open /etc/fstab with whatever text editor you prefer.
sudo vim /etc/fstab
Add the line to the file and save it.
//192.168.0.xx/smb/remote_hdd /mnt/remote cifs username=<Username>,password=<Password>,_netdev 0 0
Logs:
Additionally, if your attempt to mount a remote samba directory is failed, go to “/var/log/samba” and see the log file: log.smbd.
cd /var/log/samba
sudo cat log.smbd
Whenever the attempt failed, it’s always logged in the file.
Failure I experienced:
Well, well, well… I was feeling like a Linux guru, ready to conquer the world of open source! But boy, was I wrong! I managed to open and read files like a boss, but when it came to creating, writing, or editing files, I hit a brick wall. Talk about a confidence crusher! Don’t worry, this isn’t a tutorial post, just a cry for help from a struggling Linux enthusiast. Can someone please lend a hand and save me from this digital distress? 😂
So, what I did was open this file: /etc/samba/smb.conf, because it’s the file where I wrote all the accessing credentials and permissions when I first edited it last year.
vim /etc/samba/smb.conf
[global]
server string = File Server
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast wins
[smb]
path = /shares/smb
force user = user_name
force group = users
create mask = xxx
force create mode = xxx
directory mask = xxx
force directory mode = xxx
public = xxx
writable = xxx
guest ok = xxx
As you can see, the settings require users to log in with the specific username I set. I figured that if I added the same group name as the one my laptop user belongs to, I might be able to write, create, and edit files on the laptop. So, I added the laptop_group name in the server system and edited the file as well.
[global]
server string = File Server
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast wins
[smb]
path = /shares/smb
force user = user_name
force group = users, laptop_group
create mask = xxx
force create mode = xxx
directory mask = xxx
force directory mode = xxx
public = xxx
writable = xxx
guest ok = xxx
But it didn’t work out… Well, I’m still searching for a solution for this lol.
Anyways, whenever I found a way, I’ll update this post! Thanks for the reading as always bro!