LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to access Windows's share in Linux terminal command? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-access-windowss-share-in-linux-terminal-command-4175456088/)

pph765 03-29-2013 08:25 PM

How to access Windows's share in Linux terminal command?
 
Hi experts,
How to access Windows's share in Linux terminal command?

I am using LinuxMint 14, Mate. I can access MS Windows shares through GUI, but I can't access Win share in terminal. People told me I need mount the shares.I tried many ways but all end up failed to access the windows share.

Can anybody help me?

frankbell 03-29-2013 08:43 PM

I just did it in this fashion:

I su'ed to root, then determined the identity of the Windows driver with fdisk -l (sda1 and sda2). Then, still as root, I created a mountpoint in /mnt, and mounted the drive as follows (unless otherwise specified in fstab, only root can mount a drive; typically, removable devices can usually be mounted by the logged-in user who connects them):

Code:

NarwhalLX frankbell # mkdir /mnt/sda2
NarwhalLX frankbell # mount /dev/sda2 /mnt/sda2
NarwhalLX frankbell # ls /mnt/sda2
aaw7boot.log            Intel                $Recycle.Bin
$AVG                    mfg                  RHDSetup.log
Books                  msdia80.dll          RRbackups
Boot                    pagefile.sys        swshare
bootmgr                PerfLogs            SWTOOLS
BOOTSECT.BAK            PMAIL                System Volume Information
Config.Msi              ProgramData          Users
Documents and Settings  Program Files        Windows
hiberfil.sys            Program Files (x86)

You can learn more about fstab (file system table) here.

suicidaleggroll 03-29-2013 09:01 PM

frankbell - That process is for mounting a local drive of any format (ext, windows, etc). That's not what the OP is asking for. He's asking how to mount a shared Windows drive over the network.

OP - You should use cifs to mount a networked Windows share, see below.

I maintain a Windows/Linux shared network that uses a setup like this, so my config might be helpful to you. I have a WinXP machine located at 192.168.1.118 sharing a folder called "shared" on the network. The Linux machines (all of them, from CentOS to Fedora to OpenSUSE) have the following in /etc/fstab:
Code:

//192.168.1.118/shared  /home/shared            cifs    auto,_netdev,gid=source,file_mode=0664,dir_mode=0775,iocharset=iso8859-5,credentials=/etc/sambapasswords    0 0
/home/shared is obviously the location where the shared drive is being mounted on the Linux boxes (which must be created before trying to mount there), "source" is a generic group that all developers on the network are members of, and /etc/sambapasswords is a simple ascii file containing the authentication information for the mount, of the format:
Code:

username = <user>
password = <pass>

Of course replacing <user> and <pass> with the username and password you want to use for authentication.

frankbell 03-29-2013 09:50 PM

Oops. Thanks for catching my mistake.

pph765 03-30-2013 12:30 AM

Thanks. But I can not locate "/etc/sambapasswords"
 
Thank you very much. It sounds OK. But I can not locate the file "/etc/sambapasswords" (I did "sudo smbpasswd -a <myself>")

I'm running LinuxMint 14 & LMDE 201303 Desktop (Debian Edition, Mint, KDE)

Another Question: Can I replace the IP address (192.168.1.xx) with the windows system name <\\system12> ? Cause IP address assigned by the router, not necessary constant.

jschiwal 03-30-2013 01:31 AM

The name and location of the credentials file is arbitrary. It should be accessible only by the user who should know the username & password. I use $HOME/.credentials. You create this file yourself. The reason being is that credentials in the fstab file would be readable by everyone. So the fstab file only contains the location of the file containing the creds. It's up to you to use permissions that maintain the secrecy of the credentials.

suicidaleggroll 03-30-2013 02:35 PM

Quote:

Originally Posted by pph765 (Post 4921435)
Another Question: Can I replace the IP address (192.168.1.xx) with the windows system name <\\system12> ? Cause IP address assigned by the router, not necessary constant.

The Windows machine should have a static IP.


All times are GMT -5. The time now is 09:36 AM.