• Skip to primary navigation
  • Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives
  • Contact

check

Check If Domain Joined

by Ulysses · Oct 28, 2020

Here’s the command to check if instance is domain joined.

realm discover domain.com

realm discover domain.com

To check if AD user is working.

id user@ad.example.com

id user@ad.example.com

To check if AD group is working.

getent group ad-group

getent group ad-group

Filed Under: Linux Tagged With: check, domain, join, sssd, user

GCE Agent Powershell

by Ulysses · May 11, 2020

This is a Powershell script to restart a service if it’s down.

$ServiceName = 'GCEAgent'
$arrService = Get-Service -Name $ServiceName
 
if ($arrService.Status -ne 'Running')
{
 
    Start-Service $ServiceName
    write-host $arrService.status
    write-host 'Service starting'
    Start-Sleep -seconds 60
    $arrService.Refresh()
    if ($arrService.Status -eq 'Running')
    {
        Write-Host 'GCE Agent Service is now Running'
    }
 
}
else
{
    Write-Host 'GCE Agent Service is Running'
}

$ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' }

Filed Under: Cloud, Windows Tagged With: check, powershell, restart, service

GCP Check Instances Running

by Ulysses · Jan 18, 2020

Here’s how to check if instances are running in GCP.

#!/bin/bash
while IFS=', ' read -r a b c; do
  instance="${a//[[:blank:]]/}"
  project="${b//[[:blank:]]/}"
  zone="${c//[[:blank:]]/}"
  gcloud compute instances describe $instance \
  --zone $zone --project $project \
  --format='table[no-heading](name,status,zone)'
done < instance-list.txt

#!/bin/bash while IFS=', ' read -r a b c; do instance="${a//[[:blank:]]/}" project="${b//[[:blank:]]/}" zone="${c//[[:blank:]]/}" gcloud compute instances describe $instance \ --zone $zone --project $project \ --format='table[no-heading](name,status,zone)' done < instance-list.txt

Instances are read from an external file. File is comma delimited with instance name, project id and zone data.

Filed Under: Cloud Tagged With: check, compute, gcloud, gcp, instances, running, sdk

Removing Old Kernels

by Ulysses · Jun 10, 2019

How to check which kernel is running on your system

uname -sr

uname -sr

List all kernels installed on the system.

rpm -q kernel

rpm -q kernel

Removing old kernels using package-cleanup. This keeps 2 kernels on the system.

yum install yum-utils
package-cleanup --oldkernels --count=2

yum install yum-utils package-cleanup --oldkernels --count=2

Filed Under: Linux Tagged With: check, kernel, remove

RPM Check Packages

by Ulysses · Feb 20, 2019

How to check RPM if packages are installed.

rpm -qa --last 
rpm -qa --last | more
rpm -qa --last | grep "package name"

rpm -qa --last rpm -qa --last | more rpm -qa --last | grep "package name"

Filed Under: Linux Tagged With: check, rpm

Check Memory in Linux

by Ulysses · Feb 6, 2019

Here are several commands to check memory in Linux.

free -m
cat /proc/meminfo
vmstat -s
top

free -m cat /proc/meminfo vmstat -s top

Filed Under: Linux Tagged With: check, memory

Check Argument in Bash

by Ulysses · Jan 15, 2019

How to check for an argument in a script in Bash.

if [ -z "$1" ] ; then
  echo "there are no arguments"
else
  echo "there is an argument"
fi

if [ -z "$1" ] ; then echo "there are no arguments" else echo "there is an argument" fi

Filed Under: Linux Tagged With: argument, check, if then else

Copyright © 2012–2021

  • Cloud
  • Linux
  • Git