Added new partition to system, "permission denied" when running programs
Solution 1
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.
Solution 2
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.
The partition may be mounted with
noexec
. To check this, runmount
and see ifnoexec
is listed next to the relevant entry. Since you're mounting from/etc/fstab
, you can removenoexec
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:- It does not need the executable bit set.
-
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.)
Solution 3
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.
Solution 4
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
Solution 5
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.
Related videos on Youtube
Caspar
Updated on September 18, 2022Comments
-
Caspar almost 2 years
Possible Duplicate:
Ubuntu took away permissions from my Data partitionI 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? :)
-
Deepak Verma almost 12 yearsI 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.
-
-
reverendj1 almost 12 yearsHave you checked that you did not specify
noexec
in fstab for that partition? -
Eliah Kagan almost 12 yearsNTFS 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.
-
Deepak Verma almost 12 years@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.
-
Deepak Verma almost 12 years@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.
-
Caspar almost 12 yearsI added my
/etc/fstab
to my original post. See above. -
Caspar almost 12 yearsSee my
/etc/fstab
in my original post. -
Caspar almost 12 yearsThe partition is an ext4 partition.
-
Deepak Verma almost 12 years@Caspar: sorry, the original post made me think it was NTFS. I added an edit that may help.
-
Caspar almost 12 yearsI already did that. :)
-
Caspar almost 12 yearsWell, 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.