This is an article for showing on how to share folder in Linux using an utility called samba. Precisely before sharing a specific folder in Linux, to be able to make a certain person or only a specific user that can access that specific folder shared, first of all create a user for accessing it. The article for creating user can be found in the following article titled ‘Add Samba User in Linux with smbpasswd’ in this link or another article titled ‘Create User for specific purpose like Samba Sharing’ in this link or even in this link which is actually an article titled ‘Reset Samba User Password via Command Line’ to reset password for an existing samba user.
So, after the user has already been created the next step is to make sure that the sharing folder definition has already been defined. Below are steps taken to provide the sharing folder via samba :
1. Create the folder which is going to be shared.
This step can be done by typing the command ‘mkdir folder_name’. For instance, creating a folder in the home user location as shown below :
user@hostname:~$ mkdir share user@hostname:~$
2. Make sure that the permission of the folder is set to 777.
This step is just changing the permission of the already created folder specified in the 1st step. It can be shown in the following output example by just typing the command specified :
root@hostname:/home/user# chmod -Rv 777 share/ mode of 'share/' changed from 0775 (rwxrwxr-x) to 0777 (rwxrwxrwx) root@hostname:/home/user#
3. Make sure that samba service has already installed. For a further reference on installing samba in Ubuntu Linux, just access the following link which is actually the article titled ‘Installing Samba on Ubuntu’. For other reference just consult on Google or other search engines to find it out.
4. Make sure that samba service can be started. This is how to check the status of the samba service :
root@hostname:/home/user# systemctl status smbd ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd) Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled) Active: active (running) since Thu 2017-11-02 09:41:23; 53min ago Docs: man:systemd-sysv-generator(8) Process: 27592 ExecStop=/etc/init.d/smbd stop (code=exited, status=0/SUCCESS) Process: 27605 ExecStart=/etc/init.d/smbd start (code=exited, status=0/SUCCESS) Tasks: 6 Memory: 14.0M CPU: 1.929s CGroup: /system.slice/smbd.service ├─27623 /usr/sbin/smbd -D ├─27624 /usr/sbin/smbd -D ├─27626 /usr/sbin/smbd -D ├─27639 /usr/sbin/smbd -D ├─27649 /usr/sbin/smbd -D └─27799 /usr/sbin/smbd -D Nov 02 09:41:23 hostname systemd: Starting LSB: start Samba SMB/CIFS daemon (smbd)... Nov 02 09:41:23 hostname smbd: * Starting SMB/CIFS daemon smbd Nov 02 09:41:23 hostname smbd: ...done. Nov 02 09:41:23 hostname systemd: Started LSB: start Samba SMB/CIFS daemon (smbd). Nov 02 09:41:37 hostname smbd: pam_unix(samba:session): session opened for user guest by (uid=0) Nov 02 09:43:50 hostname smbd: pam_unix(samba:session): session closed for user nobody Nov 02 09:43:50 hostname smbd: pam_unix(samba:session): session opened for user guest by (uid=0) Nov 02 10:30:07 hostname smbd: pam_unix(samba:session): session closed for user nobody Nov 02 10:30:10 hostname smbd: pam_unix(samba:session): session closed for user nobody root@hostname:/home/user#
5. Edit the samba file configuration so that the sharing file definition for the folder already created can be published by samba. The following is the sharing file definition added in a samba file configuration located normally in /etc/samba/smb.conf :
[share] path = /home/user/share valid users = guest browseable = yes writeable = yes
6. Don’t forget to restart the samba service. Just done it by typing the following command :
root@hostname:/home/user# systemctl restart smbd root@hostname:/home/user#
It means, the folder sharing named ‘share’ can be accessing using the samba user account ‘guest’.