Linux share folder between users

How to share files between a Linux and Windows computer

The easiest and most reliable way to share files between a Linux and Windows computer on the same local area network is to use the Samba file sharing protocol. All modern versions of Windows come with Samba installed, and Samba is installed by default on most distributions of Linux.

Create a shared folder on Windows

First, create a shared folder on your Windows machine.

  1. Open the Control Panel.
  2. Go to Network and Sharing Options.
  3. Go to Change Advanced Sharing Settings.
  4. Select Turn on Network Discovery and Turn on File and Print Sharing.

Now, create a new folder to share or choose an existing folder that you’d like to share.

  1. Right-click the folder and select Properties.
  2. Go to the Sharing tab.
  3. Above the Share button is the network name of the share you are creating. It should look like \\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName. Make a note of this network name to use later on your Linux machine.
  4. Click Share.

Access a Windows shared folder from Linux, using Konqueror

Many Linux distributions use the KDE desktop environment and the Konqueror file manager/browser. If this is what you are using, you can follow these steps to access your Windows shared folder:

  1. Click the K menu icon.
  2. Select Internet ->Konqueror.
  3. In the Konqueror window that opens, click the Network Folders link, or type remote:/ in the address bar and press Enter .
  4. Click the Samba Shares icon.
  5. Click the icon of your Windows Home workgroup.
  6. Click the Workgroup icon.
  7. Click the icon for your computer.
  8. When prompted, enter the username and password for the Windows account that created the share.
  9. Click OK.

Access a Windows shared folder from Linux, using Nautilus

Many Linux distributions, especially those that use the GNOME desktop environment, use the Nautilus file manager. If this is what you’re using, you can follow these steps to access your Windows shared folder:

  1. Open Nautilus.
  2. From the File menu, select Connect to Server.
  3. In the Service type drop-down box, select Windows share.
  4. In the Server field, enter the name of your computer.
  5. Click Connect.

Alternatively, in the Nautilus address bar, you can type smb://ComputerName/ShareName and press Enter . For instance, when you created your Windows Share, if the share name was listed as:

Type smb://YOURCOMPUTERNAME/Users/YourUserName/ShareFolderName and press Enter . Note the smb: at the beginning; in Linux, use forward slashes instead of backslashes.

Access a Windows shared folder from Linux, using the command line

You can also access your Windows share from the Linux command line using the smbclient program.

  1. Open a terminal.
  2. Type smbclient at the command prompt.
  3. If you receive a «Usage:» message, this means smbclient is installed, and you can skip to the next step. If the command is not found, however, you need to install smbclient. Follow these steps to install it.

Источник

How to Share Files and Folders Between Linux and Windows

Samba makes it easier than you might think

If your Linux machine is on a network, chances are you might want to share a directory (folder) or two to other users. Some Linux desktop environments (such as GNOME) make this incredibly simple. Some distributions and/or desktop environments, however, (such as Elementary OS) don’t offer a simple GUI for the sharing of folders.

Should you happen to be using a desktop environment that doesn’t make the process of sharing directories to your network a simple point-and-click affair, you’re not out of luck. Thanks to Samba (the underlying technology that makes this happen), you can still share those directories. It’s a bit tricker, but it’s not terribly hard.

What Is Samba?

Samba is an open-source software that enables Linux-based systems to communicate with Windows and macOS systems via the Common Internet File System (CIFS). Samba gets its name from the Server Message Block (SMB) protocol, which is at the heart of CIFS. Without Samba, directories on Linux wouldn’t be visible to Windows or macOS machines on your network.

For the purpose of this demonstration, we tested using Elementary OS 5 (Loki), which is based on Ubuntu Linux (so the process will be the same for any Ubuntu-based distribution) and Samba version 4.7.6.

Installing Samba

Chances are, you’re going to have to install Samba, as it is not included on most Linux desktop distributions. To install Samba, follow these steps:

Open a terminal window from your desktop menu.

Issue the command

sudo apt install samba samba-common -y

When prompted, type your user password.

Allow the installation to complete.

That’s all there is to the installation.

Configuring Samba

This is where things do get a bit challenging. What you must do is manually configure what are called Shares, with the Samba configuration file. In simple terms, a share is a directory you want to share with others on your network. We’ll create a very basic share.

The first thing to do is back up the original Samba configuration file. To do this, open a terminal window and issue the command

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

With the original file backed up, it’s now safe to edit the original. Issue the command

sudo nano /etc/samba/smb.conf

and scroll to the very bottom of that file. What we’re going to do is add a new share for the Public folder, found in your user home directory. Let’s say your username is jack. The full path to that Public folder would be /home/jack/Public. That’s important to know.

This new share will look like this:

[Public]
path = /home/jack/Public
browseable = yes
writeable = yes
read only = no

Save and close that file by typing Ctrl + x. Finally, restart Samba with the command

Adding Users

Now we have to add our Linux users to Samba. Why? Because although the Linux system recognizes the users, Samba does not. One thing to understand is that anyone wanting to have access to those shared directories will need to have an account on your machine. You can create anonymous access to those shared folders, but it lacks security (and we want to keep our machines as secure as possible).

Fortunately, there are only two simple commands to run. We’ll stick with our sample user, jack. The first command adds the user to Samba (requiring you type and verify a new password). This command is:

sudo smbpasswd -a jack

You might first be prompted for your users’ sudo password. Type that and then, when prompted, type and verify a new Samba password for the Samba user.

The second command enables the user for Samba. This command is:

sudo smbpasswd -e jack

Ready for Access

That’s it. The new user is added and will then be able to access the shares. If you go to another machine on your network, you should be able to access that share from your desktop’s file manager (with the username and password you configured using the smbpasswd command). How you access the share will depend upon the operating system and file manager used on the other machines.

Источник

How to create a Shared Folder between two Local User in Linux?

This article shows how to set-up a shared folder between two local users in Linux. The shared directory/folder will be accessible to both the users, they will be able to read/write each other’s file.

Let us create shared directory /home/shareFolder for user Bob and Alice and add them to a common group named projectA.

Note: You can create the uses Bob and Alice using following commands:

    So, start by creating common group using groupadd command.


Now, create shared directory and change group for it using chgrp command.


After this we need to change appropriate permissions for the shared directory using chmod command.

Here 770 permission means:


We also need to set the SGID(Set-Group-ID) bit for the sharedFolder directory, now all newly created subdirectories/files under sharedFolder will inherit sharedFolder permissions.


Finally we add users to the common group with whom to share the folder

Now /home/sharedFolder is accessible to both the user Bob and Alice. But others can’t access this directory. This directory will be accessible to only members of projectA group.

Источник

How to Set-up shared folder/repository between two or more users on Linux

We had a case where we wanted two different applications (run by different users) to be able to read and write from the same file system.
This is how we solved this problem:

  1. Create a group which these users will belong to :[shell]groupadd GROUP_NAME[/shell]
  2. Edit user1 and user2 to be a member of this group:[shell]
    usermod -a -G GROUP_NAME user1 ;
    usermod -a -G GROUP_NAME user2;
    [/shell]
  3. Create a shared directory. In our case, it had to be the document root for an Apache site. Thus we chose the location SHARED_FOLDER
  4. Now we need to change the group of this folder :[bash]chgrp -R GROUP_NAME SHARED_FOLDER [/bash]
  5. We’ll also need to grant the group write access on this folder :[bash]chmod g+w SHARED_FOLDER [/bash]
  6. Now we’ll need to set the GroupID flag on this folder. For a directory, the set-groupID flag means that all files created inside that directory will inherit the group of the directory. Without this flag, a file takes on the primary group of the user creating the file. This property is important to people trying to maintain a directory as group accessible. The subdirectories also inherit the set-groupID property. (http://www.dartmouth.edu/

rc/help/faq/permissions.html).[bash]chmod +s SHARED_FOLDER[/bash]

  • Now in your .bashrc / .bash_profile, set the umask as 002. Setting this umask ensures that all the newly created files by this user will have the permission “rw-rw-r”. Thus giving the group write permission.: [bash] umask 002 [/bash]
  • Now when either of the users create any file in the SHARED_FOLDER, all the users of this group will have the read/write permissions on that file. Not only this, these permissions will be on the subfolders and the files with-in that folder as well.

    But, if any of these users create a file outside the SHARED_FOLDER, the primary group of that file/folder will be the same as the primary group of that user. Thus files/folder only in the SHARED_FOLDER are shared between these users.

    This is just one of the many great abilities that Linux provides.

    Источник

    Thread: Best way to share folders between two Linux computers.

    Thread Tools
    Display

    Best way to share folders between two Linux computers.

    I have two linux computers (one is running ubuntu 9.04 and the other Debian Lenny and Slackware64).

    I would like to share a folder between these computers.

    What’s the best way to do this and What are the steps I should follow? What should I install on both computers?

    Re: Best way to share folders between two Linux computers.

    NFS is native to Linux, but SSH(FS) is another option.
    Here is a How-To for NFS, and for SSH and SSHFS.
    FTP is still an option.

    Re: Best way to share folders between two Linux computers.

    install on both computers

    as for how, Mr Google will advise for the other distros and a forum search here will show for Ubuntu

    Re: Best way to share folders between two Linux computers.

    ssh server (openssh-server) and then use eihter the «places» menu to connect or use sshfs

    Re: Best way to share folders between two Linux computers.

    You already have ssh installed (most probably).

    Open nautilus, ctrl+l, then type
    ssh://user@debian_machine
    and voila, you have a file browser on the remote machine.

    Bogdan

    Re: Best way to share folders between two Linux computers.

    You already have ssh installed (most probably).

    Open nautilus, ctrl+l, then type
    ssh://user@debian_machine
    and voila, you have a file browser on the remote machine.

    Bogdan

    Thanks for your help my friends!

    #1 Where do I get user and debian_machine info in Ubuntu?
    #2 How can I access the folder without user and password?
    #3 Does this work on any Linux computer (Slackware, for instance)?

    Re: Best way to share folders between two Linux computers.

    Hi.

    1)-debian_machine is the hostname of your Debian server (the one that you try to access).
    You can use also the ip address.
    -user is the username you use to login on that machine.
    2)if you set ssh key authentication, probably the access it will work without passwords.

    However, you might want to look at nfs, if you want a permanent share between the 2 computers.
    3)It works on any linux distro with openssh server/client installed.

    Re: Best way to share folders between two Linux computers.

    For me the most convenient way is via samba in nautilus: right click on the shared folder and sharing option.
    And on the client machine go to networks and you’ll find the share, click on it and it will be mounted by gvfs.
    BUT there is a serious problem with gvfs mounts sshfs or samba:
    Often when I suspend my laptop or the network connection is interrupted, I cant browse or unmount my gvfs share therefore I cant remount it again leaving me with no choice but to reboot the client machine.
    How can I go around this? Permanent mounts are not an option for me bacause I move around a lot.
    One Idea was to write a script that unmounts all my gvfs mounts before suspending and then remounts them when wakeing but maybe unmount wont work if lets say a movieplayer is open and playing a file from the share when I suspend.
    What say you to this?

    Re: Best way to share folders between two Linux computers.

    I used to be a big proponent of Samba, but it requires too much fiddling, as well as administering a whole new set of users and passwords and shares. If all you need to do is make folders available to other linux boxes NFS is the easiest as long as you don’t mind using the shell. Anyway, here’s how to setup a simple share for a whole range of machines.

    First: install NFS and make sure its working.

    Next set up your shares. You need to edit ‘/etc/exports’ I used ‘sudo vim /etc/exports’ but if you prefer an editor from this century you could do ‘gksudo gedit /etc/exports’

    Since I have a closed network, I decided to share my ‘/home’ directory with every machine on the network to do so I added the line

    Источник

    Читайте также:  Gv rx16p256de rh драйвер windows 10
    Оцените статью