Skip to main content

How to Configure Samba to Share a Folder with Two Users on Ubuntu (with Read/Write and Read-Only Permissions)

Samba is a file sharing software that allows you to share files between Linux and Windows computers. It is a popular choice for home users and businesses alike.

In this article, we will show you how to configure Samba to share a folder with two users, one with read/write permissions and one with only read permissions, on Ubuntu.


Before you begin, you will need the following:

  • A Linux computer running Ubuntu
  • Two user accounts
  • A shared folder


  1. Install Samba.
sudo apt install samba
  1. Create the shared folder.
sudo mkdir /shared
  1. Configure Samba's global options.

Open the Samba configuration file /etc/samba/smb.conf in a text editor.

Add the following lines to the [global] section:

security = user
passdb backend = tdbsam

This will set the security mode to user, which means that users will be authenticated using their local Linux accounts. The passdb backend option specifies the database that Samba will use to store user passwords. In this case, we are using the tdbsam database, which is a simple flat file database.

  1. Set up a user account for each user.

Create two user accounts, one for each user who will be accessing the shared folder. For example:

sudo adduser user1
sudo adduser user2
  1. Configure Samba share directory settings.

Add the following lines to the [share] section of the smb.conf file:

path = /shared
available = yes
valid users = user1,user2
write list = user1

This will create a share named share that is accessible to the users user1 and user2. The read only option is set to no, which means that both users will have read/write permissions to the shared folder. The write list option specifies the users who are allowed to write to the shared folder.

  1. Update the firewall rules.

If you are using a firewall, you will need to open the port that Samba uses. The default port is 139.

sudo ufw allow 139/tcp
  1. Restart Samba.
sudo systemctl restart smbd

Once you have completed these steps, the shared folder will be available to the two users. The user user1 will have read/write permissions to the folder, while the user user2 will only have read permissions.



Popular posts from this blog

Create Great looking diagrams -

I was looking for an online diagram creating tool. Came across where I could create actually great looking diagrams without much of learning curve. The tool is 1. Very easy to use 2. Has drag and drop of elements to your diagram 3. Collaboration (which I have not tested). 4. Works from anywhere on a browser with Internet connection (I used it in Google Chrome on Linux Mint 10) When you click on the "Try it now" a new screen will open as below. You can either create a blank page to create a diagram from scratch or select from a bunch of samples and work on them to create one for your requirement. There are options to export the diagrams you created to SVG, JPEG, PNG and XML format once you register for free on the website. Once you register you can save the diagrams that you created in the site itself and retrieve it at a later time by logging into the website. I made three diagrams and it was real easy and simple. The site has two kind of pa

Kerio Connect - SQLLite journal.db error

Today I noted that the Keio Connect mail server had thousands of error.log files with 75MB size filled up in the server. As always Google gave the answer. The error looks some what like below. [10/Aug/2011 10:49:35] SQLiteDbWriteCache.h: write_thread - file '/path/to/file/<user>/.journal.db', SQLite error: code 1, error SQLITE_ERROR[1]: no such table: journal_temp The solution is as below 1. Delete the cache from the client's workstation 2. Delete the profile 3. Stop the server 4. Go to the server and navigate through the user's store folder 5. Delete the .journal.db (for Linux it is  find . -name "FILE-TO-FIND"-exec rm -rf {} \; ) 6. Start the server 7. Create a new profile for the clients workstation With help from Kerio Forum Cyberciti