Command Line

Updated: September 28, 2024

Commands for windows cmd, powershell, cmder

Some commands will only work in cmd &! powershell || cmder

Table of Contents

Commands

Login

net user <name> <newpasswd>

Files and Folder

dir                     # the ls of linux
clip                    # redirects output to clipboard
copy                    # copy files to another location
move                    # move files to another location
edit                    # start file editor
cd                      # change directory
md                      # create a folder (can also use mkdir)
rd                      # delete a folder (can also use rmdir)
del                     # delete files (can also use erase)
ren                     # rename files
expand                  # decompress compressed files
fc                      # compare files and show differences
find                    # find string of text inside a file
print                   # print out contents of a file
tree                    # show file structure of disk or folder
history                 # list commands used in current session

Checksum

certutil -hashfile <file> md5     # sha256 or whatever type of hash was used.

SSH

vim %programdata%\ssh\sshd_config                   # edit ssh config on windows
Get-Service -Name *ssh*                             # list ssh services and their status
Get-Service sshd | Restart-Service -force           # restart ssh, esp after editing config
icacls .\.ssh\                                      # lists owners of keys

System Information

systeminfo              # get information of windows system
date                    # output or set current date
time                    # output or set system time
hostname                # display name of computer
ver                     # show windows version
gpresult                # show group policies
gpupdate                # update group policies
cacls                   # show or change ACL of files
nvidia-smi              # show nvidia gpu info

Get-CimInstance -Class Win32_Processor
Get-CimInstance -Class Win32_volume
Get-CimInstance -Class Win32_physicalMemory
Get-CimInstance -Class Win32_OperatingSystem

Windows Defender

get-mpcomputerstatus    # see if defender is on
get-mpcomputerstatus | select realtimeprotectionenabled   # check if a setting is enabled
get-mppreference        # show settings that can be configured

update-mpsignature -verbose     # update virus definitions
start-mpscan -scantype <fullscan|quickscan>     # scan for virus
start-mpwdoscan         # offline scan in recovery mode (machine will reboot)
remove-mpthreat         # removes active threats antivirus hasnt already mitigated

eg
set-mppreference -scanparameters 2      # sets for full scan
set-mppreference -remediationscheduleday 1              # set scan day to sunday
    0 – Everyday
    1 – Sunday
    2 – Monday
    3 – Tuesday
    4 – Wednesday
    5 – Thursday
    6 – Friday
    7 – Saturday
    8 – Never
set-mppreference -remediationscheduletime 06:00:00
set-mppreference -scanschedulequickscantime 06:00:00    # set a schedule for 6 am quickscans

set-mppreference -disablerealtimemonitoring $true       # disable windows defender
set-mppreference -disableremovabledrivescanning $false  # enable external drive scanning
Set-MpPreference -DisableScanningMappedNetworkDrivesForFullScan $false  # enable network drive scanning
set-mppreference -excludeextention docx       # exclude a file type from scans
set-mppreference -exclusionpath C:\Users      # skip scan on that path
remove-mppreference -exclusionpath C:\Users   # would remove above setting
set-mppreference -quarantinepurgeitemsafterdelay 30   # quarantine item 30 days before deletion

Network

ipconfig                # show network interface information
ping                    # send ICMP request to target host
tracert                 # find the path of packets traveling over the network
nslookup                # find ip address by resource name
route                   # display network route tables
arp                     # shows table of IP addresses converted into physical addresses
netsh                   # start a network settings control program
getmac                  # show the mac address of the network adapter
tftp                    # start tftp client in console

Disk Management

diskpart                # display and adjust disk partitions
chkdisk                 # checks disk and shows stats
defrag                  # start disk defragmentation
convert                 # change FAT disk to NTFS
format                  # format the disk
label                   # create, change or delete disk volume label
recover                 # recover data froma bad or damaged disk
vol                     # display volume label and serial number for disk

wmic logicaldisk get name # lists existing drives

Applications and Processes

schtasks                # execute a command or start a sceduled application
shutdown                # shutdown or reboot
tasklist                # list pids
taskkill                # stop or halt task by pid
reg                     # start registry editor
runas                   # launch task as another user
doskey                  # edit command lines, recall windows commands, create macros