1. Courses
  2. Developer Foundations
  3. Your Developer Setup
  4. Stop 2

35 minBeginner

The terminal without fear

Every developer tool has buttons, but its full power is in the terminal. Engineers type Git, npm and Node commands all day. This lesson covers the twenty or so commands and four ideas behind almost everything they type, on both Windows and macOS.

By the end you can

  • Move around folders with absolute and relative paths without getting lost
  • Read any command as program, flags and arguments, and use its exit code
  • Explain why "command not found" happens, and fix it by reading PATH
  • Chain small commands with pipes and redirection to answer a real question about a CSV
  • Use environment variables, run scripts and npx, and delete files safely

The everyday picture

At head office, you can ask the stock team for a report by filling a form in the portal. You pick from dropdowns, press Submit, and get exactly what the form allows. Or you can walk to the store manager and say: "Show me the Riverside store's rice sales since Monday, only the 5 kg bags, sorted by day." You get the answer in one sentence, as long as you know how to ask.

A graphical app is the form. The terminal is talking to the manager directly. It feels harder at first, because there are no dropdowns to remind you of the options. But every request is short, exact and repeatable, and you can write it down and give it to a teammate, or to a robot like GitHub Actions, which has no mouse at all.

Terminal, shell and prompt

Three words get mixed up. The is the window. The is the program inside it that reads your command and runs it. The is the text the shell prints when it is ready, such as PS C:\Users\you> or you@mac ~ %.

macOS uses zsh by default. Linux servers usually use bash. zsh and bash take the same commands for everything in this course. Windows has PowerShell, which is powerful but different: its commands pass objects, not text, and the names differ (Get-ChildItem instead of ls). Git for Windows also installs Git Bash, a bash shell for Windows.

This course's rule: on Windows, use Git Bash for Git and npm work, so you type the same commands as your teammates on macOS and as GitHub Actions on Linux. Where PowerShell is common, this lesson shows it too. To make Git Bash the default in VS Code, run Terminal: Select Default Profile from the Command Palette and choose Git Bash.

Where am I? Paths and the current folder

A shell is always "standing" in one folder, the . pwd prints it, cd changes it, ls lists what is in it. Everything you type with a file name is looked up from there.

An starts at the top: /Users/you/work on macOS, C:\Users\you\work on Windows (Git Bash writes it /c/Users/you/work). It means the same place no matter where you stand. A starts from where you are. Three shortcuts make relative paths useful: . means "this folder", .. means "one folder up", and ~ means "my home folder".

Two habits prevent most confusion. First, run pwd when an error says a file does not exist. Usually the file exists and you are standing in the wrong folder. Second, avoid spaces in folder names (store-report, not Store Report). A space splits a name into two arguments unless you put quotes around it.

Quick check

You are standing in /Users/you/work/store-report/scripts. Which relative path reaches reports/s014.csv inside store-report?

/Users/you work store-report data sales.csv scripts you are here pwd reports 1. .. up one level 2. data/ down into data cat ../data/sales.csv from scripts
Standing in scripts, the relative path ../data/sales.csv means: go up one level to store-report, then down into data. The absolute path /Users/you/work/store-report/data/sales.csv reaches the same file from anywhere.

Reading any command: program, flags, arguments, exit code

Every command has the same shape. Take git log --oneline -n 5 main. The first word, git, is the program. Words starting with dashes are , options that change its behaviour: --oneline (long form, two dashes) and -n 5 (short form, one dash, with a value). The rest are , the things it works on: main. Short flags can often be joined: ls -la is ls -l -a. When unsure, add --help.

When a program finishes, it returns an . Zero means success. Anything else is failure, and some numbers have meanings: 127 is "command not found", 126 is "found but not allowed to run". You rarely see the exit code, but everything automatic depends on it. && runs the next command only if the previous one succeeded, || only if it failed. A CI job in GitHub Actions fails when any step's command exits with a non-zero code (GitHub Actions: continuous integration). A pre-commit hook that exits non-zero stops the commit (VS Code for teams, later in this course). In bash or zsh, echo $? prints the last exit code; in PowerShell, use $LASTEXITCODE.

Quick check

A data export script prints "ERROR: file missing" but ends with exit code 0. What does a CI job running it do?

How the shell finds a program: PATH

When you type node, how does the shell know where Node is? It reads an called PATH, a list of folders separated by : (macOS, Linux, Git Bash) or ; (Windows). It checks each folder in order and runs the first match. If no folder has it, you get command not found (bash, zsh) or "is not recognized as a name of a cmdlet" (PowerShell).

That one rule explains three common problems. A tool you just installed is "not found" because your open terminal read PATH when it started, before the installer changed it; open a new one. A tool runs the wrong version because an older copy sits in a folder earlier in the list; which -a node (bash, zsh) or Get-Command node -All (PowerShell) shows every match in order. And a tool installed by npm into a project is "not found" because node_modules/.bin is not on PATH at all. That last one is what npx and npm scripts solve, as you will see in the Build it section.

Environment variables also carry settings into programs. Node reads them through process.env. A variable set with export (bash, zsh) or $env:NAME = 'value' (PowerShell) lasts until you close that terminal, and every program started from it inherits a copy. Writing NAME=value command on one line sets it for that one command only. This is how the same partner-api code connects to a test database on a laptop and the real one on the server: same code, different environment.

Quick check

which -a node prints two paths, one under /opt/homebrew/bin and one under /usr/local/bin. When you type node, which one runs?

prettier --check . shell reads PATH PATH, in order /opt/homebrew/bin no prettier /usr/bin no prettier … every folder checked command not found exit code 127 node_modules/ .bin/prettier npx prettier or npm run adds .bin to PATH
Typing a bare name makes the shell search each PATH folder in order and run the first match. A tool installed into the project lives in node_modules/.bin, which is not on PATH. npx and npm scripts add that folder for you, so the project's own version runs.

Small tools, joined by pipes

Unix-style shells give you many tiny programs that each do one job: head shows the first lines, tail -n +2 skips the header line, cut -d, -f1 takes the first comma-separated column, sort sorts, uniq -c counts repeated lines, grep keeps lines that match, wc -l counts lines. A , written |, feeds one program's output into the next. Together they answer questions no single tool can.

sends output to a file instead of the screen: > replaces the file, >> appends to it. Programs have two output streams. Normal results go to , error messages to , so an error does not end up inside your report file. 2> errors.log sends only the errors to a file.

PowerShell pipes objects instead of text. Import-Csv turns each row into an object with named fields, so you can group and sum without counting columns. The PowerShell version is often longer to type and easier to read.

Speed and safety habits

Press Tab to complete a file or folder name; press it twice to see the options. Press Up to bring back earlier commands, and Ctrl+R in bash or zsh to search your history (PowerShell has the same with PSReadLine). Ctrl+C stops the running command, which you will use for every dev server. On macOS this one really is Ctrl, not Cmd.

Deleting from the terminal skips the bin. rm file deletes a file, rm -r folder deletes a folder and everything inside, and rm -rf does it without asking and without complaining. A space in the wrong place turns rm -rf ./build into rm -rf . /build, which deletes the current folder. Before any rm -r, run pwd, then ls the exact path you are about to delete. In PowerShell, Remove-Item -Recurse accepts -WhatIf, which prints what it would delete and deletes nothing. If the files were committed, Git can bring them back (Undo anything, in Git from the Inside). Uncommitted work is gone.

Build it

Build a small store report folder, then answer real questions about a sales CSV with pipes, environment variables, a script and PATH. Outputs are from zsh on macOS; Git Bash prints the same results, though its error messages are worded a little differently and start with bash: instead of zsh:. PowerShell versions are in the tabs. The Practice section has a path exercise you can try in your browser, too.

  1. Create the folder structure

    mkdir -p creates folders, including missing parent folders, and does not complain if they already exist.

    Terminal
    pwd
    mkdir -p ~/work/store-report/data ~/work/store-report/scripts ~/work/store-report/reports
    cd ~/work/store-report
    ls
    Output
    /Users/you
    data
    reports
    scripts
  2. Add a sales file and walk around with relative paths

    In VS Code, create data/sales.csv with these lines (amounts in cents). Then practise moving with .. and coming back with ~.

    Output
    siteId,articleCode,qty,amountCents
    S-014,A-1001,2,1700
    S-014,A-2040,3,1137
    S-014,A-0007,1,300
    S-102,A-1001,1,850
    S-102,A-3311,4,1000
    S-014,A-3311,2,500
    Terminal
    cd data
    pwd
    cd ../scripts
    pwd
    cd ~/work/store-report
    head -n 3 data/sales.csv
    Output
    /Users/you/work/store-report/data
    /Users/you/work/store-report/scripts
    siteId,articleCode,qty,amountCents
    S-014,A-1001,2,1700
    S-014,A-2040,3,1137

    Windows has the same idea with different names. PowerShell has ls, cp, mv, rm and cat as aliases for its own commands, so simple uses work. Flags do not: Remove-Item -rf fails with "A parameter cannot be found that matches parameter name 'rf'". Another reason to use Git Bash for this course.

  3. Copy, rename and delete safely

    Terminal
    cp data/sales.csv reports/sales-copy.csv
    mv reports/sales-copy.csv reports/sales-2026-10-07.csv
    ls reports
    rm reports/sales-2026-10-07.csv
    Output
    sales-2026-10-07.csv

    mv both moves and renames. rm printed nothing, which in the shell means it worked.

  4. Answer questions with pipes

    How many lines (including the header)? How many lines per store? Read the pipeline left to right: skip the header, keep column 1, sort so equal stores sit together, count each group.

    Terminal
    wc -l data/sales.csv
    tail -n +2 data/sales.csv | cut -d, -f1 | sort | uniq -c
    grep '^S-014' data/sales.csv > reports/s014.csv     # keep S-014 lines in a file
    awk -F, '$1 == "S-014" { sum += $4 } END { print sum }' data/sales.csv
    Output
    7 data/sales.csv
          4 S-014
          2 S-102
    3637

    S-014 sold 3,637 cents, which is $36.37. The grep line printed nothing because > sent its output into the file.

  5. Set and read an environment variable

    Set STORE_ID for the session, then once for a single command, and read it from Node.

    Terminal
    export STORE_ID=S-014
    node -e 'console.log("Store from env:", process.env.STORE_ID)'
    STORE_ID=S-102 node -e 'console.log(process.env.STORE_ID)'   # this command only
    echo $STORE_ID
    Output
    Store from env: S-014
    S-102
    S-014
  6. Write a script that fails properly

    Create scripts/count-sales.sh. It takes a file name as its first argument, writes errors to stderr and exits with 1 on failure, so other tools can tell that it failed.

    Terminal
    #!/usr/bin/env bash
    # count-sales.sh: print how many sale lines each store has in a CSV file
    file="${1:-data/sales.csv}"          # first argument, or this default
    if [ ! -f "$file" ]; then
      echo "count-sales: no such file: $file" >&2   # >&2 sends the message to stderr
      exit 1                                        # non-zero exit code = failure
    fi
    tail -n +2 "$file" | cut -d, -f1 | sort | uniq -c

    The first line, called a , tells the system to run the file with bash. Then run it three ways:

    Terminal
    ./scripts/count-sales.sh; echo "exit code: $?"
    chmod +x scripts/count-sales.sh                  # allow it to run as a program
    ./scripts/count-sales.sh; echo "exit code: $?"
    ./scripts/count-sales.sh data/nope.csv && echo "report ready" || echo "report failed"
    Output
    zsh: permission denied: ./scripts/count-sales.sh
    exit code: 126
          4 S-014
          2 S-102
    exit code: 0
    count-sales: no such file: data/nope.csv
    report failed

    On Windows, Git Bash usually treats any file that starts with #! as runnable, so chmod makes no difference there. To mark it executable for teammates on macOS and Linux, Git has git update-index --chmod=+x, which you will meet after What Git really is, the first lesson of Git from the Inside.

  7. Cause and fix "command not found"

    Typing the script's name alone fails, because its folder is not on PATH. Print PATH one folder per line, add the folder, and try again.

    Terminal
    count-sales.sh
    echo $PATH | tr ':' '\n'
    export PATH="$HOME/work/store-report/scripts:$PATH"
    which count-sales.sh
    Output
    zsh: command not found: count-sales.sh
    /opt/homebrew/bin
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /Users/you/work/store-report/scripts/count-sales.sh

    This change lasts until you close the terminal. To keep it, add the export line to ~/.zshrc (macOS) or ~/.bashrc (Git Bash). In PowerShell, $env:PATH -split ';' prints the list, and the permanent setting is under "Edit environment variables for your account" in Windows settings. Restart the terminal after changing it.

  8. Run project tools with npx and npm scripts

    Install Prettier into a project. It lands in node_modules/.bin, which is not on PATH, so the bare name fails, while npx and npm scripts find it. On Windows, run this in Git Bash: /dev/null and && are bash syntax.

    Terminal
    mkdir -p ~/work/price-tools && cd ~/work/price-tools
    npm init -y > /dev/null
    npm install --save-dev --save-exact prettier@3.9.9
    prettier --version
    npx prettier --version
    npm pkg set scripts.format:check="prettier --check ."
    npm run format:check
    Output
    added 1 package, and audited 2 packages in 522ms
    
    1 package is looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    zsh: command not found: prettier
    3.9.9
    
    > price-tools@1.0.0 format:check
    > prettier --check .
    
    Checking formatting...
    All matched files use Prettier code style!

    If a package is not installed, npx asks "Need to install the following packages ... Ok to proceed?" and downloads it. Read the package name before you say yes, because a misspelt name can be someone else's package (Security and quality in JavaScript projects).

Taskbash / zsh / Git BashPowerShell
Where am IpwdGet-Location (pwd)
List files, including hiddenls -laGet-ChildItem -Force
Make nested foldersmkdir -p a/b/cNew-Item -ItemType Directory -Force a/b/c
Copy, movecp, mvCopy-Item, Move-Item
Delete a folderrm -r folderRemove-Item -Recurse folder (try -WhatIf)
Show a filecat fileGet-Content file
Find linesgrep 'S-014' fileSelect-String 'S-014' file
Set env var (session)export NAME=value$env:NAME = 'value'
Last exit codeecho $?$LASTEXITCODE
Where is this programwhich -a nodeGet-Command node -All

Bring it to your team

Terminal habits decide whether a team's setup is repeatable. Ask these when you join a repo or review a README.

  • "Can every setup step in our README be copied and pasted into a terminal, in order, on Windows and macOS?"
  • "Which shell do we assume on Windows, Git Bash or PowerShell, and is that written down?"
  • "Which environment variables does this service need, and where is the example file that lists them?"
  • "Do our scripts exit with a non-zero code when they fail, so CI really stops?"
  • "Do we run project tools through npm scripts, so everyone uses the version in the lockfile?"

Red flags

  • A setup guide that says "install prettier globally" instead of using the project's own version.
  • A script that prints "ERROR" but still exits with 0, so the pipeline shows green.
  • Production passwords pasted into a terminal command, where they stay in shell history.
  • A cleanup step built from rm -rf $SOME_VAR/, which deletes from the top if the variable is empty.

Practice

Work out where a path points

Write resolvePath(cwd, input, home) that does what the shell does with a path: it returns the absolute path that input means when you stand in cwd. Paths use /. A path starting with / is absolute, ~ at the start means home, . means "this folder", .. means "one folder up", and you can never go above /. Return the result without a trailing slash (except for / itself).

JavaScript exerciseRuns in your browser with tests
function resolvePath(cwd, input, home) {
  // Start from the right place, then walk the parts one by one
  return cwd + '/' + input;
}
Ctrl + Enter runs
Show a solution
JavaScript
function resolvePath(cwd, input, home) {
  let start = cwd;
  if (input.startsWith('/')) start = '';                  // absolute: ignore cwd
  else if (input === '~' || input.startsWith('~/')) {     // ~ means home
    start = home;
    input = input.slice(1);
  }
  const parts = [];
  for (const part of (start + '/' + input).split('/')) {
    if (part === '' || part === '.') continue;            // empty or "this folder"
    if (part === '..') parts.pop();                       // up one (pop on [] does nothing)
    else parts.push(part);
  }
  return '/' + parts.join('/');
}
Pass the exercise to finish this task.

Answer a question with one pipeline

In the store-report folder from Build it, write one pipeline that prints how many sale lines each article has (the second column), most frequent first. Run it, then use grep -c to count how many lines store S-102 has. Write both commands down as you would paste them into a team chat.

  • The pipeline skips the header line before counting.
  • It cuts the second column, not the first.
  • It sorts before uniq -c, because uniq only counts lines that sit next to each other.
  • It sorts the counts as numbers, largest first (sort -rn).
  • The grep pattern is anchored with ^, so it matches the store column only.
Show a model answer
Terminal
tail -n +2 data/sales.csv | cut -d, -f2 | sort | uniq -c | sort -rn
grep -c '^S-102' data/sales.csv
Output
      2 A-3311
      2 A-1001
      1 A-2040
      1 A-0007
2

Lines with the same count may come out in a different order on your machine. Without the first sort, uniq -c would count A-1001 twice as two separate groups of one, because its two lines are not next to each other.

Check yourself

You installed Node with the official installer. In the terminal that was already open, node -v says "command not found". What is the most likely cause?

In bash, what does npm test && git push do when one test fails?

Prettier is in a project's devDependencies. Typing prettier --check . fails, but npm run format:check (which runs the same thing) works. Why?

Flashcards

Open my review

Key takeaways

  • The terminal is the window, the shell reads your commands. On Windows, use Git Bash so your commands match macOS, Linux and CI.
  • Relative paths start where you stand. Run pwd first when a file "does not exist".
  • Every command is program, flags and arguments, and it ends with an exit code. 0 means success, and automation relies on it.
  • "Command not found" means no folder in PATH has that program. Open a new terminal, check with which -a, or use npx for project tools.
  • Pipes join small tools into answers. Check the path before every rm -r.
Episode transcriptTalking to the store manager directly · about 13 minutes · tap any line to play from there
  1. NadiaImran, it's the evening before a festival rush, Eid or Diwali or Christmas, and you get a forty megabyte CSV of the day's sale lines from every store. One store's numbers look wrong. What do you do?
  2. ImranOpen it in Excel, wait a minute, watch the laptop freeze, then filter by store.
  3. NadiaIn the terminal, one short command counts that store's lines in under a second. Another counts the lines for every store at once.
  4. ImranThat's the part of developer life I always skipped. I'd open the terminal, type one command a colleague gave me, and close it fast.
  5. NadiaThen this episode is for you. By the end, the terminal should feel like a tool, and not like a trap.
  6. NadiaThe lesson's picture is head office. You can ask the stock team for a report through a form in the portal. You pick from dropdowns and get exactly what the form allows.
  7. NadiaOr you walk up to the manager and say: show me the Riverside store's rice sales since Monday, only the five kilo bags, sorted by day.
  8. ImranAnd you get it in one sentence, as long as you know how to ask.
  9. NadiaExactly. An app with buttons is the form. The terminal is the manager. Harder at first, because there are no dropdowns to remind you. But every request is short and exact, and you can write it down for a teammate.
  10. ImranOr for GitHub Actions, which has no mouse at all.
  11. NadiaRight. Everything automatic in this course is terminal commands underneath.
  12. ImranFirst, vocabulary. Terminal, shell, console. My team uses them like they're the same word.
  13. NadiaThe terminal is the window. The shell is the program inside it that reads your command and runs it. The prompt is the short text the shell prints when it's ready for you.
  14. ImranAnd which shells will I meet?
  15. NadiaOn a Mac, zsh by default. On Linux servers, usually bash. Those two take the same commands for everything in this course. Windows has PowerShell, which is powerful but different. Its commands pass objects, and the names are longer.
  16. ImranSo a Windows developer and a Mac developer type different things?
  17. NadiaThey can. So the course has one rule. On Windows, use Git Bash for Git and N P M work. It comes with Git for Windows, and it means you type the same commands as your Mac teammates and as the Linux machines in CI.
  18. ImranFine. Where do I start?
  19. NadiaWith one question: where am I? A shell is always standing in one folder, the current directory. P W D prints it. C D changes it. L S lists what's in it.
  20. ImranAnd paths?
  21. NadiaTwo kinds. An absolute path starts at the very top, like slash Users, slash you, slash work. It means the same place from anywhere. A relative path starts from where you're standing.
  22. NadiaThree shortcuts make relative paths work. A single dot means this folder. Two dots mean one folder up. And the tilde means my home folder.
  23. NadiaThe first diagram is a folder tree. If you can see it, the scripts folder is marked, you are here. If not, picture a project folder with three folders inside: data, scripts and reports.
  24. NadiaYou're standing in scripts, and you want the sales file in data. The relative path is dot dot, slash data, slash sales dot CSV. Up one level, then down into data.
  25. ImranI've had so many file not found errors in my life.
  26. NadiaAnd usually the file exists, and you're standing in the wrong folder. So the first habit: when a file doesn't exist, type P W D before anything else.
  27. ImranNext: how do I read a long command someone pastes in Slack?
  28. NadiaEvery command has the same shape. The first word is the program. Words starting with dashes are flags, options that change its behaviour. The rest are arguments, the things it works on.
  29. NadiaTake git log, dash dash oneline, dash n five, main. Git is the program. Oneline and n five are flags. Main is the argument.
  30. ImranAnd when it finishes?
  31. NadiaIt returns an exit code. Zero means success. Anything else means failure. One hundred and twenty-seven means command not found. One hundred and twenty-six means the file was found, but it isn't allowed to run.
  32. ImranI never see these numbers.
  33. NadiaYou don't, but every automatic thing depends on them. A double ampersand runs the next command only if the first one succeeded. A GitHub Actions job fails when a step exits with anything but zero. A pre-commit hook that exits non-zero stops the commit.
  34. ImranSo a script that prints error but exits with zero...
  35. NadiaShows a green pipeline while something is broken. That's one of the red flags in the lesson.
  36. ImranNow the big one. Command not found. I installed something, I type its name, and the shell says it doesn't exist.
  37. NadiaThat's PATH. It's an environment variable, a list of folders. When you type node, the shell checks each folder in order and runs the first match. If no folder has it, you get command not found.
  38. ImranSo my guess would be that the installer failed, and I need to run it again as administrator.
  39. NadiaThat's the most common wrong guess, Imran. Usually the install worked. The terminal you had open read PATH when it started, before the installer changed it. Open a new terminal and it's there.
  40. ImranWhat are the other ways PATH bites people?
  41. NadiaThe wrong version runs, because an older copy sits in a folder earlier in the list. The lesson shows how to list every match in order, on both Mac and Windows.
  42. NadiaThe third case is in the second diagram. You install Prettier into a project, you type prettier, and the shell checks every PATH folder. None of them has it.
  43. NadiaIf you're looking, the red box at the bottom says command not found, exit code one twenty-seven. The green box beside it is a folder inside the project called node modules, dot bin.
  44. ImranSo the tool is installed, just not anywhere the shell looks.
  45. NadiaExactly. N P X, and N P M scripts, put that folder on PATH while they run. So the project's own version runs, the one pinned in the lockfile.
  46. ImranWhich is why the README should say npm run format, and not install Prettier globally.
  47. NadiaYes. A global install means each laptop may have a different version.
  48. ImranYou said environment variable. What else lives there?
  49. NadiaSettings that a program reads when it starts. Node reads them through process dot env. If you export a variable, it lasts until you close the terminal, and every program you start from it gets a copy.
  50. NadiaThat's how the same partner API code talks to a test database on a laptop and the real one on the server. Same code, different environment.
  51. ImranNow the CSV trick from the start.
  52. NadiaThe shell has many tiny programs that each do one job. One shows the first lines. One skips the header. One cuts out a column. One sorts. One counts repeated lines. A pipe, the vertical bar, feeds one program's output into the next.
  53. ImranAnd together they answer questions none of them answers alone.
  54. NadiaThat's it. Skip the header, keep the store column, sort, and count each group. You get lines per store. Redirection does the other half: one angle bracket sends output to a file, and two of them add to the end of it.
  55. ImranAnd PowerShell?
  56. NadiaPowerShell pipes objects. Import CSV turns each row into an object with named fields, so you group by site ID and sum the amount without counting columns. Longer to type, easier to read.
  57. ImranBack to the festival night story.
  58. NadiaThat's the Mangrove example in the lesson. Say store S zero one four shows twelve hundred lines, and similar stores show around nine thousand. Now Tomás, our data analyst, has something concrete for the engineer, before anyone opens a debugger.
  59. ImranWhat goes wrong in the terminal that really hurts?
  60. NadiaDeleting. The terminal skips the recycle bin. R M dash r deletes a folder and everything inside it. Add dash f, and it doesn't ask and doesn't complain.
  61. NadiaOne misplaced space turns delete the build folder into delete this whole folder, and then the build folder. So before any recursive delete, print where you are, and list the exact path you're about to remove.
  62. ImranIs there a safety net?
  63. NadiaIn PowerShell, remove item takes a what if flag. It prints what it would delete, and deletes nothing. And if the files were committed, Git can bring them back. Work you never committed is gone.
  64. NadiaThe Build-it section walks you through all of it. You create a project folder with data, scripts and reports, using one command that also creates missing parent folders.
  65. NadiaYou add a small sales file for two stores, walk around with dot dot and the tilde, then copy, rename and delete.
  66. ImranThen the pipes.
  67. NadiaYou count lines, count lines per store, and save store S zero one four's lines to a file. Then you add up its amounts: three thousand six hundred and thirty-seven cents, so thirty-six dollars and thirty-seven cents.
  68. NadiaThen you set a store ID as an environment variable, and read it from Node, once for the whole session and once for a single command.
  69. ImranAnd the script?
  70. NadiaA tiny bash script that counts lines per store. The first time you run it, the Mac says permission denied, exit code one twenty-six. You mark it as runnable, and it works. Give it a missing file, and it prints an error and exits with one.
  71. NadiaThen you type its name alone, get command not found, print PATH one folder per line, add the scripts folder, and it's found.
  72. ImranSo I cause each error on purpose, and then fix it.
  73. NadiaThat's the idea. The last step installs Prettier into a project and shows the bare name failing while N P X and an N P M script work.
  74. ImranIs there anything I can try without a terminal?
  75. NadiaThe first practice task runs in your browser. You write a small function that works out where a path points, with dot, dot dot and the tilde, exactly like the shell does. The second one is a pipeline you run on the sales file.
  76. ImranQuestions for my team?
  77. NadiaCan every setup step in our README be pasted into a terminal, in order, on Windows and on a Mac?
  78. ImranWhich shell do we assume on Windows, and is that written down? And which environment variables does this service need, and where's the example file that lists them?
  79. NadiaGood. And one I like: do our scripts exit with a non-zero code when they fail, so CI really stops?
  80. NadiaA question to think about. In bash, you type npm test, double ampersand, git push. One test fails. What happens? Take a second.
  81. ImranThe tests fail, so npm test exits with something other than zero, and the double ampersand skips the push.
  82. NadiaExactly right. If you used a semicolon instead, both would run, and you'd push failing code.
  83. ImranLet me sum up. One: the terminal is the window, the shell reads my commands, and on Windows I use Git Bash so my commands match everyone else's.
  84. ImranTwo: command not found means no folder in PATH has the program. Open a new terminal, list the matches, or use N P X for tools inside the project.
  85. ImranThree: every command ends with an exit code, and zero means success.
  86. NadiaOne addition to the third. Pipes and exit codes work together. Small tools joined by pipes answer the question, and the exit code tells the next step whether to carry on.
  87. NadiaNext time, VS Code itself. The five views, the Command Palette, and the shortcuts that save you an hour a week.
  88. ImranSee you then.
Finished reading?Mark it complete to fill in its stop on your course line.

Use it at work

Runbook

Symptoms, first checks with commands, fixes and when to escalate, for one alert.

Open in the DevOps & TechOps Lab
Next stopVS Code essentials
Was this lesson helpful?
Questions and discussion

Loading the discussion…