7zip in mac os

Install brew install p7zip Extract 7z x file.7z Compress 7z a file.7z mydirectory

April 6, 2022 · 1 min · ulysses

gcp backup instance

Here’s the script to backup GCP disks. #!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)") for disk in $disks do gcloud compute disks snapshot $disk \ --snapshot-names=$disk-$now \ --zone=us-central1-a \ --project=project-id \ --async done

April 3, 2022 · 1 min · ulysses

remove extended attributes on mac

If you have a file with @ sign at end, this is how to remove extended attributes on the Mac OS. Example. ls -l -rwxr-xr-x@ 4 username staff 128 Mar 24 10:51 sample.txt Remove extended attributes. xattr -c sample.txt Result ls -l -rwxr-xr-x 4 username staff 128 Mar 24 10:51 sample.txt

April 3, 2022 · 1 min · ulysses

vi search and replace

How to do search and replace in Vim. Search for “foo” and replace it with “bar” in the current line. Use :s :s/foo/bar/g Search for “foo” and replace it with “bar” in the entire document. Use :%s :%s/foo/bar/g You can also pipe instead of forward slash. Useful if your search contains a /. :%s|foo/|bar|g

April 3, 2022 · 1 min · ulysses

redhat 8 network manager

In Redhat 8, every time you the Network Manager get’s restarted it overwrites /etc/resolv.conf. To prevent that from hapenning, create a new file called /etc/NetworkManager/conf.d/90-dns-none.conf and add the following lines. Restart Network Manager. Your /etc/resolv.conf should be unchanged. [main] dns=none Restart Network Manager $ systemctl reload NetworkManager

March 10, 2022 · 1 min · ulysses

gcp project quotas

Here’s how to get your project quotas in GCP. gcloud compute project-info describe --project your-project-id

March 8, 2022 · 1 min · ulysses

gcp regional quotas

Here’s how to get Regional Quotas for your project in GCP. gcloud compute regions describe us-central1 --project your-project-id

March 8, 2022 · 1 min · ulysses

windows check if port is listening

Here’s how to check if port is listening on a Windows Server. Log in to the destination server. netstat -ano | find "443" | find "LISTEN" tasklist /fi "PID eq "443"

March 3, 2022 · 1 min · ulysses

bash reformat numbers

How to reformat numbers in Bash. $ n=1023555 $ m=$(numfmt --to=si n) $ echo $m 1.1M Other options --to=none # no scaling. Output: 1023555 --to=si # International System of Units (SI) standard. Output 1.1M --to=iec # International Electrotechnical Commission (IEC) standard. Output: 1.1Mi --to=iec-i # International Electrotechnical Commission (IEC) standard. Output: 1.1M --to=auto # ‘auto’ can only be used with --from. fmtnum

February 27, 2022 · 1 min · ulysses

python boto3 s3 list objects

How to list S3 objects using Python Boto3 import boto3 from sys import argv bucket=argv[1] s3 = boto3.resource('s3') mybucket = s3.Bucket(bucket) def list_buckets(): print("List of Buckets: ") for bucket in s3.buckets.all(): print(bucket.name) def list_files(): print("Buckets: The objects in the \"" + bucket + "\" buckets are ... ") for files in mybucket.objects.all(): print(files.key) def main(): #list_buckets() list_files() if __name__ == "__main__": main() Running command $ python test.py bucket-name # with python $ ./test.py bucket-name # without python Results ...

February 27, 2022 · 1 min · ulysses