brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: w is the first security check when a server feels off

Security
~/tips/tip-security-w-who-is-logged-in

w

Shows who is logged in right now, from where, and what they are running.

When a server behaves strangely, the first thing I want to know is whether someone else is on it. w answers that in one screen.

It prints one line per login session: the user, the terminal, where the login came from, how long it has been idle and the command that session is running right now.

w
w -i
w alice

The header line also gives you the uptime and the load average, so you get a quick health check for free. With -i you see the IP address instead of a host name, which is handy when reverse DNS gives you something vague. Add a user name to see only that account.

What to look for: a login from an address you don’t recognise, a session that has been idle for days (someone forgot to log out, or a tmux session nobody remembers), and the WHAT column. A shell running something like a miner or an nc listener stands out fast.

One limit to keep in mind. w reads the utmp records, so it only lists sessions that registered a login. A process started by a hacked web app or a cron job never shows up here. For those you still need ps or ss. I see w as the cheap first glance, not as proof that nobody is there.

Further reading: w(1) manual page

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link