Operations 4 min read

Extracting System Configuration Using Linux Commands

This tutorial explains how to capture IP addresses, filter empty lines, count regular files in /bin, copy the inittab file, and count non‑comment configuration lines on a Linux host using standard shell commands such as ifconfig, grep, ls, cp, and wc.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Extracting System Configuration Using Linux Commands

This guide demonstrates how to extract and process system configuration information on a Linux host using standard command‑line tools.

Problem: Save all IP addresses to a file, remove empty lines, count regular files in /bin, copy /etc/inittab to the current directory, and count non‑comment, non‑empty lines in the copied file.

Solution overview: Use ifconfig to capture IP data, grep with appropriate options to filter lines, ls and wc to count files, cp to copy, and a pipeline of grep and wc to count effective configuration lines.

Step 1 – Store IP information: ifconfig > ipadd.txt

Step 2 – Display the file without empty lines: grep -v ^$ ipadd.txt

Step 3 – Count regular files in /bin (excluding shortcuts): ls -l /bin/* | grep ^- | wc -l

Step 4 – Copy /etc/inittab to the current directory as init.txt : cp /etc/inittab init.txt

Step 5 – Count effective configuration lines in init.txt (exclude lines starting with # and empty lines): grep -v ^# init.txt | grep -v ^$ | wc -l

The commands produce the expected outputs, e.g., the ls pipeline returns 94 files and the final count of valid configuration lines is 1 .

LinuxshellbashSystem Configurationgrep
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.