User can create S3 bucket by mb command, but have required permission for the same.
- ‘mb’ stands for make bucket.
Below command will create bucket under the region which is mentioned in config file.
- aws s3 mb s3://<bucket-name>
E.g.: Aws s3 mb s3://newbucket
Below command will create bucket which you mentioned with command
- aws s3 mb s3://<bucket-name> –region <Region-Name>
E.g.: aws s3 mb s3://newbucket –region us-west-2
User can use rb command to delete specified bucket, but should have required permissions. ‘rb’ stands for remove bucket.
Below command will work if bucket is empty
- aws s3 rb s3://<delete bucket name>
E.g.: aws s3 rb s3://mybucket
User can delete Bucket and their contents also in single command.
- aws s3 rb s3://<delete bucket name> –force
E.g.: aws s3 rb s3://mybucket –force
mv is used to move files from local to s3 or vice versa.
By this command, user can move required file on desired S3 location
- aws s3 mv <Local file> <S3 Target Location>
- aws s3 mv <Local-file> <S3 Target Location>/<Local-File1>
In below command, all files from current folder or any subfolder is moved onto S3 location
- aws s3 mv <Folder-name> <S3 Target Location> –recursive
If user wants to movve same folder on S3 location, then specify the folder name too
- aws s3 cp<Folder-name> <S3 Target Location>/<Folder-name> –recursive
Move a file form S3 bucket location to local machine
- aws s3 mv <S3 Source Location> .
User can move the file to a local machine with different name
- aws s3 mv <S3 source Location> <Desired-file-name>
User can also move all files from S3 location to local machine by below command:
- aws s3 mv <S3 Source Location> . –recursive
Use can move files/folder from one s3 location to another s3 location
- aws s3 mv <S3 source location> <Target S3 location> –recursive
User can delete file(s) from S3 location by rm command.
Using below command, user can delete single file from s3 bucket
- aws s3 rm s3://< s3 location>/<filename>
To delete all files from s3 location, use –recursive option
aws s3 rm s3://<s3 location> –recursive
User can print number of lines of any file through CP and WC –l option
- aws s3 cp < S3 bucket location>/<File-name> -|wc –l
E.g.: aws s3 cp s3://mybucket/myfolder/myfile.txt -|wc -l
User is able to see contents of file with combination of CP and Cat Command; it would be good if file is small.
- aws s3 cp <S3 bucket location>/<File-name> -|cat
E.g.: aws s3 cp s3://mybucket/myfolder/myfile.txt -|cat