Education › Forward Deployed › Stage 1: The role & engineering foundations

Linux and the shell in someone else's environment

Finding your way on unfamiliar machines without root: processes, logs, disks, permissions, and the commands that answer 'why is it broken?'

Beginner ~35 min read Module 2 of 20

On your own laptop you have root, your tools and unlimited time. At a customer site you often get a jump host, a shared account, an unfamiliar distribution, no internet, a change window that closes in forty minutes and someone watching over your shoulder. This lesson adapts core Linux skills to that reality: orienting yourself on an unknown machine in two minutes, working without root, answering the classic "why is it broken?" questions from processes, disks, logs and the network, and leaving a clean trail so the customer trusts you with access next time.

After this module you can
  • Orient yourself on an unfamiliar Linux host quickly and safely
  • Diagnose CPU, memory, disk, process and service problems without root
  • Read logs with journalctl and log files to find the first real error
  • Test network paths from inside the customer's environment
  • Work in a way that is recorded, reversible and respectful of the customer's systems

The first two minutes on a new machine

Before changing anything, find out where you are and what you are allowed to do. These commands are read-only and work as an ordinary user on almost every distribution.

Orientation: who, where, what, how much
bash
whoami; id                      # your user and groups
hostname -f; uname -r           # which machine, which kernel
cat /etc/os-release             # distribution and version
uptime                          # load averages and time since boot
df -h; free -h                  # disk and memory at a glance
sudo -n -l 2>/dev/null || echo "no passwordless sudo"
  • Note the distribution family: package names, service names and log locations differ between Red Hat-style and Debian-style systems.
  • Check sudo -l (or ask): many customers grant narrow sudo rules, such as restarting one service, rather than full root.
  • Find the shared conventions: where applications live (/opt, /srv), where logs go, which user the service runs as.
  • Start script or a terminal recorder if the customer allows it, so you have a record of what you ran.

Processes, memory and disk

Who is using the machine?
bash
ps aux --sort=-%mem | head -15       # top memory consumers
ps aux --sort=-%cpu | head -15       # top CPU consumers
top -b -n 1 | head -20               # snapshot, works without an interactive terminal
du -xh --max-depth=1 /var 2>/dev/null | sort -h | tail
find /tmp -xdev -size +500M 2>/dev/null

Full disks cause a startling variety of symptoms: databases refusing writes, services that will not start, logins that hang. df -h shows space; df -i shows inodes, which can run out on systems with millions of tiny files even when space remains. A deleted file still held open by a process keeps its space until the process restarts; lsof +L1 lists those if lsof is installed.

Watch out

Never delete files on a customer machine to free space without asking who owns them. Propose what to remove, get agreement, and prefer compressing or moving logs over deleting them.

Services and logs

Most long-running software on modern Linux is managed by systemd. You can usually read service state and logs without root, even if you cannot restart services.

Is it running, and what did it say?
bash
systemctl status myapp --no-pager          # state, PID, last log lines
systemctl list-units --failed --no-pager   # anything that crashed
journalctl -u myapp --since "1 hour ago" --no-pager | tail -50
journalctl -p err -b --no-pager | tail -30  # errors since boot
tail -F /var/log/myapp/app.log             # follow a file log

Find the first error, not the loudest. A failed database connection at 09:02 explains the hundreds of request errors that follow it. Search with grep -n -i -m 20 'error\|exception\|denied\|refused' and then read the lines just before the first match. Permission problems often hide in the path: namei -l /path/to/file shows the owner and mode of every directory on the way, which is how you discover the parent directory nobody can enter.

Network checks from inside

The customer's network is the most common reason things work on your laptop and fail on their server. Test the exact path your software will use, from the machine it will run on.

Can this host reach that service?
bash
getent hosts api.internal.example        # name resolution via system resolver
nc -zv db.internal.example 5432          # is the TCP port reachable?
curl -sv https://api.internal.example/health -o /dev/null 2>&1 | grep -E 'Connected|SSL|HTTP/'
env | grep -i proxy                      # HTTP_PROXY / HTTPS_PROXY / NO_PROXY in effect
ss -tlnp 2>/dev/null | head              # what is listening locally
  • getent uses the same resolver as applications; dig and nslookup may query different servers and mislead you.
  • If nc connects but curl fails, the problem is above TCP: TLS, a proxy, or the application.
  • Corporate proxies are often required for outbound traffic and must be excluded for internal hosts with NO_PROXY; the next lessons cover this in depth.

Working like a guest

  • Read before you write. Gather evidence with read-only commands first and share what you found before proposing a change.
  • Change one thing at a time, with a rollback ready: copy a config to file.bak.YYYYMMDD before editing it.
  • Use the customer's change process. If changes need a ticket or a window, use it, even for small ones.
  • Use tmux or screen on jump hosts so a dropped VPN does not kill a long-running command.
  • Collect, do not exfiltrate. If you need logs off the machine, agree what may leave, redact secrets and personal data, and use the customer's approved transfer method.
  • Leave it as you found it: remove temporary files and tools you installed, and write down what you changed.
Tip

End each access session with a three-line note to the customer: what you looked at, what you changed (or 'no changes'), and what happens next. It builds the trust that gets you access faster next time.

Hands-on practice

Troubleshoot a machine you did not build

  1. Start a fresh Linux VM or container (any distribution you are less familiar with) and create an unprivileged user; log in as that user.
  2. Run the orientation commands and write a five-line summary of the machine.
  3. As root in another session, create a problem: fill a small filesystem, or make a service's log directory unreadable, or stop a dependency.
  4. Back as the unprivileged user, find the cause using only read-only commands and logs, and write down the evidence.
  5. Propose the fix as you would to a customer: what to change, the risk, and the rollback.
  6. Apply it, verify, and write the three-line end-of-session note.
Cheat sheet

Linux and the shell in someone else's environment — at a glance

Main things to focus on

  • Orient first: user, host, distribution, load, disk, memory, sudo rights.
  • Gather evidence read-only before proposing changes.
  • Find the first error in the logs, not the loudest.
  • Test network paths from the machine the software runs on.
  • Check inodes and deleted-but-open files when disks look full.
  • Record, back up, change one thing, leave a note.

Orientation

whoami; id; hostname -fIdentity and machine
cat /etc/os-release; uname -rDistribution and kernel
uptime; df -h; df -i; free -hLoad, disk, inodes, memory
sudo -n -lWhat you may run as root

Processes and files

ps aux --sort=-%mem | headMemory hogs
top -b -n 1One-shot snapshot
du -xh --max-depth=1 DIR | sort -hWhat fills a directory
lsof +L1Deleted files still held open
namei -l PATHPermissions along a path

Services and logs

systemctl status SVC --no-pagerState and recent logs
systemctl list-units --failedCrashed units
journalctl -u SVC --since "1 hour ago"Service logs
journalctl -p err -bErrors since boot

Network

getent hosts NAMEResolve like applications do
nc -zv HOST PORTTCP reachability
curl -sv URL -o /dev/nullTLS and HTTP details
env | grep -i proxyProxy settings in effect
ss -tlnpLocal listeners

Common pitfalls

  • Changing configuration before collecting evidence.
  • Deleting files to free space without asking who owns them.
  • Trusting dig when the application uses the system resolver.
  • Running long commands on a jump host without tmux.
  • Copying logs with secrets or personal data off the customer's network.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →