简体   繁体   English

C程序未执行:权限被拒绝

[英]C program not executing: permission denied

I have installed C/C++ compiler using 我已经使用以下方法安装了C / C ++编译器

sudo apt-get install build-essential

created file named "first.c" and write an initial code of C language in it. 创建名为“ first.c”的文件,并在其中编写C语言的初始代码。

cc -c first.c

cc -o first first.c

./first

-bash: ./first: Permission denied

chmod +x first

ls -al


sana@ubuntu:/media/E68828DA8828AACF/Documents/cWork$ ls -al
total 25
drwx------ 1 sana sana 4096 Dec 16 08:47 .
drwx------ 1 sana sana 4096 Dec 16 08:17 ..
-rw------- 1 sana sana 8379 Dec 16 08:47 first
-rw------- 1 sana sana   82 Dec 16 08:23 first.c
-rw------- 1 sana sana   82 Dec 16 08:22 first.c~
-rw------- 1 sana sana 1504 Dec 16 08:23 first.o

Solved : using changing my current working directory to sana@ubuntu:~/Documents$ instead sana@ubuntu:/media/E68828DA8828AACF/Documents/cWork$ 解决:使用我的当前工作目录更改为sana @ ubuntu:〜/ Documents $而不是sana @ ubuntu:/ media / E68828DA8828AACF / Documents / cWork $

why ?? 为什么?? i dont understand 我不明白

sana@ubuntu:~/Documents$ touch first.c
     sana@ubuntu:~/Documents$ gedit first.c
     sana@ubuntu:~/Documents$ cc -c first.c
     sana@ubuntu:~/Documents$ cc -o first first.c
     sana@ubuntu:~/Documents$ ./first
     i am sana 
     sana@ubuntu:~/Documents$

yes exacty the device is mounted with noexec option that do not execute any script from drive to run scripts you need to change noexec option. 是的,确实是使用noexec选项挂载了设备,该选项不执行驱动器中的任何脚本来运行需要更改noexec选项的脚本。 The method of which is given here . 这里给出其方法。

Did you give execute permission to first ; 你给执行权限first ; done by chmod +x first ? chmod +x firstchmod +x first完成?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM