My Cheat Sheets

Here you will find my collection of cheatsheets. This is mainly because I find it hard to remember every command. So i make a note here and refer back to it when needed.

If you like it please leave a comment, or if you have a command to recommend then please let me know.

Please note that this page is:

VMware Cheatsheet

These cheats sheets are to be used on VMware plaform

CommandWhat it does?
/etc/init.d/hostd restart
/etc/init.d/vpxa restart
Restart ESX host services
# Check if your VM has (Change Block Tracking) enabled or not
(Get-VM -Name XXXXXX).ExtensionData.Config.ChangeTrackingEnabled
(Get-VM -Name XXXXXX).ExtensionData.Config.ChangeTrackingEnabled
# Find VMs where CBT (Change Block Tracking) is Enabled
Get-VM| Where-Object{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}
Change block tracking is when the disk writes all changes as blocks to disks. It means the entire datastore allocation is used. Useful for backup software
Get-VM | Get-NetworkAdapter | Select @{N='VM';E={$_.Parent.Name}},@{N='AdapterName';E={$_.Name}},@{N='Type';E={$_.Type}} | Where-Object{$_.Type -eq "e1000"}Get VM Network details that equal E1000 - useful if your servers should be on VMXNET3 (10gb)
Get-vm | Select Name, @{N="IP Address";E={@($_.guest.IPAddress[0])}}Get VM IP address
Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, @{N="ESX Host";E={Get-VMHost -VM $_}}, @{N="Datastore";E={Get-Datastore -VM $_}} |sort-object DatastoreGets VM Name, Cluster details, host details and Datastore information
Get-VM | Get-NetworkAdapter | Select-Object Parent,TypeGets VM details and shows the display adapter
get-vm | foreach-object -process {get-harddisk $_} | select-object storageformat | format-listDisplays what storage format is used - thick lazy zero, thick eager zero, thin provisioned
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-90)} | Select-Object VM, Name, Created, SizeMBGet Snapshot details
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-120)} | Remove-Snapshot -Confirm:$falseRemove all snapshots older than 120 days
Get-VM | Format-Table Name, @{Label="NumSnapshots";Expression={(Get-Snapshot -VM $_ | Measure-Object).Count}}  Lists all VMs and displays how many snapshots per VM
get-vm |% { get-view $_.id } | select Name, @{ Name=";ToolsVersion";; Expression={$_.config.tools.toolsVersion}}Get VMware Tools version
get-vmhost | select Name,@{Name="Time";Expression={(get-view $_.ExtensionData.configManager.DateTimeSystem).QueryDateTime()}}Get the time on the hosts ESX servers
ForEach ($VM in Get-VM ){($VM.Extensiondata.Guest.Disk | Select @{N="Name";E={$VM.Name}},DiskPath, @{N="Capacity(MB)";E={[math]::Round($_.Capacity/ 1MB)}}, @{N="Free Space(MB)";E={[math]::Round($_.FreeSpace / 1MB)}}, @{N="Free Space %";E={[math]::Round(((100* ($_.FreeSpace))/ ($_.Capacity)),0)}})} Get VM Name, Displays disk paths, used space and free space.
Get-VMHost | Sort Name | Get-View | Select Name, @{N="CPU";E={$_.Hardware.CpuPkg[0].Description}}Get CPU information of ESX Host
Get-VMHost |Sort Name |Get-View |Select Name, @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},@{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},@{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} Get ESX host, get server information, Number of CPU sockets, Cors and the speed of the CPU mhz
Get-Vmhost *This lists useful information about all your ESX hosts
get-vmhost -datastore XXXXXList useful information about a particular datastore
Get-VMHostService -vmhost XXXXXGets details about all services on the host
Get-VMHostService | where {$_.key -eq "TSM-SSH"}Get SSH service details from hosts
Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Start-VMHostServiceStart SSH service on host
Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Stop-VMHostServiceStop SSH service on host
Get-VM | Get-SnapshotGets snapshot details from servers powered on or powered off
Get-VM | Get-VMGuest | format-tableUseful command to strip out VM details - such as IP, OS etc
Get-VMHost | Select @{N="Cluster";E={Get-Cluster -VMHost $_}}, Name, @{N="NumVM";E={($_ | Get-VM).Count}} | Sort Cluster, NameLists the number of clusters, and each VM on each host and cluster
ForEach ($VM in Get-VM ){($VM.Extensiondata.Guest.Disk | Select @{N="Name";E={$VM.Name}},DiskPath, @{N="Capacity(MB)";E={[math]::Round($_.Capacity/ 1MB)}}, @{N="Free Space(MB)";E={[math]::Round($_.FreeSpace / 1MB)}}, @{N="Free Space %";E={[math]::Round(((100* ($_.FreeSpace))/ ($_.Capacity)),0)}})}Extracts Disk space info on all VMs
Get-VMHost |Sort Name |Get-View |Select Name, @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}},@{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},@{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}} Lists each host, cpu , mem etc
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.ManagementTrafficEnabled} | Select Hostname, PortGroupName, IP, SubnetMaskGet host management network details
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.vMotionEnabled} | Select Hostname, PortGroupName, IP, SubnetMaskGet host vmotion network details
Get-VMHost | Get-Cluster | Select Name, DrsEnabled, DrsMode, DrsAutomationLevelGet Host DRS settings
Get-VMHost | Get-Cluster | Select Name, VMSwapfilePolicyGet host swap file details
Get-VMHost | Get-Cluster | Select Name, HAAdmissionControlEnabledGet Host HA details
Get-VMHost | Get-Cluster | Select Name, HAFailoverLevel, HARestartPriority, HAIsolationResponseGet Host failover settings
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Select Hostname, PortGroupName, IP, MTUGet VMkernel details fom hoss
Get-VirtualSwitch | Select VMHost, Name, MTUGet MTU value from hosts
Get-View -ViewType HostSystem | Sort Name | Select Name,@{N="BIOS version";E={$_.Hardware.BiosInfo.BiosVersion}}, @{N="BIOS date";E={$_.Hardware.BiosInfo.releaseDate}}Get host bios details
Get-VIEvent -maxsamples 10000 |where {$_.Gettype().Name-eq "VmCreatedEvent" -or $_.Gettype().Name-eq "VmBeingClonedEvent" -or $_.Gettype().Name-eq "VmBeingDeployedEvent"} |Sort CreatedTime -Descending |Select CreatedTime, UserName,FullformattedMessage -First 10Find VMs created in the last 10 days

Linux Cheatsheet

These cheats sheets are to be used on Linux Servers (Typically RHEL)

Networking

CommandWhat is does?
route add -net 10.98.208.40 netmask 255.255.255.255 gw 172.31.191.254
Add a static root - substitute for your IP information
route del -net 10.98.208.40 netmask 255.255.255.255 gw 172.31.191.254
Remove static route
ifconfig eth1 192.168.1.2 netmask 255.255.240.0 gw 192.168.1.1
Configure Ethernet
/etc/sysconfig/network-scripts
Location for Networking boot configuration
ifup eth1 boot

enable NIC at boot
ifdown eth1 boot
disabled NIC at boot
ip -s link
enable overview of traffic
dhclient eth01
dhclient ens33
get new IP from DHCP
/etc/sysconfig/network
basic Network config
cat /etc/resolv.confDNS server details
cat /etc/hostsLocal host file
cat /etc/services
Ports used for Firewall
iptable -F
Flush IPtables
iptables -I INPUT -p tcp --dport 48000 -j ACCEPTOpen port 48000 on firewall

Aix Cheatsheet

I’m a big fan of the verstility of of AIX. Its such a reliable OS and once you get your head around the concepts its very easy to manage and maintain. If you know Linux you can apply the majority of that knowledge to AIX.

Most of these commands will also work on Linux

CommandWhat it does
find / -xdev | xargs ls -ld | sort -rnk 5 | moreSearch AIX Filesystem for files
egrep –p “ Search string “ –f filename.loguseful for grep very large dsmsched.logs
q vol devclass=lto_tapeQueries Tape Library and Lists Scratch tapes
q req lists requests to reply to
lscfg –vl fcs3Get details of a fibre card fcs3
nohup /opt/Tivoli/tsm/client/ba/bin/rc.tsmclient >/dev/null 2>&1Starts TSM Process
dd if=/dev/cdrom of=line500v7.1WindowsServer.iso bs=1024Command how to copy ISO on AIX
ls |sort |awk ‘{name=toupper($1);if(name==pre1) printf(“** %s  %s\n”,$1,pre2); pre1=name;pre2=$1}’AIX command used to find the duplicate files
find /var -xdev | xargs ls -ld | sort -rnk 5 | moreFinding large files in AIX (EG /VAR)
startsrc -s qdaemonrestart error daemon

Terraform Cheatsheet

CommandWhat it does?
terraform -install-autocompleteEnables tab completion
-helpShows the help files
applyapply the changes
consolecreates and interactive console
destroydestroys the Terraform-managed infrastructure
fmtused to rewrite Terraform configuration files
force-unlockused to remove lock on the state for the current configuration
getused to download and update modules
graphused to generate a a graph
importused to import existing resources
initused to initilize a working directory
outputused to extract the value of an output variable
planused to create an execution plan
providersused to print information about providers (eg VMware, AWS, HyperV etc etc etc)
pushused to upload your configuration
refreshused to update the state of a file
show useds to provide output from a state or plan file
stateused for advanced state management
taintused to mark resources as tainted
validateused to validate the syntax of terraform files
untaintused to unmark a resourse as tainted
workspaceused to manage workspaces
Type or VariableWhat it does
"var" prefixUser String Variable
Interpolate
"var.MAP["KEY"]User Map Variable
Value of Key
"${var.LIST}"Value of the list as a list
List elements by Index
"self.ATTRIBUTE"Own Resource
"TYPE.NAME.ATTRIBUTE"Other Resource
"data.TYPE.NAME.ATTRIBUTE"Data Source
MODULE.NAME.OUTPUT"Module outputs
"Count.FIELD"Count
"path.TYPE"Path
"terraform.FIELD"Terraform Meta

San Volume Controller (SVC) Cheat Sheet

Command ▾Common Arguments & DescriptionCommand Description
svcinfo lsclusterDisplays cluster members id, name, location, ip-address etcDisplay info about clusters
svcinfo lscontrollerDisplays controllers id, name etcDisplay info about controllers visible to the system
svcinfo lsfabricDisplays remote_wwpn, remote_nportid, id, node_name, local_wwpn, local_port etcDisplay connectivity between nodes and other controllers and hosts
svcinfo lshostDisplays controllers id, name etcDisplay info about controllers visible to the system
svcinfo lshostvdiskmaphost1 (Obtain a list of the virtual disks that are mapped (visible) to host1, including vdisk_id, vdisk_name, wwpn etc)Obtain a list of the virtual disks that are mapped (visible) to a given host
svcinfo lsmdiskDisplays id, name, status, mode, mdisk_grp_name etc for all MDisksDisplay info about MDisks visible to the cluster
svcinfo lsmdiskgrpDisplays id, name, status, mdisk_count, vdisk_count, capacity etc for all MDisk groupsDisplay info about MDisk groups visible to the cluster
svcinfo lsrcconsistgrpapp_CG1 (Displays a detailed view of consistency group app_CG1 including state, status and sync attributesDisplays a detailed view of Metro or Global Mirror consistency groups visible to the cluster
svcinfo lsrcrelationshipDisplays id, name, master_cluster_name, master_vdisk_name, consistency_group_name etcDisplay information about all the Metro Mirror relationships visible to the cluster
svcinfo lsvdiskDisplays id, name, io_group_name, status, mdisk_grp_id, mdisk_grp_name, capacity etc for all VDisksDisplay information about VDisks recognized by the cluster
svcinfo lsvdiskvdisk1 (Displays detailed information about vdisk1 including mdisk_grp_name and remote copy relationship RC_name)Display detailed information about a specific VDisk recognized by the cluster
svctask mkrcrelationship-master master_vdisk_name -aux aux_vdisk_name -cluster cluster_name -name data_1 (Creates a new rc relationship named data_1)Creates a new Metro or Global Mirror relationship with virtual disks (VDisks)
svctask mkvdisk-mdiskgrp 0 -iogrp 0 -size 50 -vtype striped -unit gb -name app1_1 (Create a vdisk named app1_1)Create a sequential, striped of image mode Vdisk
svctask mkvdiskhostmap-host host1 -scsi 1 app1_1 (Create a new mapping between vdisk app1_1 and host1 assigning SCSI LUN ID 1 to app1_1 on host1)Create a new mapping between a virtual disk and a host making the vdisk accessible for I/O to the specified host
svctask startrcconsistgrp-primary master -force (Start the consistency group copy process, specifying the copy direction (the master becomes the primary) even if the copy process leads to a temporary loss of consistency during synchronisation (-force))Start the Metro or Global Mirror consistency group copy process
svctask startrcrelationshiprc_rel_app1 (Start the remote copy relationship for relationship name rc_rel_app1)Starts the Metro Mirror or Global Mirror relationship copy process
svctask stoprcconsistgrp-access app_CG1 (Stops the copy process for consistency group app_CG1 and allows write access to consistent secondary VDisks in app_CG1 (-access))Stops the copy process for a Metro Mirror or Global Mirror consistency group
Follow by Email
YouTube
YouTube
Instagram