KKIMS on-site docs
Your workstation

Which shell to use

Which shell to run commands in on Linux, macOS and Windows (bash, zsh, PowerShell, Git Bash, WSL), and a table of equivalents for environment variables, line continuation, quoting JSON, base64, secrets, exit codes and curl.

Every command on this site is written for one of three shells: bash (Linux), zsh or bash (macOS) and PowerShell (Windows). On Windows a few commands are better in Git Bash, and those blocks are labelled bash. This page says which shell to open, and how the common things differ between them.

#Pick your shell

#Linux

Use bash, the default on Ubuntu, Debian, RHEL, Rocky and Amazon Linux. zsh works for every command here too.

Check:

bash
echo "$SHELL"; bash --version | head -n 1

You should see something like /bin/bash and GNU bash, version 5.2....

#macOS

Use Terminal or iTerm2 with the default zsh (since macOS 10.15). Every bash block on this site runs unchanged in zsh, with one exception noted where it matters: a # in an unquoted argument is a comment in bash but not in zsh, which only matters if you paste comments on the same line as a command.

Check:

bash
echo "$SHELL"; zsh --version

You should see /bin/zsh and zsh 5.9 ... or similar.

#Windows

Use PowerShell by default. Either Windows PowerShell 5.1 (built in, "Windows PowerShell" in the Start menu) or PowerShell 7 (pwsh, install with winget install -e --id Microsoft.PowerShell). Every PowerShell command here works in both unless it says otherwise. Windows Terminal (built into Windows 11) is the most comfortable window to run them in.

Use Git Bash (installed with Git for Windows) when a block is labelled bash on the Windows tab. That is the case for:

  • the repository's own shell scripts, such as deploy/kind/up.sh (Windows has no sh of its own);
  • openssl (Git for Windows ships it; PowerShell does not);
  • reading values out of .env.local with sed;
  • running the CMS, website and worker dev servers on the host (see Windows notes).

Do not use the old Command Prompt (cmd.exe): no command on this site is written for it.

Check, in PowerShell:

powershell
$PSVersionTable.PSVersion; $ExecutionContext.SessionState.LanguageMode

You should see a version (5.1... or 7.x) and FullLanguage. If the second line says ConstrainedLanguage, your organisation has locked PowerShell down: commands that call .NET directly (for example generating random bytes with [System.Security.Cryptography...]) will fail, and unsigned .ps1 scripts may not run. Every command on this site avoids those, and where one would need it the page gives a Git Bash way instead.

#WSL (Windows Subsystem for Linux)

WSL gives you a real Ubuntu on Windows, where the Linux tab's commands work as written. It is a good choice if you are comfortable with Linux, with three cautions:

  • Tools installed in Windows (Docker Desktop, Chrome) and tools installed inside WSL are separate. Docker Desktop's "WSL integration" makes docker work inside your WSL distribution; turn it on in Docker Desktop, Settings, Resources, WSL integration.
  • Keep the code inside the WSL filesystem (~/kims, not /mnt/c/...). Working on /mnt/c is many times slower for npm install and the site build.
  • Your AWS, kube and git configuration in WSL (~/.aws, ~/.kube, ~/.gitconfig) is separate from Windows's (%USERPROFILE%\.aws and so on).

The engineer's own laptop used PowerShell and Git Bash, not WSL, so the Windows tab is what was actually tested on Windows.

#Equivalents

The same thing in each shell. Use this table when adapting a command or reading a log.

#Setting a variable for the next commands

bash
export AWS_REGION=ap-south-2
echo "$AWS_REGION"
bash
export AWS_REGION=ap-south-2
echo "$AWS_REGION"
powershell
$env:AWS_REGION = "ap-south-2"
$env:AWS_REGION

The variable lasts until the window is closed. In PowerShell, $Region = "ap-south-2" (no env:) makes a PowerShell variable that programs do not see; use $env:NAME for anything a program like aws or node reads.

#Setting a variable for one command only

bash
KIMS_LIGHTHOUSE=skip npm run site:build -- --from-dir apps/website/content-fixtures
bash
KIMS_LIGHTHOUSE=skip npm run site:build -- --from-dir apps/website/content-fixtures
powershell
$env:KIMS_LIGHTHOUSE = "skip"; npm run site:build -- --from-dir apps/website/content-fixtures; Remove-Item Env:KIMS_LIGHTHOUSE

PowerShell has no NAME=value command form. Set it, run, then remove it.

#Making a variable permanent

bash
echo 'export AWS_PROFILE=kims' >> ~/.bashrc
bash
echo 'export AWS_PROFILE=kims' >> ~/.zshrc
powershell
[Environment]::SetEnvironmentVariable("AWS_PROFILE", "kims", "User")

Open a new window afterwards. If PowerShell is in Constrained Language Mode the Windows line fails; use Settings, System, About, Advanced system settings, Environment Variables, New (under "User variables") instead.

#Splitting a long command over several lines

Shell Continuation character Example
bash, zsh, Git Bash \ at the very end of the line kubectl -n kims \
PowerShell ` (backtick) at the very end of the line kubectl -n kims `

Nothing, not even a space, may follow the continuation character. The commands on this site are mostly on one line to avoid this; if you copy a multi-line bash command into PowerShell, either join it into one line or replace each trailing \ with a backtick.

#Quoting a JSON argument

JSON on the command line is where shells differ most. Prefer a file: almost every AWS CLI option that takes JSON also accepts file://name.json, and it works the same in every shell.

text
aws s3api put-bucket-cors --bucket <ASSETS_BUCKET> --cors-configuration file://cors.json

If you must pass JSON inline:

bash
aws ssm start-session --target <INSTANCE_ID> --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"host":["<RDS_ENDPOINT>"],"portNumber":["5432"],"localPortNumber":["15432"]}'
bash
aws ssm start-session --target <INSTANCE_ID> --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"host":["<RDS_ENDPOINT>"],"portNumber":["5432"],"localPortNumber":["15432"]}'
powershell
aws ssm start-session --target <INSTANCE_ID> --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters "host=<RDS_ENDPOINT>,portNumber=5432,localPortNumber=15432"

On Windows the AWS CLI's shorthand syntax (key=value,key=value) avoids JSON quoting altogether. PowerShell 5.1 strips the double quotes inside a single-quoted JSON string before the program sees them, so '{"a":"b"}' arrives as {a:b} and fails to parse; PowerShell 7.3 and later pass it correctly. If you are unsure, use a file.

#Writing a file with exact content

When a page shows file content (a JSON policy, a YAML pod), save it with your editor (Other tools). If you create it from the shell, make sure of the encoding on Windows:

bash
cat > cors.json <<'EOF'
[{"AllowedOrigins":["https://<CMS_HOST>"],"AllowedMethods":["PUT"],"AllowedHeaders":["content-type"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]
EOF
bash
cat > cors.json <<'EOF'
[{"AllowedOrigins":["https://<CMS_HOST>"],"AllowedMethods":["PUT"],"AllowedHeaders":["content-type"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]
EOF
powershell
Set-Content -Path cors.json -Encoding ascii -Value '[{"AllowedOrigins":["https://<CMS_HOST>"],"AllowedMethods":["PUT"],"AllowedHeaders":["content-type"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]'
Warning

In Windows PowerShell 5.1, > and Out-File write UTF-16 with a byte-order mark. The AWS CLI, kubectl and Node cannot read such a file as JSON or YAML. Always use Set-Content -Encoding ascii (or utf8 in PowerShell 7), or save from an editor as "UTF-8".

#Base64

bash
printf '%s' 'hello' | base64          # encode: aGVsbG8=
printf '%s' 'aGVsbG8=' | base64 -d    # decode: hello
bash
printf '%s' 'hello' | base64          # encode: aGVsbG8=
printf '%s' 'aGVsbG8=' | base64 -D    # decode (older macOS); -d also works on macOS 13 and later
powershell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("hello"))          # encode: aGVsbG8=
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("aGVsbG8="))    # decode: hello

The Windows lines call .NET and fail in Constrained Language Mode; Git Bash has base64 and works the same as Linux. Linux's base64 wraps output at 76 characters; add -w 0 for one line.

Reading a value out of a Kubernetes Secret (they are stored base64-encoded):

bash
kubectl -n kims get secret kims-database -o jsonpath='{.data.url}' | base64 -d
bash
kubectl -n kims get secret kims-database -o jsonpath='{.data.url}' | base64 -d
bash
# Git Bash
kubectl -n kims get secret kims-database -o jsonpath='{.data.url}' | base64 -d

That prints a secret to your screen: do it only when you must, and clear the screen afterwards.

#Random secrets

bash
openssl rand -base64 32
bash
openssl rand -base64 32
bash
# Git Bash (Git for Windows includes openssl)
openssl rand -base64 32

You should see 44 characters ending in =. Kubernetes Secrets uses this directly inside the kubectl create secret command so the value never appears on screen.

#Typing a secret without it going into your history

Commands you type are saved in your shell history (~/.bash_history, ~/.zsh_history, PowerShell's ConsoleHost_history.txt). Never type a password or token as part of a command. Read it into a variable instead:

bash
read -rs DB_PASSWORD && export DB_PASSWORD
bash
read -rs DB_PASSWORD && export DB_PASSWORD
powershell
$s = Read-Host -AsSecureString "Password"; $env:DB_PASSWORD = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($s)); Remove-Variable s

The terminal waits with nothing shown: paste or type the value and press Enter. Afterwards, refer to $DB_PASSWORD (bash) or $env:DB_PASSWORD (PowerShell). Remove it when done with unset DB_PASSWORD or Remove-Item Env:DB_PASSWORD. In Constrained Language Mode the Windows line fails; use Git Bash's read -rs instead.

In bash and zsh, a command that starts with a space is also left out of history if HISTCONTROL=ignorespace (bash) or setopt HIST_IGNORE_SPACE (zsh) is set. Do not rely on it unless you have checked.

#Did the last command work?

bash
echo $?
bash
echo $?
powershell
$LASTEXITCODE

0 means success. In PowerShell, $? is only True or False and is less reliable for programs; use $LASTEXITCODE.

Note

PowerShell shows stderr in red. git, kubectl, npm, helm and the migration runner print progress on stderr. PowerShell 5.1 colours it red and can wrap it in NativeCommandError even when the command succeeded. Judge by the last line of output and $LASTEXITCODE, never by the colour.

#curl

Shell Use Why
bash, zsh, Git Bash curl The real curl
Windows PowerShell 5.1 curl.exe curl is an alias for Invoke-WebRequest, which takes different options and prints an object
PowerShell 7 curl.exe (or curl) The alias was removed, but curl.exe always works

Windows 10 1803 and later ship curl.exe in C:\Windows\System32. The null device is /dev/null in bash and NUL in PowerShell:

bash
curl -s -o /dev/null -w "%{http_code}\n" https://translation.googleapis.com
bash
curl -s -o /dev/null -w "%{http_code}\n" https://translation.googleapis.com
powershell
curl.exe -s -o NUL -w "%{http_code}\n" https://translation.googleapis.com

Any status code (even 404) means the network path is open; a long wait then 000 means it is blocked.

#Finding a program and where it is

bash
command -v kubectl
bash
command -v kubectl
powershell
Get-Command kubectl | Select-Object -ExpandProperty Source

Use this when the wrong version runs: it shows which file the shell actually starts. On Windows, where.exe kubectl lists every match on PATH, in order.

#Searching output

bash, zsh PowerShell
kubectl get pods | grep cms kubectl get pods | Select-String cms
... | head -n 20 ... | Select-Object -First 20
... | tail -n 20 ... | Select-Object -Last 20
wc -l file (Get-Content file).Count

#Paths and folders

Linux macOS Windows
Home ~ = /home/<you> ~ = /Users/<you> ~ or $HOME = C:\Users\<you> (%USERPROFILE%)
AWS config ~/.aws/ ~/.aws/ $HOME\.aws\
kubeconfig ~/.kube/config ~/.kube/config $HOME\.kube\config
Git config ~/.gitconfig ~/.gitconfig $HOME\.gitconfig
Temp /tmp $TMPDIR $env:TEMP
Path separator / / \ (PowerShell also accepts /)
Git Bash's view of C:\Users\you /c/Users/you

#Git Bash rewrites paths that start with /

Git Bash (MSYS) converts arguments that look like Unix paths into Windows paths before running a Windows program. docker exec <container> ls /repo becomes ls C:/Program Files/Git/repo inside the container and fails. Either run such commands in PowerShell, or switch the conversion off for one command:

bash
MSYS_NO_PATHCONV=1 docker compose -f local/docker-compose.yml --profile jenkins exec jenkins git ls-remote -- file:///repo refs/heads/main

The same applies to kubectl cp and kubectl exec paths such as /bundle/data-bundle.

#If it goes wrong

What you see Cause Fix
curl : A parameter cannot be found that matches parameter name 's' PowerShell's curl alias Type curl.exe
'export' is not recognized A bash command in PowerShell Use the Windows tab, or $env:NAME = "value"
The term 'openssl' is not recognized PowerShell has no openssl Run it in Git Bash
Error parsing parameter '--parameters': Invalid JSON on Windows PowerShell 5.1 dropped the inner quotes Use file://params.json or the shorthand syntax
A JSON or YAML file you wrote "looks fine" but tools say it is invalid Written by PowerShell 5.1 as UTF-16 Rewrite it with Set-Content -Encoding ascii or save as UTF-8 in an editor
Cannot invoke method. Method invocation is supported only on core types in this language mode. Constrained Language Mode Use the Git Bash way, or ask IT
A path like C:/Program Files/Git/repo appears in an error Git Bash path conversion MSYS_NO_PATHCONV=1 before the command, or use PowerShell
running scripts is disabled on this system PowerShell execution policy Nothing on this site needs a .ps1; run the command directly or use Set-ExecutionPolicy -Scope CurrentUser RemoteSigned if your IT allows it

#Sources

Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.