Linux Command Line Cheat Sheet for Windows Admins

Linux for the Windows and VMware admin: a Windows to Linux command translation table, where files live, and how packages, services, networking and firewalls differ per distribution.

First five minutes on a strange box

What am I even on
cat /etc/os-release
Is the service running
systemctl status nginx
Why did it stop
journalctl -u nginx -n 50
Is the disk full
df -h
What is listening
ss -tulpn
Get out of the editor
Esc then :q!
Read this before the command tables. Distributions disagree about package managers, firewalls and network configuration, and a command from the wrong family fails in a way that reads like a broken system. Every table below names the family it belongs to. Start with /etc/os-release and you will not guess.

Getting in from Windows

StepCommand, in PowerShell or cmd
Connect with the Windows OpenSSH client. Check it first with ssh -V.ssh zaur@10.0.0.21
Connect on another portssh -p 2222 zaur@10.0.0.21
First time it asks about a fingerprintType yes once. It is remembered in known_hosts.
Make a key instead of typing a passwordssh-keygen -t ed25519
Put that key on the serverssh-copy-id zaur@10.0.0.21
Send a file upscp report.csv zaur@10.0.0.21:/tmp/
Bring a file downscp zaur@10.0.0.21:/var/log/syslog .
Where did I landpwd and whoami
Do one thing as rootsudo systemctl restart nginx
Stay as root for a whilesudo -i, and exit to drop back
Leave the serverexit, or Ctrl+D
sudo is not quite UAC. There is no prompt on the screen to click: you type your own password, not root’s, and only if your account is allowed to. sudo -l lists what you may run. If the answer is nothing, the account was never granted it, and no amount of retrying changes that.
Password refused although it is correct? Many servers accept keys only. That is not a broken password, it is PasswordAuthentication no on the far side, and the fix is a key. The SSH cheat sheet covers keys, the config file, tunnels and file transfer in full.

Which family am I on

FamilyDistributions you will actually meet
RHEL familyRHEL, Rocky, AlmaLinux, Oracle Linux, CentOS Stream, Fedora
Debian familyDebian, Ubuntu, and most appliances built on them
SUSE familySLES, openSUSE Leap
Photon OSThe vCenter Server Appliance and several VMware appliances
AlpineContainers, rarely a full machine
QuestionCommand
Distribution and versioncat /etc/os-release
Kernel and architectureuname -a
Hostname, OS and virtualisationhostnamectl
Uptime and loaduptime
Am I rootid
Time and time zonetimedatectl

Windows to Linux

WindowsLinux
dirls -la
cd \cd /
type file.txtcat file.txt, or less file.txt for long output
copy / xcopy /Ecp / cp -r
move / renmv, which does both
del / rd /srm / rm -r
mdmkdir -p
robocopyrsync -avh --progress
findstr "text" filegrep "text" file
dir /s /b | findstr namefind / -name "name*" 2>/dev/null
tasklistps aux
taskkill /PID 123 /Fkill -9 123
taskkill /IM name.exe /Fpkill -9 name
Task Managertop, or htop if installed
sc query / net startsystemctl status / systemctl start
Event Viewerjournalctl
netstat -anoss -tulpn
ipconfig /allip a
route printip r
arp -aip neigh
nslookupdig, or host
tracerttraceroute, or tracepath
systeminfohostnamectl plus free -h and lscpu
diskpart / list volumelsblk -f and df -hT
icaclschmod and chown
takeownchown user:group file
schtaskscrontab -e, or a systemd timer
shutdown /r /t 0reboot
clsclear
where cmdwhich cmd
setenv
help cmd / cmd /?man cmd, or cmd --help
Run as administratorsudo before the command
Two traps that catch everyone. Paths are case sensitive, so /etc/Hosts is not /etc/hosts. And rm has no recycle bin and no confirmation: rm -rf on the wrong path is final.

Where things live

PathWhat it holds
/etcConfiguration. The closest thing to the registry, except it is text.
/var/logLog files
/home/userUser profiles. Root’s own home is /root.
/optThird-party software, the rough equivalent of Program Files
/usr/bin, /usr/sbinPrograms on the PATH
/tmpTemporary files, usually cleared on reboot
/mnt, /mediaMount points for other file systems
/proc, /sysKernel state presented as files, not real files on disk
Windows ideaLinux reality
Drive lettersOne tree from /. Other disks are mounted into it.
BackslashForward slash
Case-insensitive namesCase sensitive, always
Extension decides what runsThe execute bit decides. Extensions are a convention.
Hidden attributeA leading dot in the name, shown by ls -a
Recycle binNone from the command line
Locked files in useA running process keeps deleted files alive until it closes them

Packages, by family

TaskRHEL familyDebian family
Refresh metadatadnf check-updateapt update
Installdnf install nanoapt install nano
Removednf remove nanoapt remove nano
Update everythingdnf upgradeapt upgrade
Searchdnf search termapt search term
Which package owns a filerpm -qf /usr/bin/ssdpkg -S /usr/bin/ss
Is it installedrpm -q iproutedpkg -l iproute2
Other familiesInstall command
RHEL 7 and olderyum install nano
SLES and openSUSEzypper install nano
Photon OS, including the vCenter appliancetdnf install nano
Alpine, mostly containersapk add nano
Package names are not portable either. The same tool ships as iproute on RHEL and iproute2 on Debian, and ss or ip missing usually means the package is absent, not the system broken.

Services and logs, by family

TaskCommand
State of a servicesystemctl status sshd
Start, stop, restartsystemctl start|stop|restart sshd
Start at bootsystemctl enable --now sshd
Everything that failedsystemctl --failed
Logs for one servicejournalctl -u sshd -n 50
Follow, like tail -fjournalctl -u sshd -f
DetailRHEL familyDebian family
SSH service namesshdssh
General system log file/var/log/messages/var/log/syslog
Authentication log file/var/log/secure/var/log/auth.log
Admin group for sudowheelsudo
Mandatory access controlSELinux, getenforceAppArmor, aa-status
Editor that is always therevivi, usually nano as well
The service is not always called what you expect. systemctl restart ssh works on Ubuntu and fails on Rocky, where the unit is sshd. When in doubt, systemctl list-units --type=service | grep -i ssh.

Network and firewall, by family

TaskCommand, any modern distribution
Addresses, short formip -br a
Routing tableip r
Neighbours, the ARP cacheip neigh
Listening sockets with processesss -tulpn
Interface counters and errorsip -s link
Which DNS server is in usecat /etc/resolv.conf, or resolvectl status where systemd-resolved runs
Where the config livesDistribution
nmcli, NetworkManagerRHEL family, and Ubuntu with a desktop
/etc/netplan/*.yaml then netplan applyUbuntu Server 18.04 and later
/etc/network/interfacesDebian, and older Ubuntu
/etc/sysconfig/network-scripts/ifcfg-*RHEL 7 and older. Deprecated on RHEL 9.
wicked or YaSTSLES
/etc/systemd/network/*.networkPhoton OS and anything using systemd-networkd
Firewall taskRHEL family, firewalldUbuntu, ufw
Is it onfirewall-cmd --stateufw status
What is openfirewall-cmd --list-allufw status verbose
Open a portfirewall-cmd --add-port=8443/tcp --permanentufw allow 8443/tcp
Apply the changefirewall-cmd --reloadapplied immediately
ifconfig and netstat are not the answer any more. They come from the unmaintained net-tools package and are absent by default on RHEL 8 and later, on recent Ubuntu, and on most appliances. Use ip and ss: they are installed, and they report things the old tools cannot.

Surviving vi

GoalKeys
Start typingi
Stop typing, back to command modeEsc
Save and quit:wq
Quit, discarding everything:q!
Undo the last thing you didu
Delete the current linedd
Search/text then n for the next hit
Top and bottom of the filegg and G
Go to line 42:42
Show line numbers:set number
Two habits worth building. Copy the file before editing it, with cp /etc/fstab /etc/fstab.bak, and prefer nano when it exists. vi matters because it is the only editor guaranteed to be there, including on an ESXi host. The vi cheat sheet covers selecting, deleting, search and replace in full.

Where a Windows admin actually meets Linux

PlatformWhat to know before typing
ESXi shellNot Linux. VMkernel with a BusyBox shell, so no systemctl, no package manager and a reduced set of options on ordinary commands.
ESXi, restart a service/etc/init.d/hostd restart, and services are listed under /etc/init.d/
ESXi, the logs/var/log/vmkernel.log, hostd.log, vpxa.log, vobd.log
ESXi, versionvmware -vl or esxcli system version get
ESXi, keeping a changeConfiguration is restored from a backup at intervals, so force a save with /sbin/auto-backup.sh
vCenter Server ApplianceReal Linux, Photon OS. You land in the appliance shell: type shell to get bash.
VCSA, servicesservice-control --status --all, and systemctl works as well
VCSA, logs and packagesLogs under /var/log/vmware/, packages through tdnf
WSL on your own workstationA real distribution, usually Ubuntu. Windows drives appear under /mnt/c.
NAS and appliancesOften BusyBox with a cut-down shell. Check what exists before relying on it.
Do not treat an ESXi host as a Linux server. It has no package manager, its shell is deliberately minimal, and SSH is off by default for a reason. Installing things, editing files by hand or leaving SSH enabled all count as an unsupported configuration. Use esxcli and the API, and turn SSH back off when you are done.

FAQ

Permission denied, and I am root. How?
Three usual causes: the file has no execute bit, so chmod +x; the file system is mounted read-only, which findmnt or mount | grep ro, will show; or SELinux on the RHEL family is refusing it, which getenforce and the audit log confirm. Unlike Windows, root can still be stopped by the second and third.
I deleted a big log file and the space did not come back.
A process still holds the file open, so the blocks stay allocated until it closes. Find it with lsof | grep deleted and restart that service. Truncating instead of deleting avoids the problem: : > /var/log/big.log.
Which command shows the equivalent of Event Viewer?
journalctl on anything with systemd. Useful forms are -u name for one service, -p err for errors only, -b for this boot and --since "1 hour ago". On older systems without systemd, read /var/log/messages or /var/log/syslog directly.
Do I need to learn bash scripting?
Not to troubleshoot. Reading a script and running commands one at a time covers most of what a Windows admin needs on Linux, and PowerShell 7 runs on Linux if you want your own tooling there. Learn pipes, redirection and grep first, they carry the most weight.
Why does the same command work on Ubuntu and fail on Rocky?
Because they are different families. Package managers, firewall front ends, network configuration, service names and log file locations all differ, and the tables above name which is which. The kernel is common ground; almost everything around it is a distribution decision.