How do I know whether a command runs locally or on the server?
A command runs in the shell currently accepting your input. Before making a change, verify the computer name and account instead of relying only on the prompt. An SSH session remains remote until it exits.
Instructions
1. Record your local identity
Run these checks before connecting. Keep the local computer name in mind when moving between several tabs.
hostname
whoamiBoth commands report the Windows machine and account where this PowerShell session runs.
2. Check the remote Linux identity
After connecting, read the server identity and current directory. The account may differ from the one used on your Windows PC.
hostname
whoami
pwdThese read-only commands show the remote hostname, login account and working directory. Confirm them against your intended server.
3. Return to the Windows shell
Complete or deliberately detach any foreground work before ending an SSH session. Then check the hostname again.
exitThis closes the current remote shell. If you opened nested SSH sessions, each exit moves back one session.
Check the result
- The remote hostname matches the server you intend to manage.
- After exit, hostname again returns your local computer name.
Troubleshooting
- The prompt looks unchanged
- Prompts are configurable. Trust hostname and the session sequence rather than colours or symbols.
- The terminal closes completely
- You may have exited the original local shell. Reopen a terminal; do not assume a remote task stopped without checking its service or job state.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
