How to Install Samba on Ubuntu 20.4.1
How to Install Samba on Ubuntu 20.4.1
Introduction:
Samba is a server used for communicating between windows and Linux. It has 2 protocols,
- 1.SMB(Server Message Block),
- 2.NMB (NetBIOS Message Block).
It also used to share Linux files and printers with windows system, and also gives Linux users access to files on windows system.
The port numbers for samba are: 137,138 - UDP(User Datagram protocol) 139,445 - TCP(Transfer control protocol)
Installation process:
To check the installed version of OS, run the following command.
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Install Samba:
To install samba type below command:
root@linuxhelp:~# apt install samba -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
attr ibverbs-providers libcephfs2 libibverbs1 librados2 librdmacm1 python3-crypto python3-dnspython python3-gpg
python3-ldb python3-markdown python3-packaging python3-pygments python3-pyparsing python3-samba python3-tdb
samba-common samba-common-bin samba-dsdb-modules samba-vfs-modules tdb-tools
Suggested packages:
python-markdown-doc python-pygments-doc ttf-bitstream-vera python-pyparsing-doc bind9 bind9utils ctdb ldb-tools ntp
| chrony smbldap-tools winbind heimdal-clients
…..
Server role: ROLE_STANDALONE
Done
Once above step is completed check the samba status by using below command:
root@linuxhelp:~# systemctl status smbd
smbd.service - Samba SMB Daemon
Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-10-29 23:24:05 PDT; 5min ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 25833 (smbd)
Status: "smbd: ready to serve connections..."
Tasks: 4 (limit: 2285)
Memory: 14.2M
CGroup: /system.slice/smbd.service
├─25833 /usr/sbin/smbd --foreground --no-process-group
├─25835 /usr/sbin/smbd --foreground --no-process-group
├─25836 /usr/sbin/smbd --foreground --no-process-group
└─25837 /usr/sbin/smbd --foreground --no-process-group
Then create a directory for samba share by using below steps:
root@linuxhelp:~# mkdir /home/user/share1
root@linuxhelp:~# mkdir /home/user/share2
After creating a directory give permission for both directories by using below command:
root@linuxhelp:~# chmod 777 /home/user/share1
root@linuxhelp:~# chmod 777 /home/user/share2
Then we need to create samba share user to access samba share by using below command:
root@linuxhelp:~# useradd user1
root@linuxhelp:~# useradd user2
Once completed set samba password for both users by using below command:
root@linuxhelp:~# smbpasswd -a user1
New SMB password:
Retype new SMB password:
Added user user1.
root@linuxhelp:~# smbpasswd -a user2
New SMB password:
Retype new SMB password:
After completed above steps then configure samba file by using below steps:
root@linuxhelp:~# nano /etc/samba/smb.conf
[share1]
path = /home/user/share1
valid users = user1, user2
read list = user2
write list = user1
browseable = yes
[share2]
path = /home/user/share2
valid users = user1, user2
read list = user1
write list = user2
browseable = yes
Check configuration file by using below command:
root@linuxhelp:~# testparm
Once completed goto run terminal type samba share id:
There will be a two folders share1 and share2 like that in snap2:
Then goto share1 and login as user1 and user2 and same for share2 like that in snap3:
With this method to install samba on Ubuntu comes to end.
# useradd username
To set a samba password for the user type the below command
# smbpasswd -a username
# testparm
# nano /etc/samba/smb.conf
# systemctl status smbd
# apt install samba -y
Please help me!
Thank you!