• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for December 2020

MySQL Select Like

December 27, 2020

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';

# 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';

Filed Under: Linux, Misc Tagged With: like, mysql, pattern, search

AWS CloudShell

December 24, 2020

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.

Filed Under: Cloud Tagged With: aws, azure, cloudshell, gcp, vm

Yum localinstall

December 24, 2020

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

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

yum localinstall /path/to/rpmfile1.rpm yum localinstall /path/to/rpmfile2.rpm

Filed Under: Linux Tagged With: install, local, rhel, rpm, yum

Adding New Users in Powershell

December 23, 2020

Here’s an easy way to add Windows users in Powershell.

net user username 'password' /add

net user username 'password' /add

Passwords must meet requirements. While you are at it, give it Admin rights.

net localgroup Administrators username /add

net localgroup Administrators username /add

Filed Under: Windows Tagged With: admin, new, powershell, rights, users

Reboot Instance Script

December 21, 2020

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

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

Filed Under: Linux Tagged With: bash, instance, lightsail, reboot

HTTPD on Redhat & Centos

December 4, 2020

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

systemctl enable httpd # enable on bootup systemctl status httpd # get status systemctl start httpd # start systemctl stop httpd # stop systemctl restart httpd # restart

Filed Under: Linux Tagged With: centos, enable, redhat, start, status, stop

EFS Encryption

December 3, 2020

If you have an existing EFS that’s unencrypted, you can encrypt it be creating a snapshot using AWS Backup, and then restoring the file system to a new EFS with encryption. If you choose to restore in a directory in the same file system, it will not be encrypted. It has to be a new EFS. In addition, you’ll be asked to select which encryption key to use. The default key will work, unless you have your own.

Filed Under: Cloud Tagged With: aws, backup, efs, encryption, key, restore, unencrypted

Add Existing User To A Group

December 3, 2020

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

usermod -a -G groupname username usermod -a -G www-data john

List all users belonging to a group.

lid -g www-data

lid -g www-data

List all the groups the user belongs to.

groups john

groups john

Filed Under: Linux Tagged With: add, existing, group, user

  • Home
  • About
  • Archives

Copyright © 2023