This will display only lines 40-50 in a file called lines.txt.
$ cat lines.txt | head -n 50 | tail -n 10 |
For lines 90-100.
$ cat lines.txt | head -n 100 | tail -n 10 |
and so on.
cloud engineer
This will display only lines 40-50 in a file called lines.txt.
$ cat lines.txt | head -n 50 | tail -n 10 |
$ cat lines.txt | head -n 50 | tail -n 10
For lines 90-100.
$ cat lines.txt | head -n 100 | tail -n 10 |
$ cat lines.txt | head -n 100 | tail -n 10
and so on.
Here’s how to view system memory on Linux.
Default display is in kB
cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB |
cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB
Display in MB
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB |
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB
Output in GB
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB |
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB
How to lock a package or software in RedHat.
# For RHEL 5 yum install yum-versionlock # For RHEL 6 and 7 yum install yum-plugin-versionlock # For RHEL 8 and 9 yum install python3-dnf-plugin-versionlock |
# For RHEL 5 yum install yum-versionlock # For RHEL 6 and 7 yum install yum-plugin-versionlock # For RHEL 8 and 9 yum install python3-dnf-plugin-versionlock
Locking a package
yum versionlock gcc-* |
yum versionlock gcc-*
List locked packages
yum versionlock list |
yum versionlock list
Key-based SSH login is prompting a password despite it’s already setup to use keys. As turns out, the home directory was changed to 777. To fix, I changed home folder permissions and restarted SSH. It probably does not need a restart, but it doesn’t hurt.
chown -R username:username /home/username find /home/username -type d -exec chmod 755 {} \; find /home/username -type f -exec chmod 644 {} \; |
chown -R username:username /home/username find /home/username -type d -exec chmod 755 {} \; find /home/username -type f -exec chmod 644 {} \;
sudo systemctl restart ssh |
sudo systemctl restart ssh
Here’s how to restore or set the Bash prompt on RHEL systems.
echo "PS1='\u@\h \w]\$'" >> ~/.bashrc source ~/.bashrc |
echo "PS1='\u@\h \w]\$'" >> ~/.bashrc source ~/.bashrc
Here’s how to get health status of a GCP Load Balancer Backend Services.
For all load balancers except target pool.
gcloud compute backend-services get-health BACKEND_SERVICE_NAME \ --region us-central1 \ --project project-id |
gcloud compute backend-services get-health BACKEND_SERVICE_NAME \ --region us-central1 \ --project project-id
For target pool load balancers, use this command.
gcloud compute target-pools get-health TARGET_POOL_NAME \ --region us-central1 \ --project project-id |
gcloud compute target-pools get-health TARGET_POOL_NAME \ --region us-central1 \ --project project-id
Here’s how to enable performance insights on a RDS instance.
Enable
aws rds modify-db-instance \ --db-instance-identifier sample-db-instance \ --enable-performance-insights \ --region us-east-1 \ --profile default |
aws rds modify-db-instance \ --db-instance-identifier sample-db-instance \ --enable-performance-insights \ --region us-east-1 \ --profile default
Disable
aws rds modify-db-instance \ --db-instance-identifier sample-db-instance \ --no-enable-performance-insights \ --region us-east-1 \ --profile default |
aws rds modify-db-instance \ --db-instance-identifier sample-db-instance \ --no-enable-performance-insights \ --region us-east-1 \ --profile default
Here’s how to list the luns for a particular volume.
gcloud bms volumes luns list --project project-id --region us-central1 --volume at-xxxxxxx-volxxx |
gcloud bms volumes luns list --project project-id --region us-central1 --volume at-xxxxxxx-volxxx