Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to use CHMOD in linux? When I try to delete a file/folder, permission is denied. What exact params must I give for chmod here?

This is what I need to do. Execute a command ./build.mips , but I get permission denied error.

-bash: ./build.mips: Permission denied
share|improve this question

migrated from Jan 12 '11 at 8:06

This question came from our site for professional and enthusiast programmers.

Not programming..... – leppie Jan 12 '11 at 6:58
so wher shud i post these doubts then? – kiki Jan 12 '11 at 7:05
I think this question is acceptable since it's a shell issue. – chrisaycock Jan 12 '11 at 7:06
up vote 3 down vote accepted

If you can't delete a file even after you've chmod'ed it to 777, the problem may be with the directory that the file is in. For example:

# no permission to write in the current directory...
$ ls -la
total 0
dr-xr-xr-x   3 chrisaycock  staff   102 Jan 12 02:00 ./
drwxr-xr-x+ 59 chrisaycock  staff  2006 Jan 12 01:59 ../
-rw-r--r--   1 chrisaycock  staff     0 Jan 12 02:00 test.txt

# ... and thus I can't delete a file in this directory
$ rm test.txt
rm: test.txt: Permission denied

# so I give myself permission to write
$ chmod u+w .

# just to confirm that I can write in this directory
$ ls -la
total 0
drwxr-xr-x   3 chrisaycock  staff   102 Jan 12 02:00 ./
drwxr-xr-x+ 59 chrisaycock  staff  2006 Jan 12 01:59 ../
-rw-r--r--   1 chrisaycock  staff     0 Jan 12 02:00 test.txt

# and now I can remove the file
$ rm test.txt
share|improve this answer

If you want to be able to run the program, run:

chmod a+x ./build.mips

Of course, you must have permission to do that.

share|improve this answer
how to get the permission is my question..also, when I try to delete a directory, i get permission denied. Even after i give chmod -c 777 . – kiki Jan 12 '11 at 6:49
@kiki try going to the parent directory and doing chmod 777 on that. – barlop Jan 12 '11 at 9:20
@kiki: Using 777 is almost always a bad idea for security. Only grant permissions that are actually needed. – Dennis Williamson Jan 12 '11 at 11:43

To delete files or folder it is much easier to gain root permission to delete it than to chmod (or chown) it before deletion.

you can do (if you need only one command with root permission. You need to configure your sudo to do that, depending of your Linux distribution)

$ sudo rm test.txt


$ su (prompt to type the root password)
# rm test.txt
# exit (or CRTL+D)

or (if no root user on the machine)

$ sudo -s
# rm test.txt
# exit

Use the same procedures to chmod files that you don't own.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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