无法打开输出文件 a.out:权限被拒绝,进行简单编译
我在 vim 中编写了一些代码,每当我尝试运行代码时,它都会显示:
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
我应该做什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
移动到允许您写入的目录。
Move to a directory where you are allowed to write.
这是因为如果您只有写权限,但您不是该目录的所有者。
检查您的用户名:
<前><代码>whoami
让您自己成为目录及其内容的所有者:
设置读/写/执行权限
请参阅https:// askubuntu.com/questions/466605/cannot-open-output-file-permission-denied
This is because if you only have write permissions, but you are not the owner the directory.
Check your user name:
Make yourself the owner of the directory and its contents:
Set read/write/execute permission
refer https://askubuntu.com/questions/466605/cannot-open-output-file-permission-denied
当您运行 sudo 时,您实际上是以 root 用户身份运行命令。可能您最终搞乱了权限,以便 root 拥有这些文件。因此,当您运行 sudo 时,它就可以工作(root 可以在这些目录中写入)。您需要coolmego 才能拥有这些文件。例如:
When you run sudo, you are actually running the commands as root user. Possibly you ended up messing up the permissions so that root owns the files. Thus when you run sudo, it just works (root can write in those directories). You need coolmego to own those files. For example:
删除 /etc/fstab 中的选项用户。 fstab 中包含 user 的任何内容都会自动挂载为 noexec,除非 fstab 中明确给出了 exec。
Remove option user in /etc/fstab. Anything with user in the fstab is automatically mounted noexec unless exec is explicitly given in the fstab.
尝试向您要获取输出的目标目录授予读写权限。如果您使用个人系统,您可以执行“sudo chmod 777”
Try giving read write permission to the directory in which you are targeting to get the output. In case you are using a personal system you can do "sudo chmod 777 "
我遇到了同样的问题,1小时后我发现这是我的防病毒软件,我将其关闭,一切正常。
I was having the same problem, after 1 hour i found out it was my Antivirus, i shut that down and everything worked fine.
尝试 chmod -R 777 ~/coolmego/cprograms
try
chmod -R 777 ~/coolmego/cprograms