Learn › Linux

Linux for Windows Admins: The Shell and the Filesystem

Linux for Windows admins: how the filesystem is laid out, the shell commands you'll use daily, and how they map to what you know on Windows.

Beginner 10 min read
By Gopinath Karthikeyan

Even in Windows-heavy companies, Linux is everywhere: Jenkins and Ansible servers, monitoring tools, containers, cloud appliances. You don’t need to become a Linux expert – but you do need to be comfortable at a Linux prompt. This guide gets you there.

What you need: Ubuntu in WSL on your Windows laptop (wsl --install in an admin PowerShell, then restart) or an Ubuntu VM.

The big differences

Windows Linux
Drives: C:\, D:\ One tree starting at /; extra disks are mounted into it
\ in paths / in paths
Names not case-sensitive Case-sensitive: Report.txt and report.txt are different files
Administrator root, or a normal user with sudo
Registry and many config tools Mostly plain text config files under /etc
Services systemd units (see the services guide)

Where things live

Path What’s there
/home/<user> Users’ home folders (like C:\Users)
/root The root user’s home
/etc System and app configuration
/var/log Log files
/var/lib App data (e.g. /var/lib/jenkins)
/tmp Temporary files, cleared on reboot
/usr/bin, /usr/local/bin Programs
/opt Third-party software

Moving around

pwd                 # where am I? (like 'cd' with no arguments on Windows)
ls                  # list files
ls -la              # long list, including hidden files (names starting with .)
cd /var/log         # change directory
cd ~                # go home
cd ..               # up one level

Working with files

mkdir -p ~/lab/scripts            # create folders (-p = parents too)
touch ~/lab/notes.txt             # create an empty file
cp notes.txt notes.bak            # copy
mv notes.bak old-notes.txt        # move / rename
rm old-notes.txt                  # delete – no Recycle Bin!
rm -r ~/lab/oldfolder             # delete a folder and everything in it

rm doesn’t ask and there’s no undo. Double-check paths, especially with -r and wildcards.

Reading files

cat file.txt               # print the whole file
less /var/log/syslog       # page through (q to quit, / to search)
head -n 20 file.txt        # first 20 lines
tail -n 50 file.txt        # last 50 lines
tail -f /var/log/syslog    # follow new lines live (Ctrl+C to stop)

Searching

grep -i error /var/log/syslog          # lines containing 'error' (case-insensitive)
grep -r "listen" /etc/nginx/           # search inside every file under a folder
find /var/log -name "*.log" -mtime -1  # .log files changed in the last day

Pipes work like PowerShell – but with text

ls -l /var/log | sort -k5 -n | tail -5     # 5 biggest entries
grep -c "Failed password" /var/log/auth.log

Linux pipes pass text, not objects, so you’ll use tools like grep, sort, cut, awk and wc to slice it.

Editing files

nano is the easiest editor: nano notes.txt, type, Ctrl+O to save, Ctrl+X to exit. Learn vim basics later – it’s on every server.

Help

man ls         # the manual (q to quit)
ls --help      # quick summary

Windows ↔ Linux cheat sheet

Task PowerShell Linux
List files Get-ChildItem ls -la
Read a file Get-Content cat, less
Last lines, live Get-Content -Tail 20 -Wait tail -f
Search text Select-String grep
Processes Get-Process ps aux, top
Disk space Get-PSDrive df -h
Who am I whoami whoami

What’s next

Next: Users, permissions and sudo.

LinuxBeginnerBashWindows Admin

Gopinath Karthikeyan

Gopinath Karthikeyan – Windows Site Reliability Engineer with about 12 years in enterprise Windows Server infrastructure, and founder of WinOps Academy. YouTube · LinkedIn

More in Linux