University of Oregon

Personal tools

Working With CIFS Shares

The UO's College of Arts and Sciences Information Technology (CASIT) section offers space for general purpose storage. The means of connecting to this storage is with the CIFS protocol, aka Windows networking. Most are aware of how to do this in Windows and OS X, but knowing how to connect from Linux, the file server Bordeaux, for instance, is less common.

You may want to connect from our file server to these shares to back up your data. For ad hoc connections, an expedient way is to use Samba's smbclient. This program has many options, most of which are not needed for typical purposes on the UO network. Typical usage will specify the workgroup/domain in which your account resides, usually AD, and the server and share you want to attach to. If your AD user name differs from your Center user name (in most cases, it will not), you can specify the user name as well.

smbclient -W AD -U chuckt //cas-fs2/psychology

 The above illustrates how to connect to the "psychology" share on cas-fs2. Running the command will give you a prompt similar to a command-line sftp program:

chuck@bordeaux:~$ smbclient -W AD -U chuckt //cas-fs2/psychology
Enter chuckt's password:
Domain=[AD] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \>

Type "help" for a list of commands available in this interface:

smb: \> help
? allinfo altname archive blocksize
cancel case_sensitive cd chmod chown
close del dir du echo
exit get getfacl geteas hardlink
help history iosize lcd link
lock lowercase ls l mask
md mget mkdir more mput
newer open posix posix_encrypt posix_open
posix_mkdir posix_rmdir posix_unlink print prompt
put pwd q queue quit
readlink rd recurse reget rename
reput rm rmdir showacls setea
setmode stat symlink tar tarmode
translate unlock volume vuid wdel
logon listconnect showconnect .. !
smb: \>

Commands that may be most useful include put, mput, get and mget. These put and get files and directories. By default mput and mget work only on files, but by using recurse, which toggles recursive mode, you can work with directory trees. In doing so, you will likely want to turn off the prompt at each file. This is done with the prompt command.

The ! modifier is also useful in that it runs the given command locally rather than remotely. This permits you to, for example, see the contents of your local current working directory.

smb: \LCNI\Desktop\> !dir sge*
smb: \LCNI\Desktop\> dir sge*
NT_STATUS_NO_SUCH_FILE listing \LCNI\Desktop\sge*
smb: \LCNI\Desktop\> dir
. D 0 Wed Aug 19 16:36:12 2015
.. DA 0 Wed Aug 19 16:36:12 201565535 blocks of size 16777216. 65535 blocks available
smb: \LCNI\Desktop\>


The smbclient is useful for managing files and folders, but it does not permit other programs to use these files on remote shares. For a persistent connection like those you can establish with Finder or Windows Explorer, you need to be able to mount remote CIFS shares to a local mount point. For this, you can use the mount.cifs command. As this is a protected command, your account will need to have the associated sudo privileges. Contact LCNI

The mount.cifs command takes as arguments the share that you are mounting, the local mount point to which the share is to be connected, and any options. These options include the ability to supply a user name and password using a credentials file. Putting DuckID credentials in this file permits concealing passwords while allowing mounting of a CIFS share. The example below mounts the psychology share from the cas-fs2 server to a local cas-fs2 directory (mount point).

sudo /sbin/mount.cifs //cas-fs2/psychology ~/cas-fs2/ -o credentials=~/.cifs,uid=<LCNI account>,gid=<LCNI group>

Note the use of the sudo command. Inclusion in the sudo list will allow your account to run the mount.cifs command. Also, the example above uses the ~ to indicate the home directory, so both the cas-fs2 mount point and the .cifs credentials file are directly under the home directory. The uid= and gid= options specify the LCNI account and group with which to mount the share.

The credentials file is a simple text file that should be protected from reading by anyone except the owner. You can set the permissions appropriately by using the chmod command (chmod 0400 ~/.cifs) The format of the file is as follows:


In most cases, the value of domain will be "AD", the University's main domain.