Welcome!

Linux Containers Authors: Elizabeth White, Yeshim Deniz, Pat Romanski, Liz McMillan, Zakia Bouachraoui

Related Topics: Linux Containers

Linux Containers: Article

Linux on a corporate desktop Part 2: File sharing with Samba

How to install, configure, and use Samba.

(LinuxWorld) -- An hour before I deleted Windows 98 from my computer at work, I asked a colleague if she would oblige me to store some MP3s on her computer. I explained I was messing around with my computer, and wanted to store some songs in a safe spot. She said yes. (Thank you, Jen.) I navigated to her machine on the network, and dropped several gigabytes of music into her shared directory. As I completed this task, I noted how user-friendly Microsoft, and Apple for that matter, make local area networking.

Since my Linux workstation needed to converse with my coworker's Windows 9x computers on Microsoft's terms, I had some work to do. (See How to get Linux on your corporate desktop, Part 1 for the backstory on this saga.) If I could configure my Linux box to browse the network with the same ease that Windows and Macintosh users do, so much the better. Luckily, found two little applications that help us set up and take advantage of the monster called Samba, and allow us to poke around a local Windows domain and mount shared files. While it may seem frivilous to set up Windows-Linux filesharing to retrieve music, this exercise illustrates how easy it is to slip a Linux computer into a corporate network.

The first step is finding the Samba suite. Luckily, I use Slackware 8.0, which comes stock with Samba running like an Olympic track and field star. Most recent Linux distributions come with Samba. If your version does not, open a browser, navigate to www.google.com/linux and type "Samba" into the search query field. Freshmeat or Tucows will be near the top of the results. Kick around until you find the most recent version of Samba. As of this writing, the latest version is 2.2.3a. Download the tarball and save it to your home directory. That's right, I said tarball. Tar.gz. Definitely not the RPM. We're using source. We want to walk before we run.

"Okay," you say. "I've downloaded this file. What the heck do I do with it?"

"You compile and install it, silly."

Here's how:

  1. Open a terminal on your Linux machine.
  2. I prefer the gnome-terminal. Open your terminal, and navigate to the directory that contains the samba-2.2.3a.tar.gz file. This file is compressed. We need to de-compress it.

  3. Uncompress the tarball
  4. 2. Type gunzip samba-2.2.3a.tar.gz Don't expect any text output, because you aren't going to get any. This will replace the original file with a file called samba-2.2.3a.tar

  5. Un-tar the file
  6. Type: tar -xvf samba-2.2.3a.tar This will "un-pack" the archive, resulting in a new directory called samba-2.2.3a. Those switches we placed after the tar command, you know, the -xvf? The x means the program tar is going to eXtract the files from the archive. The v means tar is going to be Verbose about what it is doing to the archive. Simply put, you are going to see a bunch of lines scrolling down your terminal. These lines display all the files being extracted from the archive, and the path they are being extracted to. The f switch is weird. I am a bit unclear on what the f switch does. The tar man page tells me that it selects the device ARCHIVE, but that is all it says. This is a bit confusing. I use the f switch because that is how I learned to use tar. If you know what it does e-mail me with the answer.

    Now you can delete the .tar file, or save it in whichever directory you like to save .tar files.

    We have source code!

  7. Get where you need to go
  8. Change directories into the samba-2.2.3a directory. Type ls to view the contents of this directory.

    This is going to be fun.

    The very first action that should be performed when you get to this point with ANY source code is to read the README file. I like to use pico to read text files. You may prefer vi, jstar, or emacs. Pico is super quick and easy. Type pico README to read the README file. Read this file in its entirety.

    Since you learned so much reading the README documentation, you may be capable of completing the Samba install on your own. If this is the case, get on yer horse and start riding, although I welcome you to read along with the rest of us and walk through the process together.

  9. Change to the source directory
  10. This directory contains the Makefile. This directory also contains a script called configure.

  11. Run the configure script
  12. Type: ./configure This script checks your system for dependencies to make sure everything will compile correctly. This script takes a bit of time to complete. Be patient. When the configure script completes, it will return you to the command prompt.

  13. Compile!
  14. Type: make This command compiles all code and readies the Samba suite for final installation. make takes even longer than configure.

  15. Become root
  16. Type su, press ENTER, and enter the root password followed by a second ENTER. If you don't know, we just changed our user-status to root. We can now perform any action the root account has permissions to perform.

  17. Installation time
  18. It's time to install Samba. Type make install, sit back, and watch the final bit of output produced during the Samba install. This output is showing you where all the binary files, libs, man files, and other files are being placed throughout your file system.

  19. Link the libraries
  20. After make install, I like to enter the ldconfig command. Go ahead. Then type exit to return to your normal user account. That ldconfig command links the newly installed application to all of the correct lib files required to use said application.

  21. Smile
  22. Pat yourself on the back -- you just installed Samba from source.

    Samba configuration

    Before I can get my MP3s back and screamin' in my ears, I need to edit the smb.conf file. The smb.conf file is located in one of two places: the /etc directory, or the /etc/samba directory. I tend to place it in both directories. If something happens to one, I have a back-up in the bullpen.

    The smb.conf file is set up the same way as most config files. There are variables, and there are values. If the variable was IP ADDRESS the value would be YOUR.I.P.ADDRESS

    example:

    IP ADDRESS="YOUR.I.P.ADDRESS"

    Edit the file, go down through each variable, and enter the correct values for your specific network situation. I encourage you to manually edit this file and learn smb.conf's details.

    I have edited the smb.conf so many darned times -- I hate editing it -- I found a quick solution to this problem.

    GnoSamba configuration

    GnoSamba is a graphical interface for editing the smb.conf file. Search Freshmeat.com for gnosamba. Download the tarball. Compile and install the source:

    gunzip gnosamba-version.tar.gz
    tar -xvf gnosamba-version.tar
    cd gnosamba-version/
    pico README
    pico INSTALL
    ./configure
    make 
    su {root password}
    make install
    ldconfig
    exit

    Following the above commands should have GnoSamba installed in a jiffy.

    Now type gnosamba at the command line. Depending on your security restrictions, you may need to run this program as the "root" user to submit changes to the smb.conf file.

    The GUI will fly onto the screen. smb.conf begs to be configured.

    Click the File menu in the top-left hand corner of the GUI, then drop down to and select Open Configuration File.

    This action loads the current settings listed in smb.conf file. Services are listed on the left, parameters and values are listed on the right. Select the "Global" service on the left. On the right, you can double-click each parameter, and enter a new value to be associated with that parameter. Go ahead and change the "Workgroup" value to match your workgroup or domain on the Windows network. Go ahead and change all the values listed in smb.conf to match your particular network environment. There are far too many values for me to go every single one of them. If you don't know what changing one of the values will do, then leave it at its default. You can go back and read the smb.conf file for a better idea of what everything does.

    GnoSamba

    Once you are done changing all of the values in the smb.conf file, go ahead and click the menu-button titled "Write". This will finalize the changes to the smb.conf file. After you are done changing the configuration file, navigate to the "File" menu and select "Exit".

    Browsing the network

    Now that we have configured smb.conf, we may browse the network. After this, those MP3s will be mine!

    We need to go to www.google.com/linux, and search for an application called LinNeighborhood. LinNeighborhood is a great Samba front end, and is akin to the LinNeighborhood network browser bundled into the different Windows operating systems. It allows you to browse the network, and mount network shares in your filesystem. Once these network shares are mounted, you can treat them like any other directory in your filesystem. If configured, you can read and write to these mounted directories.

    Download the latest LinNeighborhood tarball. As of now, the latest version I could find was 0.6.4. Once downloaded, compile and install the application. Again:

    gunzip LinNeighborhood-version.tar.gz
    tar -xvf LinNeighborhood-version.tar
    cd LinNeighborhood-version/
    pico README
    pico INSTALL
    ./configure
    make 
    su
    {root password}
    make install
    ldconfig
    exit

    We have two more things to do before we can browse the network. Slackware 8.0 by default installs a kernel with smbfs loadable as a module. This smbfs is a type of network file system, and is a loadable module. This module technology is similar to a "driver" in the Windows environment. Modules need to be activated before they are of any use. To activate the smbfs module, become "root" and modprobe smbfs:

    su
    {root password}
    modprobe smbfs
    exit

    There won't be any output when you do this, but rest assured the module was loaded. It might be a good idea to set this module to be loaded at boot time. You can do this in the /etc/rc.d/rc.local script. Become "root", type pico /etc/rc.d/rc.local, and add modprobe smbfs to the bottom of the file. Make sure there is not a "#" symbol in front of this line. ctrl-x, y, and enter will save the file.

    Last thing: We need to make sure we will have permissions to mount the share. Mounting a share means to create a directory in your local file-system, which represents a directory on a remote machine.

    You must have the correct permissions to mount a remote share on your local filesystem. smbmount is responsible for mounting remote shares. smbmount actually calls upon smbmnt to mount the share to your file system. What we need to do is make smbmnt SUID root, so it is able to do its job.

    su
    {root password}
    chmod 4755 /usr/bin/smbmnt
    exit

    That's it.

    Ready, set, browse!

    Type LinNeighborhood and press enter to initialize the application. Next, go to the "Options" menu and select "preferences". Here you can specify your workgroup, along with your user name and password information for the workgroup. Save your changes and click "okay". Now, you can again go to the "Options" menu, and select "Browse entire network". This will bring up a dialogue box that asks if you want to browse as a different user. Decide which user you'd like to browse the network as, and click okay. This will scan the network, and display all of the available computers on the network. Click the "+" symbol next to each computer to expand that particular computer's shared directories.

    When you find a directory you'd like to browse, double-click that directory. Another dialogue box will appear. This dialogue box allows you to specify where in your file system you'd like to mount this share. You are also given the option of mounting the share as a different user. Remember where the default mount-point is. Click "mount". Now you can open your favorite file manager -- Slackware 8.0 comes with nautilus -- and browse the share. Finally! There are all my MP3s. Now I just copy them to the directory of my choice. Although it seems that they are on my hard drive, they are really housed on another machine on the network.

    You should poke around the rest of the menus in LinNeighborhood. Look at some of your options. It's a great program.

    Review

    We've accomplished quite a few things today. We learned how to install the Samba suite, how to install source code, the basics of configuring Samba, and how to browse the Windows network. We also learned how to load a module, add a line to the start-up script, and set a SUID of a file to root. I hope you had fun.

More Stories By Nick Davis

Nick Davis is an IDG.net and Linux.SYS-CON.com editor.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to great conferences, helping you discover new conferences and increase your return on investment.
DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by FinTechEXPO. ICOHOLDER gives detailed information and help the community to invest in the trusty projects. Miami Blockchain Event by FinTechEXPO has opened its Call for Papers. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Miami Blockchain Event by FinTechEXPOalso offers sp...
Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. The IoT Global Network is a platform where you can connect with industry experts and network across the IoT community to build the successful IoT business of the future.
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.