Rob DiNardo - Web Development Tips

Home › Blogs › Rob's blog

How To Mount A Network Share In Linux

Rob — October 13, 2013 - 14:04

I have an external drive connected to my router's USB port that I use a store center. And when I log into my linux (Xubuntu) box, I am able to open Thunar (the default file browser) and click the Browse Network location under the NETWORK column heading in the left navigation pane.

Thunar Looking At Network Shares

After that, I can see the name of the drive that I set in the router settings. Using Thunar file explorer, I can drill down into the folder structure. If any folder is restricted, I am greeted with a login modal box to enter my username and password..

Network Password Modal

Navigating all the folders in your share using the GUI file browser will work for many applications like file copying, renaming, etc. But if you wish to do more tasks like add the .jpg extension to all files in the folder, you will need to mount the share folder first.

The first step to mount a network share is to list all available shares on in your internal network. Running one of the following command should list the shares available.

smbclient -I 192.168.1.1 -L //

smbclient -I 192.168.1.1 -L //sharename/

smbclient -I 192.168.1.1 -U Rob -L //sharename/

To mount the drive, you should first make a directory in the /mnt folder..

mkdir /mnt/myfolder

Then, to mount the network share to that folder, use one of the following commands (replace <USERNAME> and <PASSWORD> with proper credentials)..

mount -t cifs //192.168.1.1/ShareName /mnt/myfolder -o "username=<USERNAME>,password=<PASSWORD>"

mount -t smbfs //192.168.1.1/ShareName /mnt/myfolder -o "username=<USERNAME>,password=<PASSWORD>"

At this point, you can do things like add jpg to all files in a directory within the mounted folder..

find /mnt/myfolder/Phone-Pix/ -type f -not -name "*.*" -exec mv "{}" "{}".jpg \;

  • Linux
  • Mount
  • Network
  • Script
  • Rob's blog
  • Login to post comments

User login

  • Request new password

Code

  • WordPress Plugins