NOTE Windows directories use the backslash,
\
, to delimit paths as opposed to Unix's forward slash,/
!!
-
C:\
(or whichever root drive Windows is installed on) is a root drive. -
C:\Program Files\
is where 64-bit applications are installed. -
C:\Program Files (x86)\
is where 32-bit applications are installed. -
C:\ProgramData\
[hidden] is a hidden directory where application-specific settings reside. -
C:\Users\
is the directory for all users, including theDefault
user. Similar to Linux's/home
directory. -
C:\Users\[username]\
is each specific user's home folder. Their settings and files are saved here and in subdirectories.-
C:\Users\[username]\Documents\
is theDocuments
folder for the current user. -
C:\Users\[username]\Desktop\
is theDesktop
folder for the current user.
-
-
C:\Windows\
is where Windows-specific programs and libraries are located.C\Windows\System32\
is where (counterintuitively) 64-bit main component Windows system applications configuration settings are located.
-
cd
orchdir
is to change directories, just like with Linux'scd
. -
dir
lists the contents of a directory, similarly to Linux'sls
-
md
ormkdir
creates directories. -
copy
copies a file. This is the equivalent to Linux'scp
. -
move
works like cutting and pasting files, equivalent to Linux'smv
. -
del
orerase
deletes files and directories. Directories will prompt a user to confirm.- Note that files deleted with this command do not go to the
Recycle Bin
, unlike when they are deleted with the GUI.
- Note that files deleted with this command do not go to the
-
rd
orrmdir
removes a directory if it's empty. Non-empty directories must be removed withrmdir /S
orrd /S
. -
find
will search a file for whatever is defined. For example,find "hello" greeting.txt
will search thegreeting.txt
file for the stringhello
. -
exit
will closecmd
. -
type
followed by a file name will show the contents of a file. Similar tocat
in Linux. -
| more
or "pipe more" shows contents of the command-line in a per-screen format. -
>
will output to a file. It will make a new file or rewrite it if it exists.Example:
echo hello > greeting.txt
will create a newgreeting.txt
file every time it is run. -
>>
will append to a file. It will either start a new file or add lines to the existing one.Example:
echo world >> greeting.txt
will keep adding the wordworld
to a new line of this file.
Environment Variable | Default Value |
---|---|
%CD% | Current directory |
%DATE% | The current date |
%OS% | Windows |
%ProgramFiles% | C:\Program FIles |
%ProgramFiles(x86)% | C:\Program Files (x86) |
%TIME | The current time |
%USERPROFILE% | C:\Users{username} |
%SYSTEMDRIVE% | C:\ |
%SYSTEMROOT% | C:\Windows |
Example:
echo %CD%
will print thecurrent directory
path. Note: this variable is different from the terminal command,cd
.
wmic
has the following query structure:
wmic [GLOBAL SWITCHES] [ALIAS] [VERBS] [PROPERTIES]
Example:
wmic os get /value
will return all properties ofwmic os
for you to choose properties from:
```console
BootDevice=\Device\HarddiskVolume6
BuildNumber=18362
BuildType=Multiprocessor Free
Caption=Microsoft Windows 10 Pro
... [results truncated]
```
Example 2:
wmic /APPEND:report.txt os get caption
will retrieve the operating system's common name and append that to a filereport.txt
. In this example,/APPEND:report.txt
is a global switch,os
is an alias,get
is our verb andcaption
is our property we're retrieving.
You can modify wmic
queries with the where
clause.
Example 3:
wmic service where (startmode="auto") get caption
finds services where thestartup
property equalsauto
.
The net user
and net localgroup
and net accounts
command-line utilities allow you to manage and interact with different local user and group-related settings.