Sharing Files In Linux And Windows

1 minute read

Description:

Although I have these steps in a couple places, I wanted to make a single post with the different combinations of sharing folders between Windows/Linux.

From Windows -> Linux

1. Networking and Sharing -> File/Print sharing

  1. Share the folder, set permissions for everyone

  2. Under the security settings either add a specific user or add “everyone” and set permissions to what you need access for.

  3. From Linux, install the cif-utils package.

sudo apt-get install cifs-utils

b. Now create a new folder on your desktop and mount the Windows share to that folder:

mount t cifs o username=geek,password=thepass //WindowsPC/Share /home/username/path

From Linux -> Windows:

  1. Install Samba
sudo apt-get install samba
  1. Configure username/password that will be used in Windows to access the share:
smbpasswd -a smb
  1. Create a folder to share:
mkdir ~/Desktop/Share
  1. Edit Samba config file:
sudo vi /etc/samba/smb.conf

Edit:

[]
path = /home/username/Desktop/Share;
available = yes
valid users = smb;
read only = no
browsable = yes
public = yes
writable = yes

# Save and close the file
  1. Restart the SMB service for changes to take effect:
sudo service smbd restart

# Note: I like to do a "chmod 770 -R" on the shared directory

# Note: I like to do a "chown user:group -R" on the shared directory

From Windows -> Windows:

  1. Create the share using the steps above

  2. Run – \ip\sharename

  3. Enter the username and password from above

From Linux -> Linux:

  1. Install Samba Client:
sudo apt-get install smbclient
  1. To list all shares:
smbclient -L //ipaddress/sharedfoldername -U user
  1. To connect:
smbclient //ipaddress/sharedfoldername -U user
  1. To mount:
mount t cifs o username=geek,password=thepass //geekmini/root /media/Video
  1. To access via File Browser:
smb:///ipaddress/sharedfoldername