Command Directory
I’ve been meaning to do this for awhile now… Here’s my own list of handy commands/one-liners.
Azure - Bash
az group create --name <resourcegroupname> --location <region>
- Create a resource group in bash cloud console.
az acr create --resource-group <resourcegroupname> --name <acrinstancename> --sku Basic
- Create a new Azure Container Registry (ACR) instance. Note: The name of the ACR must be globally unique.
az group list --query "[?name=='<resourcegroupname>']" -o table
- Verify that a resource group was created.
az acr list --resource-group <resourcegroupname>
- Confirm that a new ACR was created.
Azure - Powershell
Remove-AzResourceGroup -Name "<ResourceGroupName>" -Force -AsJob
- Delete resource group and everything thing inside it.
Test-AzDnsAvailability -DomainNameLabel <custom-label> -Location '<location>'
- Quick little command to confirm if a DNS name is available (unused) within a given location.
Azure - Log Analytics Workspace Queries (Kusto)
AzureActivity
| where HTTPRequest<>dynamic({"clientIpAddress":'1.2.3.4'}) and Level == 'Information'
Azure activity logs where the client IP address is not 1.2.3.4 and the log level is not categorized as information-level severity.
SecurityEvent
| where EventID == '4625'
Rule looking for windows event id 4625 (failed login).
Ethtool
ethtool -p <interface name>
- Blink the physical network light to signify which interface the system actually thinks is “eth0” “eth1” etc.
Git
Note: Github has an excellent cheatsheet here
git add [file]
- add a file as it looks now to your next commit (stage)
git reset [file]
- unstage a file while retaining the changes in working directory.
git commit -m "[descriptive message]"
- commit your staged content as a new commit snapshot
git rm [file]
- delete the file from project and stage the removal for commit
git status
- show modified files in working directory, staged for next commit
Java Keytool
keytool -delete -alias <cert alias> -keystore <jks keystore file>
- Deletes the certificate that has the specified alias name.
keytool -list -v -keystore <jks keystore file>
- Provides information on the certificate(s) inside a JKS file.
Linux - Disk Usage
df -h
- View disk partition space usage.
du -h <dir> | grep '[0-9\.]\+G'
- Return disk space usage for directories consuming 1 GB or more.
Linux - DNS
dig @<nameserver><common name><record type> +short
- Returns just the IP/data for the record.
Linux - Kernel Information
uname -a
- Provides general information about the linux kernel, system hostname, etc.
cat /proc/cmdline
- Provides information on the booted kernel parameters / flags.
Linux - modprobe
modprobe -q vmxnet3 && echo "vmxnet3 installed" || "vmxnet3 not installed"
- Confirm if vmxnet3 network driver is installed.
Linux - openssl
openssl s_client -cert <path to tls cert> -connect <remote mail server fqdn or ip>:25 -starttls smtp -state -msg | tee <log file path>
- Debugs SMTP starttls negotiation.
openssl s_client -connect <remote host>:<destination port>
- Debugs the HTTPS transaction between client and remote host.
openssl x509 -noout -in cert.pem -dates
- Returns the dates that a pem formatted certificate is valid for.
openssl s_client -connect google.com:443 -tls1_2
- Tests to see if a remote site can support TLS 1.2. The -tls1_1 and -tls1 arguments can be used instead too.
Linux - Process Information
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww –sort=pid | grep -i <command that corresponds to process> | grep -iv grep
- Provides the process details for a specific process that matches the grep search. Details include: process id, parent process id, non-swapped physical memory being used (in kB), swapped memory being used, CPU utilization, physical memory utilization, and command path. Also uses an inverse grep search to eliminate the grep search itself from the output.
Linux - Searching
grep -iv <search string><file path>
Returns case insensitive entries that DON’T match the search string.
Linux - sendmail
for x in `find . -type f -name “qf*” | xargs grep -l [email protected] | cut -b3-`; do y=d`echo $x | cut -b2-`; mv $x /root/loopingmessages; mv $y /root/loopingmessages/; done`
- Search QF header files for an email address, identify corresponding df counter-part, and move both of the files to a looping message directory. (Huge thanks to Zack Train on this one).
Linux - System Info
dpkg-reconfigure tzdata
- Change system time zone in Ubuntu server.
Linux - ufw
sudo ufw allow from <source IP, subnet, or "any"> to <destination ip, subnet, or "any"> port <destination port> proto <tcp|udp>
rule syntax for allowing traffic for a specific port/protocol via ufw firewall. Note: all ufw rule changes happen immediately and are persistent
sudo ufw delete <full rule command>
- delete rule from rule list
sudo ufw disable
- Shuts down ufw firewall
sudo ufw enable
- Starts/enables ufw firewall
sudo ufw status verbose
- Displays the status of ufw and what rules are configured.