docker exec

If you want to SSH to a Docker container, use the Docker exec command. docker exec -it container_name bash docker exec -it --user root container_name /bin/bash I’m using a Git Bash terminal, so I have to prefix the docker command with winpty. winpty docker exec -it container_name bash Result root@681bbe3f65f1:/var/www/html# Ctrl-D to exit.

April 9, 2021 · 1 min · ulysses

troubleshoot nameservers with dig

Here’s how to troubleshoot nameservers with dig. dig hostname dig domain.com To test a specific nameserver. dig @nameserver hostname dig @nameserver ip-address Other options. dig hostname.domain.com +short dig hostname.domain.com +noall +answer dig @nameserver MX domain.com dig @nameserver AAAA domain.com

April 8, 2021 · 1 min · ulysses

startup script

Here’s how to run a script on bootup on Rhel 7 that’s running systemd. First create a script. It this case, it will create a file called test.txt. #!/bin/bash > /root/test.txt Make the script executable. chmod /root/test.sh Now create a service in /etc/systemd/system/test.service # vi /etc/systemd/system/test.service [Unit] Description=A test service After=network.target [Service] Type=simple ExecStart=/root/test.sh TimeoutStartSec=0 [Install] WantedBy=default.target Reload systemd. systemctl daemon-reload Enable the service. systemctl enable test.service Start the service. systemctl start test.service Reboot and test. ...

April 6, 2021 · 1 min · ulysses

gitbash path

Open Git Bash. Change to the root directory of Git Bash. cd ~ echo $PATH /bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin Edit .bash_profile or .bashrc. It was .bash_profile in my case. Showing a truncated path. Add your custom path to the PATH variable. Save file. Exit Git Bash. PATH="/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path" Open Git Bash again and check your updated Path. echo $PATH Result. /bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path

April 4, 2021 · 1 min · ulysses

set timezone permanently

It’s recommended to set the clock to UTC. In rare occasions, local time may be needed. Here’s how to set your server’s timezone permanently. Check the date first. date Backup localtime. Set it to US Eastern Time. mv /etc/localtime /etc/localtime.backup ln -s /usr/share/zoneinfo/America/New_York /etc/localtime Backup clock. Set it to US Eastern Time. cp -p /etc/sysconfig/clock /etc/sysconfig/clock.backup > /etc/sysconfig/clock echo ZONE=\"America/New_York\" > /etc/sysconfig/clock Run the date again to validate. date

March 18, 2021 · 1 min · ulysses

gcp 400 bad request

After logging in, I tried to run Terraform in GCP and received this error: oauth2: cannot fetch token: 400 Bad Request Here’s the fix. Login using application-default. gcloud auth application-default login You can then Terraform. terraform apply

March 15, 2021 · 1 min · ulysses

bitwarden

I changed password managers from LastPass to BitWarden the other day. Migrating your credentials requires exporting and importing a CSV file from one program to another. It was an easy transition. Everything seems to work. As you may be aware, LastPass decided to make their free account limited to just one device. Customers will need to choose which device to use, whether desktop or mobile. Not both. If you want it on multiple devices, you’ll need to fork up $3 per month. It is not that expensive, but there are other alternatives. A few recommend BitWarden. It will let you sync to all devices for free. It was an easy choice.

March 11, 2021 · 1 min · ulysses

gcp cloud shell vim settings

I had an issue with using the backspace in Vim in GCP’s Cloud Shell. Every time I’m in the insert mode and I want to edit using backspace, it doesn’t delete the characters. It shows these characters “^?” instead. Well, it turned out to be a backspace setting that you can set within .vimrc. So, here’s my working setup. colo desert syntax on set backspace=indent,eol,start set nocompatible The first line uses the desert theme. The second line turns on syntax highlighting. It’s on by default. The third line fixes the backspace issue I mentioned above.

March 10, 2021 · 1 min · ulysses

aws backup setup

This script creates an AWS backup vault, adds a backup plan and a backup selection. Set up profile, region and Account ID first. #!/bin/bash profile="default" region="us-east-1" id=$(aws sts get-caller-identity --query Account --output text) Create a vault. aws backup create-backup-vault \ --backup-vault-name my-vault \ --profile $profile \ --region $region Create a backup plan. aws backup create-backup-plan \ --backup-plan file://back-plan.json \ --profile $profile \ --region $region backup-plan.json { "BackupPlan": { "BackupPlanName": "efs-0000", "Rules": [ { "RuleName": "efs-0000", "TargetBackupVaultName": "my-vault", "ScheduleExpression": "cron(0 0 ? * * *)", "StartWindowMinutes": 60, "CompletionWindowMinutes": 10080, "Lifecycle": { "DeleteAfterDays": 7 } } ] } } Get the backup plan ID. ...

March 6, 2021 · 1 min · ulysses

aws get account id

Here’s a quick way to find the AWS Account ID via AWS CLI. aws sts get-caller-identity --query Account --output text Output is a 12 digit number (redacted) xxxxxxxxxxxx AWS Account ID is a 12 digit number unique to each AWS account. Occasionally, there are scripts and policies that need the ID of the account. The command above is one way of querying the account ID so they can be used for policies that need them.

March 6, 2021 · 1 min · ulysses