2/15/2010

Networking Ubuntu 9.10 and Windows XP

This article explains how to share files and folders between your Ubuntu 9.10 computer and your Windows XP computer through your wired, ethernet home network. For background information and additional details, see Mount samba shares with utf8 encoding using cifs. Though this background information focuses on servers, it also applies to workstation computers. Therefore, procedures and examples in the article below focus on networking Ubuntu 9.10 and Windows XP computers.

To network Ubuntu 9.10 with Windows XP, you need to perform two procedures:
  1. On your XP computer, use the Set Up Sharing on Windows XP procedure below to share your XP Shared Documents folder with all network users.
  2. On your Ubuntu computer, use the Set Up Sharing on Ubuntu procedure below to create a share point, which is a desktop icon through which you have read and write access to the Shared Documents folder on your XP computer.
Set Up Sharing on Windows XP
To set up Windows XP to share documents with Ubuntu through your wired, ethernet home network, do the following:
  1. On your Windows XP computer, click My Computer to display its window.
  2. Right-click Shared Documents, click Properties to display its window, and then click Sharing to display its page.
  3. In the "Network sharing and security" frame:
    1. Select Share this folder on the network.
    2. Write down the Share name, which is "SharedDocs" in this example. You will need the Share name when you perform the Set Up Sharing on Ubuntu procedure below.
    3. Select Allow network users to change my files.
  4. Click Apply to set folder permissions, and then click OK to close the window.
  5. Click Start, click Settings, and then click Control Panel to display it.
  6. Double-click System to display its window, and then click Computer Name to display its page.
  7. Write down the contents of the Full-computer-name field, which is "alpha" in this example. You will need the Full computer name when you perform the Set Up Sharing on Ubuntu procedure below.
Set Up Sharing on Ubuntu
To set up Ubuntu to share documents with Windows XP through your home network, do the following:
  1. On your Ubuntu computer, click Applications, select Accessories, click Terminal to display its window, and then do the following:
    1. Type sudo aptitude install smbfs, press Enter, type your password, press Enter again, follow the prompts, and then to install the smbfs packages, which you need for sharing files on the network.
    2. Type sudo mkdir /media/ubuntusharename, and then press Enter to name the share icon that will be on the Ubuntu desktop. Use a meaningful name for the ubuntusharename. This example uses "betashare" because the Ubuntu computer name is beta.
    3. Type sudo nano /etc/nsswitch.conf, and then press Enter to display the nsswitch configuration file through the nano editor.
    4. On the Hosts line, use the arrow keys to move your cursor to the "d" in dns on the hosts line, type wins and a space immediately before dns so that the hosts line is
      hosts: files mdns4_minimal [NOTFOUND=return] wins dns mdns4.
    5. Press Ctrl+X, type y, and then press Enter to save your edits and close the nano editor.
    6. Type sudo aptitude install winbind, and then press Enter to install windbind.
  2. Close the terminal window, and then turn off your Ubuntu computer completely.
  3. Turn your Ubuntu computer back on, click Applications, select Accessories, click Terminal to display its window, and then do the following:
    1. Type sudo cp /etc/fstab /etc/fstab_old, and then press Enter to back up your fstab file. Do not skip this step because fstab is an important system file. In case you need to recover fstab, use the following command: sudo mv /etc/fstab_old /etc/fstab.
    2. Type sudo nano /root/.smbcredentials, and then press Enter to display your credentials file, which might be empty.
    3. Add two lines to your credentials file:
      username=winusername
      password=winpassword
      Replace winusername with your user name on your Windows XP computer. Replace winpassword with your Windows XP password.
    4. Press Ctrl+X, type y, and then press Enter to save your edits and close the nano editor.
    5. Type sudo chmod 700 /root/.smbcredentials, and then press Enter so that only root can access your credentials file.
    6. Type sudo nano /etc/fstab, and then press Enter to display your fstab file. At the bottom of the file, add the following line:
      //wincomputername/winsharename /media/ubuntusharename cifs guest,rw,iocharset=utf8,file_mode=0777 0 0
      Replace wincomputername with your Windows XP Full computer name, which is "alpha" in the Set Up Sharing on Windows XP procedure above. Replace winsharename with your Windows XP Share name, which is "SharedDocs" in the Set Up Sharing on Windows XP procedure above. Replace ubuntusharename with your Ubuntu share name, which is "betashare" in this example. Therefore, this line on the example Ubuntu computer is:
      //alpha/SharedDocs /media/betashare cifs guest,rw,iocharset=utf8,file_mode=0777 0 0
    7. Press Ctrl+X, type y, and then press Enter to save your edits and close the nano editor.
    8. Type sudo mount -a, and then press Enter to display your Ubuntu-share icon on your Ubuntu desktop.
  4. Close the terminal window, and then double-click your Ubuntu-share icon to open it. It should contain the same folders and files as the Shared Documents folder on your Windows XP computer.