# Automated Linux System Information Gathering via Custom Scripts

In a distributed enterprise environment, manual hardware audits are impractical and time-consuming. This technical guide outlines how to leverage the [Execute Custom Script](https://www.hexnode.com/mobile-device-management/help/how-to-create-and-execute-custom-scripts-on-linux/) capability in Hexnode UEM to pull high-fidelity system information and runtime command output from Linux endpoints using a Bash-based diagnostic tool.

By deploying this script, IT administrators move from reactive troubleshooting to data-driven infrastructure management, allowing them to validate whether Ubuntu, Fedora, or Debian workstations adhere to organizational performance and security requirements.

**Core Technical Capabilities** 
--------------------------------

The diagnostic script targets specific Linux sub-systems to extract actionable telemetry:

- **Kernel & Distro Mapping:** Uses uname and /etc/\*release parsing to identify the exact Linux environment. This is critical for ensuring security patches and kernel updates are correctly targeted.
- **Resource Profiling:** Utilizes lscpu and free -h to map static physical hardware architecture against real-time resource utilization.
- **Process Forensics:** Employs ps with memory sorting to identify high-consumption processes that may require administrative review.
- **Network Topology:** Uses ip -brief to provide a snapshot of connectivity and IP assignments without the clutter of verbose command outputs.

**Enterprise Use Cases & Hexnode Integration** 
---------------------------------------------------

Integrating this script into your Hexnode UEM workflow transforms raw data into actionable intelligence across four key scenarios:

### **1. Pre-Deployment Hardware Audits** 

Before rolling out resource-intensive software (such as CAD tools or Docker environments), admins can deploy this script via Hexnode to a “Pilot Group.”

**Hexnode Advantage:** Instead of logging into each machine, the Action History tab captures the output of hardware commands. Admins can verify if devices meet minimum requirements (e.g., 2 CPU cores, 4GB RAM, 20GB disk space, and 64-bit architecture).

### **2. Incident Response & Performance Debugging** 

When an employee reports a “slow” machine, the first step is identifying the bottleneck.

**Scenario:** An admin executes the script on a specific device via the Hexnode dashboard.

**Hexnode Advantage:** The Top 5 Processes by Memory Usage section immediately reveals if an enterprise app is leaking memory, allowing for targeted corrective actions.

### **3. Fleet-Wide Compliance & Lifecycle Management** 

Identify kernel versions that require updates based on internal security policies.

**Scenario:** Run the script across the entire Linux fleet to gather uname -r data.

**Hexnode Advantage:** By reviewing the logs in Action History, admins can identify outdated kernels and schedule mandatory OS updates via Hexnode’s policy engine.

### **4. Post-Onboarding Verification** 

Ensure new workstations are provisioned with the correct hostname and network configurations.

**Hexnode Advantage:** Use the script as a “Final Check” in the onboarding sequence. The ip -brief addr output confirms the device is correctly positioned within the corporate VLAN.

**Technical Implementation: The Diagnostic Script** 
----------------------------------------------------

Copy the Bash code below and save it as a .sh file (e.g., sys\_audit.sh).

Bash script to change user password in Linux

\#!/bin/bash # System Information Script echo "=====================================" echo " Linux System Information " echo "=====================================" # Hostname and OS echo "Hostname: $(hostname)" echo "OS: $(uname -o)" echo "Kernel: $(uname -r)" echo "Architecture: $(uname -m)" echo "Distribution: $(cat /etc/\*release | grep PRETTY\_NAME | cut -d= -f2)" # CPU Info echo "-------------------------------------" echo "CPU Information:" lscpu | grep -E 'Model name|Socket|Core|Thread|MHz' # Memory Info echo "-------------------------------------" echo "Memory Information:" free -h # Disk Usage echo "-------------------------------------" echo "Disk Usage:" df -h --total | grep total # Top 5 Processes by Memory Usage echo "-------------------------------------" echo "Top 5 Processes by Memory Usage:" ps -eo pid,comm,%mem,%cpu --sort=-%mem | head -n 6 # Network Info echo "-------------------------------------" echo "Network Interfaces:" ip -brief addr echo "=====================================" echo " End of System Information Report " echo "=====================================" 

   1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

  \#!/bin/bash 

\# System Information Script 

echo "====================================="

echo " Linux System Information "

echo "====================================="

\# Hostname and OS 

echo "Hostname: $(hostname)"

echo "OS: $(uname -o)"

echo "Kernel: $(uname -r)"

echo "Architecture: $(uname -m)"

echo "Distribution: $(cat /etc/\*release | grep PRETTY\_NAME | cut -d= -f2)"

\# CPU Info 

echo "-------------------------------------"

echo "CPU Information:"

lscpu | grep -E 'Model name|Socket|Core|Thread|MHz'

\# Memory Info 

echo "-------------------------------------"

echo "Memory Information:"

free -h

\# Disk Usage 

echo "-------------------------------------"

echo "Disk Usage:"

df -h --total | grep total

\# Top 5 Processes by Memory Usage 

echo "-------------------------------------"

echo "Top 5 Processes by Memory Usage:"

ps -eo pid,comm,%mem,%cpu --sort=-%mem | head -n 6

\# Network Info 

echo "-------------------------------------"

echo "Network Interfaces:"

ip -brief addr 

echo "====================================="

echo " End of System Information Report "

echo "=====================================" 

   

 

  

**Deployment Steps** 
---------------------

### **Step 1: Validation** 

Test the script locally on a single test machine before mass deployment:

chmod +x sys\_audit.sh && ./sys\_audit.sh

### **Step 2: Hexnode Deployment** 

The script can be deployed in two ways:

#### **A. Direct Actions (One-time)** 

1. Navigate to **Manage > Devices**.
2. Select the target Linux device(s).
3. Click **Actions > Execute Custom Script**.
4. Upload the .sh file and execute.

#### **B. Automation (Scheduled)** 

1. Navigate to **Automate > Linux**.
2. Upload the .sh file and define the schedule (interval).
3. Add target Linux devices or groups and **Save**.

### Step 3: Verifying Results 

Once the script is deployed, IT admins must verify the output in the portal:

1. Navigate to **Manage > Devices**.
2. Select the specific Linux device.
3. Select **Action History** and click **Show Output**.

Hexnode UEM displays the generated output, showing details like hostname, OS version, Kernel version, architecture, and current CPU/RAM utilization.

[![Script for Linux system information gathering](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2026/03/Linux-system-information-gathering-scaled.png)](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2026/03/Linux-system-information-gathering-scaled.png "Linux system information gathering")

### Summary Table for Administrators 

Information Category Command Used Enterprise Value Identity uname, /etc/\*release Compliance and Patch Management CPU/RAM lscpu, free -h Capacity Planning and Upgrades Storage df -h Proactive Maintenance (Disk space alerts) Processes ps -eo … Security Visibility and Performance Debugging Networking ip -brief Connectivity Troubleshooting  Note: 
It is highly recommended to manually validate script execution on a test system before bulk deployment. Hexnode is not responsible for any damage or loss resulting from the behavior of custom scripts.