The ability to access shared folders with Ubuntu enables you to interact with files and folders stored on a remote machine. Ubuntu offers you different methods to retrieve files, transfer data or collaborate with another operating system such as Windows. In this article, I will explore different approaches on how to access shared folder in Ubuntu and have a seamless sharing experience.
Key Takeaways
- Learning how to use a graphical interface for accessing folders.
- Knowing how to use commands to access shared folders.
- Understanding the difference between cifs-utils and smbclient.
Requirements
- User must have sudo/root privilege.
- User must have a text editor.
Process Flow Chart
[Distro Used Throughout the Tutorial: Ubuntu 22.04.02 LTS]
With the help of a graphical interface or command line tools, accessing shared files has become incredibly convenient. I have shown here two different approaches to accomplish this task. So, regardless of your expertise in Ubuntu, you can now easily manage files with Ubuntu.
Nautilus is regarded as the official file manager for GNOME desktop environment or default desktop environment. It provides a graphical user interface (GUI) to navigate and manage files and folders in Ubuntu. In this method, my primary goal is to show you how to enable sharing of a folder created in Ubuntu and access it from both Ubuntu and Windows.
Steps to Follow >
➊ Power on Ubuntu.
➋ Choose a folder you want to share with other operating systems such as Windows. I have chosen the folder called Share in my Desktop for this purpose.
➌ Afterwards, right-click on Share folder and a popup menu will appear and click on Local Network Share.➍ A dialogue box will appear on the screen as in the image below. Select Share this folder, Allow others to create and delete files in this folder, and then press Create Share.
➎ Now Nautilus will require you to press Add the permissions automatically to finally prepare the folder for sharing.
➏ You will see that the folder Share is ready to access.
The green share icon at the bottom-right corner of the folder indicates that you can share this folder’s contents.
➐ Now you can create files in this folder. I have saved an image, Photos.jpeg and created a folder, Files to share within the Share directory.➑ Now go to the Ubuntu terminal and run the following command.
hostname -I
- hostname -I: Obtains IP address of the current Linux system.
➒ Now go to This PC in Windows and type IP of your Linux system and name of folder, Share in the address box.
\\192.168.153.128\Share
- 168.153.128: IP address of Linux system.
- Share: Name of folder which needs to be accessed.
From the above image, it is clear that I can view the contents of the “Share” folder from Windows and have full control over these files.
Read More: Install, Configure and Connect Samba on Ubuntu Using GUI
If you want to have remote access over a network or customize command scripts according to your sharing requirements, command-line tools will be a perfect choice. The cifs-utils and smbclient packages are prominent command-line tools for this purpose. In this method, I will demonstrate to you how to handle folders that were originally created on Windows but are being accessed from Ubuntu.
Step 1: Enable Sharing Options in Windows
Before a folder can be accessed from a remote environment, it is necessary to enable sharing options in Windows.
Steps to Follow >
➊ Open Control Panel and go to Network and Internet > Network and Sharing Center.
➋ Click on Change advanced sharing settings at the left side of the page.➌ Then, turn on network discovery, file and print sharing, and click Save changes.
Read More: How to Share Files between Linux and Windows Dual Boot [3 Methods]
Step 2: Enable Sharing Options for a Folder in Windows
Subsequently, you have to activate the sharing settings of a folder in Windows. For this purpose, I used Windows_Share folder created on Windows. You can either create a fresh folder similar to mine or use a preexisting one.
Steps to Follow >
➊ I have created a folder called Windows_Share on Windows and saved a file named Document in it.➋ Afterwards, right-click on Windows_Share and go to Properties.
➌ Navigate to Sharing > Advanced Sharing.
➍ Select Share this folder and then click on Permissions.
➎ Here, I clicked on Add since I prefer only the account, User, to be able to share the Windows_Share folder. Otherwise, you can select Everyone to give anyone access to your folder.
➏ Then put in the name of your desired user account. I enlisted my account, User, and clicked OK.
➐ You will be redirected to Permissions for Windows_Share. Enable Full Control, Change, and Read permissions for your desired account. You can enable these options for anyone by selecting Everyone. Click OK to save these changes.
As you can see, User is my Windows user account which has all three permissions of the shared folder, Windows_Share.
➑ Now go to Security and check the recent changes for your specified account for sharing the folder. Press Close to close Windows_Share Properties.
Read More: How to Share Files between Linux and Windows
Two prominent command line tools for accessing shared folders are cifs-utils package and smbclient package. The cifs-utils package has more comprehensive features for managing shared folders. On the other hand, the smbclient tool is a lightweight utility for basic sharing operations with folders.
CIFS or Common Internet File System contains tools and utilities that help to mount and manage SMB/CIFS share files, printers, or serial ports over a network. The cifs-utils package helps to mount SMB shares to local directories. Therefore, this package will build a bridge between Windows and Ubuntu for the shared folder, Windows_Share.
Steps to Follow >
➊ Open your Ubuntu terminal.
➋ Execute the following command to install the cifs-utils package.
sudo apt install cifs-utils
- sudo: Permits a user with administrative privileges to execute commands.
- apt install: Installs a specific package.
- cifs-utils: Package that supports mounting CIFS/SMB file system. CIFS is the core file-sharing protocol used by Samba.
mkdir /home/ayesha/Desktop/cifs_share
- mkdir: Creates a new directory or folder.
- /home/ayesha/Desktop/cifs_share: Absolute path of cifs_share folder in Desktop.
My newly created cifs_share directory in Desktop will now be able to mount the shared folder, Windows_Share.
➍ Lastly to mount a shared folder run the following command:
sudo mount -t cifs //192.168.0.105/Windows_Share /home/ayesha/Desktop/cifs_share -o username=User
- sudo: Permits a user with administrative privileges to execute commands.
- mount: Attaches or mounts a file system to a specific directory.
- -t cifs: ‘t’ specifies that CIFS (Common Internet File System) needs to be mounted.
- 192.168.0.105: IP address of Windows system.
- Windows_Share: Name of the shared folder in Windows which needs to be accessed.
- /home/ayesha/Desktop/cifs_share: Absolute path of cifs_share folder in Desktop of my Linux system.
- -o: Specifies the options to be used when mounting a file system, in this case, specifies username option.
- username =User: Provides the name of the account in Windows which has access to the shared folder.
➎ Now navigate to Files >Desktop > cifs_share.
➏ Open cifs_share folder and you can view the word file, Document from Ubuntu. The image above shows that the word file, Document which was created in Windows can now be accessed from Ubuntu.
For interacting with SMB shares, smbclient is a command-line tool that provides a client interface to access and manage resources on SMB (Server Message Block) servers. The smbclient tool offers various tools to browse, download and manage files on SMB shares.
Steps to Follow >
➊ Open your Ubuntu terminal.
➋ To install smbclient package, execute the command below.
sudo apt install smbclient
- sudo: Permits a user with administrative privileges to execute commands.
- apt install: Installs a specific package.
- smbclient:Name of the package which needs to be installed.
smbclient //192.168.0.105/Windows_Share -U User
- smbclient: Command that interacts with SMB shares.
- 192.168.0.105: IP address of my Windows system.
- Windows_Share: Name of the shared folder.
- -U: Specifies username.
- User: Name of Windows user account which has access to shared folder.
➍ In order to get a better understanding of this accessing method, let’s list its contents with the following command.
ls
- ls: Lists contents of a directory.
Read More: How to Access Samba Share from Windows [2 Methods]
Comparative Analysis of Methods
Going through the aforementioned methods, it is understandable you might feel confused about the right procedure. Take a look at the pros and cons below and decide which method works best for you.
Methods | Pros | Cons |
---|---|---|
Method 1 |
|
|
Method 2
(Case 1) |
|
|
Method 2 (Case 2) |
|
|
To summarize, method 1 is suitable if you prefer a graphical interface over commands. It may not be a feasible choice when working in an environment without GUI. On the other hand, method 2 is reliable for working efficiently in a remote environment.
Although case 1 is a more comprehensive tool, it’s difficult to operate due to its complicated configuration process. On the other hand, lightweight and compatible case 2 is a favorite choice when it comes to basic share operations. However, consider your required level of functionality for shared files, expertise in Linux commands, or network speed to choose the most suitable method for you.
Conclusion
An effective sharing process between Ubuntu or any other operating system like Windows should include easy access to shared folders in Ubuntu. This article demonstrated three simple ways to accomplish this task. However, the best method for accessing folders ultimately depends on your preference for a graphical interface such as Nautilus or a command-line interface like cifs-utils and smbclient command.
People Also Ask
Related Articles