Fedora Linux Support Community & Resources Center
  #1  
Old 28th January 2012, 10:29 PM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
windows_vistafirefox
SAMBA directory access in command line

I can access SAMBA shares on my LAN when I go to network connection. I mount them successfully. I can copy files back and forth from a folder on my machine to and from the SAMBA share. So far so so good.

But I have not been able to change my directory to the SAMBA share. A command like "cd smb://localshare" does not work. I also tried to mount smb://localshare in my fstab file, but it did not work either. If some sytem tools in charge of opening GUI folders for me can do that, I should be able to do that from the command line, at least as "su". I am running Fedora-11 and Fedora-16 both, and both installations have the same issue.

I must be missing some simple but key ingredient to make this work. Can you help?
Thank you.
Reply With Quote
  #2  
Old 28th January 2012, 10:38 PM
nonamedotc Offline
Community Manager
 
Join Date: Mar 2011
Location: USA
Posts: 3,803
linuxchrome
Re: SAMBA directory access in command line

in your fstab file (or sudo mount ....), use the following

Code:
mount -t cifs //server/share /mnt/share -o username=****,password=****
There might be some permissions changes needed too. Hope this helps.

Last edited by nonamedotc; 28th January 2012 at 10:38 PM. Reason: typo.
Reply With Quote
  #3  
Old 29th January 2012, 06:15 PM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
linuxfedorafirefox
Re: SAMBA directory access in command line

Thank you for the reply, but I am afraid it did not work. The message from the command "mount -t cifs ..." is:
"mount error: could not resolve address for readyshare: Name or service not known. No ip address specified and hostname not found".

On the other hand, I can open Places-->Network, and the window it opens shows 'readyshare' as one of the available servers. I can even double click 'readyshare' and open it. I see all the files in it, I can read and write. So it is clearly there but the command-line commands like "cd //readyshare" or even "cd smb://readyshare" do not work. It is mounted somewhere, but the GUI window will not tell me where that is. Under properties it is merely listed as "//readyshare". It is not even added to /etc/mtab. So it is sort-of-mounted and available, but not 'really mounted'.
Reply With Quote
  #4  
Old 29th January 2012, 07:07 PM
jswmcw Offline
Registered User
 
Join Date: Jan 2011
Location: Ohio
Posts: 45
linuxchrome
Re: SAMBA directory access in command line

I believe nautilus mounts network shares under "~/.gvfs".

---------- Post added at 02:07 PM ---------- Previous post was at 01:50 PM ----------

Also, the below command should work to manually mount the share:
Code:
mount.cifs //<server name or ip>/<share name> /<mount point> -o username=<USER>,password=<PASSWORD>,domain=<WORKGROUP>
Note: Replace fields denoted by "< >" with the proper info. (Minus the "< >").
__________________
:C
"Anybody who tells me I can't use a program because it's not open source, go suck on rms. I'm not interested. 99% of that I run tends to be open source, but that's _my_ choice, dammit." -- Linus Torvalds, 2004.
Reply With Quote
  #5  
Old 29th January 2012, 07:30 PM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,157
linuxfirefox
Re: SAMBA directory access in command line

nonamedtoc gave you the basic format for mounting the remote share, but generally a bit more setup is involved for that to work. I'll use one of mine as an example. First, you need to know the ipaddress of the remote host and, optionally, the hostname (computer name) of the remote host.

My wife has a Windows XP desktop computer with the computer name (host name) of cortana with a shared NTFS data partition with the share name of MyData. The ipaddress on the LAN for cortana is 192.168.1.2.

I create the mount point direcotry /mnt/cortana
I add a line in my /etc/hosts file: 192.168.1.2 cortana
I add a line in my /etc/fstab file: //cortana/MyData /mnt/cortana cifs uid=1000,gid=1000,noauto,sec=none 0 0

The "noauto" option in the fstab file means it will not try to automount at bootup (that computer might not be on).
Tthe "uid=1000,gid=1000" option mounts it with me (user 1000) owning the directories for full rw access.
The MyData share is set to allow "everyone", so no userID/password are required so the "sec=none" option bypasses any logon/password prompting.

Then when I want to mount that share I give the command: sudo mount /mnt/cortana or sudo mount //cortana/MyData

Without the fstab entry, I would the mount command like so: sudo mount.cifs //cortana/MyData /mmt/cortana -o uid=1000,gid=1000,sec=none

It's important that you first create the mount point directory and associate the ipaddress to the hostname in the /etc/hosts file.

Last edited by PabloTwo; 29th January 2012 at 07:43 PM.
Reply With Quote
  #6  
Old 30th January 2012, 04:12 AM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
linuxfedorafirefox
Re: SAMBA directory access in command line

Thank you jswmcw and PabloTwo for your replies. They helped, and I made progress but I am not successful yet. First of all, the directory ~/.gvfs is empty, However the other suggestions both worked up to a point (Both mount.cifs, and putting the mount point in the fstab.) In other words, the mount command succeeded. At least it did not complain or return an error code. However the directory I was mounting was still inaccessible. Because, after the mount command, the mounted directory's owner, read/write permissions everything went haywire. Before the mount command, in the /mnt directory the subdirectory u_drive was listed as follows:
"drwxr-xr-x. 2 root root 4096 2012-01-29 19:43 u_drive".
After the successful mount command it was listed as:
"d?????????? ? ? ? ? ? u_drive"
Needless to say 'u_drive' was inaccessible. I tried all sorts of different combinations of uid, gid, domain values (as myself and as root both) for the mount command. I tried it with and without passwords. In all cases the mount succeeded but the directory was inaccessible as shown above.

Is there another parameter I need to pass to mount.cifs to fix this?

Again thanks a lot for your help!
Reply With Quote
  #7  
Old 30th January 2012, 04:48 AM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,157
linuxfirefox
Re: SAMBA directory access in command line

I've just reread your original post at the top. We seem to have veered way off course. Some clarifications are in order.
Quote:
Originally Posted by captain52
I can access SAMBA shares on my LAN when I go to network connection. I mount them successfully. I can copy files back and forth from a folder on my machine to and from the SAMBA share. So far so so good.

But I have not been able to change my directory to the SAMBA share.
When you say "my directory", just what directory on what machine are you talking about?
Reply With Quote
  #8  
Old 30th January 2012, 05:13 AM
spskhokhar Offline
Registered User
 
Join Date: Nov 2011
Location: Punjab, India
Posts: 23
linuxubuntufirefox
Re: SAMBA directory access in command line

~/.gvfs will only contain, if access remote machine via nautilus. To do so (in GUI mode):
1. open nautilus
2. press Ctrl+L
3. smb://winMachine

On windows machine, make sure you have read/write (whatever is the requirement) permissions in security tab also.
If it is accessible, then smbmount can also do.

also can check the accessibility via smbclient command
# smbclient -L winComputerName -W myDomain.com -U username
enter windows password
Reply With Quote
  #9  
Old 30th January 2012, 02:23 PM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
windows_vistafirefox
Re: SAMBA directory access in command line

Quote:
Originally Posted by PabloTwo View Post
I've just reread your original post at the top. We seem to have veered way off course. Some clarifications are in order.

When you say "my directory", just what directory on what machine are you talking about?
I guess I did not make that clear, I apologize. What I mean is this: In any x-window (or any other type of command-line console) I want to issue the command "cd /mnt/u_drive" after mounting the shared samba shares on /mnt/u_drive. Previously, I could not even issue a successful mount command. Thanks to your help I can do that now, but I still cannot access it. (See my last post.)

In contrast, using the "Network" facility on Fedora, I get partial access to the samba shares. It is not bad: I can read and write both, I can do "drag-and-drop" type copying files both ways. On the other hand I cannot open one of these files inside a C/C++ program, because it needs a full path name, and none of the plausible path names (most plausible being /mnt/u_drive) does not work. /mnt/u_drive remains inaccessible to all command-line tools.
Reply With Quote
  #10  
Old 30th January 2012, 03:10 PM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,157
linuxfirefox
Re: SAMBA directory access in command line

OK, so then "/mnt/u_drive" is a directory on your local Fedora machine you have created as a mount point, right?
Quote:
...after mounting the shared samba shares on /mnt/u_drive.
You can only mount one remote share per mount point.. you're saying "shares", plural, so your wording here leaves me wondering.
For "drwxr-xr-x. 2 root root 4096 2012-01-29 19:43 u_drive" to end up as "d?????????? ? ? ? ? ? u_drive" after your supposedly successful mount command, would indicate to me the permissions on that directly has changed. Specifically, that can happen if all of the "x" (exec) bits are unset on a directory. Of course, that shouldn't be happening.

You need to show what line you put in the fstab file and/or what "mount" commands you used before being able to make any assessment as to why the permissions would have been clobbered so badly.
You could try, as root, after the "u_drive" directoy goes wonky... "chmod a+x /mnt/u_drive" and see what, if anything, happens.

And another point of clarification.. you keep referring to "samba shares". Do you have the samba service enabled and configured. Samba is used to allow Windows machines to access shares on a Linux machine. Running a samba service is not needed at all for a Linux box to access shared directories or partitions on a Windows machine.

All the advice/suggestions given previously here presume you just want to mount and access some shared folder on a Windows box on your LAN from your Linux box, and do so from the command line. If there is something more than that as your goal, or this isn't quite the situation, then you need to say what is.

You also state that you are able to use the GUI to mount and access the share(s). Are they already mounted and accessible via the GUI when you try "mounting" a share from command line? If so, I don't know what kind of conflict may or may not occur.

Last edited by PabloTwo; 30th January 2012 at 03:12 PM.
Reply With Quote
  #11  
Old 31st January 2012, 03:21 AM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
linuxfedorafirefox
Re: SAMBA directory access in command line

Quote:
Originally Posted by PabloTwo View Post
OK, so then "/mnt/u_drive" is a directory on your local Fedora machine you have created as a mount point, right?.
Yes that is correct.

Quote:
Originally Posted by PabloTwo View Post
You can only mount one remote share per mount point.. you're saying "shares", plural, so your wording here leaves me wondering.
Yes I understand that. My IT-speak apparently leaves much to be desired, sorry about that.

Quote:
Originally Posted by PabloTwo View Post
For "drwxr-xr-x. 2 root root 4096 2012-01-29 19:43 u_drive" to end up as "d?????????? ? ? ? ? ? u_drive" after your supposedly successful mount command, would indicate to me the permissions on that directly has changed. Specifically, that can happen if all of the "x" (exec) bits are unset on a directory. Of course, that shouldn't be happening.

You need to show what line you put in the fstab file and/or what "mount" commands you used before being able to make any assessment as to why the permissions would have been clobbered so badly.
Here is the fstab line: "//readyshare/u_drive /mnt/u_drive cifs uid=1001,gid=100,domain=HOMEGROUP,rw,noauto,sec=no ne 0 0"

Quote:
Originally Posted by PabloTwo View Post
You could try, as root, after the "u_drive" directoy goes wonky... "chmod a+x /mnt/u_drive" and see what, if anything, happens.
I did, but it did not do anything, The error message is: "chmod: cannot access `u_drive': Permission denied"

Quote:
Originally Posted by PabloTwo View Post
All the advice/suggestions given previously here presume you just want to mount and access some shared folder on a Windows box on your LAN from your Linux box, and do so from the command line. If there is something more than that as your goal, or this isn't quite the situation, then you need to say what is.
Yes this is all I want to do, you guessed it correctly. Again pardon my poor IT-speak, which apparently confused the issue needlessly.

Quote:
Originally Posted by PabloTwo View Post
You also state that you are able to use the GUI to mount and access the share(s). Are they already mounted and accessible via the GUI when you try "mounting" a share from command line? If so, I don't know what kind of conflict may or may not occur.
Good point. When I login, this does not start automatically. I have to go to Fedora-Places-->Network to get it started. After it is already running, I first stop it before I attempt to mount it by hand. To do so, I right click the u_drive icon, and click "unmount volume" first. As you might expect, this causes the icon to disappear.

Thank you for your time and effort trying to understand my problem. I much appreciate it.
Reply With Quote
  #12  
Old 31st January 2012, 08:57 PM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,157
linuxfirefox
Re: SAMBA directory access in command line

Quote:
I did, but it did not do anything, The error message is: "chmod: cannot access `u_drive': Permission denied"
Yeah, you have to run that command as root.
Quote:
//readyshare/u_drive /mnt/u_drive cifs uid=1001,gid=100,domain=HOMEGROUP,rw,noauto,sec=no ne 0 0
Maybe just a typo entering that in the forum reply, but if "no ne" is in the fstab file, change that to "none". Other than that, I don't spot anything wrong. uid=100 would appear to be the "users" group. I presume "uid=1001" is a valid user, and that "readyshare" is the name of the hostcomputer and that you've set an ip address for it in your /etc/hosts file (?). Actually "readyshare" can be any name you want, just as long as whatever name you use for the remote machine is associated with the correct ip address.
Code:
readyshare            <ipaddress>
and that "u_drive" is the shared directory or partition (?). Also, with the name of "readyshare", is this a network enabled external hdd storage device plugged into your router or an actual computer on the LAN? I have no experience with using external storage devices (NAS boxes and such), only mounting and accessing shared partitions/folders on Windows computers on my LAN.

Last edited by PabloTwo; 31st January 2012 at 09:09 PM.
Reply With Quote
  #13  
Old 1st February 2012, 03:37 PM
captain52 Offline
Registered User
 
Join Date: Jan 2009
Location: California
Posts: 26
linuxfedorafirefox
Re: SAMBA directory access in command line

Yes I issued the "chmod a+x..." command as root, not as myself. It did not help. Also the fstab is correct, when I copied it here, I must have made an error. The word "none" is spelled correctly.

However I got some extra information. Apparently SELinux is responsible for this. Here is the message from SELinux alert log:
"SELinux denied samba access to /mnt/u_drive. If you want to share this directory with samba it has to have a file context label of samba_share_t. If you did not intend to use /mnt/u_drive as a samba repository it could indicate either a bug or it could signal a intrusion attempt."

Here is another related message in the log:
"SELinux is preventing samba (smbd) "getattr" to /mnt/u_drive (cifs_t)."
Reply With Quote
  #14  
Old 1st February 2012, 03:50 PM
PabloTwo Online
"Registered User" T-Shirt Winner
 
Join Date: Mar 2007
Location: Seville, FL
Posts: 6,157
linuxfirefox
Re: SAMBA directory access in command line

You can view the SELinux context on the u_drive directory with:
Code:
ls -dZ /mnt/u_drive
You can change the context, as root, using:
Code:
chcon -t samba_share_t /mnt/u_drive
See if doing that helps.

Last edited by PabloTwo; 1st February 2012 at 03:52 PM.
Reply With Quote
Reply

Tags
access, command, directory, line, samba

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an ISO image out of a directory from command line joe.pelayo Using Fedora 5 7th February 2010 05:13 AM
Install samba from command line in FC4 -mk- Using Fedora 2 8th September 2005 10:46 PM
howto see size of directory on command line? linuxted Using Fedora 7 9th July 2005 09:38 PM


Current GMT-time: 17:53 (Tuesday, 30-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat