How to mount a samba shared folder in Linux?

To mount a Samba shared folder on Linux, you can follow these steps:

  1. Firstly, make sure to install the samba client software package. Run the following command in the terminal to install it:
sudo apt-get install cifs-utils
  1. Create a local directory for mounting the shared folder. You can choose to create the directory at any location, for example:
sudo mkdir /mnt/share
  1. Mount the shared folder to a local directory using the following command:
sudo mount -t cifs //samba_server_ip/share_name /mnt/share -o username=samba_username,password=samba_password

Among them, samba_server_ip is the IP address of the Samba server, share_name is the name of the shared folder, samba_username and samba_password are the username and password of the Samba server.

  1. The file that contains information about the filesystems and their mount points in Unix-like operating systems.
sudo nano /etc/fstab

Add the following lines at the end of the document:

//samba_server_ip/share_name /mnt/share cifs username=samba_username,password=samba_password 0 0

Save and close the file.

  1. The “fstab” file, located in the directory “/etc”
sudo mount -a

You have now successfully mounted the Samba shared folder onto a local directory in Linux. You can access the shared files and folders in the /mnt/share directory.

bannerAds