Access Folder and File Sharing from Linux via Command Line

Posted on

There is a way in Linux operating system distribution and any variant relates to it to be able to access folder and file sharing. Either it is folder and file sharing defined in Linux using samba and even in Windows which is configured through Folder and File sharing mechanism.

Just with a simply command executed in the command line via bash prompt, the activity of accessing folder and file sharing can be accomplished.

First of all, the important thing to do is installing samba-client. Please refer to this article titled ‘Install Samba Client‘.

After Samba Client package has successfully installed, execute the following command to connect

This is how to connect to Windows File and Folder Sharing from Linux operating system distribution variant. The command is executed in command line via bash prompt.

[user@hostname]# smbclient //xxx.xxx.xxx.xxx/sharing -U Administrator
Enter Administrator's password:
Domain=[WORKGROUP] OS=[Windows Server 2003 3790 Service Pack 2] Server=[Windows Server 2003 5.2]
smb: \>

Description : 

smbclient : It is a tool which exist as the installation of samba client package successfully done. In the context of this article, it is used to connect to folder and file sharing. 
//xxx.xxx.xxx.xxx/sharing : It is the URL address of folder and file sharing which is going the accessed and connected
-U : It is an option command of smbclient used to specify user which is going to be used to connect and access folder and file sharing specified
Administrator : It is the name of the user which is going to be used to connect and access folder and file sharing. 

The above actually not only just a pattern, but based on the output of the command executed, the connection to the folder and file sharing has already succeed. It is shown from the samba command console displayed in the output, which is ‘smb: \>’.

To be able to use all the available command exist in samba command console, just type help in the samba command console :

smb: \> help
?              allinfo        altname        archive        backup
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             ln
mask           md             mget           mkdir          more
mput           newer          notify         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        timeout        translate      unlock
volume         vuid           wdel           logon          listconnect
showconnect    tcon           tdis           tid            logoff
..             !
smb: \>

From the available command exist that can be used in samba command console, below is an example of the command which can be used, for an example ‘dir’ for displaying the content of the currently working folder in folder and file sharing :

smb: \> dir
.                             D        0  Wed Dec  3 06:57:25 2014
..                            D        0  Wed Dec  3 06:57:25 2014
xxxxx.sql                     A  3565214  Mon Oct 13 10:40:15 2014
xxx-xxxx-xxxx.xxxx.exe        A  9216702  Fri Dec 27 18:12:30 2013
xxxxxxxx                      D        0  Thu Oct  9 08:48:04 2014
xxxxxx-xxxx                   D        0  Thu Oct  9 08:57:04 2014
xxxxxxx.war                   A 25071621  Mon Jan 20 16:16:03 2014
xxxx_xxxxx_xxxx_xxx_xx_x      D        0  Wed Dec  3 06:57:00 2014
xxxxxx-xxx                    D        0  Mon Oct 13 08:46:45 2014
xxxxx-xxxx                    D        0  Mon Dec 30 11:40:56 2013
xxxxxx-xxxxx.jasper           A    65834  Thu Jan  9 16:44:18 2014
xxxxxx-xxxxx.jrxml            A    19256  Thu Jan  9 16:44:13 2014
xxxxxxxxx_xxxx_xxx_xxx.exe    A 50449456  Mon Dec 23 21:46:30 2013
xxxxxx                        D        0  Tue Dec 31 16:13:50 2013
xxxxxxxx                      A      381  Mon Dec 30 20:54:39 2013
xxx-xxxx-xxxxxx-xxxx.exe      A 29040552  Mon Dec 30 18:39:38 2013
xxxx.php                      A     6198  Tue Mar  4 13:36:58 2014
xxxxxxxx xxx xxxxxx xxxx xx   D        0  Fri Dec 27 16:25:53 2013
xxxxxxx                       D        0  Mon Dec 30 11:39:56 2013
xxxxxx-xxxx                   D        0  Mon Dec 30 11:52:48 2013
xxxxxxx-xxxx-xx-xx            D        0  Thu Oct  9 08:58:57 2014
xxxxxx-xxxxxx                 A 52897280  Thu Oct  9 08:53:21 2014
xxxxxx.trn                    A 105794048  Fri Apr 11 15:16:56 2014
xx. xxxxxx xxxx-xxxxxxx       D        0  Mon Sep 30 16:19:56 2013
xxxxxxx.php                   A    43262  Sun Jan 19 15:10:01 2014
xxxxx_xxx_xxx.php             A     3927  Fri Jan 10 15:02:38 2014
xxxxx_xxxxx.php               A     6068  Sun Jan 19 16:19:36 2014
xxxxx_xxxxxx.php              A     1839  Sun Jan 19 14:49:44 2014
xxxxxx                        D        0  Fri Dec 27 18:51:56 2013
xxx_xxxx_xxxxx_xxxxxx.php     A     1369  Sun Jan 19 21:51:58 2014
xxxxxxx                       A 87315968  Thu Jan  9 06:51:34 2014
xxxxxxxxxx-xxxxxx             A 174630400  Thu Oct  9 08:53:43 2014
xxxxxxxxx.mdf                 A 87031808  Fri Mar 28 17:15:33 2014
xxxxxxxxxxxx.trn              A 87315968  Fri Apr 11 15:17:48 2014
xxxxxxxxxxx_log.ldf           A 529596416  Fri Mar 28 17:15:33 2014
xxxxxxxxxx                    A 113559040  Wed Jan  8 06:40:02 2014
xxxxxxxxx-xxxxxx              A 227116544  Thu Oct  9 08:53:58 2014
xxxxxxxxx.mdf                 A 113246208  Fri Mar 28 17:15:33 2014
xxxxxxxxxxx.trn               A 113559040  Fri Apr 11 15:18:27 2014
xxxxxxxxxxx_xxx.ldf           A 853016576  Fri Mar 28 17:15:33 2014
xxxxxxxxx                     A 107267584  Wed Jan  8 12:35:45 2014
xxxxxxxxxxxx-xxxxxx           A 214533632  Thu Oct  9 08:54:11 2014
xxxxxxxxxxxx.mdf              A 106954752  Fri Mar 28 17:15:32 2014
xxxxxxxxx.trn                 A 110413312  Mon Apr 21 15:42:08 2014
xxxxxxxxxx_log.ldf            A 853016576  Fri Mar 28 17:15:32 2014
xxx_xxx_xxx.exe               A  1911592  Fri Dec 27 23:59:19 2013
xxx_xxxx_xxx.exe              A  1227048  Mon Dec 23 21:02:29 2013
xxx-xxxx-xxxxx-x.x.x-x-xxxx   D        0  Fri Dec 27 17:49:40 2013
xxx-xxxx-xxx-x.x.x-x-xxx.zip  A 133210687  Sat Dec 28 00:19:49 2013
xxx-xxx-x.x.x-xx-xx.exe       A 95614089  Mon Dec 30 18:10:06 2013
xxx-xxx-x.x.x-x-xx-xx.exe     A 123794144  Mon Dec 30 17:54:05 2013
[xx.xx]xxxxxx(1)              D        0  Fri Dec 27 16:38:28 2013
[xx.xx]xxxxxx(1).rar          A 69320844  Mon Dec 23 20:25:32 2013

26212047 blocks of size 4096. 19988420 blocks available
smb: \>

Another command which can be used in the samba command console is ‘pwd’. And it is used to display the full path of current working folder of folder and file sharing.

smb: \> pwd 
Current directory is \\xxx.xxx.xxx.xxx\sharing\
smb: \>

The next command which can be used is ‘quit’ :

smb: \> quit

Other commands can also be used depend on the situation and the purpose.

2 thoughts on “Access Folder and File Sharing from Linux via Command Line

Leave a Reply