install openjdk 8

Here’s the installation instructions for OpenJDK 8. For Fedora, Redhat and Oracle Linux. yum install java-1.8.0-openjdk For Debian and Ubuntu. apt-get install openjdk-8-jre To see if the packages (symbolic links) are there, they can be found in /etc/alternatives/, at least in Redhat 7. ls -l /etc/alternatives/

January 31, 2021 · 1 min · ulysses

restart rpc gssd service

If a Linux user is having an access problem with a NFS share, and particularly with key expiration, then check if the RPC GSSD service is up and running. NFS clients uses the RPCSEC_GSS protocol to establish security credentials with a NFS server using Kerberos authentication. Here’s an example of a key expire error due to a NFS client not authenticated properly. df -h df: '/data/dir1': Key has expired df: '/data/dir2': Key has expired df: '/data/dir3': Key has expired Check if RPC GSSD service is healthy. Restart the service if there are credential errors. ...

January 31, 2021 · 2 min · ulysses

aws ec2 list firewall rules

AWS EC2 Firewall rules are defined within security groups. Security groups are attached to an instance. An instance can have up to 5 security groups. Essentially, this script gathers all the security groups associated with an instance, loops through them, and then outputs the ingress and egress rules of each security group to a file in a text format. #!/bin/bash # set variables instanceid='i-xxxxxxxxxxxxxxxx' region='us-east-1' profile='sample' # log and temp files output="ec2-sg.log" tmpfil="ec2-sg.tmp" # empty log at start > $output # get sg ids aws ec2 describe-instances \ --instance-ids $instanceid \ --region $region \ --profile $profile \ --query 'Reservations[*].Instances[*].SecurityGroups[*].[GroupId]' --output text > $tmpfil while read -r id; do echo '============================================' >> $output echo $id >> $output echo '============================================' >> $output echo '---------------- INGRESS -------------------' >> $output aws ec2 describe-security-groups \ --group-ids $id \ --profile $profile \ --region $region \ --output text \ --query 'SecurityGroups[].IpPermissions[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]' >> $output echo '---------------- EGRESS --------------------' >> $output aws ec2 describe-security-groups \ --group-ids $id \ --profile $profile \ --region $region \ --output text \ --query 'SecurityGroups[].IpPermissionsEgress[].[FromPort,ToPort,IpProtocol,IpRanges[].CidrIp[]|[0]]' >> $output done Here’s a sample output. ...

January 26, 2021 · 2 min · ulysses

adding domains in certbot

You can register multiple domains to a single SSL certificate. This is particularly useful if you are hosting multiple domains on one server. This command adds more domains to your existing certificate. certbot --expand -d existing.com -d newdomain1.com -d newdomain2.com Check if the domains were added. certbot certificates Certbot certificates are valid for 90 days, but they automatically renew themselves if expiration is less than 30 days. If you need to renew manually for some odd reason, you can run this command. You can also perform a dry-run before renewing. ...

January 25, 2021 · 1 min · ulysses

using or on regular expressions

Here’s a regex using the pipe symbol as OR to allow only 6 possible values. regex="efs-(00|04|08|12|16|20)00" Matches: efs-0000 efs-0400 efs-0800 efs-1200 efs-1600 efs-2000 No matches: efs-0100 efs-2200 efs-0600 efs-1400 efs-1800 efs-1110 111022 asdb023 2330asd 1200-efs 1205 abc $var is compared with $regex to find a match. $var is any of the variables above. if [[ $var != $regex ]]; then echo "Not a match" else echo "It's a match" fi

January 21, 2021 · 1 min · ulysses

aws efs create terraform

Here’s how to build an EFS file system using Terraform. Create a main.tf file. terraform { required_providers { aws = { version = ">= 3.22.0" source = "hashicorp/aws" } } } provider "aws" { profile = "default" region = "us-east-1" } resource "aws_efs_file_system" "efs-test" { creation_token = "efs-test" performance_mode = "generalPurpose" throughput_mode = "bursting" encrypted = "true" tags = { Name = "efs-test" } } resource "aws_efs_mount_target" "efs-mt-example" { file_system_id = aws_efs_file_system.efs-test.id subnet_id = "subnet-xxxxxxxxxxxxxxxxx" security_groups = ["sg-xxxxxxxxxxxxxxxxxx"] } To launch, run terraform. ...

January 18, 2021 · 1 min · ulysses

aws lightsail create terraform

Here’s how to launch a LightSail instance using Terraform. Create a main.tf file. terraform { required_providers { aws = { version = >= 3.22.0" source = "hashicorp/aws" } } } provider "aws" { profile = "default" region = "us-east-1" } resource "aws_lightsail_instance" "yourinstance" { name = "yourinstance" availability_zone = "us-east-1a" blueprint_id = "amazon_linux_2" bundle_id = "nano_2_0" } To launch, run the following Terraform commands. terraform init terraform apply

January 18, 2021 · 1 min · ulysses

install docker on ubuntu 20.04 lts

Here’s the script how to install Docker on Ubuntu 20.04 LTS. #!/bin/bash sudo apt-get update # install dependencies sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common # add the gpg key for docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # add the repository in the Linux mint 20 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo "$UBUNTU_CODENAME") stable" sudo apt-get update # install docker e docker-compose sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo "$UBUNTU_CODENAME") stable" sudo apt-get -y install docker-ce docker-compose # add the user system to sudo group, no sudo command sudo usermod -aG docker $USER # prints docker version =) docker --version

January 18, 2021 · 1 min · ulysses

efs tags auto assign backup tags

Here’s a script that scans all EFS systems in several AWS accounts and regions and randomly assigns backup tags to EFS systems that are missing backup tags. This is assuming EFS is using AWS Backup service using tags to apply backup policies. If there are no backup tags, an EFS gets assigned a randomly picked backup policy. #!/bin/bash # log file output="test.log" tmpfil="temp.txt" # empty file > $output # set random array arr[0]="efs-0000" arr[1]="efs-0400" arr[2]="efs-0800" arr[3]="efs-1200" arr[4]="efs-1600" arr[5]="efs-2000" rand=$[ $RANDOM %6 ] backup=${arr[$rand]} # set accounts and regions declare -a account=("default" "one" "two" "three" "four" "five") declare -a region=("us-east-1" "us-east-2" "us-west-1" "us-west-2") for i in "${account[@]}"; do echo "===================" >> $output echo $i >> $output echo "===================" >> $output for j in "${region[@]}"; do echo $j >> $output aws efs describe-file-systems \ --query "FileSystems[*].[FileSystemId,Tags[?Key=='aws-backup']|[0].Value]" \ --profile $i \ --region $j \ --output text > $tmpfil while read -r id tag; do if [[ $tag == "" ]]; then aws efs tag-resource \ --resource-id $id \ --tags Key="aws-backup",Value=${arr[$rand]} \ --profile $i \ --region $j >> $output echo "Added backup tag $backup to $id" >> $output elif [[ $tag == "no-backup" ]]; then echo "Backup tag is already set to no-backup on $id." >> $output else echo "No backup tag changes applied to $id." >> $output fi done

January 17, 2021 · 2 min · ulysses

aws cli contains

The AWS CLI has a not so well-known comparison operator called “contains” which can be used to filter or query the output of your results. In this example, we want to show only instances that were not terminated. Here’s a query containing “?!contains().” aws ec2 describe-instances \ --query 'Reservations[*].Instances[?!contains(State.Name, `terminated`)].{Instance:InstanceId}' --output text

January 16, 2021 · 1 min · ulysses