Linux CLI Basics
9 examples to get you started with Linux CLI - 6 basic and 3 intermediate.
Search across all documentation pages
9 examples to get you started with Linux CLI - 6 basic and 3 intermediate.
pwd, cd, and ls are the three commands you use before anything else.
pwd # print the current directory
cd ~/projects/my-sdk-app
ls -la # list all files, including hidden ones, with detailsls -la reveals hidden files like .env and .aws, which do not show with a plain ls.cd - jumps back to the previous directory, handy when bouncing between two folders.pwd is worth running before any command that deletes or overwrites files, so you know exactly where you are.cat, head, and tail print file contents straight to the terminal.
cat requirements.txt # print the whole file
head -n 20 app.log # first 20 lines
tail -n 20 app.log # last 20 lines
tail -f app.log # follow new lines as they are writtentail -f is the standard way to watch a log file while an SDK script is running.head is useful for checking a large describe-* JSON dump without scrolling forever.-c to count bytes instead of lines, rarely needed but good to know exists.grepgrep finds lines matching a pattern, across one file or a whole tree.
grep "AccessDenied" app.log
grep -r "boto3.client" . # recursive search from the current directory
grep -i "error" app.log # case-insensitive
grep -n "region_name" config.py # show line numbers-r is what you reach for when you cannot remember which file defines something.-i avoids missing matches because of casing (Error vs error).aws ... | grep InstanceId filters CLI output the same way.Related: jq & Parsing AWS CLI/SDK JSON Output - a more precise way to filter structured JSON than
grep.
find locates files across a directory tree by name, extension, or modification time.
find . -name "*.py" # every Python file under the current dir
find . -name "*.tf" -newer main.tf # Terraform files edited after main.tf
find . -type d -name "__pycache__" # locate directories to clean upfind searches the filesystem tree; grep -r searches file contents. Use find when you know the name, grep -r when you know the content.-exec to act on results, e.g. find . -name "*.pyc" -exec rm {} \;.find to a project directory, not /, to avoid scanning the entire disk.A pipe (|) sends one command's output into the next; > and >> write output to a file.
aws ec2 describe-instances --output json > instances.json # save to a file
cat instances.json | grep "InstanceId" # then search it
aws s3 ls | grep "my-bucket" # or filter directly
echo "run started" >> deploy.log # append a line> overwrites a file; >> appends. Mixing them up is a common way to lose a log's history.json output into jq (next page) is far more precise than piping into grep.2>&1 redirects stderr into the same stream as stdout, useful when capturing a full command's output including errors.export sets a variable for the current shell session; echo $VAR reads one back.
export AWS_PROFILE=dev
export AWS_REGION=us-east-1
echo $AWS_PROFILE
unset AWS_PROFILE # remove it when you are done with that scopeexport makes the variable visible to any program you launch from this shell, including aws, python, and node.export, a plain assignment (AWS_PROFILE=dev) is only visible to the current shell, not to programs it launches.unset a scoped credential-related variable when you finish a task - covered in depth on the env vars and credentials page.chmod and ls -l control and reveal who can read a file - critical for ~/.aws/credentials.
ls -l ~/.aws/credentials
# -rw------- 1 you you 123 Jul 23 10:00 /Users/you/.aws/credentials
chmod 600 ~/.aws/credentials # owner read/write only, nobody else600 means only the file owner can read or write it - no group or world access.~/.aws/credentials or ~/.aws/config.&& and ;&& runs the next command only if the previous one succeeded; ; runs it regardless.
aws sts get-caller-identity && echo "credentials OK"
mkdir -p build && cd build && python ../deploy.py
false ; echo "this still runs"&& is the safer default for scripts, since a failed step stops the chain instead of continuing on bad state.$? holds the exit code of the last command if you need to check it explicitly: echo $?.set -euo pipefail at the top of a bash script to make every step behave like it is chained with &&.&, jobs, and kill let you run something in the background and control it later.
python long_poll.py & # run in the background, prompt returns immediately
jobs # list background jobs in this shell
kill %1 # stop job 1nohup command & keeps a background process alive after you close the terminal.Ctrl+Z suspends the current foreground job; bg resumes it in the background, fg brings it back.grep.export/unset for secrets correctly.Stack versions: This page was written for boto3 1.43.x (Python 3.10+) and the AWS SDK for JavaScript v3 (Node.js 18+).
Reviewed by Chris St. John·Last updated Jul 23, 2026