Windows计算机和设备可以使用网络共享在它们之间互连和共享文件和文件夹。但是,如果您还在某些计算机上使用Ubuntu Linux ,则它们与(Ubuntu Linux)Windows之间的网络共享并不简单。要将您的Ubuntu Linux计算机连接到Windows计算机并共享文件和文件夹,您需要进行一系列设置。第一个是使用Samba协议启用文件共享。您还必须更改Ubuntu Linux PC使用的工作组(Ubuntu Linux PCs)这样您的所有计算机都属于同一个工作组。在本教程中,我们将演示如何启用文件共享以及如何在 Ubuntu PC 上配置和更改工作组:
注意:(NOTE:)我们使用Ubuntu 20.04 LTS创建了这篇文章。
如何在Ubuntu Linux中启用文件共享(安装(Ubuntu Linux)Samba)
Ubuntu Linux中默认不安装共享服务或Samba。Samba的安装过程在复杂性上有所不同,具体取决于您喜欢使用的方法。这是安装Samba(Samba)最简单、最直接的方法:
首先,通过同时按键盘上的CTRL + ALT + T终端。(Terminal)
Ubuntu Linux 中的终端
在终端(Terminal)窗口中,运行以下命令:sudo apt update。此命令从您的 Ubuntu PC 上配置的所有源下载包信息。换句话说,它从互联网上下载有关软件包更新版本或其依赖关系的数据。运行此命令后,系统可能会要求您输入用户密码。
在Ubuntu Linux(Ubuntu Linux)中运行 sudo apt update
接下来,运行命令sudo apt install samba。此命令告诉Ubuntu Linux下载并安装(Ubuntu Linux)Samba(共享服务)所需的所有软件包,以便在您的计算机上运行。等待(Wait)命令执行其操作,如果系统要求您确认是否要安装某个软件包,请输入Y(是)(Y (Yes))并按键盘上的Enter 键(Enter)接受。
在Ubuntu Linux(Ubuntu Linux)中运行 sudo apt install samba
安装完成后,Samba应该会在您的Ubuntu Linux机器上运行。但是,为了确保一切正常,您可能需要重新启动 PC,然后再继续本教程的下一部分。
如何在Ubuntu Linux计算机上共享文件夹
Samba运行后(Samba),您可以轻松地共享文件夹。为此,首先打开Files。
在 Ubuntu Linux 中打开文件
接下来,转到要在网络上共享的文件夹,然后右键单击它以打开上下文菜单。在菜单上,选择属性(Properties)。
在Ubuntu Linux(Ubuntu Linux)中打开文件夹的属性
在“属性(Properties)”窗口中,选择本地网络共享(Local Network Share)并检查名为“共享此文件夹”的设置。(“Share this folder.”)
在本地网络共享(Local Network Share)中共享此文件夹
如果需要,更改共享名称(Share name)并添加评论。(Comment)然后,还可以根据您希望如何授予其他网络用户访问您的共享文件夹的权限,选择或取消选择“允许其他人在此文件夹中创建和删除文件”(“Allow others to create and delete files in this folder”)和“访客访问(适用于没有用户帐户的人)”设置。(“Guest access (for people without a user account”)
配置如何在Ubuntu Linux中共享文件夹(Ubuntu Linux)
完成后,单击“创建共享(Create Share)”按钮开始与您的网络共享该文件夹,包括与其连接的所有Windows计算机和设备。
如何设置 Ubuntu 工作组
在大多数情况下,您不必更改工作组名称,因为默认情况下,Ubuntu、Windows和Mac OS都具有相同的工作组名称,实际上是WORKGROUP。但是,如果您必须更改它,请按照以下步骤操作。
打开终端(Terminal)窗口(CTRL + ALT + T),然后运行以下命令:sudo gedit /etc/samba/smb.conf。然后,按Enter。如果您之前没有在此会话中使用过终端, (Terminal)Ubuntu应该会要求您输入您的用户帐户密码。
在Ubuntu Linux(Ubuntu Linux)中运行 sudo gedit /etc/samba/smb.conf
接下来,Samba 配置文件(Samba configuration file)在gedit窗口中打开。如有必要,向下滚动,直到在“(Scroll)全局设置”(Global Settings)部分找到工作组行。
Ubuntu 工作组设置
更改 Ubuntu工作组(workgroup)值以匹配您要将Ubuntu计算机添加到的工作组的名称。然后,单击保存(Save)并重新启动Ubuntu以确保应用新设置。
保存(Save)以应用Ubuntu工作组更改
注意:(NOTE:)如果您的网络包含Windows计算机,则需要确保工作组的设置与您的Ubuntu计算机上的相同。如果您希望您的Ubuntu PC(PCs)加入您的Windows工作组,请执行此操作。要了解如何执行此操作,请查看本教程:Windows 10 工作组及其更改方法( The Windows 10 workgroup and how to change it)。
您是否在(Are)Ubuntu和Windows之间共享文件夹?
您可以在Ubuntu(Ubuntu)(或任何Linux PC)中启用共享并将其配置为加入Windows工作组以在同一网络上可见并共享文件、文件夹和打印机。如果您想了解有关在本地网络上设置其他 PC 或如何利用Linux和Windows之间的网络功能的更多信息,请查看下面列出的文章。
How to enable file sharing (Samba) and set the workgroup in Ubuntu Linux -
Windows computers and devices can interconnect and share files and folders betwеen them uѕing network shares. Howеver, if you alsо use Ubuntu Linux on some of your computers, network sharing between them and Windows is nоt straightforward. Τo connect your Ubuntu Linux computers to Windows computers and share files and folders, yоu need to make a series of settings. The first one is to enable file sharing using the Samba protocol. You also have to chаnge thе workgroup υsed by your Ubuntu Linux PCѕ so that all your computers belong to the same workgroup. In thiѕ tutorial, we will demonstrate how to enable file sharing and thеn how to configure and change the workgroup on a Ubuntu PC:
NOTE: We created this article using Ubuntu 20.04 LTS.
How to enable file sharing (install Samba) in Ubuntu Linux
The sharing service or Samba is not installed by default in Ubuntu Linux. The installation process of Samba varies in complexity, depending on the method you prefer to use. Here’s the easiest and most straightforward way to install Samba:
First of all, open the Terminal by simultaneously pressing CTRL + ALT + T on your keyboard.
Terminal in Ubuntu Linux
In the Terminal window, run this command: sudo apt update. This command downloads package information from all the sources configured on your Ubuntu PC. In other words, it downloads data from the internet about updated versions of software packages or their dependencies. After you run this command, you might be asked to enter your user password.
Running sudo apt update in Ubuntu Linux
Next, run the command sudo apt install samba. This command tells Ubuntu Linux to download and install all the software packages required for Samba - the sharing service - to run on your computer. Wait for the command to do its thing and, if you’re asked to confirm that you want to install a certain package, accept by entering Y (Yes) and pressing Enter on your keyboard.
Running sudo apt install samba in Ubuntu Linux
Once the installation is done, Samba should be running on your Ubuntu Linux machine. However, just to make sure that everything is OK, you might want to restart your PC before moving on to the next part of this tutorial.
How to share folders on a Ubuntu Linux computer
Once Samba is running, you can easily share folders. To do that, first open Files.
Opening Files in Ubuntu Linux
Next, go to the folder that you want to share on the network and right-click on it to open a contextual menu. On the menu, select Properties.
Opening Properties of a folder in Ubuntu Linux
In the Properties window, select the Local Network Share and check the setting called “Share this folder.”
Share this folder in Local Network Share
Change the Share name and add a Comment if you want. Then, also select or deselect the “Allow others to create and delete files in this folder” and “Guest access (for people without a user account” settings according to how you want to give other network users access to your shared folder.
Configuring how the folder is shared in Ubuntu Linux
When done, click the Create Share button to start sharing that folder with your network, including all the Windows computers and devices connected to it.
How to set the Ubuntu workgroup
In most cases, you don’t have to change the workgroup name because, by default, Ubuntu, Windows, and Mac OS all have the same workgroup name, which is actually WORKGROUP. However, if you have to change it, follow the next steps.
Open a Terminal window (CTRL + ALT + T), and run the following command: sudo gedit /etc/samba/smb.conf. Then, press Enter. If you haven’t previously used the Terminal this session, Ubuntu should ask you to type in your user account password.
Running sudo gedit /etc/samba/smb.conf in Ubuntu Linux
Next, the Samba configuration file opens in a gedit window. Scroll down, if necessary, until you find the workgroup line in the Global Settings section.
Ubuntu workgroup setting
Change the Ubuntu workgroup value to match the name of the workgroup you want to add your Ubuntu computer to. Then, click Save and restart Ubuntu to make sure that the new settings are applied.
Save to apply the Ubuntu workgroup change
NOTE: If you have a network that includes Windows computers, you need to make sure the workgroup is set up the same as on your Ubuntu computers. Do that if you want your Ubuntu PCs to join your Windows workgroup. To learn how to do this, check out this tutorial: The Windows 10 workgroup and how to change it.
Are you sharing folders between Ubuntu and Windows?
You can enable sharing in Ubuntu (or any Linux PC) and configure it to join a Windows workgroup to be visible on the same network and share files, folders, and printers. If you want to know more about setting up other PCs on a local network or how to utilize the networking features between Linux and Windows, check out the articles listed below.