You must give the monitoring agent permission to read every process's `/proc/<pid>/` info and bind to port 162 without running as root. How?
AdvancedScenarioUsers, groups and access control
Answer
Situation read → Use Linux capabilities instead of root.
What I'd do →
- In the systemd unit:
[Service]
User=monagent
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
NoNewPrivileges=yes
systemctl daemon-reload && systemctl restart monagent.- Verify:
grep Cap /proc/$(pidof monagent)/status | xargsand decode withcapsh --decode=....
Why → Capabilities split root into small privileges; the bounding set guarantees the process can never gain more.
Interview tip → Prefer AmbientCapabilities in systemd over setcap on the binary, because file caps get lost on package upgrades.
More on Users, groups and access control
You need to onboard 50 new developers onto a shared build server, each with their own account and SSH key. How do you do it?BeginnerThree teams share one server and each needs a project directory only its members can write to, with new files staying group-owned. How do you set it up?BeginnerA junior engineer needs to restart nginx but must not get full root. How do you grant that?BeginnerAn engineer leaves the company today. What do you do with their Linux account on 30 servers?BeginnerA service account for a backup tool must exist on every server but nobody should be able to log in as it. How do you create it?BeginnerYour security team requires passwords to expire every 90 days for human users only. How do you implement it?Beginner