Pages

Linux Samba Server : share server files directory with linux or window pc

How to create a linux server to share directory of projects(php,.net java) with other linux system PC or window system PC. 

How to create a network share via Samba using the Command-line interface/Linux Terminal, simple and brief way targeting Windows users.

1. Install Samba in linux server 14.04 or 16.04 18.04

sudo apt-get update
sudo apt-get install samba  

2.Create User in samba

$ add user <username>
$ sudo smbpasswd -a <user_name>
3. Create a directory to be shared

$  mkdir /var/www/html/<folder_name>
Give folder rights

$ sudo chmod 777 -R <folder_name>
Now edit the file smb.conf before Make sure you take a safe backup copy of the original /etc/samba/smb.conf file to your home folder, in case you make an error while editing

sudo cp /etc/samba/smb.conf ~
Edit the file "/etc/samba/smb.conf"

$ sudo nano /etc/samba/smb.conf
Add the folder access right to user access from another pc/window and can guest also

[<folder name>]
    comment = normal access
    path = /var/www/html/<folder path>
    browsable = yes
    guest ok = no
    writable = yes
    valid users = @<user name>
    create mask = 777
    force create mode = 777
    security mask = 777
    force security mode = 777
    directory mask = 2775
    force directory mode = 2775
    directory security mask = 2775
    force directory security mode = 2775

Restart the Server

$ sudo service smbd restart
OR command for restart

$ sudo systemctl restart smbd.service
$ ​sudo systemctl restart nmbd.service
Checking working

$ testparm
save To access your network share make a static IP address for this server to access from other window or linux pc to shared network(using router or net) url and register in your linux or window hosts file 
/etc/hosts files

localhost   <HOST_IP_OR_NAME> 

save file and close.

Now, run in the browser

https://<HOST_IP_OR_NAME>/<folder_name>

share directory access from linux

smb://<HOST_IP_OR_NAME>
share directory access from window in file manager

In filemanager  in your another pc window or linux
\\<HOST_IP>
\\192.11.11.1\test

No comments:

Post a Comment

Popular Posts