如何使用流行的Linux GUI在您的网络上共享文件

如何轻松在你的Linux机器上创建网络共享,无需使用命令行 - 让我来教你如何做

“`html

greenfilesgettyimages-1298291227

我经常在Linux家庭网络中共享文件和文件夹。实际上,我有一台机器存放着一个特定文件夹,里面有所有我的初稿手稿。当我决定将这些文件留在内部(而不是冒险让第三方云提供商用它们来训练AI神经网络)时,Samba是显而易见的解决方案。

对于那些使用Linux几十年的人来说,设置Samba共享是小菜一碟。对于那些对这个开源操作系统还不够了解的人来说,就没那么简单了。谢天谢地,两个最受欢迎的Linux GUI(GNOME和KDE Plasma)使得创建这些共享变得更容易一些。

我想带你走过这个过程,让你可以轻松在Linux机器上创建网络共享。

如何在这些Linux GUI中跨网络共享文件

第一步:安装Samba

你需要什么: 要使这个工作,你需要一个带有GNOME或KDE Plasma桌面环境的Linux发行版。你还需要一个拥有sudo权限的用户。就是这样。让我们来实现它。我将演示在一个基于Ubuntu的发行版(Pop!_OS)上。如果你使用基于Fedora的发行版,请确保在安装Samba过程中用dnf包管理器替换apt-get。

  1. 安装Samba:如果你的Linux发行版没有预安装Samba,你可以用以下命令安装:
sudo apt-get install samba -y

如果你的发行版是基于Fedora的,命令将是:

sudo dnf install samba -y
  1. 添加并启用用户以访问Samba:默认情况下,用户需要添加并启用以使用Samba。这只需要两个命令。第一个命令将用户添加到Samba:
sudo smbpasswd -a USERNAME

其中USERNAME是你的Linux用户名。

你首先会被要求输入你的sudo密码,并要求输入和确认一个Samba密码。

接下来,你需要用以下命令启用用户:

sudo smbpasswd -e USERNAME

其中USERNAME是你的Linux用户名。

从GNOME共享

  1. 安装Nautilus扩展:为了使这个在Nautilus文件管理器(又名“文件”)中可以工作,你需要用以下命令安装一个软件:
sudo apt-get install nautilus-share -y

如果你的发行版使用dnf,命令为:

“` “`html

sudo dnf 安装 nautilus-share -y
  1. 重新启动 Nautilus 您可以使用以下命令重新启动 Nautilus:
nautilus -q
  1. 共享您的文件夹 打开 Nautilus 并找到您想要共享的文件夹。右键单击该文件夹,然后选择本地网络共享。
nautilus-share

如果您看不到此菜单项,则可能需要注销然后重新登录。

  1. 配置共享 在弹出的窗口中,单击“共享此文件夹”的复选框。一旦您这样做了,您可以命名共享,然后(如果您希望允许用户修改共享内容)单击“允许其他人在此文件夹中创建和删除文件”的复选框。如果您想允许匿名登录到共享中,您可以单击“访客访问”的复选框(尽管出于安全原因,我不建议这样做)。
gnome-share

单击“创建共享”,然后在提示时单击“自动添加权限”。如果收到包含“net usershare’ 返回错误 255”的错误消息,则需要运行以下两个命令:

sudo mkdir -p /var/lib/samba/usershares/
sudo chmod go+rwx /var/lib/samba/usershares/

完成后,您应该能够从您的网络访问共享的文件夹。

从 KDE Plasma 共享

  1. 安装文件共享组件 登录 KDE Plasma 并打开 Konsole 应用程序。发出以下命令:
sudo apt-get 安装 kdenetwork-filesharing -y

如果您的发行版基于 Fedora,则该命令将是:

sudo dnf 安装 kdenetwork-filesharing -y

然后,您需要按照上述添加和启用用户用于 Samba 共享的相同过程进行操作。

  1. 打开要共享的文件夹的共享选项卡 right右键单击要共享的文件夹,然后单击“属性”。在弹出窗口中,单击“共享”选项卡。

  2. 修复权限 在“共享”选项卡的顶部,您可能会看到一个带有标有“修复权限”的按钮的警告。单击该按钮。提示时,单击“更改权限”。

kde-permissions

“““html

  1. Enable the share Back at the Share tab, click the checkbox for Share this folder with other computers on the local network. Once you’ve done that, you can then configure the share by giving it a name and allowing/configuring guest access. I would suggest leaving Everyone with Read-Only permissions and giving your user Full Control. Once you’ve done that, click OK.
kde-share

Once you’ve taken care of these steps, you can share any folder (so long as you have permission to access it) from your Linux machine to your network.

Additional Topics: Q&A

Q: Can I share folders between Linux and Windows using Samba? A: Yes, Samba allows you to share folders between Linux and Windows computers. By setting up Samba on your Linux machine and configuring the necessary permissions, you can seamlessly share files and folders across different operating systems. This makes collaboration between Linux and Windows users much easier.

Q: Are there any security concerns when using Samba shares? A: Like any network service, it’s important to consider security when using Samba shares. To enhance security, it is recommended to use strong passwords for Samba users and limit guest access. Additionally, keep your Samba software up to date to ensure you have the latest security patches.

Q: Can I access Samba shares from a mobile device? A: Yes, you can access Samba shares from mobile devices. There are file manager apps available for iOS and Android that support connecting to Samba shares. By installing one of these apps, you can browse and manage files on your Samba shares directly from your mobile device.

Q: Is there a graphical interface for managing Samba shares on Linux? A: Yes, there are several graphical tools available for managing Samba shares on Linux. Besides the Nautilus extension mentioned in the article, you can also use tools like system-config-samba and SWAT (Samba Web Administration Tool) to configure and manage Samba shares through a user-friendly interface.

The Impact and Future of Samba

Samba, being a powerful tool for file and print sharing, has had a significant impact on the ease of sharing files across different operating systems. Its ability to bridge the gap between Linux, Windows, and other operating systems has made it an essential component in many network environments.

Looking forward, Samba will continue to play a vital role in facilitating seamless collaboration and file sharing between different platforms. With the increasing popularity of cloud storage and remote file access, Samba’s flexibility and cross-platform compatibility will remain highly relevant in the years to come.

Reference List

  1. Best Cloud Storage Services in 2024 (Expert Reviewed)
  2. Linux Kernel 6.8 offers some exciting new features and ‘fixes all over’
  3. Stop Popup Ads on your Samsung Phone or Tablet
  4. BigLinux makes Linux easy for anyone – and it should be way more popular
  5. The top cloud storage services you can buy to protect your files

Now that you’ve learned how to create network shares on your Linux machine using GNOME and KDE Plasma, why not give it a try? Sharing files and collaborating with others on your home network has never been easier. If you found this article helpful, share it with your friends and colleagues on social media. Happy sharing! 😄🚀

“`