• Skip to primary navigation
  • Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Ulysses

WordPress Critical Error

by Ulysses · Apr 11, 2021

If you get a WordPress “There has been a critical error on your website” error, you probably have an issue with a theme or plugin. The quickest way to troubleshoot is to rename the plugins directory since there’s no way to login. This technically disables all plugins. Rename it back to plugins and enable each plugin one by one.

Disable all plugins.

mv plugins plugins-backup

mv plugins plugins-backup

Login and restore the plugins directory.

mv plugins-backup plugins

mv plugins-backup plugins

Enable each plugin one by one and check if the site is broken.

Filed Under: WP Tagged With: critical, error, plugins, themes

Docker Exec

by Ulysses · Apr 9, 2021

If you want to SSH to a Docker container, use the Docker exec command.

docker exec -it container_name bash

docker exec -it container_name 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

winpty docker exec -it container_name bash

Result

root@681bbe3f65f1:/var/www/html#

root@681bbe3f65f1:/var/www/html#

Ctrl-D to exit.

Filed Under: Linux Tagged With: bash, container, docker, exec, git bash

Troubleshoot Nameservers with Dig

by Ulysses · Apr 8, 2021

Here’s how to troubleshoot nameservers with dig.

dig hostname
dig domain.com

dig hostname dig domain.com

To test a specific nameserver.

dig @nameserver hostname
dig @nameserver ip-address

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

dig hostname.domain.com +short dig hostname.domain.com +noall +answer dig @nameserver MX domain.com dig @nameserver AAAA domain.com

Filed Under: Linux Tagged With: dig, nameservers, test, troubleshoot

Startup Script

by Ulysses · Apr 6, 2021

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

#!/bin/bash > /root/test.txt

Make the script executable.

chmod /root/test.sh

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

# 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

systemctl daemon-reload

Enable the service.

systemctl enable test.service

systemctl enable test.service

Start the service.

systemctl start test.service

systemctl start test.service

Reboot and test.

reboot

reboot

Validate if the script ran. Check if the file was created.

Filed Under: Cloud, Linux Tagged With: bootup, rhel 7, script, systemd

GitBash Path

by Ulysses · Apr 4, 2021

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

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"

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

echo $PATH

Result.

/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path

/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/custom/path

Filed Under: Windows Tagged With: edit, git bash, path

Set Timezone Permanently

by Ulysses · Mar 18, 2021

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

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

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

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

date

Filed Under: Linux Tagged With: permanent, redhat, set, timezone

GCP 400 Bad Request

by Ulysses · Mar 15, 2021

After logging in, I tried to run Terraform in GCP and received this error:

oauth2: cannot fetch token: 400 Bad Request

oauth2: cannot fetch token: 400 Bad Request

Here’s the fix. Login using application-default.

gcloud auth application-default login

gcloud auth application-default login

You can then Terraform.

terraform apply

terraform apply

Filed Under: Cloud Tagged With: 400, bad, fetch, gcp, login, oauth2, request, token

BitWarden

by Ulysses · Mar 11, 2021

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.

Filed Under: Misc Tagged With: bitwarden, lastpass, managers, password

GCP Cloud Shell Vim Settings

by Ulysses · Mar 10, 2021

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

colo desert syntax on set backspace=indent,eol,start

  • 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.

Filed Under: Cloud Tagged With: backspace, cloud, gcp, shell, vim, vimrc

AWS Backup Setup

by Ulysses · Mar 6, 2021

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)

#!/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

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

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
                }
            }
        ]
    }
}

{ "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.

planid=$(aws backup list-backup-plans \
  --query "BackupPlansList[?BackupPlanName=='efs-0000'].BackupPlanId" \
  --profile $profile \
  --region $region \
  --output text)

planid=$(aws backup list-backup-plans \ --query "BackupPlansList[?BackupPlanName=='efs-0000'].BackupPlanId" \ --profile $profile \ --region $region \ --output text)

Create a backup selection.

# Create a backup selection
aws backup create-backup-selection \
--backup-plan-id $planid \
--cli-input-json file://backup-selection.json \
--profile $profile \
--region $region

# Create a backup selection aws backup create-backup-selection \ --backup-plan-id $planid \ --cli-input-json file://backup-selection.json \ --profile $profile \ --region $region

backup-selection.json

{
    "BackupSelection": {
		"SelectionName": "efs-0000",
        "IamRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/service-role/AWSBackupDefaultServiceRole",
        "Resources": [],
        "ListOfTags": [
            {
                "ConditionType": "STRINGEQUALS",
                "ConditionKey": "aws-backup",
                "ConditionValue": "efs-0000"
            }
        ]
    }
}

{ "BackupSelection": { "SelectionName": "efs-0000", "IamRoleArn": "arn:aws:iam::xxxxxxxxxxxx:role/service-role/AWSBackupDefaultServiceRole", "Resources": [], "ListOfTags": [ { "ConditionType": "STRINGEQUALS", "ConditionKey": "aws-backup", "ConditionValue": "efs-0000" } ] } }

The enable EFS backup, add a tag key of aws-backup with a value of efs-0000.

Filed Under: Misc

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 78
  • Go to Next Page »

Copyright © 2012–2021