How To Use LS and CP command In AWS?
Amazon Simple Service Storage(S3) is used for Storage. Amazon S3 is a simple interface that user can use to store and retrieve any amount of data, at any time, from anywhere. There are certain AWS CLI S3 commands which help user to manage S3 buckets and its objects.
1. LS Command with EXPLANATION and USAGE
LS Command is used to listing Objects and files of Aws S3 Bucket
1.1 List All S3 Buckets
To view all the buckets for current user, execute the following ls command: –
- AWS S3 ls or AWS s3 ls s3://
1.2 List All Objects in any S3 Bucket
To see all folders and files of any S3 Bucket, execute the following command: –
- AWS s3 ls <Target-Bucket> or AWS s3 ls s3://<Target-Bucket>
1.3 List all Objects in a Bucket Recursively
To display all the subfolders and their contents use below command
- AWS s3 ls s3://<Target-Bucket> –recursive
1.4 Total Size of All Objects in a S3 Bucket
To display size in the S3 bucket, and the total number of files in the s3 bucket
- AWS s3 ls s3://<Target-Bucket> –recursive –human-readable –summarize
2. Copy Command
By this command, user can copy required file from local machine to S3 location or from s3 location to local machine.
2.1 Copy Local File to S3 Bucket
By this command, user can copy required file on desired S3 location
- AWS s3 cp <Local file> <S3 Target Location>
If user wants to copy local file with Different name on S3 location
- AWS s3 cp <Local-file> <S3 Target Location>/<Local-File1>
2.2 Copy Local Folder with all Files to S3 Bucket
In below command, only files from folder is copied onto S3 location
- Aws s3 cp <Folder-name> <S3 Target Location> –recursive
Ex: AWS s3 cp project s3://ma-manu-test –recursive
If user wants to copy same folder on S3 location, then specify the folder name too
- Aws s3 cp<Folder-name> <S3 Target Location>/<Folder-name> –recursive
Ex: AWS s3 cp project s3://ma-manu-test/project –recursive
2.3 Copy/Download a File from S3 Bucket
Download a file form S3 bucket location to local machine
User can download the file to a local machine with different name
- AWS s3 cp <S3 Source Location> .
- Note:- Dot(.) in above command use for current directory of local machine.
User can download the file to a local machine with different name
- AWS S3 cp <S3 source Location> <Desired-file-name>
2.4 Copy/Download All Files Recursively from a S3 bucket
User can also copy all files from S3 location to local machine by below command:
- AWS S3 cp <S3 Source Location> . –recursive
This is a fantastic blog from which people can learn a lot. It is very informative and is explained in…
Thanks for sharing such knowledgeable Content on Automation testing, to know how to enhance the performance of ERP's like Oracle…
Thanks.. this list is much needed.
This one is also good to use. Thanks for sharing this.. Might be we can also add it in list…
How about youtube-dl?