• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Hide All Windows Except Current

September 10, 2022

Less clutter is good. There are times when there’s too many windows in our desktop. Having less clutter leads to better focus. Here’s how to hide all Windows on a Mac OS except for the current or active one.

Command + Option + h

Command + Option + h

I wished there was a command to bring them all back, but I have not found one yet.

Filed Under: Misc

History Without Line Numbers

September 8, 2022

Here’s how to display history without the line numbers.

history -w /dev/stdout

history -w /dev/stdout

Result

cd /etc/httpd/conf
view httpd.conf 
vim wiki.conf 
vim ssl.conf

cd /etc/httpd/conf view httpd.conf vim wiki.conf vim ssl.conf

Filed Under: Linux Tagged With: history, lines, list, without

CloudWatch Notifications

September 7, 2022

How to give someone access to enable/disable CloudWatch notifications.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "cloudwatch:DescribeAlarms",
                "cloudwatch:EnableAlarmActions",
                "cloudwatch:DisableAlarmActions"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}

{ "Version": "2012-10-17", "Statement": [ { "Action": [ "cloudwatch:DescribeAlarms", "cloudwatch:EnableAlarmActions", "cloudwatch:DisableAlarmActions" ], "Effect": "Allow", "Resource": "*" } ] }

Filed Under: Cloud Tagged With: aws, cloudwatch, disable, enable, notifications

DF command takes too long

September 7, 2022

Here’s a workaround if the df command takes too long to run.

This limits listing to local file systems only.

df -l

df -l

Filed Under: Linux Tagged With: command, df, long, too

GCP Role Policy Binding

September 6, 2022

How to display the policy binding.

gcloud compute instances get-iam-policy SERVER --project=PROJECT_ID --zone=ZONE

gcloud compute instances get-iam-policy SERVER --project=PROJECT_ID --zone=ZONE

Result

# There is no binding policy
etag: ACAB
 
# There is a binding policy
bindings:
- members:
  - serviceAccount:SERVICEACCOUNT
  role: organizations/xxxxxxxxxxxx/roles/ROLE
etag: xxxxxxxxxxx=
version: 1

# There is no binding policy etag: ACAB # There is a binding policy bindings: - members: - serviceAccount:SERVICEACCOUNT role: organizations/xxxxxxxxxxxx/roles/ROLE etag: xxxxxxxxxxx= version: 1

Add a role binding policy

gcloud compute instances add-iam-policy-binding SERVER \
--project=PROJECT_ID \
--zone=ZONE \
--member=serviceAccount:SERVICEACCOUNT \
--role="organizations/xxxxxxxxxxxx/roles/ROLE"

gcloud compute instances add-iam-policy-binding SERVER \ --project=PROJECT_ID \ --zone=ZONE \ --member=serviceAccount:SERVICEACCOUNT \ --role="organizations/xxxxxxxxxxxx/roles/ROLE"

Remove a role binding policy

gcloud compute instances remove-iam-policy-binding SERVER \
--project=PROJECT_ID \
--zone=ZONE \
--member=serviceAccount:SERVICEACCOUNT \
--role="organizations/xxxxxxxxxxxx/roles/ROLE"

gcloud compute instances remove-iam-policy-binding SERVER \ --project=PROJECT_ID \ --zone=ZONE \ --member=serviceAccount:SERVICEACCOUNT \ --role="organizations/xxxxxxxxxxxx/roles/ROLE"

Filed Under: Cloud Tagged With: binding, gcp, policy, role, vm

Jekyll on Docker Container

August 30, 2022

Here’s how to run Jekyll in a Docker container.

mkdir blog
cd blog
docker run -v $(pwd):/site bretfisher/jekyll new .
docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve

mkdir blog cd blog docker run -v $(pwd):/site bretfisher/jekyll new . docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve

Another option is to use docker compose. Create a docker-compose.yml file.

version: 3.5
services:
  jekyll:
    image: bretfisher/jekyll-serve
    volumes:
      - .:/site
    ports:
      - '4000:4000'

version: 3.5 services: jekyll: image: bretfisher/jekyll-serve volumes: - .:/site ports: - '4000:4000'

Run Jekyll.

cd blog
docker-compose up -d

cd blog docker-compose up -d

Stop Jekyll.

cd blog
docker-compose down

cd blog docker-compose down

Filed Under: Linux Tagged With: container, docker, docker-compose, down, jekyll, up

Cleanup Stale CVS Snapshots

August 30, 2022

Here’s the script that looks mounts with stale file handles and removes them.

#!/bin/bash
file='/tmp/stale.txt'
df -h | grep Stale > $file
sed -i -e 's/df: ‘/'""'/g' $file
sed -i -e 's/’: Stale file handle/'""'/g' $file
while IFS= read -r line; do
  echo 'unmounting '$line
  umount $line
done < $file

#!/bin/bash file='/tmp/stale.txt' df -h | grep Stale > $file sed -i -e 's/df: ‘/'""'/g' $file sed -i -e 's/’: Stale file handle/'""'/g' $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file

Filed Under: Linux Tagged With: bash, cvs, file, handles, snapshots, stale

Cleanup CVS Snapshot Volumes

August 30, 2022

How to unmount CVS snapshot volumes all at once using a Bash script. I ran into a scenario where I had to unmount 115 volumes. Instead of manually running umount on each one, I use the script below to unmount all 115 volumes. The script performs a grep for ‘.snapshot’ and then writes the results to a file. I then read the file line by line and perform unmount on each one.

#!/bin/bash
file='/tmp/snapshots.txt'
df -h | grep .snapshot | awk '{print $6}' > $file
while IFS= read -r line; do
  echo 'unmounting '$line
  umount $line
done < $file

#!/bin/bash file='/tmp/snapshots.txt' df -h | grep .snapshot | awk '{print $6}' > $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file

Filed Under: Linux Tagged With: bash, cvs, snapshots, umount

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Go to page 6
  • Interim pages omitted …
  • Go to page 123
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023