How to Access Shared Folder in Linux Terminal

How to Access Shared Folder in Linux Terminal

If you want to know how to access shared folder in linux terminal, the usual approach is to mount the shared folder with the correct protocol, then browse it like any other directory. For Windows-style shares, that usually means SMB/CIFS. For Linux or Unix shares, it is often NFS. Once mounted, you can use standard terminal commands such as cd, ls, and df to work with the share.

What you need before connecting

Before you try to access a shared folder, confirm a few basics. Most failures come from a missing package, the wrong protocol, or a permission problem rather than the mount command itself.

  • The share path, for example, //server/share for SMB/CIFS or server:/export/path for NFS
  • Network access to the remote host
  • Credentials if the share is private
  • Client tools installed on your Linux system
  • A local mount point, which is an empty directory where the share will appear

If you are not sure which protocol the shared folder uses, ask the person or system that provided the share. A Windows file share is commonly SMB/CIFS. A Linux server export is commonly NFS.

How to access a shared folder using SMB/CIFS

How to access a shared folder using SMB CIFS

Use SMB/CIFS when connecting to a Windows share, Samba share, or many NAS devices. On most distributions, you need the cifs-utils package first.

1. Install the required client tools

On Debian or Ubuntu:

sudo apt update
sudo apt install cifs-utils

On Fedora:

sudo dnf install cifs-utils

On Arch Linux:

sudo pacman -S cifs-utils

2. Create a mount point

Choose a local directory where the shared folder will appear.

sudo mkdir -p /mnt/shared

You can use a different directory if you prefer, as long as it exists and is empty.

3. Mount the SMB share

Use the mount command with the CIFS type:

sudo mount -t cifs //server/share /mnt/shared -o username=yourname

If the share requires a password, you will usually be prompted for it. If your server uses a domain or workgroup, include it when needed:

sudo mount -t cifs //server/share /mnt/shared -o username=yourname,domain=WORKGROUP

For better security, many people prefer a credentials file instead of typing the password directly in the command line.

4. Use a credentials file if needed

Create a file such as ~/.smbcredentials:

username=yourname
password=yourpassword
domain=WORKGROUP

Protect it so only your user can read it:

chmod 600 ~/.smbcredentials

Then mount with:

sudo mount -t cifs //server/share /mnt/shared -o credentials=/home/yourname/.smbcredentials

This method is easier to reuse and avoids placing the password directly in shell history.

How to access a shared folder using NFS

How to access a shared folder using NFS

Use NFS when the remote system exports a directory through NFS, which is common on Linux and Unix servers.

1. Install the required client tools

On Debian or Ubuntu:

sudo apt update
sudo apt install nfs-common

On Fedora:

sudo dnf install nfs-utils

On Arch Linux:

sudo pacman -S nfs-utils

2. Create a mount point

sudo mkdir -p /mnt/shared

3. Mount the NFS export

sudo mount -t nfs server:/export/path /mnt/shared

If the server uses NFSv4 specifically, you may want to force that version:

sudo mount -t nfs -o vers=4 server:/export/path /mnt/shared

NFS usually relies on server-side permissions and user IDs rather than a username and password prompt.

How to check that the share is mounted

How to check that the share is mounted

After mounting, verify that the folder is available and that the system recognizes it as a network mount.

ls /mnt/shared
cd /mnt/shared
pwd
df -h | grep shared

You can also inspect all mounted file systems with:

mount | grep /mnt/shared

If the directory is empty, that does not always mean the mount failed. It may simply mean the remote folder is empty.

How to unmount the shared folder

When you are finished, unmount it cleanly so the system releases the connection.

sudo umount /mnt/shared

If the mount is busy, close any terminal sessions that are inside the directory and stop any programs using files there. Then try again.

If needed, you can see what is using the mount with:

lsof +f -- /mnt/shared

How to make the mount persistent

If you want the shared folder to mount automatically after reboot, add an entry to /etc/fstab. This is useful for shares you use often, but be careful, because a bad entry can cause boot delays or mount errors.

Example for SMB/CIFS

//server/share /mnt/shared cifs credentials=/home/yourname/.smbcredentials,iocharset=utf8,uid=1000,gid=1000 0 0

Example for NFS

server:/export/path /mnt/shared nfs defaults 0 0

After editing /etc/fstab, test it before rebooting:

sudo mount -a

If there is an error, fix it before relying on the automatic mount.

Quick reference: SMB/CIFS vs NFS

ScenarioTypical protocolCommon mount style
Windows file shareSMB/CIFSmount -t cifs
Linux server exportNFSmount -t nfs
NAS deviceUsually SMB/CIFS or NFSDepends on the device settings

Common errors and fixes

Error or symptomLikely causeWhat to try
No such file or directoryWrong share path or missing local mount pointCheck the remote path and ensure the mount directory exists
Permission deniedWrong credentials or server-side permissionsVerify username, password, domain, and share permissions
Host is unreachableNetwork, DNS, or firewall issuePing the host, check name resolution, and confirm the server is reachable
mount error(13)Authentication problem on SMB/CIFSTry the credentials file, confirm the domain, and check share access
Mount succeeds but files look wrongUID/GID mismatch or permission mapping issueAdd uid, gid, or adjust server permissions
wrong fs typeMissing client package or wrong protocol selectedInstall the correct tools and confirm whether the share is SMB/CIFS or NFS

Helpful troubleshooting checks from the terminal

If the mount does not work, these checks can narrow down the problem quickly:

  • Test name resolution: ping server or getent hosts server
  • Check the route: ip route
  • Confirm the server is listening: for SMB, port 445 is commonly used; for NFS, the required ports depend on the version and server setup
  • Inspect kernel messages: dmesg | tail
  • Confirm installed tools: which mount.cifs or which mount.nfs

Also make sure you are using sudo only where needed. Mounting a share usually requires elevated privileges, but browsing the mounted directory afterward often does not, depending on how the share is configured.

Best practices for working with shared folders

Best practices for working with shared folders
  • Use a dedicated mount point such as /mnt/shared or /media/share
  • Prefer a credentials file over putting passwords directly in commands
  • Test a temporary mount before adding anything to /etc/fstab
  • Verify ownership and permissions if the share is read-only or files appear inaccessible
  • Unmount cleanly when you are done

Frequently Asked Questions About how to access shared folder in linux terminal

How do I access a shared folder in Linux terminal?

Mount the shared folder with mount, then use cd and ls to browse it. The exact command depends on whether the share uses SMB/CIFS or NFS.

How do I know whether to use SMB/CIFS or NFS?

If the share comes from Windows or many NAS devices, SMB/CIFS is common. If it comes from a Linux or Unix server, NFS is often used. If you are unsure, check the server documentation or ask the administrator.

Do I need root access to mount a shared folder?

Usually yes, so sudo is commonly required for mounting and unmounting. Once mounted, regular file access may not need root privileges if permissions allow it.

Why can I mount the share but not edit files?

That usually means the remote permissions do not allow writing, or the share is mounted with read-only access. Check server-side permissions and the mount options.

How do I unmount a shared folder in Linux?

Use sudo umount /mount/point. If the mount is busy, close any open files or terminal sessions using it, then try again.

What command opens a shared folder in Linux?

There is no single command that fits every case. First mount the share, then use standard terminal commands like cd, ls, and file editors or copy commands.

Conclusion

The most reliable way to handle how to access shared folder in linux terminal is to identify the protocol first, mount the share to a local directory, and verify the mount from the terminal before relying on it. SMB/CIFS is common for Windows-style shares, while NFS is common for Linux exports. If something fails, start with the network connection, the share path, and the credentials, then work through the mount errors one by one.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *