Skip to main content

Command Palette

Search for a command to run...

Linux file

Updated
6 min read
Linux file

1. /etc — Where the System Learns How to Behave

A deep dive into the most important directory in Linux — the one that stores all the rules your system lives by.

When you first start using Linux, the file system can feel like a maze of random folders. You see names like /bin, /usr, /var, and /etc, and none of them seem to tell you much about what they contain.

But spend a little time inside /etc, and you will quickly realize it is unlike any other directory. It is not just storing data — it is storing decisions. Every file inside /etc is a rule, a preference, or an instruction that the system reads to figure out how it should behave.

Think of /etc as the control panel of your entire Linux system. While programs and binaries live elsewhere, the instructions that tell those programs what to do, where to look, and who to trust — all of that lives in /etc.

This design philosophy is one of Linux's greatest strengths: behavior is not baked into programs. It is stored in human-readable configuration files that anyone can open, read, and modify.


Reading the Key Files

cat /etc/hosts
cat /etc/resolv.conf
cat /etc/passwd

/etc/hosts

127.0.0.1 localhost
192.168.1.10 myserver.local

This file is essentially a manual phone book for your computer. Before your machine even contacts a DNS server on the internet, it checks this file first.

If the domain is listed here, it uses the IP address you specified — no network request needed. System administrators use this to redirect traffic, block websites, or set up local development environments.

0.0.0.0 ads.example.com

This blocks access completely — using just a text file.


/etc/resolv.conf

nameserver 8.8.8.8

This tells your system which DNS server to contact when resolving domain names.

If this file is empty or incorrect:

  • Websites will not load

  • Internet will appear broken

  • But the network is actually working fine


/etc/passwd

alice:x:1001:1001:Alice:/home/alice:/bin/bash

Format:

username:x:UID:GID:comment:home_directory:shell

This file stores user information such as username, UID, home directory, and shell. The actual password is stored securely in /etc/shadow.


Why This Design Matters

Linux stores configuration in files instead of hardcoding behavior into programs. This gives:

  • Flexibility

  • Transparency

  • Easy debugging

You can change system behavior without modifying source code.


Key Insight

Editing a file in /etc is not just editing text — it is changing how the system behaves.

2. DNS — The Hidden Step Behind Every Website

Every time you open a browser and type a URL, an invisible process happens before anything loads. That process is DNS.

Computers understand IP addresses, not domain names.

google.com → 142.250.190.46

DNS converts human-friendly names into machine-friendly IP addresses.


How Linux Resolves a Domain

  1. Check /etc/hosts

  2. Check /etc/resolv.conf

  3. Query DNS server

  4. Receive IP address

  5. Establish connection


Commands That Reveal It

cat /etc/resolv.conf
ping google.com
dig google.com
nslookup google.com

When DNS Breaks

ping 8.8.8.8
ping google.com

If the first works and the second fails:

  • Internet is working

  • DNS is broken


Key Insight

Most "internet is down" problems are actually DNS problems.

3. Routing — How Linux Decides Where Data Goes

DNS gives the IP address. Routing decides how to reach it.

The Linux kernel uses a routing table to decide where packets should go.


View Routing Table

cat /proc/net/route
ip route show
route -n

Example Routing Table

Destination Gateway Interface Meaning
192.168.1.0/24 0.0.0.0 eth0 Local network
0.0.0.0/0 192.168.1.1 eth0 Default route
10.8.0.0/24 0.0.0.0 tun0 VPN

Important Concept

Applications do not control routing. The kernel does.


Modify Routes

sudo ip route add 10.0.0.0/8 via 192.168.1.254
sudo ip route del default
sudo ip route add default via 192.168.1.1

Key Insight

Networking decisions are made by the kernel using routing tables.

4. /proc — A Live Window Into the System’s Brain

/proc looks like a folder, but it is not a real directory. It is created by the kernel in real time.

When you read files inside /proc, you are reading live system data — not disk data.


Key Files

/proc/cpuinfo
/proc/meminfo
/proc/uptime
/proc/net/route
/proc/loadavg

Example

cat /proc/meminfo

Every time you run it, values change.


Processes

echo $$
ls /proc/$$

Each process has its own directory.


Key Insight

/proc is a live interface to the kernel.

5. /dev — When Hardware Becomes a File

Linux treats hardware as files.


Examples

/dev/sda
/dev/null
/dev/zero
/dev/random
/dev/tty

/dev/null

echo "hello" > /dev/null
ls error 2> /dev/null

Output disappears completely.


Disk Operations

sudo dd if=/dev/zero of=/dev/sdb bs=1M count=100
sudo dd if=/dev/sda of=backup.img

Key Insight

Hardware is accessed through the same interface as files.

6. Users & Permissions — Transparency and Security

Linux manages users using simple text files and a permission system enforced by the kernel.


/etc/passwd

cat /etc/passwd

Format

username:x:UID:GID:comment:home:shell

Permissions

ls -l file.txt
-rw-r--r--

Modify Permissions

chmod 000 file.txt
chmod 644 file.txt
chmod 755 script.sh

Key Insight

Permissions are enforced by the kernel — not applications.

7. Services & Boot — How Linux Comes to Life

Linux follows a structured boot process.


Boot Flow

  1. BIOS / UEFI

  2. GRUB

  3. Kernel

  4. systemd

  5. Services


/boot

ls /boot

Service Example

[Unit]
Description=Web Server
After=network.target

[Service]
ExecStart=/usr/sbin/nginx
Restart=on-failure

[Install]
WantedBy=multi-user.target

Commands

systemctl status nginx
systemctl start nginx
systemctl stop nginx
systemctl enable nginx
journalctl -u nginx -f

Key Insight

Nothing runs randomly — everything is defined and controlled.


Final Understanding

Linux works as a connected system:

  • /etc → configuration

  • /proc → system state

  • /dev → hardware

  • routing → networking

  • permissions → security


Conclusion

Linux is not just commands. It is a transparent, logical system where everything is visible and connected.

Once you understand this structure, Linux becomes predictable, powerful, and much easier to master.