C in Fedora — install gedit, compile with gcc and write your first program
Setting up C in Fedora is the first practical step in IC2. Before you write a single line of C code you need two things: a text editor to write the code and a compiler to turn it into an executable program. In Fedora that means gedit and gcc.
This article walks you through the complete setup and your first C program running in the terminal.
Table of Contents
What is gcc and why do you need it?
In Python you ran programs directly, the interpreter read your .py file and executed it. C doesn’t work that way. C is a compiled language, before running, your source code (the .c file you write) must be translated into machine code that the processor can execute directly.
That translation is done by the compiler. In Linux the standard C compiler is gcc (GNU Compiler Collection). It takes your .c file and produces an executable binary.
You write: hello.c ← source code (text) gcc compiles: hello ← executable binary (machine code) You run: ./hello ← the program executes
Without gcc you can write C code but you can’t run it. It’s the essential tool for every lab in IC2.
Step 1 — Verify gcc is installed
Fedora usually comes with gcc pre-installed. Check with:
gcc --version
If gcc is installed you’ll see something like:
gcc (GCC) 14.x.x 20xxxx Copyright (C) 2024 Free Software Foundation, Inc.
If you get “command not found”, install it:
sudo dnf install gcc

Type your Fedora password when prompted and confirm with y. The installation takes a few minutes.
Step 2 — Install gedit
gedit is the text editor we use for writing C code in IC2. It’s simple, lightweight and has syntax highlighting for C — it colours keywords, strings and comments to make the code easier to read.
Check if it’s already installed:
gedit --version
If not installed:
sudo dnf install gedit
Again, enter your password and confirm. Once installed verify it opens:
gedit
A window should open. Close it for now, we’ll open it properly from the terminal in a moment.
Step 3 — The & operator — why you always open gedit with it
This is one of the most important things to know for IC2 workflow. When you run a program from the terminal, the terminal waits for that program to finish before accepting new commands. If you open gedit without &:
gedit main.c # terminal is frozen until you close gedit

The terminal is blocked. You can’t compile, run or do anything else until you close the editor — which defeats the purpose.
The solution is the & operator, it runs the program in the background, freeing the terminal immediately:
gedit main.c & # gedit opens AND the terminal stays available

Now you can type in the terminal while gedit is open. You’ll see a process ID printed (something like [1] 12345) — that’s normal, it’s just telling you the background process started.
Always open gedit with & in IC2.
Step 4 — Write your first C program
Navigate to your IC2 folder and create a new file:
cd ~/GCID/IC2/Labs mkdir Lab1_hello cd Lab1_hello touch hello.c gedit hello.c &
In gedit, type this program, type it, don’t copy and paste:
#include <stdio.h>
int main() {
printf("Hello from C!\n");
return 0;
}
Save with Ctrl + S and go back to the terminal.

Understanding every line
#include <stdio.h> — this is a preprocessor directive. It tells gcc to include the Standard Input/Output library before compiling. printf lives in this library — without this line gcc doesn’t know what printf is.
int main() — the entry point of every C program. When you run the program, execution starts here. int means it returns an integer to the operating system when it finishes.
printf("Hello from C!\n") — prints text to the terminal. \n is the newline character — without it the next terminal prompt appears immediately after your text on the same line.
return 0 — returns 0 to the operating system, which by convention means “program finished successfully”. A non-zero return value means an error occurred.
Step 5 — Compile with gcc
In the terminal (not in gedit), run:
gcc hello.c -o hello
Breaking down this command:
gcc → the compiler hello.c → the source file to compile -o hello → output: name the executable "hello"
If there are no errors, gcc produces no output, silence means success. A new file called hello appears in your directory:
ls -l
-rw-r--r--. 1 sergio sergio 73 Jun 7 hello.c -rwxr-xr-x. 1 sergio sergio 8432 Jun 7 hello
Notice the permissions: hello.c has rw-r--r-- (read/write, no execute). hello has rwxr-xr-x — gcc automatically makes the output executable.
Step 6 — Run the program
./hello
Output:
Hello from C!

The ./ before the program name is important, it tells the shell “look for this program in the current directory”. Without it the shell searches your PATH directories (where system commands live) and doesn’t find your program.
The complete IC2 workflow
This is the cycle you’ll repeat for every lab:
# 1. Navigate to your lab folder cd ~/GCID/IC2/Labs/Lab1_hello # 2. Open the file in gedit (background) gedit hello.c & # 3. Write or edit the code in gedit — Ctrl+S to save # 4. Compile gcc hello.c -o hello # 5. Run ./hello # 6. If there are errors — read the error, edit the file, compile again gedit hello.c & gcc hello.c -o hello ./hello
Step 4, 5 and 6 repeat until the program works correctly.
Understanding gcc error messages
When your code has errors, gcc tells you exactly what’s wrong and where. Learning to read these messages is one of the most valuable skills in IC2.
Syntax error — missing semicolon
printf("Hello from C!\n") // missing ;
hello.c:4:5: error: expected ';' before 'return'
Read it as: file hello.c, line 4, column 5, expected ; before return. The error message tells you exactly where to look.
Undefined reference — missing include
// Missing #include <stdio.h>
int main() {
printf("Hello\n");
return 0;
}
hello.c:3:5: warning: implicit declaration of function 'printf' /usr/bin/ld: undefined reference to 'printf'
The linker can’t find printf because you didn’t include stdio.h.
File not found
gcc helo.c -o hello # typo in filename
gcc: error: helo.c: No such file or directory
Check the filename with ls and correct the typo.
Compiling multiple files
When your program has multiple .c files you compile them together:
gcc main.c utils.c -o program
Or compile each to an object file first:
gcc -c main.c # produces main.o gcc -c utils.c # produces utils.o gcc main.o utils.o -o program
In IC2 labs you’ll mostly compile single files, but knowing this exists is useful.
Useful gcc flags
gcc hello.c -o hello # basic compilation gcc hello.c -o hello -Wall # enable all warnings (recommended) gcc hello.c -o hello -g # include debug info (for gdb) gcc hello.c -o hello -O2 # optimise the output
Always use -Wall during development, it catches many subtle mistakes:
gcc hello.c -o hello -Wall
Quick summary
# VERIFY INSTALLATION gcc --version gedit --version # INSTALL IF NEEDED sudo dnf install gcc sudo dnf install gedit # ALWAYS OPEN GEDIT WITH & gedit filename.c & # opens editor + keeps terminal free # COMPILE gcc source.c -o executable # basic gcc source.c -o executable -Wall # with warnings (recommended) # RUN ./executable # ./ means "in current directory" # IC2 WORKFLOW touch main.c # create file gedit main.c & # open editor # write code → Ctrl+S to save gcc main.c -o main # compile ./main # run # fix errors → save → compile → run → repeat # READ ERROR MESSAGES # filename:line:column: error: description # hello.c:4:5: error: expected ';' before 'return' # ↑ go to line 4, fix the problem there # & OPERATOR command & # run in background — terminal stays free # without & → terminal frozen until program closes
In the next article we look at variables and data types in C, how they differ from Python and what makes C’s type system strict.
