How to create a simple C program on Debian 12
To Create Simple C Program on Debian 12
Introduction
C is a widely utilized programming language recognized for its simplicity and efficiency. Developed in the early 1970s, it has become a fundamental building block for numerous modern programming languages. C is especially favored in system programming, embedded systems, and application development due to its capability to interact closely with hardware.
Procedure :
Step 1 : Check the OS version by using following command.
root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Step 2 : Update the system packages by using following command.
root@linuxhelp:~# apt update
Get:1 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:2 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://security.debian.org/debian-security bookworm-security/main Sources [120 kB]
Get:5 http://security.debian.org/debian-security bookworm-security/main amd64 Packages [188 kB]
Get:6 http://security.debian.org/debian-security bookworm-security/main Translation-en [115 kB]
Get:7 http://deb.debian.org/debian bookworm/main Sources [9,487 kB]
Get:8 http://deb.debian.org/debian bookworm/non-free-firmware Sources [6,436 B]
Get:9 http://deb.debian.org/debian bookworm/main amd64 Packages [8,787 kB]
Get:10 http://deb.debian.org/debian bookworm/main Translation-en [6,109 kB]
Get:11 http://deb.debian.org/debian bookworm/non-free-firmware amd64 Packages [6,236 B]
Get:12 http://deb.debian.org/debian bookworm/non-free-firmware Translation-en [20.9 kB]
Get:13 http://deb.debian.org/debian bookworm-updates/main Sources.diff/Index [11.7 kB]
Get:14 http://deb.debian.org/debian bookworm-updates/main amd64 Packages.diff/Index [11.7 kB]
Ign:14 http://deb.debian.org/debian bookworm-updates/main amd64 Packages.diff/Index
Get:15 http://deb.debian.org/debian bookworm-updates/main Translation-en.diff/Index [11.7 kB]
Ign:15 http://deb.debian.org/debian bookworm-updates/main Translation-en.diff/Index
Get:16 http://deb.debian.org/debian bookworm-updates/main Sources T-2024-09-10-2011.55-F-2024-04-23-2036.10.pdiff [1,206 B]
Get:16 http://deb.debian.org/debian bookworm-updates/main Sources T-2024-09-10-2011.55-F-2024-04-23-2036.10.pdiff [1,206 B]
Get:17 http://deb.debian.org/debian bookworm-updates/non-free-firmware Sources [2,076 B]
Get:18 http://deb.debian.org/debian bookworm-updates/non-free-firmware amd64 Packages [616 B]
Get:19 http://deb.debian.org/debian bookworm-updates/non-free-firmware Translation-en [384 B]
Get:20 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [2,468 B]
Get:21 http://deb.debian.org/debian bookworm-updates/main Translation-en [2,928 B]
Fetched 25.1 MB in 5s (4,866 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
270 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Repository 'http://deb.debian.org/debian bookworm InRelease' changed its 'Version' value from '12.4' to '12.7'
Step 3 : Install the C compiler by using following command.
root@linuxhelp:~# apt install build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
The following packages were automatically installed and are no longer required:
libc-ares2 libgrpc++1.51 libgrpc29 libprotoc32 libre2-9
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 270 not upgraded.
Step 4 : Write simple C program using nano editor by using following command.
root@linuxhelp:~# nano test.c
#include <stdio.h>
int main () {
printf("linuxhelp gives good videos!\n");
return 0;
}
Step 5 : Compile C program with the output name by using following command.
root@linuxhelp:~# gcc test.c -o ctest
Step 6 : Run compiled file to get output of the C program by using following command.
root@linuxhelp:~# ./ctest
linuxhelp gives good videos!
Conclusion :
We have reached the end of this article. In this guide, we have walked you through the steps required to create simple C program on Debian 12. Your feedback is much welcome.
Comments ( 0 )
No comments available