- Computers & Software»
- Operating Systems
How to Mount a Windows Share In Linux
Before We Start
Before we can mount a share, Samba must be enabled and configured on your Linux computer. Samba is what allows Linux to access shared folders on a Windows machine. Without it, you won't be able to access Windows shares.
Mounting a Windows Share in Linux
There are a couple of different methods for mounting your share, depending on the version of Windows you are attempting to connect to. CIFS is the protocol we will use to access network shares on newer Windows machines. For older Windows computers, we will use SMB.
The basic syntax we will use is as follows:
mount -t [protocol] //ServerName/ShareName /mnt -[options]
[Protocol] will be replaced with either "cifs" or "smb" (both without quotes) depending on the Windows computer you are connecting to. [Options] can include a username and password that have the necessary permissions to access the Windows share. Note that "mnt" is the folder that the share will be mounted to. It can be set to any name you like in any location within Linux, but the folder must exist before you run the command.
"ServerName" is the hostname of the Windows computer you are accessing, and "ShareName" is the name the folder is shared as in Windows.
Here is an example of using the above command to connect to a share on a Windows XP machine:
mount -t cifs //ServerName/ShareName /mnt -ouser=administrator,password=password
Windows XP is OS, so we are using CIFS as the protocol to connect to. The "ouser" option specifies the username of the Windows computer you are using to connect, and "password" is the password for that same account. Note that if you use the "password" option you will be typing the password in plain text onto the terminal. This can be avoided by excluding the "password" option, which will cause Linux to prompt you for the password in a protected field.
For example, typing:
mount -t cifs //ServerName/ShareName /mnt -ouser=administrator
Will prompt you for administrator's password. The password won't be shown on the screen.