Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
Ubuntu took away permissions from my Data partition

I reformatted a NTFS partition on my system with ext4 because I want to use it on my current Ubuntu installation, not on Windows. I added an entry to /etc/fstab to mount it at start-up. The mount point is /home/username/bin. I changed the owner of /home/username/bin and all of its sub-directories to my regular account and its user group. Finally, I set all permissions to 755.

My /etc/fstab looks as follows:

proc        /proc               proc    nodev,noexec,nosuid               0       0
UUID=[uuid] /                   ext4    errors=remount-ro                 0       1       
UUID=[uuid] /data               vfat    utf8,umask=007,gid=46             0       1
UUID=[uuid] /home               ext4    defaults                          0       2
UUID=[uuid] /home/username/bin  ext4    rw,suid,dev,exec,auto,user,async  0       2
UUID=[uuid] none                swap    sw                                0       0

My problem is now that while I'm able to read and write files on this new partition, I cannot run applications/programs located there. As a regular user, I always get a "permission denied" error. As root (with sudo), just nothing happens, which means it immediately puts me back to the shell prompt. The applications should produce textual output or open windows. Some of these applications are binaries, some are scripts. I try to launch them with ./program. If I copy them back to my home folder, I can run them without problems.

Actually, I kept these applications for months in another sub-directory /home/username/apps of my home folder and ran them from there, without any problems.

How can I fix this? What am I doing wrong? :)

share|improve this question

marked as duplicate by Eliah Kagan, Mitch, Tom Brossman, izx, hbdgaf Sep 8 '12 at 13:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
I believe my edit at the end of my answer will fix your problem. Basically, it sounds like the owner of the bin directory is root, and needs to be changed after mounting the first time. –  Marty Fried Jul 17 '12 at 16:53

6 Answers 6

I was having similar problems, not being able to execute shell scripts stored on NTFS, even with sudo, even after editing fstab as described above.

It turns out I had never made the mount point directory. I unmounted the partition, made the mount point directory for the partition:

mkdir /media/Windoze7

and then mounted again.

sudo mount -a
share|improve this answer

Ignore this - original post implied NTFS, but this is not the case.

When you mount an NTFS partition, unlike ext3 or ext4, it mounts with permissions set for only the user, where group and other have no permission at all (rwx------). Setting the permissions with chmod or setting the owner with chown will only change the permissions for the directory, not anything in the directory.

The solution is to specify the correct parameters in /etc/fstab/. The ones I use successfully, to make myself the owner is this (change 0000000000000000 to the correct UUID, and change LOGIN_NAME to your login name):

UUID=0000000000000000 /home/LOGIN_NAME/bin ntfs-3g auto,users,uid=LOGIN_NAME,gid=LOGIN_NAME,utf8,dmask=002,fmask=113 0 0

This should all be on one single line in fstab.

The reason for this is that NTFS permissions are done differently than native Linux permissions, so certain translations must be specified to be used by Linux.

End of Ignore this -------------

EDIT:

Sorry for the misdirection.

I believe you can fix this by changing the owner of the ~/bin directory after mounting it the first time. In a bash shell, enter the command sudo chown LOGIN_NAME:LOGIN_NAME /home/LOGIN_NAME/bin, changing LOGIN_NAME to your name, of course.

I tested this out using a USB drive, and it mounted fine in my bin directory. The only difference was that I used only the option "auto" in fstab.

share|improve this answer
2  
NTFS certainly does have a concept of owner, and that concept is just as powerful as the owner concept in Unix-style file permissions. Furthermore, Ubuntu's NTFS driver (ntfs-3g) has full support for native NTFS permissions and ownership. However, this is complicated, and it can be confusing, and the default mount options don't have it enabled. Your answer is a very reasonable approach, and the most common one, but NTFS permissions are just as powerful as UNIX permissions, and you can use them fully on Ubuntu if you want. –  Eliah Kagan Jul 17 '12 at 4:09
    
@EliahKagan: Thanks for the correction; I guess I misremembered the reason somehow. I think the explanation I once read probably said that it uses ACL and has no simple concept of owner or something similar. I edited my answer, but perhaps it would be just as well to leave it out. –  Marty Fried Jul 17 '12 at 5:03
3  
The partition is an ext4 partition. –  Caspar Jul 17 '12 at 13:10
    
@Caspar: sorry, the original post made me think it was NTFS. I added an edit that may help. –  Marty Fried Jul 17 '12 at 16:55
    
I already did that. :) –  Caspar Jul 17 '12 at 17:44
up vote 2 down vote accepted

I solved it. The problem were the mount options in /etc/fstab. Changing them to defaults (which is equivalent to changing user to nouser) solves the problem, everything works now as expected.

share|improve this answer
1  
I was about to suggest that; that was what I used for my test to check my suggestion. I actually started to add it, but I wanted to make sure that your options weren't set for particular reasons. –  Marty Fried Jul 17 '12 at 18:48
    
Well, somehow I thought it might be necessary to let users mount that new partition because I'm mounting it as a sub-folder of my home. As it turned out, I was wrong. –  Caspar Jul 18 '12 at 10:07

Have you tried mounting this ext4 partition somewhere outside your home directory? For example, set up its entry in /etc/fstab something like this:

UUID=[uuid] /ext4bins  ext4    rw,suid,dev,exec,auto,user,async  0       2

If you are able to mount it elsewhere and execute files and applications, then you can take a second step to get the behavior you wanted, which is being able to execute applications from ~/bin, by creating a symbolic link like so:

ln -s /ext4bins /home/[username]/bin

Replace [username] with your own username, obviously. This will make the mounted partition in /ext4bins appear to be mounted in /home/[username]/bin, and as long as files are exectuable in /ext4bins, you will be able to execute them through ~/bin as well. E.g.

/ext4bins/myscript.sh

will run the same as

~/bin/myscript.sh
share|improve this answer

You can access files on your newly created ext4 partition, but you cannot run programs. When you do, you get a "Permission denied" error. This suggests two possibilities, as reverendj1 has suggested:

  • The files might not have execute permissions. To give a file execute permissions from the command line, run:

    chmod +x filename

    If you just want to give execute permissions to the owner of the file:

    chmod u+x filename

    To give a file execute permissions in Nautilus (the file browser), right-click on the file and click Properties. Click the Permissions tab. Check the box that says Allow executing file as a program, and click Close.

    enter image description here

  • The partition may be mounted with noexec. To check this, run mount and see if noexec is listed next to the relevant entry. Since you're mounting from /etc/fstab, you can remove noexec there.

In addition, please note that:

  • Usually, though not always, executables should be stored in the normal places: /bin, /sbin, /usr/bin, /usr/sbin /usr/local/bin, /usr/local/sbin, /opt/bin, ~/bin. Are you sure you really want executables on that drive. You may want to edit your question to provide more information about what you want to accomplish.

  • To run a program from the command-line that is located in the current directory by specifying its relative path, you must precede it with ./:

    ./program
  • If you are launching a .desktop file rather than an application then:

    1. It does not need the executable bit set.
    2. You should not attempt to run it as though it is itself a script or program, but instead like this:

      xdg-open application.desktop
  • If these are Windows executables that you're running with Wine, they don't actually have to have the executable bit set. If they don't, you can right-click them and click open them with Wine Windows Program Loader, or launch them from the command line like this:

    wine program.exe

(I see this provides very similar advice to a previous answer, so I've decided make this community-wiki.)

share|improve this answer
    
Actually, I want to mount that new partition under ~/bin. :) Changed my initial post accordingly. –  Caspar Jul 16 '12 at 17:08
    
@Caspar: I hope your fstab entry does not use the tilde for the path. you should use the actual full path of /home/login-name/bin instead. –  Marty Fried Jul 17 '12 at 5:06
    
I added my /etc/fstab to my original post. See above. –  Caspar Jul 17 '12 at 13:08

You need to set the execute permission. From Nautilus (the file browser), right-click on the program file, then select the Permissions tab. Check the "Allow executing file as program" checkbox. From the terminal, you can also do:

sudo chmod +x /path/to/myfile

Also, make sure you are not specifying noexec for the partition in fstab, as that will disable execution for the entire partition.

share|improve this answer
    
The execute permission is set. Sorry, forgot to add this. :) –  Caspar Jul 16 '12 at 15:46
2  
Have you checked that you did not specify noexec in fstab for that partition? –  reverendj1 Jul 16 '12 at 15:48
    
See my /etc/fstab in my original post. –  Caspar Jul 17 '12 at 13:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.