Support > About cybersecurity > Specific scenarios for installing and configuring Samba in Ubuntu
Specific scenarios for installing and configuring Samba in Ubuntu
Time : 2025-02-20 15:34:20
Edit : Jtti

Samba is an open source software that enables file sharing between Linux and Windows systems. Here are the detailed steps to install and configure Samba on an Ubuntu system.

Open the terminal and run the following command to update the list of packages:

sudo apt update

Use the following command to install Samba:

sudo apt install samba

After the installation is complete, you can view Samba version information by running the following command:

sudo smbd --version

Select a directory as the shared directory, such as /home/user/shared, and create it:

sudo mkdir -p /home/user/shared

To ensure that Samba users can access the shared directory, you need to set the appropriate permissions:

sudo chown -R user:user /home/user/sharedsudo chmod -R 775 /home/user/shared

Before editing the configuration file, it is recommended to back up the original file:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Edit the Samba configuration file

Open the Samba configuration file using a text editor, such as nano or vim:

sudo nano /etc/samba/smb.conf

Define a shared directory by adding the following at the end of the file:

[shared]path = /home/user/sharedread only = nobrowsable = yesvalid users = userwritable = yes

[shared] : indicates the share name. path: indicates the path of the shared directory. read only: no indicates that the directory can be read and written. browsable: Set to yes: The shared directory is visible on the network. valid users: Users who are allowed to access the share.

Create a Samba user for the shared directory and set a password with the following command:

sudo smbpasswd -a user

You will be prompted to enter and confirm the user password. If a user already exists but Samba access is not enabled, you can use the following command to enable it:

sudo smbpasswd -e user

After modifying the configuration file, you need to restart the Samba service to apply the changes:

sudo systemctl restart smbd

Check the Samba service status to ensure that the Samba service is running:

sudo systemctl status smbd

Testing a shared directory

In Windows, you can access the shared directory by typing \\<Ubuntu_IP> into the file Explorer.

To ensure that the Samba service runs automatically when the system starts, you can use the following command:

sudo systemctl enable smbd

Samba's configuration file /etc/samba/smb.conf contains several parts, including global configuration and shared configuration. Here are some common configuration options:

Global configuration:

[global]workgroup = MYGROUPsecurity = userguest account = nobodylog file = /var/log/samba/log.%mmax log size = 50

Sharing configuration:

[homes]comment = Home Directoriesbrowseable = nowritable = yes

[printers]comment = Printerspath = /var/spool/sambabrowseable = noguest ok = nowritable = noprintable = yes

By following these steps, you can install and configure Samba on an Ubuntu system to enable cross-platform file sharing. Ensure that permissions and user access permissions for the shared directory are set correctly to ensure system security.

Relevant contents

Linux mount command usage tutorial Factors to consider when choosing a DCIM solution Common uses of the Linux Touch command Procedure for installing Python PIP on Windows Streaming platforms migrate from client-side to server-side adaptive bitrate streaming The impact of artificial intelligence on power consumption in data centers High-defense CDN acceleration and DDoS attack defense Artificial intelligence is reshaping the data center, transforming everything from infrastructure to sustainability CDN acceleration principle and CDN acceleration technology Taiwan BGP server room rental
Go back

24/7/365 support.We work when you work

Support