简体   繁体   中英

Executing C program in Linux Terminal

I have compiled a program from my Ububtu 10.10 terminal by

gcc file_name.c -o new_file

command. It compiled successfully creating an executable file named new_file. But when I was trying to execute it by this command

./new_file

It says that permission is denied of new_file. I've checked the permission properties of that file found that I've permission to read & write it (I'm the only user of that system). Can you please help me to figure out the problem?

You have to give it exe. permissions.

So: chmod +x new_file

When you create a new file with your gcc, by default, this isn't executable. So, you have to gave it permissions of execution.

With chmod (see this) you change permissions on file.

In that specific case, you gave execution permissions ( + [plus] means gave, 'x' means execution ) to that file.

If you want to revoke that permission, you can type: chmod -x filename

编译后,文件放在a.out尝试使用a.out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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