Home Wiki Programming & Logic Linux for Engineers: The OS Behind Every Industrial Server
Programming & Logic

Linux for Engineers: The OS Behind Every Industrial Server

Why Linux for Industrial Engineers?

In industrial automation, most SCADA servers, IoT platforms, and modern control systems run on Linux. The reasons: it is free and open source, stable enough for servers to run for years without rebooting, lightweight enough to run on minimal hardware, and secure by design.

Whether you are managing a SCADA server, setting up a Raspberry Pi as a data collection unit, or connecting to a remote controller -- Linux is an essential skill for every modern industrial engineer.

The Terminal: Your Primary Tool

In Linux, the terminal is the command center. Everything can be controlled with text commands -- from managing files to restarting services.

Navigation and File Commands

# Where am I?
pwd
# Output: /home/engineer

# What files are here?
ls -la
# Shows all files with details (permissions, size, date)

# Change directory
cd /var/log/scada

# Show the last 50 lines of the system log
tail -50 /var/log/syslog

# Search for "error" in the SCADA log
grep "error" /var/log/scada/server.log

# Find all configuration files
find /etc -name "*.conf" -type f

Create, Copy, Move, and Delete

# Create a directory for sensor data
mkdir -p /data/sensors/2025/december

# Copy a config file with a backup
cp /etc/scada/config.yaml /etc/scada/config.yaml.backup

# Move old logs to the archive
mv /var/log/scada/old_*.log /archive/logs/

# Delete temporary files older than 30 days
find /tmp -name "*.tmp" -mtime +30 -delete

The File System: The Map

Linux organizes everything as a single tree starting from / (the root):

/
├── bin/       -> Essential commands (ls, cp, mv)
├── etc/       -> Configuration files (SCADA settings live here)
├── home/      -> User home directories
├── var/       -> Variable data (logs, databases)
│   ├── log/   -> System and application logs
│   └── lib/   -> Application data
├── opt/       -> Third-party software (SCADA is often installed here)
├── tmp/       -> Temporary files (cleared on reboot)
├── dev/       -> Device files (USB, serial ports)
└── proc/      -> Information about running processes

Important note: In Linux, serial ports appear as files:

# Arduino connected via USB
ls /dev/ttyUSB0
# or
ls /dev/ttyACM0

# Read data from the serial port directly
cat /dev/ttyUSB0

Permissions: Who Can Do What?

Every file in Linux has three permission levels:

-rwxr-xr--  1  engineer  scada  4096  Dec 20  config.yaml
│├──┤├──┤├──┤
│ │   │   └── Others: read only
│ │   └────── Group: read + execute
│ └────────── Owner: read + write + execute
└──────────── File type (- = file, d = directory)

r = read (4), w = write (2), x = execute (1)

# Make the startup script executable
chmod +x /opt/scada/start.sh

# Numeric permissions: owner=all, group=read+execute, others=none
chmod 750 /opt/scada/start.sh

# Change file ownership to the scada user
chown scada:scada /etc/scada/config.yaml

In industrial environments: never run SCADA services as root. Create a dedicated user with the minimum required privileges.

Service Management with systemd

systemd is the init system that manages all services in modern Linux. It starts services automatically at boot, monitors them, and restarts them if they crash.

Essential Commands

# Check SCADA service status
systemctl status scada-server

# Stop and start
systemctl stop scada-server
systemctl start scada-server
systemctl restart scada-server

# Enable automatic start at boot
systemctl enable scada-server

# View service logs (last 100 lines)
journalctl -u scada-server -n 100

# Follow logs in real time
journalctl -u scada-server -f

Creating a Custom Service

Create a service that reads sensor data and sends it to the server:

# /etc/systemd/system/sensor-collector.service
[Unit]
Description=Industrial Sensor Data Collector
After=network.target
Wants=network-online.target

[Service]
Type=simple
User=scada
Group=scada
WorkingDirectory=/opt/sensor-collector
ExecStart=/opt/sensor-collector/collect.sh
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal

# Security hardening
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
# Activate the new service
sudo systemctl daemon-reload
sudo systemctl enable sensor-collector
sudo systemctl start sensor-collector

SSH: Remote Access

SSH (Secure Shell) lets you control a remote Linux server securely. In a factory, you connect from your office to the SCADA server in the control room.

# Basic connection
ssh engineer@192.168.1.100

# Connection on a different port
ssh -p 2222 engineer@scada-server.factory.local

# Copy a file from the server to your machine
scp engineer@192.168.1.100:/var/log/scada/today.log ./

# Copy a config file to the server
scp config.yaml engineer@192.168.1.100:/etc/scada/

SSH Keys: Passwordless Connection

Generate a key pair once, and you will never need to type a password again:

# Generate a key pair
ssh-keygen -t ed25519 -C "engineer@factory"

# Copy the public key to the server
ssh-copy-id engineer@192.168.1.100

# Now connect without a password
ssh engineer@192.168.1.100

Package Management

Linux uses a package manager to install and update software. On Ubuntu/Debian:

# Update the available package list
sudo apt update

# Upgrade all installed packages
sudo apt upgrade

# Install useful tools
sudo apt install htop          # interactive process monitor
sudo apt install net-tools     # network tools (ifconfig, netstat)
sudo apt install mosquitto     # MQTT broker for IoT
sudo apt install python3-pip   # Python package manager

# Search for a package
apt search modbus

# Remove a package
sudo apt remove package-name

System Monitoring

Processes and Resources

# Running processes (snapshot)
ps aux | grep scada

# Interactive monitoring (like Task Manager)
htop

# Disk usage
df -h

# Memory usage
free -h

# What is consuming the most disk space?
du -sh /var/log/* | sort -rh | head -10

Network Monitoring

# Device IP addresses
ip addr show

# Is the server listening on the expected port?
ss -tlnp | grep 8080

# Test connectivity to another device
ping 192.168.1.50

# Trace the packet path
traceroute 192.168.1.50

# Monitor network traffic on a specific port
sudo tcpdump -i eth0 port 502   # monitor Modbus traffic

Bash Scripts: Automating Tasks

Instead of repeating the same commands daily, write a script that does it automatically:

#!/bin/bash
# /opt/scripts/daily-maintenance.sh
# Daily maintenance script for SCADA server

LOG_DIR="/var/log/scada"
BACKUP_DIR="/backup/logs"
DATE=$(date +%Y-%m-%d)

echo "[$DATE] Starting daily maintenance..."

# 1. Archive old logs
find $LOG_DIR -name "*.log" -mtime +7 -exec gzip {} \;
mv $LOG_DIR/*.gz $BACKUP_DIR/

# 2. Check disk space
USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$USAGE" -gt 85 ]; then
  echo "WARNING: Disk usage at ${USAGE}%"
  # Send alert via email or API
fi

# 3. Check service status
for service in scada-server sensor-collector mosquitto; do
  if ! systemctl is-active --quiet $service; then
    echo "ERROR: $service is down! Restarting..."
    systemctl restart $service
  fi
done

# 4. Back up configuration files
tar -czf $BACKUP_DIR/config-$DATE.tar.gz /etc/scada/

echo "[$DATE] Daily maintenance complete"
# Make the script executable
chmod +x /opt/scripts/daily-maintenance.sh

# Add it to cron to run daily at 2 AM
crontab -e
# Add the line:
# 0 2 * * * /opt/scripts/daily-maintenance.sh >> /var/log/maintenance.log 2>&1

Summary

Skill Industrial Use
Terminal Daily server management
Permissions Securing control systems
systemd Managing SCADA and IoT services
SSH Secure remote access
Package management Installing and updating software
Bash scripts Automating repetitive tasks

Linux is not just an operating system -- it is the working environment of the modern industrial engineer. Everything covered here will be used daily when managing smart factory systems.

Linux command-line bash permissions systemd SSH لينكس سطر الأوامر الصلاحيات الخدمات إدارة الخوادم الطرفية