Here’s how to setup a XFS volume.
file -s /dev/nvme2n1 mkfs -t xfs /dev/nvme2n1 |
Mount to /data.
mkdir /data mount /dev/nvme2n1 /data |
Add to /etc/fstab.
vim /etc/fstab # # UUID=xxxxxxxxxxxxxxxxxxxxxx /data xfs defaults 0 0 |
cloud engineer
Here’s how to setup a XFS volume.
file -s /dev/nvme2n1 mkfs -t xfs /dev/nvme2n1 |
file -s /dev/nvme2n1 mkfs -t xfs /dev/nvme2n1
Mount to /data.
mkdir /data mount /dev/nvme2n1 /data |
mkdir /data mount /dev/nvme2n1 /data
Add to /etc/fstab.
vim /etc/fstab # # UUID=xxxxxxxxxxxxxxxxxxxxxx /data xfs defaults 0 0 |
vim /etc/fstab # # UUID=xxxxxxxxxxxxxxxxxxxxxx /data xfs defaults 0 0
To see which disk is available for swap disk use.
lsblk blkid df -Th |
lsblk blkid df -Th
Format the disk.
fdisk /dev/xvda |
fdisk /dev/xvda
Create a swap disk.
sudo mkswap -f /dev/xvda sudo swapon -s /dev/xvda # or sudo swapon /dev/xvda |
sudo mkswap -f /dev/xvda sudo swapon -s /dev/xvda # or sudo swapon /dev/xvda
Check if swap disk is available.
lsblk free -h cat /proc/swaps cat /proc/meminfo swapon -s top vmstat vmstat 1 5 |
lsblk free -h cat /proc/swaps cat /proc/meminfo swapon -s top vmstat vmstat 1 5
Here’s how to get a list of GCP projects.
gcloud projects list |
gcloud projects list
Result:
PROJECT_ID NAME PROJECT_NUMBER your-project-id-xxxx servers xxxxxxxxxxxx |
PROJECT_ID NAME PROJECT_NUMBER your-project-id-xxxx servers xxxxxxxxxxxx
Use awk to display the project id only.
gcloud projects list | awk '{print $1}' |
gcloud projects list | awk '{print $1}'
Result
PROJECT ID your-project-id-xxxx |
PROJECT ID your-project-id-xxxx
Here are the commands to find out the bucket size in GCP.
gsutil du -s gs://bucket-name/ |
gsutil du -s gs://bucket-name/
Here’s how to set the DeleteOnTermination setting on EBS volumes. The DeleteOnTermination flag determines if an EBS volume will be kept or deleted when an EC2 instance is terminated. The DeleteOnTermination setting can be set during EC2 instance creation, or it can be applied to an existing or a running EC2 instance. The settings can be placed in a JSON file and loaded using –block-device-mappings option upon creation.
During creation.
aws ec2 run-instances \ --count 1 \ --region us-east-2 \ --key-name tfc-ohio \ --image-id ami-xxxxxxxx \ --instance-type t2.large \ --subnet-id subnet-xxxxxxx \ --private-ip-address 10.0.4.100 \ --iam-instance-profile Name=machinerole \ --security-group-ids sg-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json |
aws ec2 run-instances \ --count 1 \ --region us-east-2 \ --key-name tfc-ohio \ --image-id ami-xxxxxxxx \ --instance-type t2.large \ --subnet-id subnet-xxxxxxx \ --private-ip-address 10.0.4.100 \ --iam-instance-profile Name=machinerole \ --security-group-ids sg-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json
Contents of mapping.json
[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 30 "VolumeType": "gp2" } } ] |
[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 30 "VolumeType": "gp2" } } ]
Device name is /dev/sda1. Termination is set to true. Volume size is 30GB and EBS type is gp2.
Modifying an existing EC2 instance.
aws ec2 modify-instance-attribute \ --instance-id i-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json |
aws ec2 modify-instance-attribute \ --instance-id i-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json
Here’s the mapping.json file.
[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": false, } } ] |
[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": false, } } ]
Obviously, you can’t change Volume size and type to an existing EBS volume, but you can flip the DeleteOnTermination flag and vice versa.
Here’s how to list all the devices on your network using nmap.
nmap -sn 192.168.0.0/24 |
nmap -sn 192.168.0.0/24
If nmap is not installed, install it.
yum install nmap apt install nmap |
yum install nmap apt install nmap
Netstat is a utility for gathering network statistics. It comes preinstalled on most systems.
If missing, here’s how to install.
# Redhat, CentOS yum install net-tools # Debian, Ubuntu, Mint apt install net-tools # SLES, SUSE zypper install net-tools |
# Redhat, CentOS yum install net-tools # Debian, Ubuntu, Mint apt install net-tools # SLES, SUSE zypper install net-tools
Here are some common and useful commands.
# show version netstat -v # show routing table netstat -nr # show network interface statistics netstat -ai # show network connections netstat -ant # show network services netstat -tulpn |
# show version netstat -v # show routing table netstat -nr # show network interface statistics netstat -ai # show network connections netstat -ant # show network services netstat -tulpn
Here’s how to list the available PHP modules.
apt-cache search php- | less |
apt-cache search php- | less
To get details about a module.
apt-cache show php-curl |
apt-cache show php-curl
To install a module.
apt install php-curl |
apt install php-curl
Or install all modules.
apt install php* |
apt install php*
Restart Apache after each install.
systemctl restart apache2 |
systemctl restart apache2