Linux vs Windows

Are you a Linux diehard but want to access windows share without switching operating systems? This guide is definitely your call. Accessing Windows Share from Linux has never been a difficult task, all thanks to these two widely used ways. The first method is using mount command. The second way is by use of Graphic User interface tools, where this can also be substituted with the smbclient command.

RECOMMENDED: An Easy Way to View and Share Stuff in a Network

Using Mount Command

This is one of the easiest ways to exchange data between Linux and Windows systems. If you would like to access Windows share called //windowsserver/sharename by mounting to /mnt/win directory in Linux, all you have to do is key in the following command. Replace the windows server name, share name, your username and password with actual values.

# mkdir -p /mnt/win

# mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win

# cd /mnt/win

# ls–l

  • To enable the share //windowsserver/sharename to automatically mount every time you boot your system, insert the code below in the /etc/fstab file:

# vi /etc/fstab

  • Next is to create a password file /etc/sambapasswords:

# vi /etc/sambapasswords

  • Add the following after creating the password file:

username = winntuser

password = mypassword

  • Save your work and close the file. It is important to ensure that only root has access to your file:

# chown 0.0 /etc/sambapasswords

# chmod 600 /etc/sambapasswords

Using smb Client

Another popular way to access Windows share from Linux is by use of Samba Client. From the command line, manually configuration is not quite difficult. The samba client is similar to a normal ftp connection, where once mounted, it acts like a normal hard drive.

RECOMMENDED: Best Methods to Share Files Between Nearby Computers

To connect to a samba file server directly from you command line, follow these steps:

  1. First list all the public SMB shares by keying in the following command:

smbclient -L //server -U user

  1. Connect to a SMB share by typing this command:

smbclient //server/share -U user

  1. You are prompted for your user password, enter it in the field provided.

If you want to connect directly instead, on your command line key in:

smbclient //server/share -U user% password

With this method to access windows share from Linux however, your password will be visible on the screen, which I bet we all agree is less secure. Once you are connected, the following prompt appears:

smb: \> . To get a list of available commands, type help at the command line to get a list of available commands.

RECOMMENDED: Networking Sharing for Beginners


Leave a Reply