Setting up a Samba File Server from the command line may sound daunting but in this guide I’ll break it down in to simple steps any beginner with Linux can follow!
- A computer running Ubuntu Minimal/Server or Debian
- A computer to be the client (preferably Windows)
Connect to your Server through SSH or type the commands in to it directly. I’ll be executing all commands as root user. You can change to root with these commands:
The first step is to install Samba on the server.
apt install samba -y
You can add users easily with a single command. The -m creates a home folder for them that makes sharing convenient.
useradd -m john
You’ll also need to add a Samba password for the user.
smbpasswd -a john
Create a Backup of the smb.conf
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
Create the folder you intend to share and change ownership to the user who will have access. Replace my name with the users name.
mkdir /home/john/Share chown -R john /home/john/Share/
Open the Samba configuration file in your text editor of choice and we can begin editing!
If needed, change the workgroup to your desired name
workgroup = WORKGROUPNAMEHERE
Go to the bottom of the page and we can add the share.
[TestShare] path = /home/john/Share browsable = yes valid users = john writable = yes
You’ll need to restart the Samba service before you can access the share.
Accessing the Shares
We can now try to access the shares. Get your servers host name or IP access and type it in to windows file explorer beginning with \\. Here are examples however names or IPs will differ.
Alternatively you can click on “Network” on the left of the file explorer and it should show up. Click on the server and shares you’ve created will show up. You can click on them and enter your username and password
You can only access 1 user at a time per server. So if Bob and John both have a share on a server and you log in as Bob then you can only access Bob’s shares and trying to access John’s won’t work even with the right username and password. A restart will allow you to change users as long as you haven’t asked windows to remember your credentials.