Skip to content

Linux cheatsheet

Dmitriy Popov edited this page Dec 28, 2020 · 9 revisions

Show available size on disk

df -h 

See https://opensource.com/article/18/7/how-check-free-disk-space-linux

Show sizes in current dir, including directories

du -sh *

See https://stackoverflow.com/a/1019124/8534088

List current directory with file size in megabytes

ls -l --block-size=M

See https://unix.stackexchange.com/a/64150/360633

Get count of files in the current directory

ls | wc -l

See https://devconnected.com/how-to-count-files-in-directory-on-linux/

Remove everything from current dir recursively

rm -r *

See https://askubuntu.com/a/740808/975890

Working with Zip

Zip a file

zip log-2020.12.28.zip ./kg.log

See https://linuxize.com/post/how-to-zip-files-and-directories-in-linux/

Zip a directory

❗ relative path will be used within the zip

zip -r filename.zip directory

List files in the zip file

less filename.zip See https://stackoverflow.com/a/52602616/8534088

AWS

S3

Copy to S3 bucket

See https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html#examples

You need to pass the security credentials or to set a role on EC2 etc.

With the same file name, kgparser is S3 Bucket name.

 aws s3 cp log-2020.12.28.zip s3://kgparser

Copy from S3 bucket to a local file

This example is with setting the profile with --profile option.

aws s3 cp s3://kgparser/log-2020.12.28.zip ./log.zip --profile=dpopov-admin-kgparser
Clone this wiki locally