Equivalent Windows and UNIX Commands

author: Nathan Acks
date: 2022-08-17

UNIX <-> Windows command equivalencies (more-or-less):

cat

# Use cat to add line numbers to a file!
#
cat -n < $FILE

# Only number non-blank lines
#
cat -b < $FILE

dig

# dig command syntax; only $DOMAIN is required
#
dig @$NAME_SERVER $DOMAIN $QUERY_TYPE

# Examples
#
dig @8.8.8.8 microsoft.com A
dig @1.1.1.1 tryhackme.com
dig          google.com    MX

grep

# Case-insensitive grep
#
grep -i $STRING $FILE

# Recursive grep of all files in a folder (and its subfolders)
#
grep $STRING -r $DIRECTORY

findstr

# Use findstr to filter the output of systeminfo (or another command):
#
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"

dir

The dir command accepts wildcard listings (*.txt, etc.), and will perform a subdirectory search if given the /S flag. For example:

dir /S /P example.txt

ipconfig

Display Current DNS Settings

ipconfig /displaydns | more

Flush Local DNS Cache

ipconfig /flushdns

nslookup

# nslookup command syntax; only $DOMAIN is required
#
nslookup -type=$QUERY_TYPE $DOMAIN $NAME_SERVER

# Examples
#
nslookup -type=A  microsoft.com 8.8.8.8
nslookup          tryhackme.com 1.1.1.1
nslookup -type=MX google.com

ping

Windows ping uses the -n flag to specify the number of packets sent (in contrast to Linux’s -c).

runas

runas /user:$USERNAME $EXECUTABLE

$USERNAME may also be specified as $DOMAIN\$USERNAME for domain-joined machines.

$EXECUTABLE is treated normally (as if not prefixed by the runas command), so a full or relative path is only necessary when it’s not already in the Windows path.

If credentials are saved for a particular user (use cmdkey /list to check), then the /savecred flag will apply them automatically!

whoami

Windows’ whoami supports a couple of useful flags: