Getting started with the AWS CLI - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

Getting started with the AWS CLI
================================

### [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

Install the AWS CLI v2 on macOS and Linux, run aws configure, set up named profiles, and try real S3 and EC2 commands from your terminal.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 2 minute read

1. [What the AWS CLI is for](#content-what-the-aws-cli-is-for)
2. [Installing the AWS CLI v2](#content-installing-the-aws-cli-v2)
3. [Configuring your credentials](#content-configuring-your-credentials)
4. [Where credentials are stored](#content-where-credentials-are-stored)
5. [Named profiles for multiple accounts](#content-named-profiles-for-multiple-accounts)
6. [A few real commands](#content-a-few-real-commands)
7. [Where to go next](#content-where-to-go-next)

[\#](#content-what-the-aws-cli-is-for "Permalink")What the AWS CLI is for
-------------------------------------------------------------------------

Clicking through the AWS Console is fine for poking around, but the moment you want to script anything, list buckets quickly, or copy files to S3, the AWS CLI is the tool. It talks to every AWS service from your terminal, which means you can automate it and put it in deploy scripts. Here's how I get it running on a fresh machine.

[\#](#content-installing-the-aws-cli-v2 "Permalink")Installing the AWS CLI v2
-----------------------------------------------------------------------------

Always install **v2**. Version 1 still floats around in package managers but is no longer the one you want.

On macOS, use the official installer:

 ```
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

```

On Linux (x86\_64):

 ```
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

```

On an ARM box (like a Graviton instance or some Raspberry Pis), swap the URL for `awscli-exe-linux-aarch64.zip`.

Confirm it landed:

 ```
aws --version

```

You should see something like `aws-cli/2.x.x`.

[\#](#content-configuring-your-credentials "Permalink")Configuring your credentials
-----------------------------------------------------------------------------------

Before anything works, the CLI needs an access key. Create one under **IAM, Users, Security credentials** in the Console, then run:

 ```
aws configure

```

It asks four questions:

- **AWS Access Key ID** — your key, like `AKIA...`
- **AWS Secret Access Key** — the secret half (shown only once when created)
- **Default region name** — e.g. `eu-west-1` or `us-east-1`
- **Default output format** — `json`, `table`, or `text`. I use `json`.

[\#](#content-where-credentials-are-stored "Permalink")Where credentials are stored
-----------------------------------------------------------------------------------

`aws configure` writes two plain-text files to `~/.aws/`:

- `~/.aws/credentials` holds your keys.
- `~/.aws/config` holds the region and output format.

Because these are plain text, treat `~/.aws/credentials` like a private SSH key: never commit it, and lock down its permissions if you're unsure. You can inspect the configured values without opening the files:

 ```
aws configure list

```

[\#](#content-named-profiles-for-multiple-accounts "Permalink")Named profiles for multiple accounts
---------------------------------------------------------------------------------------------------

The moment you deal with more than one AWS account (work and personal, staging and production), named profiles save you. Set one up:

 ```
aws configure --profile staging

```

Then pass `--profile` on any command:

 ```
aws s3 ls --profile staging

```

You can also export it for a whole shell session so you don't repeat yourself:

 ```
export AWS_PROFILE=staging

```

[\#](#content-a-few-real-commands "Permalink")A few real commands
-----------------------------------------------------------------

List your S3 buckets:

 ```
aws s3 ls

```

List the contents of one bucket, then copy a file up to it:

 ```
aws s3 ls s3://my-bucket/
aws s3 cp ./backup.tar.gz s3://my-bucket/backups/

```

The `aws s3 cp` command works just like a normal `cp`, including `--recursive` for whole directories. To sync a folder (only changed files), there's `aws s3 sync`, which behaves a lot like [rsync](/sync-files-rsync-command).

Check your EC2 instances:

 ```
aws ec2 describe-instances

```

That dumps a lot of JSON. Narrow it down with the built-in `--query` (JMESPath) to pull just what you need:

 ```
aws ec2 describe-instances \
  --query "Reservations[].Instances[].{ID:InstanceId,State:State.Name}" \
  --output table

```

[\#](#content-where-to-go-next "Permalink")Where to go next
-----------------------------------------------------------

From here, almost everything is `aws  `, and `aws  help` documents each one. Tab completion is worth setting up too. With credentials configured and v2 installed, you've got the foundation for scripting anything AWS exposes.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#CommandLine](https://rocketeersapp.com/knowledge/command-line)

- [Argument list too long (Bash: /bin/rm)](https://rocketeersapp.com/knowledge/argument-list-too-long)
- [How to install Composer packages locally](https://rocketeersapp.com/knowledge/install-composer-packages-locally)
- [How to send GET and POST requests with curl](https://rocketeersapp.com/knowledge/curl-post-get-api-requests)
- [Essential Linux command line basics for developers](https://rocketeersapp.com/knowledge/linux-command-line-basics)
- [How to search file contents with grep](https://rocketeersapp.com/knowledge/search-files-grep-command)
- [The complete guide to the curl command](https://rocketeersapp.com/knowledge/curl-command-complete-guide)

 [View all 21 articles →](https://rocketeersapp.com/knowledge/command-line)
