PDA

View Full Version : [ubuntu] set user permission for share



The_ALL
October 22nd, 2008, 02:00 PM
hi all,
i just install ubuntu desktop.the installation create an user that will write "sudo" before all commands.
But when i use "sudo mount" command,to mount a windows share on ubuntu,i can access to this share only with root user (sudo su) and i can't access with current user.
I always used root when using linux, so i have no experience with sudo comand and user permission.
Can you tell me where i must add/change permission to give access to current user to that share?
Thx

Sarmacid
October 22nd, 2008, 02:16 PM
First find out your uid and gid with the command


id

Then run this


sudo mkdir -p /media/mydisk
sudo mount -o uid=1000,gid=1000 /dev/sdb1 /media/mydisk

But change uid and gid and the device to adjust to your needs.

fr.theo
October 22nd, 2008, 02:23 PM
sudo is the only excepted way, but you can search for a way to change the permission of the directory/drive or file with the chmod command I try to find the right command hold on a sec.

fr.theo
October 22nd, 2008, 02:25 PM
sudo chmod 777 (the directory of file you need to change permission) in this case your windows share. by they way is this on a network or just on a drive, sorry got a head of my self should of asked first.

The_ALL
October 22nd, 2008, 02:26 PM
maybe i wrong explain,i write an example of what i done
------------------------------------------------
$sudo mount -t cifs //"server_windows"/common -o username="windows_user",password="password" /mnt/common
$cd /mnt/common
-bash: cd: /mnt/common: Permission denied
$sudo su
#cd /mnt/common
/mnt/common#ls
pippo
pluto
newfolder
/mnt/common#
------------------------------------------------------
but i want enter in that folder as current user not root
what have to do?

fr.theo
October 22nd, 2008, 02:37 PM
I know i am repeating my self but i am not trying to be rude is it on a local drive or network drive?

The_ALL
October 22nd, 2008, 02:41 PM
sorry
is a windows network drive

fr.theo
October 22nd, 2008, 02:50 PM
sorry to ask so many questions just trying to deduct any possibilities that would hinder your access.

have you given permission on the networked computer you wish to access to allow other computers to access it, also check if you have a anti virus software that includes its own fire wall, this will also prevent you from access. try to edit its network IP setting to allow the desired machine to gain access or simply switch it off until you get what you need.

alphaniner
October 22nd, 2008, 02:53 PM
If your only problem is that you can't cd into the directory, run


sudo chmod a+rx /mnt/common

this will give all users execute (cd into) and read access to the folder.

Are you wanting this share auto- or perma-mounted? If you just browse the share from time to time you can type smb://xxx.xxx.xxx.xxx in the nautilus address bar.

The_ALL
October 22nd, 2008, 03:05 PM
............maybe write something wrong or else but i have no problem to access to this windows share
i only want that a normal ubuntu user can access to this folder mounted, as root do
why as user i can mount a share but not have access to this,and i must become root to access? is a linux internal permission problem. why i can't mount a share directly with my user without use "sudo"?

alphaniner i do
sudo chmod a+x /mnt/common
and also
chown user /mnt/common

but still i can't access to this folder as ubuntu user but only with ubuntu root

fr.theo
October 22nd, 2008, 03:08 PM
then your windows environment has not given permission to access this drive, are you using Vista or XP?, either way if your permissions on your windows is not set so that you can view it then you will not be able to gain access.

alphaniner
October 22nd, 2008, 03:11 PM
But he can access it as root, so it is not a problem on the windows end.

EDIT: I've never used mount to access a network share before, so forgive my ignorance. But why are you using the cifs option and not smbfs?

The_ALL
October 22nd, 2008, 03:13 PM
But he can access it as root, so it is not a problem on the windows end.

many thx

fr.theo
October 22nd, 2008, 03:13 PM
good point, sorry about that, didn't take note of it my apologies.

fr.theo
October 22nd, 2008, 03:24 PM
do you have smbk4 installed?, if so go to settings and configure smbk4,


in network see if the network search is set to nmblookup or use smbclient.

I use smb4k its a gui interface but makes it easier to set up your network between windows and Ubuntu, sorry if I have troubled you or wasted your time, didn't mean to annoy you or any others on the forum. I also had great difficulty with my network access took me a while to fix it.


see if that changes anything for you.

The_ALL
October 22nd, 2008, 03:25 PM
EDIT: I've never used mount to access a network share before, so forgive my ignorance. But why are you using the cifs option and not smbfs?

smbfs works ok because you can run the command without append "sudo", so you can access as normal user to this share

but i have to use "mount" command to run same scripts
i thought was a simple problem to solve.

alphaniner
October 22nd, 2008, 03:28 PM
fr.theo: do you mean smb4k? That's a KDE util.

The_ALL: I mean for mount one of the -t options is smbfs

fr.theo
October 22nd, 2008, 03:32 PM
alphaniner>> yes it is but it works in my ubuntu hardy 64 bit environment and it is a great GUI front end for samba configuration, helped me a lot when trying to set up my network.

The_ALL
October 22nd, 2008, 03:42 PM
The_ALL: I mean for mount one of the -t options is smbfs

-t smbsf not work on that type of filesystem

The problem is how to not append "sudo" to "mount" command, or add mount root permission to user.

alphaniner
October 22nd, 2008, 03:46 PM
Who owns directory you are mounting to before anything is mounted?

ie. have you tried making a folder in your home directory (so you don't have to use sudo to make it) and mounting there?

bodhi.zazen
October 22nd, 2008, 04:42 PM
This is basically a permissions problem.

permission of the mount point before the mount point are irrelevant and will change when you mount your samba share.

The problem is likely that your window user name is not the same as your Linux user name.

With the samba share mounted, please show us the output of


ls -l /mnt

And the output of


id

The_ALL
October 22nd, 2008, 06:09 PM
ok i solved.

create folder in /mnt/
$sudo mkdir /mnt/folder_mount

change ownership on that folder
$sudo chown current_ubuntu_user /mnt/folder_mount

then i modify permission access ,adding a line at the end of this file
--------------------/etc/fstab------------------------
//windows_server/share /mnt/folder_mount cifs username=windows_user,users,exec 0 0
------------------------------------------------------

the meaning is
point_of_share point_of_mount type options_for_mount_command dump pass
i put users in options_for_mount_command to give permission to use mount and umount to all user for that share,and exec for execute files


Now as user i can use mount command for this share without "sudo"
$mount //windows_server/share
password:
$cd /mnt/folder_mount
/mnt/folder_mount$ls
pippo
pluto
newfolder
/mnt/folder_mount$

alphaniner
October 22nd, 2008, 07:42 PM
Congrats. Clearly I had no idea what I was saying, my apoligies if I wasted any of your time. There is one thing I don't understand though. If you have that line in your fstab, isn't it mounted automatically at boot?