sodcalculator

10 Tech How-To

Safely Explore an Unfamiliar Linux Server

Guide 10-12425 · Updated · Step by step

This guide shows you how to explore an unfamiliar Linux server from the shell without breaking anything. You’ll learn a safe, read-only routine to understand what the system is, what it runs, and how it’s configured — before you touch a single file. You need SSH access (even read-only) and a basic comfort with the command line.

What You’ll Need

  • SSH client (OpenSSH on Linux/macOS, PuTTY or Windows Terminal on Windows)
  • Login credentials (username and password or SSH key) for the server
  • Network access to the server’s IP or hostname
  • Basic familiarity with the terminal (cd, ls, cat)

Step-by-Step

  1. Connect with SSH. Open your terminal and run: ssh username@server_ip. If you’re using a key, add -i /path/to/key. If the port is non-standard, use -p port_number.
  2. Identify the OS and kernel. Run cat /etc/os-release to see the distribution name and version. Then uname -a for kernel details. This tells you what you’re dealing with (Ubuntu, CentOS, etc.) and its age.
  3. Check who you are and your privileges. Run whoami and id. If you’re not root, you’ll have limited read access to some files — that’s fine for exploration. If you are root, be extra careful: you can break things with a single mistyped command.
  4. Check system uptime and load. Run uptime to see how long the server has been up and its load average. A high load (e.g., 10 on a 4-core machine) suggests a busy or misbehaving system.
  5. Look at running processes. Run ps aux --sort=-%mem | head -20 to see the top memory-consuming processes. This shows you what services are running (nginx, mysql, java, etc.) and who owns them.
  6. Check open network ports. Run ss -tulpn (or netstat -tulpn if ss is missing). This lists listening ports and the associated services. Note: you may need sudo to see process names; without it, you’ll still see ports.
  7. Inspect disk usage. Run df -h to see filesystem usage. A full disk (100%) can cause serious issues. Then use du -h --max-depth=1 / 2>/dev/null | sort -h | tail -20 to find the largest directories (you may need sudo for a full picture).
  8. List users and recent logins. Run cat /etc/passwd to see user accounts (ignore system accounts). For recent logins, last shows a history. This helps you understand who uses the server.
  9. Check scheduled tasks (cron). Run crontab -l for your own cron jobs, and sudo crontab -l for root’s. Also check ls /etc/cron.d/ and cat /etc/crontab for system-wide jobs. This reveals automated tasks that might affect the system.
  10. Review system logs (read-only). Run sudo tail -50 /var/log/syslog (or /var/log/messages on RHEL-based systems). Look for errors, warnings, or unusual activity. This is a goldmine for understanding past issues.
  11. Check installed packages. On Debian/Ubuntu: dpkg -l | head -50. On RHEL/CentOS: rpm -qa | head -50. This shows what software is installed, which can hint at the server’s purpose.
  12. Look at the network configuration. Run ip addr to see IP addresses and interfaces. ip route shows the default gateway. This is useful for understanding the server’s network role.
  13. Check running services (systemd). Run systemctl list-units --type=service --state=running to see active services. This is more reliable than ps for seeing what’s managed.
  14. Take notes. As you explore, write down what you find. This helps you build a mental model and avoids re-running commands.

Common Mistakes

  • Running write commands out of curiosity. Avoid rm, mv, cp, dd, and any command that modifies files. Even touch changes timestamps.
  • Using sudo unnecessarily. Sudo gives you power; a typo like sudo rm -rf /var /log (with a space) can be catastrophic. Use sudo only when needed, and double-check the command.
  • Ignoring the current directory. If you’re in / and run rm -rf *, you’ll delete everything. Always check pwd before any destructive command.
  • Assuming the server is like your local machine. It may have different paths, no GUI, and stricter permissions. Don’t rely on muscle memory.
  • Killing processes you don’t recognize. That process might be critical. Just observe, don’t act.

Tips

  • Use read-only commands first. Commands like cat, ls, ps, df, and ss are safe. Build your understanding before considering any changes.
  • Use man to understand commands. If you’re unsure what a command does, man command gives you the manual. This is free and safe.
  • Create a snapshot of key files. Before reading, you can copy a file to /tmp for reference, but don’t modify the original.
  • Use grep to filter output. For example, ps aux | grep nginx to find nginx processes. This saves time and reduces noise.
  • Check the history file. cat ~/.bash_history (or ~/.zsh_history) can show what previous admins did. This is read-only and often revealing.
  • Look at /etc/hosts and /etc/hostname. These give clues about the server’s identity and role.

Troubleshooting

Permission denied errors. If you can’t read a file, it’s likely protected. Don’t try to bypass it with sudo unless you have legitimate access. If you need to see it, ask the system administrator.

Command not found. The server may have a minimal install. Try which command to see if it’s installed. If not, you can use alternatives (e.g., ss instead of netstat).

SSH connection refused. Check that the SSH service is running (systemctl status sshd) and that the port is open (firewall). If you can’t connect, you may need to use a console (e.g., out-of-band management).

Output is too long. Use less to paginate: ps aux | less. Or use head to limit lines. This prevents the terminal from scrolling.

System seems slow. Use top or htop to see live resource usage. If you see a runaway process, note its PID but don’t kill it without understanding what it is.

You accidentally made a change. If you modified a file, you can often restore it from backups if they exist. Check /etc for backup files (e.g., file.bak). If not, inform the admin immediately.

Frequently Asked Questions

Is it safe to run sudo commands as a read-only exploration?

Only if you know exactly what the command does. Many sudo commands are read-only (like sudo tail /var/log/syslog), but some are not. Always verify the command’s effect before running it with sudo.

Can I explore the server without SSH?

If you have physical or console access (e.g., via a web-based terminal), you can. But SSH is the standard remote method and works the same way.

What if I don’t have sudo access?

You can still explore a lot: your home directory, public system files (/etc/os-release, /proc), and process lists. You just won’t see protected files like other users’ home directories or some logs.

How do I know if a server is a web server, database server, etc.?

Check running processes (ps aux) and listening ports (ss -tulpn). If you see nginx or apache, it’s likely a web server. If you see mysqld or postgres, it’s a database server.

Is it okay to run top or htop? They might use CPU.

Yes, they are safe and use minimal resources. They are read-only monitoring tools. Just press q to exit.

What should I do if I find something suspicious (e.g., unknown process)?

Do not kill it. Note the PID, user, and command. Search online or consult with the system administrator. It could be a legitimate service you’re not aware of.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →