Basics
cd\
is windows cd ..dir
→ lists the contents of the current directorydir /A
→ WIll show all contents even the hidden onestype file.txt
→ shows the contents of the file- When working with a file with spaces in the name you have to put the file in double quotes
type "cats are great.txt"
echo "Meow" > cat.txt
→ This will use echo to create a file named cat.txt and add “Meow” to itecho Meow > cat.txt
→ Will create a file with Meow in it2>
will pipe an error if it happensdel
→ deletes a filerename
→ Self explanatory -rename cat.txt kitten.txt
→ renames cat.txt to kitten.txtmove
→ Moves files -move cat.txt Desktop\
→ Moves the cat.txt to desktopcopy
→ copies a filemkdir
→ makes a directoryrmdir
→ removes a directory -rmdir /s
→ Allows you to remove a directory and all the files and directories inside it>
→ operator overwrites a file>>
→ operator appendsfc
→ Compares filesfc meow.txt cat.txt
→ Will compare the two files and state the difference
Locating Files
dir /s meow.txt
→ This will search the current directory and all of its sub directories for Meow.txtdir /s *.exe
→ The wildcard will allow us to search the current and all sub directories for all executablesdir /s *.txt /p
→ Does similar to the one above but the/p
switch makes the query stop when it fills the screentree
→ Will create a tree showing us all sub directories in a more digestable view.tree Directory\SubDirectory /F
→ This will show the tree starting atSubDirectory
the/F
switch allows us to see all the files in the directories (maybe all might just be interesting)
Searching Text in Files
find "persian" C:\Docs\cats.txt
→ will look for the string “persian” in the cats.txt file- You can pipe
find
ie|
- Find does not support Regex
- You can pipe
findstr "Alan Pasta" text.txt
→ this will search for all occurrences of either Alan or Pasta inside of the txt docmore
→ allows us to look at big outputs in a more user friendly method by allowing us to use arrowing to paginate through the output.
Permissions - Users and Groups
net
→ allows us to manage users and groups
- net user
→ Lists all users on the current machine
- net user <USERNAME>
→ Will list all details of the account to the username given.
- net localgroup
→ shows all the local groups for the machine
- net localgroup Administrators
→ shows us all the users tied to the Administrator group
- net user /add Catman thiswouldbeapassword
→ Allows you to add a user
- NOTE you have to do this running CMD as Administrator
- net localgroup Administrators Catman /add
→ Adds Catman to the administrators group
- NOTE you have to do this running CMD as Administrator
- net localgroup Administrators Catman /del
→ Removes Catman from Administrators group
- NOTE you have to do this running CMD as Administrator
- net user /del Catman
→ Deletes the user Catman
- NOTE you have to do this running CMD as Administrator
Permissions - Files and Directories
icacls
→ allows you to view and interact with permissionsicacls cat.txt
→ Will show us the ACE’s of the fileicacls "cat.txt" /grant Catman:R
→ Grants Catman read only access to cat.txticacls "cat.txt" /deny Catman:R
→ Removes the read only access to cat.txt for Catman.