Introduction
>
One of the many benefits of AWS is that it can be managed
across different operating systems with a single unified tool. The tool in
question is the AWS Command line interface. In this blog post we will show you
how to install the CLI and outline some essential commands to get you started.
Installing the CLI
Windows
For Windows operating systems you have a couple of options. You
can either run the following command:
> >
Or you can download it from here:
https://awscli.amazonaws.com/AWSCLIV2.msi
Linux
For Linux operating systems you can open a terminal and run
the following commands in order:
>
Mac
For mac operating systems you can run the following commands in order:
>> > >
9 Essential Commands
1. >Create a new bucket >
The first thing you are going to want to do when you have everything installed and configured is create a new bucket to store data. To do this run the following command
> >
2. >Copy a file from your machine to a bucket >
Once you have a bucket set up you are going to want to get some data in there. In the below example we are copying a file called example.txt to our brand new ExampleBucket we created above.
> >
3. Delete a bucket and everything within it
If you no longer need a bucket and the contents of it you can simply delete the whole thing and all the data within. To do this run the following command:
> >
4. List all the files in your bucket
Now you have some data in your bucket you might want to see what’s in there. To produce a list of the files within a bucket you can run the command below. This also shows you the size of the bucket.
> >
5. Download a file from the bucket
To download a file from your bucket you run a cp command which essential copies the file from the bucket back on to your computer. To do this use the following command:
> >
6. Move a file to a bucket
This command is slightly different from the 2nd command where we copied a file to a bucket. This command will actually move the file so it is no longer in its original place and now only exists in the bucket. Essentially this is a cut and paste as opposed to a copy and paste. To do this run the following:
> >
7. Move a file from one bucket to another
Similar to the last command this one will move a file from one bucket to a different one. This is useful if you put a file in the wrong bucket and want to remove it from one but make sure it gets to the right one. This example shows test.txt being taken from ExampleBucket and being placed into ExampleBucket2. The command is below:
> >
8. Sync files from local folder to bucket
This command will create a link between a folder on your machine and your bucket. When you add a file to the folder it will also then appear in the bucket. This is very handy if you haven’t go the time to be uploading files one by one. All you will need to do is drop files into the synced folder. In this example the folder on your machine would be called ‘example’ and that is synced with ExampleBucket. The command is as follows:
> >
9. Sync files from bucket to local folder
This command is essentially the opposite of the previous whereby you have a local folder that updates whenever a file gets added to the bucket. The command is as follows:
> >
> > > > >