Skip to main content

Terminal

Updated Nov 22, 2023 ·

Useful Aliases

alias ld='ll -d */'
alias lf='ll -p | grep -v /'
alias cl='clear'
alias histgrep='history | grep'
alias addalias='vi ~/.bashrc'
alias sr='source ~/.bashrc'
alias myip='export TF_VAR_my_ip="$(curl ifconfig.me)/32"'
alias awscreds='sudo vi ~/.aws/credentials'
alias gitacp='git add -A; git commit; git push'
alias gitac='git add -A; git commit'
alias gitst='git status'

CLI Completion

Enable completion for some of the available CLIs.

# Enable autocompletion for the Kubernetes cluster manager utility kubectl:
source <(kubectl completion bash)

# Enable autocompletion for Helm
source <(helm completion bash)

VIM Shortcuts

Go to top of the file (first line of the file).

gg 

Go to bottom of the file (last line of the file).

Shift + g  

Copy an entire line.

yy 

Paste after a line.

p 

Insert an empty line below a line.

o 

Set line numbers.

:set number 

Go to a line (like line 10).

:10 

Powershell and CMD

Checking the IP configurations:

ipconfig 

Checking all entries in the ARP cache. ARP maps IP addresses to their respective MAC addresses. Just simply means it checks the connected devices.

arp -a 

Find applications or services listening on a certain port, e.g. 3389. Add a "-p" flag to specify protocol, e.g. tcp.

netstat -p tcp -n | find '443'          # Command Prompt
netstat -p tcp -n | findstr '443' # Powershell

To display all the routing table entries:

route print 

To show the "hops" or router that a connection will go through to reach a specified target. Add "-d" flag to show just the IP address of each hop.

tracert -d youtube.com

Combination of ping and tracert:

pathping youtube.com 

To resolve a DNS name. Basically you can provide a DNS name and it will resolve the IP address. Below is a forward DNS lookup.

nslookup youtube.com 

"Non-authoritative" means that the local DNS Server cannot resolve the DNS name but its able to find a DNS Server that could resolve it.

Reverse lookup is when you have the IP address and you want to find the DNS name. To do this, set the type to PTR.

nslookup 
set type=PTR
8.8.8.8

To view or modify the file system permissions in Windows. Use "icacls", followed by the directory path. The "." means current directory.

To refresh DHCP lease:

ipconfig /release
ipconfig /renew

To empty DNS cache:

ipconfig /flushdns