DEV Community

Guru prasanna
Guru prasanna

Posted on

About Linux - Compiler , Process ,Executable

Why linux?

--> Every code run in linux machine.
--> Linux is efficient due to its command line/Terminal.

Linux commands for renaming multiple images at a time:

--> ls img_*.jpg|sed
--> mv

In terminal for manual(To know about a command)
--> man sh

After knowing about commands then we can start scripting which can lead to devops.

To know how many mount point?

findmnt --real

partition:(About home directory)
mvmvp0 p1 p2

ls /usr/bin/ --> To store all executable
ls /usr/bin/ls

To view Task manager:

top
--> Now to exit from this click q.

How to create executable?

1) type gcc
--> If not found sudo apt install gcc
c source to convert file into executable.
2) gcc helloworld.c
3) Then remove conio.h line and again run.
4) You will get this error:

warning: implicit declaration of function ‘getch’; did you mean ‘getc’?

5) Run this code in terminal:

#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}
Enter fullscreen mode Exit fullscreen mode

6) a.out --> Command not found
7) echo $PATH --> not in that directory
8) ./a.out --> Runs file inside current folder
9) echo $$ --> 3401

So using gcc we have compiled c code and converted to executable and then to run the file we used ./a.out and maked it process.

While running this code:

1) fork --> a.out
2) exec

Name change:
Before we have not specified name and now we are specifying name as helloworld and we can run with this name.

10) gcc -ohelloworld helloworld.c
11) ./helloworld --> File will be executed

Top comments (0)