🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

Create a Linux System Info Utility in C

↗ Quelle (dev.to)
🗣️ Stimme:

This Linux project creates a simple utility written in C that retrieves and displays system-level information, including the system name, memory usage, and processor details. It serves as an educational tool for understanding how to interact with Linux system calls and files like /proc/cpuinfo. The utility demonstrates the use of system calls such as uname, sysinfo, and gethostname, along with reading system data from Linux-specific files. It is ideal for beginners learning Linux system programming and provides a foundation for extending functionality, such as adding network statistics or disk usage information. Each component of the utility highlights a different aspect of Linux APIs, from retrieving kernel and architecture details with uname to gathering memory and uptime statistics using sysinfo, and processor details via /proc/cpuinfo.



Here's the code:




CODE
#include <stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<sys/utsname.h>
#include
<unistd.h>
#include
<sys/sysinfo.h>

int main() {
struct utsname sys_info;
struct sysinfo mem_info;
char hostname[256];

// Get system name, release, version, and architecture
if (uname(&sys_info) == 0) {
printf("System Information:\n");
printf(" System Name: %s\n", sys_info.sysname);
printf(" Node Name: %s\n", sys_info.nodename);
printf(" Release: %s\n", sys_info.release);
printf(" Version: %s\n", sys_info.version);
printf(" Machine: %s\n", sys_info.machine);
} else {
perror("uname");
}

// Get hostname
if (gethostname(hostname, sizeof(hostname)) == 0) {
printf(" Hostname: %s\n", hostname);
} else {
perror("gethostname");
}

// Get uptime and memory information
if (sysinfo(&mem_info) == 0) {
printf("Memory and Uptime Information:\n");
printf(" Uptime: %ld seconds\n", mem_info.uptime);
printf(" Total RAM: %ld MB\n", mem_info.totalram / 1024 / 1024);
printf(" Free RAM: %ld MB\n", mem_info.freeram / 1024 / 1024);
printf(" Shared RAM: %ld MB\n", mem_info.sharedram / 1024 / 1024);
printf(" Buffered RAM: %ld MB\n", mem_info.bufferram / 1024 / 1024);
printf(" Total Swap: %ld MB\n", mem_info.totalswap / 1024 / 1024);
printf(" Free Swap: %ld MB\n", mem_info.freeswap / 1024 / 1024);
printf(" Process Count: %d\n", mem_info.procs);
} else {
perror("sysinfo");
}

// Get processor type
FILE *cpu_info = fopen("/proc/cpuinfo", "r");
if (cpu_info) {
char line[256];
printf("Processor Information:\n");
while (fgets(line, sizeof(line), cpu_info)) {
if (strncmp(line, "model name", 10) == 0) {
printf(" %s", line + 13); // Skip "model name : "
break;
}
}
fclose(cpu_info);
} else {
perror("/proc/cpuinfo");
}

return 0;
}






Copy the code and save as a .c file

For ex: sys_info.c



Compile and Run:




CODE
gcc sys_info.c -o sys_info
./sysinfo






end



There are some 36 million lines of C code in the Linux kernel. Learning a bit of C allows you to take a look 'under the hood' at some of the low-level elements and processes of the Linux operating system.



Stay tuned for more articles on learning the Linux OS. Next up is a 'mini-shell' written in C - a simplified version of the Bash shell that is educational and fun to play around with.



Ben Santora - December 2024

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Create a Linux System Info Utility in C

Thematisch verwandte Begriffe: Create, Linux, System, Info · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...