Samba share directory with linux or window

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


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>
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


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 = admin access
    path = /var/www/html/<folder path>
    browsable = yes
    guest ok = no
    writable = yes
    valid users = @<user name>
    create mask = 664
    force create mode = 664
    security mask = 664
    force security mode = 664
    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
To access your network share  Make a Static IP address for this server to access from another pc using router or in pc from url with register url in your /etc/hosts  file 

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

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...