-1

I upgraded my ubuntu to 13.04 version. After this upgrade I am not able to execute c programs in terminal. When I try to execute, it shows an error as shown below

bash: ./cd: Permission denied

where cd is my executable file which is working fine in lower versions of ubuntu.

1
  • 3
    What is the permission of the file? (ls -l) and is the program located on NTFS drive?
    – Web-E
    Sep 28, 2013 at 18:01

3 Answers 3

1

First you have to know what are the permissions.

to know the permissions, type the below code in your terminal.

ls -lh

or

ls -l

then it'll shows the permissions of all files like below. choose your file permissions.

-rw-r--r--

you have to organize those into 4 parts.

parts:  1       2        3        4
     +--------------------------------+
     |  -  | r w -  |  r - x | - - -  |  (r: Read, w: Write, x: Executable, -: No perm)
     +--------------------------------+
perm:         ROOT     USER     GROUP    
  1. 1st part indicates file type. "-" means regular. "d" means directory, "p" for pipe e.t.c..
  2. 2nd part indicates ROOT permissions. In my example, it is "r w -". it means root have read and write permsissions, but not executable permissions.
  3. 3rd part is for USER permissions. here we can see "r - x". it means user have read, executable permissions but not write permissions.
  4. 4th part indicates permissions of GROUP. here group have "- - -". so it don't have any permissions.

You are getting error "Permission denied". "cd" is your executable file. It requires executable permission(x).

To change permissions of a file:

In your case you may don't have executable permission. for that try below caode

chmode +x <filename>      (eg: chmode +x cd   //here cd is your filename)

you can also assign other permissions by replacing "x" with "r"(read) or "w"(write).

to verify again use

ls -l (or) ls -lh.

Note: If "chmod" returns an error like "operation not permitted" then try

               sudo chmod +x <filename> (eg: sudo chmod +x cd)

for more about permissions:

              man chmod
0
0

Be sure that your cd is realy executable using the following command:

chmod +x cd
0

It looks to me like you're trying to execute built-in commands in the terminal (such as "cd"). Instead of prefacing them with a "./", call them just as "cd" from the command line.

I may be misunderstanding your query, but hopefully that works. Otherwise, follow one of the answers above that involves assigning the executable bit to the file and try running it that way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .