Every year, Linux journalists and fans will discuss whether the next year will be the year of "Linux Desktop. Although it is easier to purchase a new machine that is running Linux or migrate an existing Windows system to Linux, however, simply installing and starting Linux is not enough to build it into a daily operating system. You may have started using Linux on the desktop, but the environment for using the new Linux system may be less modern. Most enterprises, small and medium enterprises, and small office/home office environments have Windows-related requirements that must be considered. You may also need to use hardware that can only be effectively supported on Windows for Linux. Fortunately, there are various solutions to these problems.
Access a shared Windows File System
Accessing a shared Windows File System may be the most common business requirement of Linux users. Many enterprises are still using Windows as the core of their infrastructure to support enterprise mail and calendar systems (such as Microsoft Exchange Server) and exported file systems (generally known as Windows sharing) to support simple file and data sharing.
Linux provides multiple methods to access Windows sharing. The specific mechanism depends on the frequency of data access to Windows sharing, and whether the Linxu system you configured is an individual, single-user system, or shared by multiple users.
Access Windows sharing from the command line
Samba Project is an open-source Project that supports interoperability between Linux, UNIX, and other UNIX-like operating systems and Windows. Most of the repositories of Linux releases contain Samba, which is installed and configured to support Linux systems to join an existing Windows Working Group or domain and interoperate with it, it is often used as a Common Internet File System (CIFS) File server for Windows systems. Samba 4.x installation also allows the Samba server to act as an Active Directory Domain Service controller and an integrated Domain Name System for Windows domains ).
Although the Samba server provides an excellent mechanism to provide Linux resources from a Windows system so that the Linux system can be printed to a Windows Printer, if you are only interested in occasionally retrieving files from WIndows sharing, installing and configuring the Samba server may be minor. The Samba client package contains multiple utilities designed for such occasional interactions, including the smbclient application, which provides an interactive CLI) to remotely access Windows sharing.
If you are not sure about the share name provided on the remote Windows server, you can use the smbclient application to query a server, enter the-L option after the server name or IP address to list the available resources on the server, as shown in Listing 1.
Listing 1. Using smbclient to list Windows Server resources
- $ Smbclient-L win2008server
- Enter wh_'s password:
- Domain = [WORDSMITHS]
- OS = [Windows (R) Small Business Server 2008 6001 Service Pack 1]
- Server = [Windows (R) Small Business Server 2008 6.0]
- Sharename Type Comment
- --------------------
- Address Disk "Access to address objects"
- ADMIN $ Disk Remote Admin
- Brother HL-2070N Printer Brother HL-2070N
- C $ Disk Default share
- ExchangeOAB Disk OAB Distribution share
- IPC $ IPC Remote IPC
- NETLOGON Disk Logon server share
- Print $ Disk Printer Drivers
- Public Disk
- RedirectedFolders Disk
- Resources $ Disk "Event logging files"
- SYSVOL Disk Logon server share
- [...]
As shown above, the smbclient application uses the current Linux user as the user to be verified on a remote Windows Server, and prompts the user to enter a password to access the remote server. If the login name on the Windows Server is different, you can use the-U option to specify the login name to use.
After determining the name of the share you want to connect to, you can use the smbclient application to connect to a specific share to check or retrieve files, as shown in Listing 2.
Listing 2. Using smbclient to retrieve files from Windows sharing
- $ Smbclient // win2008server/Public
- Enter wh_'s password:
- Domain = [WORDSMITHS]
- OS = [Windows (R) Small Business Server 2008 6001 Service Pack 1]
- Server = [Windows (R) Small Business Server 2008 6.0]
- Smb: \> cd Software \ Linux
- Smb: \ Software \ Linux \> ls
- . D 0 Sun Jan 27 23:40:42 2013
- .. D 0 Sun Jan 27 23:40:42 2013
- Acl82express-linux-x86.bz2 A 44960643 Sun Jan 27 23:40:24 2013
- Alien_8.87.tar.gz A 64336 Sun Jan 27 23:39:24 2013
- Crossover-12.1.0-1.i386.rpm A 47233108 Sun Jan 27 23:39:14 2013
- [...]
- 59997 blocks of size 1048576. 32474 blocks available
- Smb: \ Software \ Linux \> get softmaker-office-2012-674.x86_64.rpm
- Getting file \ Software \ Linux \ softmaker-office-2012-674.x86_64.rpm \
- Of size 147058656 as softmaker-office-2012-674.x86_64.rpm \
- (16345.5 KiloBytes/sec) (average 16345.5 KiloBytes/sec)
- Smb: \ Software \ Linux \> quit
The example in Listing 2 shows that smbclient provides a CLI to connect to the remote server. This interface supports familiar Linux commands, such as cd (used to move the content in the directory on the remote server) and ls (used to list the content of the given directory ). After finding the desired file, you can use the get command to retrieve the file and store it in the directory where you want to execute smbclient. To store the retrieved files in another directory, you can use the LCD (local directory change) command to change smbclient as the directory of the current directory.
If you only need to occasionally access one or more files in Windows sharing, and do not care about using the File Manager (such as Gigolo, GNOME Nautilus, KDE doldolphin, Konqueror or Thunar) to browse Windows sharing in a graphical way, you can safely use the smbclient application. The smbclient application enables Remote sharing to be used in the context of the application, rather than in your entire system. To browse Windows sharing and provide it to the application you selected, you must mount the sharing to your system in the same way as mounting the local file system.