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?
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.
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.
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.
A "Permission denied" error means that the server rejected your connection.
Move to a directory where you are allowed to write.
This is because if you only have write permissions, but you are not the owner the directory.
Check your user name:
whoami
Make yourself the owner of the directory and its contents:
sudo chown -R "$USER:" /path/to/the/directory
Set read/write/execute permission
chmod -R 700 /path/to/the/directory
refer https://askubuntu.com/questions/466605/cannot-open-output-file-permission-denied
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With