bash: ./a.out: Permission denied ......
i am not able to run my .cpp file which is stored in the media.i am using UBUNTU ....i understand i'll have to change the mode of the directory contents..how do i do that?
|
How did you compile your program? What command(s) did you use? The typical syntax for compiling a C/C++ program is:
Code:
gcc -o <executable> <source> Code:
g++ -o <executable> <source> |
i compiled it wid g++ (filename).cpp
no error msgs wre displayed...but wen i tried to run it usin ./a.out an error msg popped up stating "u dont ave permission 2 do so" ...whereaas i was accessing it as d root...so wot do i do 2 chnge d rw mode of d file 2 executable mode...??? |
Quote:
|
You can check the mode of the file with ls -l a.out.
I usually use chmod 'u+x' a.out. It makes the file executable for myself and root without changing the mode for other users. For convenience you can make yourself a simple script. Code:
foo$ echo '#! /bin/sh
Code:
foo$ cat source.c |
My programme is in the path /media/8A28BD0B28BCF773/TC/BIN...And I am executing the code from BIN directory....Whenever I am executing ./a.out ,I am getting "permission denied".I have tried the above code snippet and also chmod command a number of times.But the mode is not changing.If I give "ls -l a.out" command,I am getting the output as
"-rw------- 1 debojit debojit 27 2011-04-06 19:21 a.out".. I am a beginner in Linux.Please help whether I am missing something... |
Is chmod failing silently, or is it giving an error message?
I'm beginning to wonder about the permissions and ownership of the directory in question. If the directory is owned by debojit, is writable, and resides on a Linux native filesystem then I'm at a loss to explain why chmod would fail. |
ya...u've got dat r8....chmod is failing silently...no error msg aftr d command....but wen i use ls -l a.out...it's givin d mode as rw...
|
Quote:
Quote:
@Debojit777 What filesystem is the disk/partition mounted at "/media/8A28BD0B28BCF773" formatted with? If it's not a Linux-compatible filesystem like ext3/4 or ReiserFS or the like, this could pose a problem with permissions. You can check the FS type by using mount. |
r8 again...it's an ntfs file system....i had Windows XP installd in my laptop and it's been jst a few weeks dat i've installed ubuntu on my laptop.
|
Quote:
I think there are some flags you can pass to mount to make files on that volume executable by default. The downside is that it would probably make all files on that volume executable, and that may not be what you want. I think you may find more help if you share the mountline you are using for this volume. My advice is to simply move the executable to a Linux native filesystem and apply the desired permissions from there. |
If You didn't Manually mounted by editing the entries in ?etc/fstab
then the system mounts it with defaults characteristics like noexec-do not execute any files from this partion so edit the above mentioned file like this /dev/sda3 /media/Wstuff ntfs auto,user,rw,sync,exec 0 0 that should give the partion files the executable status |
All times are GMT -5. The time now is 07:37 AM. |