Windows NT/2K/XP Shares
CONVENTIONS USED

This is one of the more advanced tutorials on this website. As such, there may be parts in it that may confuse newbies, so please, proceed only if you are reasonably familiar with Linux. If there are any glaring errors, please email me.

First of all, you need to know the NetBIOS name of Windows machine you want to connect to, which version of Windows it is running, and, if it is NT/2000/XP, then you also need to have the username and password for a valid user on that machine. If it is Windows 9X, this is not covered in this tutorial. You will also need Samba installed, as it is what communicates with Windows servers.

If you know this, then you can proceed.

Go to a console. You need to create a directory that we will mount the Windows share to. Basically this will be an empty directory that once we are finished will appear to contain the contents of the remote share that you are connecting to. I connect to a computer running Windows 2000 Server (called server2) with a shared directory called files. I have to use a user account on the 2000 machine, so I will use the administrator account.

I mounted the files share to a directory called sharedfiles in my home directory. For purposes of this tutorial, we will do the same.

At the console prompt change to your home directory (if you are not already there). To do this, type in cd and hit Enter.

Now type in mkdir sharedfiles. This creates a new directory called files which we will use as a mount point for the Windows share.

Next, type in something to this effect:
smbmount //server2/files /home/scott/sharedfiles -o username=administrator,password=secret
This is all one line with a space between the "-o" and "username" (and that is the letter "o", not a zero. Substitute "server2" for the name of the machine you are connecting to. Substitute "files" for the name of the share that you are mounting. Substitute "scott" for your Linux user name. Substitute "administrator" for your user account on the Windows server. And finally, change "secret" to be your password for your user account on the Windows server.

If you get this error:

21423: session setup failed: ERRDOS - ERRnoaccess (Access denied.)

then you have a problem with your Windows account name or password that you are using. Double-check to ensure you entered it correctly.

If the command works properly then it should return to the command prompt without a message.

Now type in cd sharedfiles and hit Enter.

If you now type in ls, you should see the files on the remote share. If so, congratulations! You have done it successfully.

However, if you reboot, this will be all be undone and your ~/sharedfiles/ directory will be empty. In order for this share to be reconnected each time you start your linux box you need to have this command run each time automatically. The place you put commands like that is at the end of your /etc/rc.d/rc.local file.

First you need to find out what your user ID (UID) and your group ID (GID) is. You can find out this information using the id command.

On my system, my UID and GID are both 501. Yours may differ, so substitute your own values in where appropriate in the rest of this tutorial.

Next, in the console, type in su and hit Enter. Type in the root password when prompted.

We need to be root because as a normal user, we probably do not have rights to edit the rc.local file, which is a good thing for security. Note that a bad thing for security is that any normal user can read this file, which means that they can find your password and account information easily. A future version of this tutorial will have a different, more secure method for the next bit.

You will need to edit this file using your favorite text editor. If you like using GUI tools, then simply type in kate /etc/rc.d/rc.local. You can use whatever editor you want for this, including gedit, nedit, vi, pico, nano, or whatever. Kate comes with KDE, and is a good choice.

Scoll to the bottom of this file and add the following line:

smbmount //server2/files /home/scott/sharedfiles -o username=administrator,password=secret,uid=501,gid=501

Don't forget to replace the portions of that command as you did earlier, and substitute in your own UID and GID where appropriate.

The reason for the UID and GID is that this command will run under the user root, and as thus it will mount in such a way as to not have write access for you the lowly user. So we add the UID and GID to the end of the command and it makes your user the owner of the shared directory instead of root. Forgetting the UID and GID is a common error and causes a lot of "I can't write to my Windows share" type problems amongst newbies.

You should save the file at this point and try restarting your computer. If you did it correctly, it will mount your share automagically.


© D. Olson 2001-2003 -- Originally found on The Mandrake eXPerience