https://github.com/utensils/one-liners
Linux shell (Bash/ZSH/Others) One Liners
https://github.com/utensils/one-liners
Last synced: 6 months ago
JSON representation
Linux shell (Bash/ZSH/Others) One Liners
- Host: GitHub
- URL: https://github.com/utensils/one-liners
- Owner: utensils
- Created: 2019-07-03T02:34:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-21T00:40:02.000Z (about 6 years ago)
- Last Synced: 2025-02-15T01:41:50.161Z (8 months ago)
- Size: 1000 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Linux Shell One Liners & Functions
This repo is just an ongoing collection of shell one liners that may be useful.
## Misc
List all executable binaries in your `$PATH`
```shell
find $(echo ${PATH//:/ }) -maxdepth 1 -executable -type f
```Expose unpatched CVE in the gnu `patch` commmand :trollface:
```shell
docker run -i -t alpine:latest sh -c "apk --update add git patch;git config --global user.email 'nobody';git config --global user.name 'cares';git init;echo 'a' > some_file;git add some_file;git commit -m 'Initial commit';echo -e 'b' > some_file;git diff | patch nothing;"
```Generate strong random passwords
```shell
< /dev/urandom tr -dc A-Za-z0-9 | head -c32
```Generate random MAC address, useful for creating virtual interfaces
```shell
hexdump -vn3 -e '/3 "52:54:00"' -e '/1 ":%02x"' -e '"\n"' /dev/urandom
```## AWS Related
Quickly switch between AWS accounts:
example: `aws-profile sandbox`
```shell
aws-profile(){
export AWS_PROFILE="$1"
export AWS_EB_PROFILE="$1"
aws sts get-caller-identity | \
jq -r --arg PROFILE "$AWS_PROFILE" '"Using AWS Account: "+ .Account + " (" + $PROFILE + ")"'
}
```Give s3 bucket owner full permisions to all objects:
example: `aws-set-bucket-owner somebucket-name`
```shell
aws-set-bucket-owner(){
while read object
do
echo "Updating Object: $object"
aws s3api put-object-acl --acl bucket-owner-full-control --bucket "$1" --key "$object"
done < <(aws s3 ls "s3://$1/" --recursive | sed -r 's/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}[[:space:]]+[0-9]+ //g')
}
```