aws efs tags

This script add new tags if they are missing. #!/bin/bash log="log.txt" id=$(aws efs describe-file-systems --query "FileSystems[*].[FileSystemId]" --output text --region us-east-1) tag=$(aws efs describe-file-systems --query "FileSystems[*].Tags[?Key=='aws-backup'].Value" --output text --region us-east-1 ) 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]} if [[ $tag == "" ]]; then aws efs tag-resource --resource-id $id --tags Key="aws-backup",Value=${arr[$rand]} --profile default --region us-east-1 echo "Added backup tag $backup to $id" elif [[ $tag == "no-backup" ]]; then echo "No backup on $id." else echo "No changes done to $id." fi

January 4, 2021 · 1 min · ulysses

aws cli display tags

This command lists the EC2 instance id and the tag name using query. aws ec2 describe-instances \ --query 'Reservations[].Instances[].[InstanceId,Tags[?Key==Name]|[0].Value]' \ --profile tfc \ --region us-east-2 \ --output text Output: i-xxxxxxxxxxxxxxxxx server-one i-xxxxxxxxxxxxxxxxx server-two i-xxxxxxxxxxxxxxxxx server-three |[0].Value insures output is one instance record per line.

January 2, 2021 · 1 min · ulysses

aws lightsail blueprints

Amazon Lightsail offers a variety of OS blueprints, starting from Amazon Linux 2, Ubuntu 20, Windows Server 2019 to Debian 10 to name just a few. Blueprints are a curated selection of operating systems and software that are preinstalled for the creation of instances. For brevity, only a subset of blueprints are displayed below. The description and licenseUrl portions are truncated. To display an entire list of LightSail blueprints, run this command. ...

January 1, 2021 · 2 min · ulysses

mysql select like

Here’s how to perform SQL searches using the like operator. # Format SELECT column1, column2 FROM table_name WHERE column LIKE pattern; # Search for an entry starting with a 'joe.' SELECT id,username,address FROM users WHERE username LIKE 'joe%'; # Search for an entry ending with a 'joe.' SELECT id,username,address FROM users WHERE username LIKE '%joe'; # Search for any entry with 'joe' from any position. SELECT id,username,address FROM users WHERE username LIKE '%joe%'; # Finally, using "_" as wildcards. Find any field with "j" in the second position. SELECT id,username,address FROM users WHERE username LIKE '_j';

December 27, 2020 · 1 min · ulysses

aws cloudshell

AWS just added a new feature called CloudShell. It will give users who are logged in to the AWS console access to a VM where users can run AWS CLI commands. Permissions to AWS resources is based on the user’s permissions which are managed via IAM. CloudShell is similar to the cloud shells that Azure and GCP already offer. Here’s a snapshot of AWS CloudShell.

December 24, 2020 · 1 min · ulysses

yum localinstall

Here’s how to install a RPM locally. Download the RPM first. wget https://domain.com/path/to/file/rpmfile1.rpm wget https://domain.com/path/to/file/rpmfile2.rpm Then install RPM from a local file. yum localinstall /path/to/rpmfile1.rpm yum localinstall /path/to/rpmfile2.rpm

December 24, 2020 · 1 min · ulysses

adding new users in powershell

Here’s an easy way to add Windows users in Powershell. net user username 'password' /add Passwords must meet requirements. While you are at it, give it Admin rights. net localgroup Administrators username /add

December 23, 2020 · 1 min · ulysses

reboot instance script

Here’s a new script to reboot a Lightsail instance based on input. #!/bin/bash echo 'Choose a server to reboot ...' echo '1) server-one' echo '2) server-two' echo '3) server-three' echo '4) server-four' echo '5) sever-five' echo 'q) Quit' read -p 'Choose a server to reboot: ' server case $server in 1) echo 'Rebooting server-one ...' aws lightsail reboot-instance --instance-name server-one echo 'Done' ;; 2) echo 'Rebooting server-two ...' aws lightsail reboot-instance --instance-name server-two echo 'Done' ;; 3) echo 'Rebooting server-three ...' aws lightsail reboot-instance --instance-name server-three echo 'Done' ;; 4) echo 'Rebooting server-four ...' aws lightsail reboot-instance --instance-name server-four echo 'Done' ;; 5) echo 'Rebooting server-five ...' aws lightsail reboot-instance --instance-name server-five echo 'Done' ;; q) echo 'Quit' ;; *) echo 'Invalid option' $server ;; esac Assuming awscli is working and correct permission is granted to user.

December 21, 2020 · 1 min · ulysses

httpd on redhat and centos

Here are the commands to start, stop, enable and get the status of Apache on RHEL and CentOS. systemctl enable httpd # enable on bootup systemctl status httpd # get status systemctl start httpd # start systemctl stop httpd # stop systemctl restart httpd # restart

December 4, 2020 · 1 min · ulysses

add existing user to a group

Here’s how to add an existing user to a user group in Linux. usermod -a -G groupname username usermod -a -G www-data john List all users belonging to a group. lid -g www-data List all the groups the user belongs to. groups john

December 3, 2020 · 1 min · ulysses