Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot open output file a.out: Permission denied, on a simple compilation

I wrote some code in vim and whenever I try to run the code it shows this:

coolmego@coolmego-PC:~/coolmego/cprograms$ gcc dfs8puzz.c 
/usr/bin/ld: cannot open output file a.out: Permission denied
collect2: ld returned 1 exit status
coolmego@coolmego-PC:~/coolmego/cprograms$ ./a.out
bash: ./a.out: No such file or directory

What should I do?

like image 828
sd1517 Avatar asked Mar 15 '11 14:03

sd1517


People also ask

How do I open a file in Linux permission denied?

To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose.

How do I get permission to open files in Ubuntu?

Type “sudo chmod a+rwx /path/to/file” into the terminal, replacing “/path/to/file” with the file you want to give permissions to everyone for, and press “Enter.” You can also use the command “sudo chmod -R a+rwx /path/to/folder” to give permissions to the selected folder and its files.

Can not open output file access is denied eclipse?

Eclipse C/C++: Cannot open output file *.exe: Permission denied. Solution: It's most likely that your EXE is running and can't be overwritten by the compile process. You have to stop all running processes of your EXE.

What is Permission denied?

A "Permission denied" error means that the server rejected your connection.


2 Answers

Move to a directory where you are allowed to write.

like image 144
unwind Avatar answered Sep 21 '22 14:09

unwind


This is because if you only have write permissions, but you are not the owner the directory.

  1. Check your user name:

    whoami
    
  2. Make yourself the owner of the directory and its contents:

     sudo chown -R "$USER:" /path/to/the/directory
    
  3. Set read/write/execute permission

    chmod -R 700 /path/to/the/directory
    

refer https://askubuntu.com/questions/466605/cannot-open-output-file-permission-denied

like image 23
Vijay Anand Avatar answered Sep 22 '22 14:09

Vijay Anand