Windows Basics
Files & Folders
What files are in this directory?
displays the contents of a text file.
the command used to move to the root of the current drive
Put text into a file
c:\> echo “Four score” > 1.txt
It is used to delete one or more files or directories from a file system.
What directory am I in?
We can rename files with rename or ren
we can move file to a different directory
Similar to Linux's commands, mkdir and rmdir will create and delete folders.
Creat New file
We can use copy to copy the contents of one file to a second one.
Comparing files
Creates a directory or file symbolic or hard link.
to select a set of files and then run a command on each of the files.
dir
and We can use the /A option with dir to display hidden files.
and we can Combine two files
e.g c:\> type Tuwaiq.txt Haboob.txt > BootCamp.txt
type
cd\
the C:\ drive is the root of the primary partition on Windows.
del (or erase)
echo
and we can use echo for Add text to a file e.g c:\> echo “Haboob” >> 1.txt
Cd
rename
move
e.g move Haboob.txt .\download
mkdir , rmdir
fsutil
e.g fsutil file createnew Tuwaiq.txt 101
Copy
copy HaboobFile.txt TuwaiqAcademy.txt
fc
fc File1H.txt File2T.txt
mklink
mklink /d \MyFolder \Users\User1\Documents
forfiles
forfiles [/P pathname] [/M searchmask] [/S] [/C command] [/D [+ | -] [{<date> | <days>}]]
System
Displays detailed configuration information about a computer and its operating system.
View all environment variables
Schedules commands and programs to run periodically or at a specific time, adds & removes tasks from the schedule, starts and stops tasks on demand, and displays and changes scheduled tasks.
systeminfo
set
schtasks
Find
Searches for a string of text in a file or files, and displays lines of text that contain the specified string.
Search for Text in File
We can find all the drives on our machine with the drives subcommand:
Find
To display all lines from Tuwaiq.md that contain the string Haboob, type find "Haboob" Tuwaiq.md
Findstr
findstr /c:"BootCamp" x.y
fsutil
fsutil fsinfo drives
Users
who is current user
Whoami
privileges
This command enables one to run a command in the context of another user account.
runas
Process
list all running and currently-suspended processes on the machine.
use the taskkill command to terminate a process by specifying its process ID or image name.
tasklist
the find command can also be used to filter results based on an expected string
taskkill
Other Commands
Displays or modifies discretionary access control lists (DACLs) on specified files, and applies stored DACLs to files in specified directories.
Lets say we have a text file full of unordered numbers, and we wish to order the contents beginning with the highest number. We can use the /R flag to do so.
use the reg command to interact with the Registry and display the values of the Run and RunOnce keys.
The following Net Commands can be used to perform operations on Groups, users, account policies, shares, and so on.
sort /R numbers.txt
net
e.g add "Amal" to the Administrators group with net localgroup.
e.g we can create a new local user on our machine with net user.
Now we'll clean up by removing "Amal" from the Administrators group, and then deleting the account.
icacls
We can use the /grant and /deny options to provide or remove rights to a file or folder.
reg
let's see if we can query the values of the Run and RunOnce keys for our current user: