Command Line Interface Flashcards
Set Command
view all env variables in command shell
Where Command
find executables within the PATH variable
Echo Command
repeat things
Dir Command
look at folder contents
Type Command
output contents of a file
Findstr Command
Windows grep
Hostname
system hostname
date /t
output system date (/t keeps it from trying to set)
time /t
output system time (/t keeps it from trying to set)
>
redirect STDOUT. Create/overwrite
> >
redirect STDOUT. Create/append
|
Piping sends output of one command to input of another
& and ;
execute second command regardless of success/failure of first
&&
execute second command ONLY if the first is successful
||
execute second commmand ONLY if the first fails
( )
nest commands for complex arrangement
echo “Text Here”
prints “Text Here”
echo
shows if echo is on or off
echo .
print a blank line
( )
nest commands for complex arrangement
echo “Text Here”
prints “Text Here”
echo A=%A%
prints the new variable
echo .
print a blank line
@echo off
the @ suppresses display of the line in a batch file
set A=4
defines a new variable
set A=%A%
prints the new variable
echo “A=%A%”
spaces are retained, as are quotes
echo %COMPUTERNAME%
built-in environment variable - prints the computername
where
find executaables within the PATH variable; are commands native to CMD
where dir
internal to CMD
where where
built into windows - tells you where the “where” command is located.
dir
current directory
dir .
current directory also
dir ..
parent directory
dir c:\
specific directory (absolute path)
dir /b
/b for bare, just show filenames
dir /s
/s subdirectories, recursive
dir /a:h
show hidden files
echo Hello > hello.txt
create a file
echo There»_space; hello.txt
append to the file, create if needed
type hello.txt
prints the file stated with the command
type
print a file, usually to the screen
date / time
commands to view/set date and time
findstr
find a substring
type hello.txt | findstr “There”
search for a pattern
type hello.txt | findstr /i “there”
/i ignore case
type hello.txt | findstr /r “h.*r”
regular expression (like grep)
type hello.txt | findstr lo
piping sends text from left into right
hostname
shows computer name
echo %COMPUTERNAME%
shows computer name
path
where to find executable programs
echo %PATH%
prints directories in your path
echo a & echo b & echo c
unconditional separator
dir hello.txt && echo exists
only do second command if first succeeded
dir noway.nohow || echo failed
only do second command if first failed
dir noway.nohow && echo failed
won’t print failed, assuming the file doesn’t exist
echo %ERRORLEVEL%
zero means success, otherwise failure code
Net Command
can be used to manage almost any aspect of a network and its settings including network shares, network print jobs, network users, and much more.
where net
find net command
net /?
let’s see what windows can do
net help
how to find help
net help user
expanded help on user
net user
list of all users
net user admin
detailed output of admin account/local group memebership
net help localgroup
help for localgroup
net localgroup
view all local groups on computer
net localgroup administrators
view members of administrator group
net use t:\computername\c$ /persistent:no
establish a temporary drive
dir t:\users
use temp drive
net use t: /delete
remove the t: drive label
wmic /?
explain global switches and aliases
WMIC
Windows Management Instrumentation Command line
wmic process /?
shows all the running processes. This is object oriented and can be sorted by headers.
wmic process get /all /format:list
all process details in list format
wmic process list brief
shows an output similar to tasklist in a legible format.
wmic service list brief
shows all the services that are running
wmic useraccount list brief
shows all the users on the machine
wmic nicconfig list brief
NIC information
wmic nteventlog list brief
list logs
wmic ntevent /?
query individual log entries
Powershell 1.0
Nov 2006 - Win XP
Powershell 2.0
Oct 2009 - Win 7
Powershell 3.0
Sep 2012 - Win 8
Powershell 4.0
Oct 2013 - Win 8.1
Powershell 5.0
Apr 2014 - Win 10
Cmdlets use what pattern
verb-noun
Powershell is what type of language
Object Oriented
In Powershell, external commands return as what type of data?
strings
Powershell commands return what type of data?
objects
In Powershell, an object is a data structure that contains what?
properties=data
methods=functions
In Powershell, external commands spawn what?
new process
In Powershell, internal commands run where?
inside powershell process
Objects
output from a powershell command
Classes
General term for grouped objects
CIM
Common Information Model
WMI
Windows Management Instrumentation
Indexes always start at?
0 (Zero)
Functions
A list of commands chained together to serve a purpose
Multithreading
A technique that allows a single set of code to be used by several processors at different stages of execution
Namespaces
WMI is organized into namespaces, folders that correlate products/technology
psinfo
shows basic system info, remote capabilities
pslist
shows processes in tree format
procmon
view, monitor, filter processes (GUI based)
autoruns
checks autorun registry locations
handle
shows handles of all processes
handle -p
specific process (matches partial names)
logonsessions
lists all currently logged in sessions
logonsessions -p
lists processes running in each logon sessions
psloggedon
more functionality regarding remote users sessions
tcpview
robust netstat viewer/monitor