Windows Commands
Windows Commands
Table of contents:
Windows Commands 20
File and Directory Commands: 20
Network Commands: 22
System Information and Management: 23
User Account Management: 24
Disk and Storage Management: 24
Miscellaneous Commands: 24
1. dir - List files and directories in the current directory. 25
1.1. List Files in Current Directory 25
1.2. List Files with Detailed Information 25
1.3. List Files with Hidden and System Files 25
1.4. List Files in Long Format 25
2. Listing Specific File Types 25
2.1. List All .txt Files 25
2.2. List All Files with Specific Extension (e.g., .jpg) 25
2.3. List Files in Subdirectories 25
3. Sorting Directory Listings 26
3.1. Sort by File Size 26
3.2. Sort by Date and Time 26
3.3. Sort in Reverse Order 26
4. Displaying File Attributes 26
4.1. Display File Attributes with File Names 26
4.2. Display Only Directories 26
4.3. Display Only Hidden Files 26
5. Advanced File Listing 26
5.1. List Files with Summary 26
5.2. List Files with Directory Count 26
5.3. Display File Names Only 27
6. Directory Navigation 27
6.1. List Files in Parent Directory 27
6.2. List Files in a Specific Directory 27
7. File Searching 27
7.1. Search for a File in Current Directory 27
7.2. Search for Files with Wildcards 27
7.3. Search for Files in Subdirectories 27
8. Redirecting Output 27
8.1. Redirect Output to a Text File 27
1
Copyright © PendemVamsi. All rights reserved.
2
Copyright © PendemVamsi. All rights reserved.
3
Copyright © PendemVamsi. All rights reserved.
4
Copyright © PendemVamsi. All rights reserved.
5
Copyright © PendemVamsi. All rights reserved.
6
Copyright © PendemVamsi. All rights reserved.
10. View the Directory Tree with Directories Only (No Files) 75
13. xcopy - Extended copy command with more options 76
1. Basic Command Usage 76
2. Copy Files and Subdirectories 76
3. Copy Files, Including Empty Subdirectories 77
4. Copy Hidden and System Files 77
5. Copy Only Files That Are Newer 78
6. Prompt Before Overwriting 78
7. Copy Files and Preserve File Attributes 79
8. Copy Files Over a Network (Using UNC Path) 79
9. Display Progress of File Copying 80
10. Exclude Files Based on Criteria 80
11. Display a Brief Summary 81
12. Copy a Directory and All Files, with Detailed Output 81
13. Copy Files with File Attributes and Ignore Errors 82
14. Copy Files with Dateime Criteria 82
15. Copy Files Based on File Size 82
16. Copy Files Overwriting All Files in the Destination 83
14. chkdsk - Check and repair disk errors. 83
1. Basic Command Usage 83
2. Check and Repair Disk Errors 84
3. Check for Bad Sectors and Repair Them 84
4. Display Detailed Information About the Disk Check 85
5. Check for Disk Errors Without Making Changes 85
6. Check for Errors and Log Results to a File 86
7. Schedule a Disk Check on Next System Restart 86
8. Check for File System Integrity 87
9. Check for Errors on External or Unmounted Drives 87
10. Display the Status of the Last Disk Check 88
11. Check for Errors on Remote Disk (Network Drive) 88
12. Check for Specific File System Integrity Issues 89
15. fc - Compare two files or sets of files. 89
1. Basic Command Usage 89
2. Compare Files in ASCII Mode 90
3. Compare Files in Binary Mode 90
4. Display Differences with Line Numbers 91
5. Ignore Whitespace Differences 91
6. Compare Multiple Files in a Directory 92
7. Ignore Case Differences 92
8. Display Only the Differences (No Summary) 93
9. Compare Files and Display a Summary of Differences 93
7
Copyright © PendemVamsi. All rights reserved.
8
Copyright © PendemVamsi. All rights reserved.
9
Copyright © PendemVamsi. All rights reserved.
10
Copyright © PendemVamsi. All rights reserved.
11
Copyright © PendemVamsi. All rights reserved.
12
Copyright © PendemVamsi. All rights reserved.
13
Copyright © PendemVamsi. All rights reserved.
14
Copyright © PendemVamsi. All rights reserved.
15
Copyright © PendemVamsi. All rights reserved.
16
Copyright © PendemVamsi. All rights reserved.
17
Copyright © PendemVamsi. All rights reserved.
3. Examples 246
3.1 View the NetBIOS Name Table of a Remote Machine by Hostname 246
3.2 View the NetBIOS Name Table of a Remote Machine by IP Address 246
3.3 Display the NetBIOS Name Cache 247
3.4 List Local NetBIOS Names 247
3.5 Show Name Resolution Statistics 248
3.6 Purge and Reload the NetBIOS Name Cache 249
3.7 Display Current NetBIOS Sessions (with Hostnames) 249
3.8 Display Current NetBIOS Sessions (with IP Addresses) 250
3.9 Release and Re-register NetBIOS Names 250
55. systeminfo - Display detailed system information. 251
1. General Syntax 251
2. Commands and Options 251
3. Examples 252
3.1 Display Basic System Information 252
3.2 Display System Information for a Remote Computer 253
3.3 Display System Information with Specific User Credentials 253
3.4 Filter Output Based on a Specific Criterion 254
3.5 Display Output in a Specific Format 254
3.6 Exclude Headers in the Output 255
3.7 Display Help Information 256
56. tasklist - List running processes. 256
1. General Syntax 256
2. Commands and Options 257
3. Examples 258
3.1 Display All Running Processes 258
3.2 Display All Running Processes on a Remote Computer 258
3.3 Display All Running Processes for a Specific User 259
3.4 Display Processes Using a Specific Module 259
3.5 Display Detailed Process Information (Verbose Output) 260
3.6 Filter the Process List by Name 260
3.7 Filter the Process List by PID 261
3.8 Display Output in a Specific Format 262
3.9 Exclude Headers from Output 262
3.10 Terminate a Process 263
3.11 Display Help Information 263
57. taskkill - Terminate processes or applications. 264
Basic Syntax 264
Usage 265
1. Terminate a Process by Image Name 265
2. Forcefully Terminate a Process 265
18
Copyright © PendemVamsi. All rights reserved.
19
Copyright © PendemVamsi. All rights reserved.
10. Access Registry via Command Prompt with Full Administrative Privileges: 281
60. eventvwr - Event Viewer. 281
Common wevtutil Subcommands and Options 282
1. qe (Query Event Logs) 282
2. epl (Export Event Logs) 282
3. el (List Event Logs) 283
4. gl (Get Log Information) 284
Options: 284
5. cl (Clear Event Logs) 284
6. sl (Set Log Properties) 285
7. sd (Set Security Descriptor) 286
8. gp (Get Publisher Information) 287
Additional wevtutil Usage Examples 287
Exporting System Log to an XML File: 287
Query the Last 10 Events from Application Log: 287
Clear the Security Log: 288
List All Available Logs: 288
61. services.msc - Services management console. 288
How to Access services.msc 288
Actions Available in services.msc 289
1. Start a Service 289
2. Stop a Service 289
3. Pause a Service 290
4. Resume a Paused Service 290
5. Restart a Service 290
Service Configuration 291
6. Change Startup Type 291
Windows Commands
20
Copyright © PendemVamsi. All rights reserved.
20. more - Display the contents of a text file one page at a time.
28. fsutil - File system utility for managing various file system settings.
21
Copyright © PendemVamsi. All rights reserved.
Network Commands:
30. ipconfig - Display network configuration information.
46. net time - Synchronize the computer's time with a network server.
48. route print - Display the routing table with more details.
49. nbtstat - Display statistics and current connections using NetBIOS over TCP/IP.
50. ipconfig /flushdns - Flush and reset the DNS resolver cache.
22
Copyright © PendemVamsi. All rights reserved.
54. netstat -a - Display all active network connections and listening ports.
66. gpresult - Display Group Policy settings for the current user.
68. bcdedit - Boot Configuration Data Editor for managing boot options.
72. mmc - Microsoft Management Console for creating custom management tools.
23
Copyright © PendemVamsi. All rights reserved.
Miscellaneous Commands:
88. cls - Clear the screen.
24
Copyright © PendemVamsi. All rights reserved.
● Command: dir
● Command: dir /q
● Command: dir /a
● Command: dir /w
25
Copyright © PendemVamsi. All rights reserved.
● Command: dir /s
● Command: dir /a
● Command: dir /b
26
Copyright © PendemVamsi. All rights reserved.
● Command: dir /s /b
6. Directory Navigation
● Command: dir ..
7. File Searching
8. Redirecting Output
27
Copyright © PendemVamsi. All rights reserved.
● Command: dir /s /b
● Command: dir :w
● Command: dir :a
● Command: dir /p
● Command: dir /w
● Command: dir /q
28
Copyright © PendemVamsi. All rights reserved.
● Command: dir /q /s
14.1. Display Directory Files and Folders with Date and Time
● Command: dir :c
29
Copyright © PendemVamsi. All rights reserved.
● Command: dir /s /a
● Command: dir /s
● Command: dir /q
● Command: dir /q /a
30
Copyright © PendemVamsi. All rights reserved.
● Command: cd [path]
● Description: Changes the current working directory to the specified path. For
example, cd C:\Users\YourName\Documents will change the directory to
Documents.
● Command: cd \
● Description: Changes the current directory to the root directory of the current
drive. For example, on the C: drive, it will navigate to C:\.
● Command: cd D:\FolderName
● Description: Navigates to a folder on a different drive (e.g., from C: to D:). You
must specify the drive letter along with the path.
● Command: cd FolderName
● Description: Changes the current directory to a subfolder of the current directory.
For example, cd Documents will move to the Documents subfolder in the current
directory.
31
Copyright © PendemVamsi. All rights reserved.
● Command: cd ..
● Description: Moves up one directory level. For example, if you are in
C:\Users\YourName\Documents, running cd .. will take you to
C:\Users\YourName.
● Command: cd -
● Description: Navigates to the last visited directory. This command works similarly
to using a back button in a file explorer.
● Command: cd
● Description: Displays the full path of the current working directory.
● Command: cd [nonexistentDirectory]
● Description: If you try to change to a directory that doesn't exist, you’ll get an
error message stating, "The system cannot find the path specified."
● Command: D:
32
Copyright © PendemVamsi. All rights reserved.
● Description: To change from C: to another drive like D:, simply type the drive
letter followed by a colon. This will change the current drive to D:.
Example:
mkdir MyFolder
Example:
mkdir C:\Users\YourName\Documents\NewFolder
Example:
33
Copyright © PendemVamsi. All rights reserved.
mkdir Folder1 Folder2 Folder3
● Result: Three directories (Folder1, Folder2, and Folder3) will be created in the
current directory.
Example:
mkdir ParentFolder\ChildFolder1 ParentFolder\ChildFolder2
Example:
mkdir "My New Folder"
● Result: A folder named My New Folder will be created in the current directory.
Example:
34
Copyright © PendemVamsi. All rights reserved.
mkdir "Folder 1" "Folder 2" "Folder 3"
Example:
mkdir ExistingFolder
Example:
mkdir My*Folder
35
Copyright © PendemVamsi. All rights reserved.
Example:
mkdir C:\NewFolder\SubFolder\ChildFolder
● Command: dir
● Description: After creating a directory with mkdir, use the dir command to list all
directories and files in the current location to verify the creation.
Example:
dir
● Result: Lists the directories, including the newly created ones, in the current
directory.
Example:
mkdir C:\Users\YourName\Documents\.HiddenFolder
36
Copyright © PendemVamsi. All rights reserved.
Example:
rmdir MyFolder
● Result: The folder MyFolder will be removed, but only if it's empty.
Example:
rmdir C:\Users\YourName\Documents\OldFolder
Example:
rmdir /s OldFolder
37
Copyright © PendemVamsi. All rights reserved.
2.2 Remove a Directory and Its Contents with a Full Path (with /s option)
Example:
rmdir /s C:\Users\YourName\Documents\OldFolder
● Result: The folder OldFolder and everything within it will be deleted from
Documents.
3. Forcing Removal
Example:
rmdir /s /q OldFolder
● Result: The OldFolder and its contents will be removed without any prompts or
confirmation messages.
Example:
rmdir /s /q C:\Users\YourName\Documents\OldFolder
● Result: The folder OldFolder and all its contents in Documents will be removed
quietly.
38
Copyright © PendemVamsi. All rights reserved.
Example:
rmdir MyFolder
Example:
rmdir NonExistentFolder
● Command: dir
● Description: After removing a directory, use the dir command to list the
remaining files and directories in the current location.
Example:
dir
39
Copyright © PendemVamsi. All rights reserved.
● Result: Displays the contents of the current directory, confirming that the target
directory has been removed.
Example:
rmdir /s /q C:\Users\YourName\Documents\.HiddenFolder
● Result: The hidden directory .HiddenFolder will be removed along with all its
contents.
Example:
copy C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: The file File1.txt from the Documents folder will be copied to the
Backup folder on the D: drive.
40
Copyright © PendemVamsi. All rights reserved.
Example:
copy C:\Users\YourName\Documents\File1.txt D:\Backup\File1_Copy.txt
● Result: The file File1.txt will be copied and renamed as File1_Copy.txt in the
Backup folder.
Example:
copy C:\Users\YourName\Documents\* D:\Backup\
● Result: All files from the Documents folder will be copied to the Backup folder on
the D: drive.
Example:
copy C:\Users\YourName\Documents\*.txt D:\Backup\
● Result: All .txt files from the Documents folder will be copied to the Backup
folder on the D: drive.
41
Copyright © PendemVamsi. All rights reserved.
3. Overwriting Files
Example:
copy /y C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: The file File1.txt from the Documents folder will be copied to Backup,
overwriting any existing file with the same name.
Example:
copy /-y C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: If a file with the same name exists in Backup, it will ask for confirmation
before overwriting it.
Example:
copy /h C:\Users\YourName\Documents\HiddenFile.txt D:\Backup\
42
Copyright © PendemVamsi. All rights reserved.
● Result: The hidden file HiddenFile.txt will be copied to the Backup folder on
the D: drive.
Example:
copy /s C:\Users\YourName\Documents\SystemFile.sys D:\Backup\
● Result: The system file SystemFile.sys will be copied to the Backup folder on
the D: drive.
Example:
copy C:\Users\YourName\Documents\File1.txt D:
● Result: The file File1.txt from the Documents folder will be copied to the root of
the D: drive.
6. Using Wildcards
Example:
43
Copyright © PendemVamsi. All rights reserved.
copy C:\Users\YourName\Documents\*.txt D:\Backup\
● Result: All .txt files from the Documents folder will be copied to the Backup
folder on the D: drive.
Example:
move C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: The file File1.txt from the Documents folder will be moved to the
Backup folder on the D: drive.
Example:
move C:\Users\YourName\Documents\File1.txt D:\Backup\File1_Moved.txt
2. Moving Directories
44
Copyright © PendemVamsi. All rights reserved.
● Description: Moves a directory and all of its contents from the source location to
the destination.
Example:
move C:\Users\YourName\Documents\OldFolder D:\Backup\
● Result: The entire folder OldFolder from the Documents folder will be moved to
the Backup folder on the D: drive.
Example:
move C:\Users\YourName\Documents\OldFolder D:\Backup\NewFolderName
● Result: The folder OldFolder will be moved to the Backup folder and renamed as
NewFolderName.
Example:
move /y C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: The file File1.txt from the Documents folder will be moved to the
Backup folder on the D: drive, overwriting any existing file with the same name.
45
Copyright © PendemVamsi. All rights reserved.
● Description: Prompts for confirmation before overwriting any existing file in the
destination.
Example:
move /-y C:\Users\YourName\Documents\File1.txt D:\Backup\
● Result: If a file with the same name exists in Backup, it will ask for confirmation
before overwriting it.
4. Using Wildcards
Example:
move C:\Users\YourName\Documents\*.txt D:\Backup\
● Result: All .txt files from the Documents folder will be moved to the Backup
folder on the D: drive.
Example:
move C:\Users\YourName\Documents\File1.txt D:
● Result: The file File1.txt from the Documents folder will be moved to the root of
the D: drive.
46
Copyright © PendemVamsi. All rights reserved.
Example:
move /h C:\Users\YourName\Documents\HiddenFile.txt D:\Backup\
● Result: The hidden file HiddenFile.txt will be moved to the Backup folder on
the D: drive.
Example:
move /s C:\Users\YourName\Documents\SystemFile.sys D:\Backup\
● Result: The system file SystemFile.sys will be moved to the Backup folder on
the D: drive.
Example:
47
Copyright © PendemVamsi. All rights reserved.
del C:\Users\YourName\Documents\*.txt
Example:
del C:\Users\YourName\Documents\*.*
Example:
del /p C:\Users\YourName\Documents\File1.txt
Example:
48
Copyright © PendemVamsi. All rights reserved.
del /f C:\Users\YourName\Documents\ReadOnlyFile.txt
● Result: Deletes the read-only file ReadOnlyFile.txt from the Documents folder.
Example:
del /q C:\Users\YourName\Documents\File1.txt
Example:
del /q C:\Users\YourName\Documents\*.*
Example:
49
Copyright © PendemVamsi. All rights reserved.
del /h C:\Users\YourName\Documents\HiddenFile.txt
● Result: Deletes the hidden file HiddenFile.txt from the Documents folder.
Example:
del /s C:\Users\YourName\Documents\SystemFile.sys
● Result: Deletes the system file SystemFile.sys from the Documents folder.
Example:
del /s C:\Users\YourName\Documents\*.*
● Result: Deletes all files in the Documents folder and its subdirectories.
Example:
del /q /s C:\Users\YourName\Documents\*.*
50
Copyright © PendemVamsi. All rights reserved.
● Result: Deletes all files in the Documents folder and its subdirectories without
asking for confirmation.
Example:
del C:\Users\YourName\Documents\*.log
● Result: The batch file will delete File1.txt from the Documents folder when
executed.
51
Copyright © PendemVamsi. All rights reserved.
Example:
ren C:\Users\YourName\Documents\oldFile.txt newFile.txt
Example:
ren C:\Users\YourName\Documents\*.txt *.doc
Example:
ren C:\Users\YourName\Documents\*2020*.txt *2021*.txt
● Result: Renames all .txt files containing 2020 in their filename to 2021.
52
Copyright © PendemVamsi. All rights reserved.
Example:
ren C:\Users\YourName\Documents\oldFolder newFolder
Example:
ren "C:\Users\YourName\Documents\Old File.txt" "New File.txt"
● Command: Use ren in a batch file (.bat) to rename multiple files in a folder.
53
Copyright © PendemVamsi. All rights reserved.
Example:
ren C:\Users\YourName\Documents\*.jpg *.png
Command:
cmd
type [FilePath]
●
● Description:
Displays the complete contents of a specified text file in the Command Prompt
window.
Example:
cmd
54
Copyright © PendemVamsi. All rights reserved.
type C:\Users\YourName\Documents\example.txt
●
● Result:
Outputs the content of example.txt to the console.
Command:
cmd
type [FilePath1] [FilePath2] [FilePathN]
●
● Description:
Displays the combined contents of multiple files in sequence.
Example:
cmd
type file1.txt file2.txt
●
● Result:
Outputs the contents of file1.txt followed by file2.txt.
Command:
cmd
type [FilePath] > [NewFilePath]
●
● Description:
Reads the contents of a file and writes it to a new file.
Example:
cmd
55
Copyright © PendemVamsi. All rights reserved.
type oldfile.txt > newfile.txt
●
● Result:
Copies the contents of oldfile.txt into newfile.txt.
Command:
cmd
type [FilePath] >> [ExistingFilePath]
●
● Description:
Appends the contents of one file to another file.
Example:
cmd
type additional.txt >> mainfile.txt
●
● Result:
Adds the content of additional.txt to the end of mainfile.txt.
Command:
cmd
find "[SearchString]" [FilePath]
●
● Description: Finds the specified string in the given file.
56
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
find "error" C:\logs\logfile.txt
●
Command:
cmd
find "[SearchString]" C:\Folder\*.*
●
● Description: Searches for the string in all files within a folder.
Example:
cmd
find "error" C:\Folder\*.*
●
Command:
cmd
findstr /c:"[SearchString]" [FilePath]
●
● Description: Performs a case-sensitive search for the string.
Example:
cmd
findstr /c:"ERROR" C:\logs\logfile.txt
●
57
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
find "[SearchString]" /s [Directory]
●
● Description: Searches in the folder and all subdirectories.
Example:
cmd
find "error" /s C:\logs
●
Command:
cmd
findstr /m "[SearchString]" C:\logs\*.*
●
● Description: Lists only the filenames that contain the matching string.
Example:
cmd
findstr /m "error" C:\logs\*.*
●
Command:
cmd
58
Copyright © PendemVamsi. All rights reserved.
findstr "[String1]" [FilePath] | findstr "[String2]"
●
● Description: Finds multiple strings in a file.
Example:
cmd
findstr "error" C:\logs\logfile.txt | findstr "warning"
●
Command:
cmd
findstr /x "[SearchString]" [FilePath]
●
● Description: Searches for the exact match of the string.
Example:
cmd
findstr /x "error" C:\logs\logfile.txt
●
Command:
cmd
findstr "[SearchString]" [CompressedFile.zip]
●
● Description: Allows searching inside compressed files (ZIP).
59
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
findstr "error" C:\logs\logfile.zip
●
Command:
cmd
dir | findstr /i "[SearchString]"
●
● Description: Displays files with the search string in their names.
Example:
cmd
dir | findstr /i "error"
●
Command:
cmd
find "[SearchString]" C:\Folder\*.*
●
● Description: Searches all files within a folder recursively.
Example:
cmd
find "error" C:\Folder\*.*
●
60
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
dir :W | find "[SearchString]"
●
● Description: Finds files based on their modified date.
Example:
cmd
dir :W | find "01/12/2023"
●
Command:
cmd
findstr /n "[SearchString]" [FilePath]
●
● Description: Displays the line numbers of matching lines.
Example:
cmd
findstr /n "error" C:\logs\logfile.txt
●
Command:
cmd
61
Copyright © PendemVamsi. All rights reserved.
find "[Keyword]" [FilePath]
●
● Description: Finds lines that contain a specific keyword.
Example:
cmd
find "success" C:\logs\logfile.txt
●
Command:
cmd
findstr "[SearchString]" C:\logs\logfile1.txt
●
● Description: Searches specific files for the desired string.
Example:
cmd
findstr "error" C:\logs\logfile1.txt
●
Command:
cmd
findstr /r "^.{5}$" [FilePath]
●
● Description: Finds lines that match a pattern.
62
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
findstr /r "^.{5}$" C:\logs\logfile.txt
●
Command:
cmd
dir /S | findstr /c:"[SearchString]"
●
● Description: Displays files larger than a specific size.
Example:
cmd
dir /S | findstr /c:"500MB"
●
Command:
cmd
findstr "^.{40,}" [FilePath]
●
● Description: Finds lines longer than 40 characters.
Example:
cmd
findstr "^.{40,}" C:\logs\logfile.txt
●
63
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr "\b[SearchString]\b" [FilePath]
●
● Description: Finds strings using word boundaries for exact matches.
Example:
cmd
findstr "\berror\b" C:\logs\logfile.txt
●
Command:
cmd
findstr "[SearchString]" [FilePath] | head -n 10
●
● Description: Limits search output to the first 10 lines.
Example:
cmd
findstr "error" C:\logs\logfile.txt | head -n 10
●
Command:
cmd
64
Copyright © PendemVamsi. All rights reserved.
find "[SearchString]" C:\*.txt
●
● Description: Searches specific file types (e.g., .txt).
Example:
cmd
find "error" C:\logs\*.txt
●
Command:
cmd
findstr "[String1]\|[String2]" [FilePath]
●
● Description: Displays lines matching any of the specified strings.
Example:
cmd
findstr "error\|warning" C:\logs\logfile.txt
●
Command:
cmd
find /v "[SearchString]" [FilePath]
●
● Description: Finds files that do not contain the search string.
65
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
find /v "error" C:\logs\logfile.txt
Command:
cmd
attrib [Attribute] [FilePath]
●
● Description: Changes the attributes of a file or directory. Attributes control how
files are handled by the operating system, such as whether they are read-only,
hidden, or system files.
Command:
cmd
attrib +r [FilePath]
●
● Description: Sets the file or directory as read-only. This prevents modifications or
deletions of the file.
Example:
cmd
attrib +r C:\Documents\example.txt
●
66
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
attrib -r [FilePath]
●
● Description: Removes the read-only attribute, allowing the file to be edited or
deleted.
Example:
cmd
attrib -r C:\Documents\example.txt
●
Command:
cmd
attrib +h [FilePath]
●
● Description: Marks the file or directory as hidden, making it not visible in normal
directory listings.
Example:
cmd
attrib +h C:\Documents\example.txt
●
Command:
cmd
67
Copyright © PendemVamsi. All rights reserved.
attrib -h [FilePath]
●
● Description: Removes the hidden attribute, making the file visible again in
directory listings.
Example:
cmd
attrib -h C:\Documents\example.txt
●
Command:
cmd
attrib +s [FilePath]
●
● Description: Marks the file or directory as a system file, which is typically used by
the operating system and hidden from normal users.
Example:
cmd
attrib +s C:\Windows\System32\example.dll
●
Command:
cmd
attrib -s [FilePath]
●
● Description: Removes the system attribute from a file or directory.
68
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
attrib -s C:\Windows\System32\example.dll
●
Command:
cmd
attrib +a [FilePath]
●
● Description: Marks the file for archiving, which typically means it needs to be
backed up.
Example:
cmd
attrib +a C:\Documents\example.txt
●
Command:
cmd
attrib -a [FilePath]
●
● Description: Removes the archive attribute, marking the file as not needing to be
backed up.
Example:
cmd
attrib -a C:\Documents\example.txt
69
Copyright © PendemVamsi. All rights reserved.
●
Command:
cmd
attrib +r +h +s +a [FilePath]
●
● Description: Sets multiple attributes for a file, making it read-only, hidden, a
system file, and marked for archiving.
Example:
cmd
attrib +r +h +s +a C:\Documents\example.txt
●
Command:
cmd
attrib -r -h -s -a [FilePath]
●
● Description: Removes all attributes from a file or directory, making it normal (not
hidden, system, or read-only).
Example:
cmd
attrib -r -h -s -a C:\Documents\example.txt
●
70
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
attrib [FilePath]
●
● Description: Displays the current attributes of a file or directory.
Example:
cmd
attrib C:\Documents\example.txt
Command:
cmd
tree [Drive:\Path]
●
● Description: Displays a graphical representation of the directory structure starting
from the specified directory or drive.
Example:
cmd
tree C:\Users\YourName\Documents
●
○ This will display the directory structure of Documents in a tree format.
Command:
cmd
tree [Drive:\Path] /f
●
71
Copyright © PendemVamsi. All rights reserved.
● Description: Displays the directory structure along with the filenames in each
directory.
Example:
cmd
tree C:\Users\YourName\Documents /f
●
○ This will show the directory structure of Documents with the files listed
inside each directory.
Command:
cmd
tree [Drive:\Path] /f /a
●
● Description: Displays the directory structure using ASCII characters and adds
color to the output.
Example:
cmd
tree C:\Users\YourName\Documents /f /a
●
○ This shows the directory structure with files, using ASCII characters for the
tree structure and color-coding the output.
Command:
cmd
tree [Drive:\Path] /a
●
72
Copyright © PendemVamsi. All rights reserved.
● Description: Displays the directory structure without showing individual files, only
directories.
Example:
cmd
tree C:\Users\YourName\Documents /a
●
○ This shows only the directory structure without listing the files.
Command:
cmd
tree [Drive:\Path] /a
●
● Description: By default, the tree command uses extended characters for the tree
structure, but using /a forces it to use ASCII characters instead.
Example:
cmd
tree C:\Users\YourName\Documents /a
●
Command:
cmd
tree [Drive:\Path] /f /a /s
●
● Description: Displays the directory structure, including all subdirectories, and
lists the files for each directory.
73
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
tree C:\ /f /a /s
●
○ This shows the entire directory structure of C:\, including all
subdirectories and files, using ASCII characters.
Command:
cmd
tree [Drive:\Path] /f /a /l [Level]
●
● Description: Limits the depth of the tree display to a specified number of levels.
The Level parameter defines how many levels deep the tree will be shown.
Example:
cmd
tree C:\Users\YourName\Documents /f /a /l 2
●
○ This limits the tree to display only two levels of directories and files under
Documents.
Command:
cmd
tree [Drive:\Path] > [FilePath]
●
● Description: Redirects the output of the tree command to a text file instead of
displaying it on the screen.
74
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
tree C:\Users\YourName\Documents >
C:\Users\YourName\Documents\directory_structure.txt
●
○ This will save the directory structure of Documents to a text file
directory_structure.txt.
Command:
cmd
tree \\[ServerName]\[ShareName]
●
● Description: Displays the directory structure for a network share or a remote
server.
Example:
cmd
tree \\Server01\SharedDocs
●
○ This will display the directory structure of the shared folder SharedDocs on
the remote server Server01.
10. View the Directory Tree with Directories Only (No Files)
Command:
cmd
tree [Drive:\Path] /a /d
●
75
Copyright © PendemVamsi. All rights reserved.
● Description: Shows only the directories in a tree format without displaying any
files.
● Example:
cmd
tree C:\Users\YourName\Documents /a /d
Command:
cmd
xcopy [Source] [Destination]
●
● Description: Copies files or directories from the source to the destination.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup
●
○ This copies the Documents folder from C:\Users\YourName to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /s
●
● Description: Copies all files and subdirectories, excluding empty directories.
76
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /s
●
○ This copies the Documents folder and all its contents, excluding empty
directories.
Command:
cmd
xcopy [Source] [Destination] /e
●
● Description: Copies all files and subdirectories, including empty directories.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /e
●
○ This copies the Documents folder and all its contents, including empty
subdirectories.
Command:
cmd
xcopy [Source] [Destination] /h
●
● Description: Copies hidden and system files along with regular files.
Example:
cmd
77
Copyright © PendemVamsi. All rights reserved.
xcopy C:\Users\YourName\Documents D:\Backup /h
●
○ This copies all files in Documents, including hidden and system files.
Command:
cmd
xcopy [Source] [Destination] /d
●
● Description: Copies only files that are newer than the existing files in the
destination.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /d
●
○ This copies only files from Documents that are newer than those already in
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /y
●
● Description: Suppresses prompting to confirm you want to overwrite an existing
file. By default, xcopy prompts before overwriting.
Example:
cmd
78
Copyright © PendemVamsi. All rights reserved.
xcopy C:\Users\YourName\Documents D:\Backup /y
●
○ This copies Documents to D:\Backup and suppresses any overwrite
prompts.
Command:
cmd
xcopy [Source] [Destination] /k
●
● Description: Copies files and preserves their file attributes (read-only, hidden,
etc.).
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /k
●
○ This copies the files from Documents to D:\Backup while preserving the
original file attributes.
Command:
cmd
xcopy [Source] \\[NetworkDrive]\[Share] [Destination]
●
● Description: Copies files from a local source to a remote network drive or share.
Example:
cmd
xcopy C:\Users\YourName\Documents \\Server01\SharedDocs
79
Copyright © PendemVamsi. All rights reserved.
●
○ This copies the Documents folder to the shared network folder SharedDocs
on the server Server01.
Command:
cmd
xcopy [Source] [Destination] /v
●
● Description: Verifies each file as it is copied and displays the progress of copying.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /v
●
○ This will display the progress as files are copied from Documents to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /exclude:[file]
●
● Description: Excludes files that match a pattern defined in the [file] list.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /exclude:exclude.txt
●
80
Copyright © PendemVamsi. All rights reserved.
○ This copies all files in Documents to D:\Backup, excluding any files listed
in the exclude.txt file.
Command:
cmd
xcopy [Source] [Destination] /q
●
● Description: Suppresses the display of file names being copied, showing only a
summary.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /q
●
○ This copies the files from Documents to D:\Backup but only shows the
summary of files copied, not the names of each file.
Command:
cmd
xcopy [Source] [Destination] /f
●
● Description: Displays the full source and destination path of each file being
copied.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /f
●
81
Copyright © PendemVamsi. All rights reserved.
○ This copies Documents to D:\Backup and displays the full path of each file
as it is copied.
Command:
cmd
xcopy [Source] [Destination] /c
●
● Description: Ignores errors during the copy process and continues with the next
files.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /c
●
○ This copies Documents to D:\Backup, and if any errors occur (such as file
permission issues), it ignores them and proceeds with the rest of the files.
Command:
cmd
xcopy [Source] [Destination]
●
● Description: Copies the directory structure (including subdirectories) but does not
copy the files.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup
●
82
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
xcopy [Source] [Destination] /size:[size]
●
● Description: Copies files that meet the size criteria.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /size:1024
●
○ This copies only files in Documents that are 1024 bytes (1KB) or larger to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /o
●
● Description: Copies files and retains the original owner and permissions.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /o
●
○ This copies files and ensures the original owner and permissions are kept
intact during the copy process.
83
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:]
●
● Description: Checks the specified drive for errors and reports if any are found.
Example:
cmd
chkdsk C:
●
○ This checks the C: drive for disk errors and displays the results.
Command:
cmd
chkdsk [Drive:] /f
●
● Description: Scans for disk errors and automatically fixes any issues it detects.
You may need to schedule a restart if the drive is in use.
Example:
cmd
chkdsk C: /f
●
○ This checks the C: drive and fixes any errors that are found.
84
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /r
●
● Description: Scans for bad sectors on the disk and attempts to recover readable
information. This option also includes the /f option for fixing errors.
Example:
cmd
chkdsk C: /r
●
○ This checks the C: drive, fixes errors, and attempts to recover any readable
data from bad sectors.
Command:
cmd
chkdsk [Drive:] /v
●
● Description: Provides a detailed list of all files that are checked during the disk
scan, showing more verbose output.
Example:
cmd
chkdsk C: /v
●
○ This checks the C: drive and displays detailed information about the check
process.
85
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /x
●
● Description: Forces the disk to dismount before checking for errors, which may
make the check faster, but it could result in data loss if applications are using the
drive.
Example:
cmd
chkdsk C: /x
●
○ This checks the C: drive by first dismounting it before performing the scan.
Command:
cmd
chkdsk [Drive:] /l:[Size]
●
● Description: Logs the results of the chkdsk scan to a file, allowing you to specify
the size of the log.
Example:
cmd
chkdsk C: /l:50
●
○ This logs the output to a file and limits the size of the log file to 50 KB.
86
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /f /r /x
●
● Description: Schedules a disk check for the next time the system is restarted, with
automatic fixes for errors and bad sector recovery.
Example:
cmd
chkdsk C: /f /r /x
●
○ This schedules a check for the C: drive on the next restart, fixing errors,
recovering bad sectors, and dismounting the drive if needed.
Command:
cmd
chkdsk [Drive:] /scan
●
● Description: Scans the file system for errors without requiring the system to be
rebooted.
Example:
cmd
chkdsk C: /scan
●
○ This scans the C: drive for file system errors without requiring a restart.
Command:
cmd
87
Copyright © PendemVamsi. All rights reserved.
chkdsk [Drive:] /f /r
●
● Description: Checks and repairs errors, and checks for bad sectors on an external
drive or unmounted drive.
Example:
cmd
chkdsk E: /f /r
●
○ This checks and repairs errors and attempts to recover data from bad
sectors on the E: drive.
Command:
cmd
chkdsk [Drive:] /i
●
● Description: Displays the status of the last check disk operation.
Example:
cmd
chkdsk C: /i
●
○ This shows the results of the last check disk run on the C: drive.
Command:
cmd
chkdsk \\[RemoteDrive]\[Path] /f
88
Copyright © PendemVamsi. All rights reserved.
●
● Description: Checks for disk errors on a remote drive over the network.
Example:
cmd
chkdsk \\Server01\SharedDrive /f
●
○ This checks for errors on the remote network drive SharedDrive on
Server01 and fixes any detected errors.
Command:
cmd
chkdsk [Drive:] /c
●
● Description: Disables the checking of cycles within the folder structure. Use this
when you know the file system is intact and you want to speed up the check.
Example:
cmd
chkdsk C: /c
●
○ This checks the C: drive without checking for cycles in the folder structure.
Command:
cmd
89
Copyright © PendemVamsi. All rights reserved.
fc [File1] [File2]
●
● Description: Compares two files line by line and displays any differences between
them.
Example:
cmd
fc file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and shows the lines that differ
between them.
Command:
cmd
fc /a [File1] [File2]
●
● Description: Compares files in ASCII mode (text files). It displays line-by-line
differences between two text files.
Example:
cmd
fc /a file1.txt file2.txt
●
○ This compares file1.txt and file2.txt in ASCII mode and displays the
differences.
Command:
cmd
90
Copyright © PendemVamsi. All rights reserved.
fc /b [File1] [File2]
●
● Description: Compares files in binary mode, which is used for non-text (binary)
files. It compares files byte by byte.
Example:
cmd
fc /b file1.exe file2.exe
●
○ This compares file1.exe and file2.exe in binary mode, showing
byte-by-byte differences.
Command:
cmd
fc /l [File1] [File2]
●
● Description: Displays the differences between files in ASCII mode, with the line
numbers of each difference.
Example:
cmd
fc /l file1.txt file2.txt
●
○ This compares file1.txt and file2.txt in ASCII mode and shows the
line numbers where differences occur.
Command:
cmd
91
Copyright © PendemVamsi. All rights reserved.
fc /w [File1] [File2]
●
● Description: Ignores differences in whitespace (spaces or tabs) while comparing
files.
Example:
cmd
fc /w file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, ignoring any differences in
whitespace.
Command:
cmd
fc [Directory1]\* [Directory2]\*
●
● Description: Compares multiple files in two directories.
Example:
cmd
fc C:\Documents\* D:\Backup\*
●
○ This compares all files in C:\Documents\ with all files in D:\Backup\.
Command:
cmd
fc /i [File1] [File2]
92
Copyright © PendemVamsi. All rights reserved.
●
● Description: Compares files while ignoring case differences in letters.
Example:
cmd
fc /i file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, ignoring any case differences
(e.g., "Hello" vs. "hello").
Command:
cmd
fc /n [File1] [File2]
●
● Description: Displays only the differences between files, without a summary of the
comparison.
Example:
cmd
fc /n file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, showing only the lines that are
different.
Command:
cmd
fc /s [File1] [File2]
●
93
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
fc /s file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and provides a summary of the
differences without showing every single change.
Command:
cmd
fc /c [File1] [File2]
●
● Description: Displays differences using a specified character for line separation.
Example:
cmd
fc /c file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and uses a custom character to
separate the lines with differences.
94
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
comp [File1] [File2]
●
● Description: Compares two files byte by byte and displays the results, showing
any differences.
Example:
cmd
comp file1.txt file2.txt
●
○ This compares file1.txt with file2.txt and reports any byte-level
differences.
Command:
cmd
comp /d [File1] [File2]
●
● Description: Compares two files and only displays the differences, ignoring other
information.
Example:
cmd
comp /d file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, showing only the differences
between the two files.
95
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
comp /a [File1] [File2]
●
● Description: Compares the files and displays a detailed list of differences between
them, including the offset and byte-by-byte differences.
Example:
cmd
comp /a file1.bin file2.bin
●
○ This compares file1.bin and file2.bin, showing detailed information
about their differences at the byte level.
Command:
cmd
comp /c [File1] [File2]
●
● Description: Compares files and stops after displaying the first difference found.
Example:
cmd
comp /c file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and stops after finding and
displaying the first difference.
Command:
cmd
96
Copyright © PendemVamsi. All rights reserved.
comp /n [File1] [File2]
●
● Description: Compares two files and displays only the total number of differences.
Example:
cmd
comp /n file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and shows only the number of
byte-level differences between them.
Command:
cmd
comp /i [File1] [File2]
●
● Description: Compares two text files while ignoring case differences (upper vs.
lower case).
Example:
cmd
comp /i file1.txt file2.txt
●
○ This compares file1.txt and file2.txt while ignoring any case
differences (e.g., "HELLO" vs. "hello").
Command:
cmd
comp /f [File1] [File2]
97
Copyright © PendemVamsi. All rights reserved.
●
● Description: Compares the files and displays the differences using hexadecimal
values for the byte comparison.
Example:
cmd
comp /f file1.bin file2.bin
●
○ This compares file1.bin and file2.bin, displaying the differences in
hexadecimal format.
Command:
cmd
comp [Directory1]\* [Directory2]\*
●
● Description: Compares multiple files in two directories and reports the
differences.
Example:
cmd
comp C:\Documents\* D:\Backup\*
●
○ This compares all files in C:\Documents with all files in D:\Backup.
Command:
cmd
comp /q [File1] [File2]
●
98
Copyright © PendemVamsi. All rights reserved.
● Description: Suppresses the output if the files being compared are identical,
providing a quieter comparison.
Example:
cmd
comp /q file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, and if they are identical, no
output is shown.
Example:
ren C:\Users\YourName\Documents\*.txt *.doc
●
● Result: Renames all .txt files in the Documents folder to .doc.
Example:
ren C:\Users\YourName\Documents\*2020*.txt *2021*.txt
99
Copyright © PendemVamsi. All rights reserved.
●
● Result: Renames all .txt files containing 2020 in their filename to 2021.
Example:
ren C:\Users\YourName\Documents\oldFolder newFolder
●
● Result: Renames the folder oldFolder to newFolder in the Documents directory.
Example:
ren "C:\Users\YourName\Documents\Old File.txt" "New File.txt"
●
● Result: Renames Old File.txt to New File.txt in the Documents folder.
● Command: Use ren in a batch file (.bat) to rename multiple files in a folder.
100
Copyright © PendemVamsi. All rights reserved.
●
● Result: Renames file1.txt to file1_renamed.txt and file2.txt to
file2_renamed.txt in the Documents folder.
Example:
ren C:\Users\YourName\Documents\*.jpg *.png
●
● Result: Renames all .jpg files in the Documents folder to .png.
Example:
ren C:\Users\YourName\Documents\*old*.* *new*.*
●
● Result: Renames files by replacing old in the filename with new.
101
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
find "[SearchString]" [FilePath]
●
● Description: Finds the specified string in the given file.
Example:
cmd
find "error" C:\logs\logfile.txt
●
Command:
cmd
find "[SearchString]" C:\Folder\*.*
●
● Description: Searches for the string in all files within a folder.
Example:
cmd
find "error" C:\Folder\*.*
●
102
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr /c:"[SearchString]" [FilePath]
●
● Description: Performs a case-sensitive search for the string.
Example:
cmd
findstr /c:"ERROR" C:\logs\logfile.txt
●
Command:
cmd
find "[SearchString]" /s [Directory]
●
● Description: Searches in the folder and all subdirectories.
Example:
cmd
find "error" /s C:\logs
●
Command:
cmd
findstr /m "[SearchString]" C:\logs\*.*
●
● Description: Lists only the filenames that contain the matching string.
103
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
findstr /m "error" C:\logs\*.*
●
Command:
cmd
findstr "[String1]" [FilePath] | findstr "[String2]"
●
● Description: Finds multiple strings in a file.
Example:
cmd
findstr "error" C:\logs\logfile.txt | findstr "warning"
●
Command:
cmd
findstr /x "[SearchString]" [FilePath]
●
● Description: Searches for the exact match of the string.
Example:
cmd
findstr /x "error" C:\logs\logfile.txt
●
104
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr "[SearchString]" [CompressedFile.zip]
●
● Description: Allows searching inside compressed files (ZIP).
Example:
cmd
findstr "error" C:\logs\logfile.zip
●
Command:
cmd
dir | findstr /i "[SearchString]"
●
● Description: Displays files with the search string in their names.
Example:
cmd
dir | findstr /i "error"
●
Command:
cmd
105
Copyright © PendemVamsi. All rights reserved.
find "[SearchString]" C:\Folder\*.*
●
● Description: Searches all files within a folder recursively.
Example:
cmd
find "error" C:\Folder\*.*
●
Command:
cmd
dir :W | find "[SearchString]"
●
● Description: Finds files based on their modified date.
Example:
cmd
dir :W | find "01/12/2023"
●
Command:
cmd
findstr /n "[SearchString]" [FilePath]
●
● Description: Displays the line numbers of matching lines.
106
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
findstr /n "error" C:\logs\logfile.txt
●
Command:
cmd
find "[Keyword]" [FilePath]
●
● Description: Finds lines that contain a specific keyword.
Example:
cmd
find "success" C:\logs\logfile.txt
●
Command:
cmd
findstr "[SearchString]" C:\logs\logfile1.txt
●
● Description: Searches specific files for the desired string.
Example:
cmd
findstr "error" C:\logs\logfile1.txt
●
107
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr /r "^.{5}$" [FilePath]
●
● Description: Finds lines that match a pattern.
Example:
cmd
findstr /r "^.{5}$" C:\logs\logfile.txt
●
Command:
cmd
dir /S | findstr /c:"[SearchString]"
●
● Description: Displays files larger than a specific size.
Example:
cmd
dir /S | findstr /c:"500MB"
●
Command:
cmd
108
Copyright © PendemVamsi. All rights reserved.
findstr "^.{40,}" [FilePath]
●
● Description: Finds lines longer than 40 characters.
Example:
cmd
findstr "^.{40,}" C:\logs\logfile.txt
●
Command:
cmd
findstr "\b[SearchString]\b" [FilePath]
●
● Description: Finds strings using word boundaries for exact matches.
Example:
cmd
findstr "\berror\b" C:\logs\logfile.txt
●
Command:
cmd
findstr "[SearchString]" [FilePath] | head -n 10
●
● Description: Limits search output to the first 10 lines.
109
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
findstr "error" C:\logs\logfile.txt | head -n 10
●
Command:
cmd
find "[SearchString]" C:\*.txt
●
● Description: Searches specific file types (e.g., .txt).
Example:
cmd
find "error" C:\logs\*.txt
●
Command:
cmd
findstr "[String1]\|[String2]" [FilePath]
●
● Description: Displays lines matching any of the specified strings.
Example:
cmd
findstr "error\|warning" C:\logs\logfile.txt
●
110
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
find /v "[SearchString]" [FilePath]
●
● Description: Finds files that do not contain the search string.
Example:
cmd
find /v "error" C:\logs\logfile.txt
●
Command:
cmd
attrib [Attribute] [FilePath]
●
● Description: Changes the attributes of a file or directory. Attributes control how
files are handled by the operating system, such as whether they are read-only,
hidden, or system files.
Command:
cmd
111
Copyright © PendemVamsi. All rights reserved.
attrib +r [FilePath]
●
● Description: Sets the file or directory as read-only. This prevents modifications or
deletions of the file.
Example:
cmd
attrib +r C:\Documents\example.txt
●
Command:
cmd
attrib -r [FilePath]
●
● Description: Removes the read-only attribute, allowing the file to be edited or
deleted.
Example:
cmd
attrib -r C:\Documents\example.txt
●
Command:
cmd
attrib +h [FilePath]
●
112
Copyright © PendemVamsi. All rights reserved.
● Description: Marks the file or directory as hidden, making it not visible in normal
directory listings.
Example:
cmd
attrib +h C:\Documents\example.txt
●
Command:
cmd
attrib -h [FilePath]
●
● Description: Removes the hidden attribute, making the file visible again in
directory listings.
Example:
cmd
attrib -h C:\Documents\example.txt
●
Command:
cmd
attrib +s [FilePath]
●
● Description: Marks the file or directory as a system file, which is typically used by
the operating system and hidden from normal users.
Example:
cmd
113
Copyright © PendemVamsi. All rights reserved.
attrib +s C:\Windows\System32\example.dll
●
Command:
cmd
attrib -s [FilePath]
●
● Description: Removes the system attribute from a file or directory.
Example:
cmd
attrib -s C:\Windows\System32\example.dll
●
Command:
cmd
attrib +a [FilePath]
●
● Description: Marks the file for archiving, which typically means it needs to be
backed up.
Example:
cmd
attrib +a C:\Documents\example.txt
●
114
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
attrib -a [FilePath]
●
● Description: Removes the archive attribute, marking the file as not needing to be
backed up.
Example:
cmd
attrib -a C:\Documents\example.txt
●
Command:
cmd
attrib +r +h +s +a [FilePath]
●
● Description: Sets multiple attributes for a file, making it read-only, hidden, a
system file, and marked for archiving.
Example:
cmd
attrib +r +h +s +a C:\Documents\example.txt
●
Command:
cmd
115
Copyright © PendemVamsi. All rights reserved.
attrib -r -h -s -a [FilePath]
●
● Description: Removes all attributes from a file or directory, making it normal (not
hidden, system, or read-only).
Example:
cmd
attrib -r -h -s -a C:\Documents\example.txt
●
Command:
cmd
attrib [FilePath]
●
● Description: Displays the current attributes of a file or directory.
Example:
cmd
attrib C:\Documents\example.txt
●
Command:
cmd
tree [Drive:\Path]
116
Copyright © PendemVamsi. All rights reserved.
●
● Description: Displays a graphical representation of the directory structure starting
from the specified directory or drive.
Example:
cmd
tree C:\Users\YourName\Documents
●
○ This will display the directory structure of Documents in a tree format.
Command:
cmd
tree [Drive:\Path] /f
●
● Description: Displays the directory structure along with the filenames in each
directory.
Example:
cmd
tree C:\Users\YourName\Documents /f
●
○ This will show the directory structure of Documents with the files listed
inside each directory.
Command:
cmd
tree [Drive:\Path] /f /a
●
117
Copyright © PendemVamsi. All rights reserved.
● Description: Displays the directory structure using ASCII characters and adds
color to the output.
Example:
cmd
tree C:\Users\YourName\Documents /f /a
●
○ This shows the directory structure with files, using ASCII characters for the
tree structure and color-coding the output.
Command:
cmd
tree [Drive:\Path] /a
●
● Description: Displays the directory structure without showing individual files, only
directories.
Example:
cmd
tree C:\Users\YourName\Documents /a
●
○ This shows only the directory structure without listing the files.
Command:
cmd
tree [Drive:\Path] /a
●
118
Copyright © PendemVamsi. All rights reserved.
● Description: By default, the tree command uses extended characters for the tree
structure, but using /a forces it to use ASCII characters instead.
Example:
cmd
tree C:\Users\YourName\Documents /a
●
Command:
cmd
tree [Drive:\Path] /f /a /s
●
● Description: Displays the directory structure, including all subdirectories, and
lists the files for each directory.
Example:
cmd
tree C:\ /f /a /s
●
○ This shows the entire directory structure of C:\, including all
subdirectories and files, using ASCII characters.
Command:
cmd
tree [Drive:\Path] /f /a /l [Level]
●
● Description: Limits the depth of the tree display to a specified number of levels.
The Level parameter defines how many levels deep the tree will be shown.
119
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
tree C:\Users\YourName\Documents /f /a /l 2
●
○ This limits the tree to display only two levels of directories and files under
Documents.
Command:
cmd
tree [Drive:\Path] > [FilePath]
●
● Description: Redirects the output of the tree command to a text file instead of
displaying it on the screen.
Example:
cmd
tree C:\Users\YourName\Documents >
C:\Users\YourName\Documents\directory_structure.txt
●
○ This will save the directory structure of Documents to a text file
directory_structure.txt.
Command:
cmd
tree \\[ServerName]\[ShareName]
●
120
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
tree \\Server01\SharedDocs
●
○ This will display the directory structure of the shared folder SharedDocs on
the remote server Server01.
10. View the Directory Tree with Directories Only (No Files)
Command:
cmd
tree [Drive:\Path] /a /d
●
● Description: Shows only the directories in a tree format without displaying any
files.
Example:
cmd
tree C:\Users\YourName\Documents /a /d
●
Command:
cmd
xcopy [Source] [Destination]
121
Copyright © PendemVamsi. All rights reserved.
●
● Description: Copies files or directories from the source to the destination.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup
●
○ This copies the Documents folder from C:\Users\YourName to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /s
●
● Description: Copies all files and subdirectories, excluding empty directories.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /s
●
○ This copies the Documents folder and all its contents, excluding empty
directories.
Command:
cmd
xcopy [Source] [Destination] /e
●
● Description: Copies all files and subdirectories, including empty directories.
122
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /e
●
○ This copies the Documents folder and all its contents, including empty
subdirectories.
Command:
cmd
xcopy [Source] [Destination] /h
●
● Description: Copies hidden and system files along with regular files.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /h
●
○ This copies all files in Documents, including hidden and system files.
Command:
cmd
xcopy [Source] [Destination] /d
●
● Description: Copies only files that are newer than the existing files in the
destination.
Example:
cmd
123
Copyright © PendemVamsi. All rights reserved.
xcopy C:\Users\YourName\Documents D:\Backup /d
●
○ This copies only files from Documents that are newer than those already in
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /y
●
● Description: Suppresses prompting to confirm you want to overwrite an existing
file. By default, xcopy prompts before overwriting.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /y
●
○ This copies Documents to D:\Backup and suppresses any overwrite
prompts.
Command:
cmd
xcopy [Source] [Destination] /k
●
● Description: Copies files and preserves their file attributes (read-only, hidden,
etc.).
Example:
cmd
124
Copyright © PendemVamsi. All rights reserved.
xcopy C:\Users\YourName\Documents D:\Backup /k
●
○ This copies the files from Documents to D:\Backup while preserving the
original file attributes.
Command:
cmd
xcopy [Source] \\[NetworkDrive]\[Share] [Destination]
●
● Description: Copies files from a local source to a remote network drive or share.
Example:
cmd
xcopy C:\Users\YourName\Documents \\Server01\SharedDocs
●
○ This copies the Documents folder to the shared network folder SharedDocs
on the server Server01.
Command:
cmd
xcopy [Source] [Destination] /v
●
● Description: Verifies each file as it is copied and displays the progress of copying.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /v
125
Copyright © PendemVamsi. All rights reserved.
●
○ This will display the progress as files are copied from Documents to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /exclude:[file]
●
● Description: Excludes files that match a pattern defined in the [file] list.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /exclude:exclude.txt
●
○ This copies all files in Documents to D:\Backup, excluding any files listed
in the exclude.txt file.
Command:
cmd
xcopy [Source] [Destination] /q
●
● Description: Suppresses the display of file names being copied, showing only a
summary.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /q
●
126
Copyright © PendemVamsi. All rights reserved.
○ This copies the files from Documents to D:\Backup but only shows the
summary of files copied, not the names of each file.
Command:
cmd
xcopy [Source] [Destination] /f
●
● Description: Displays the full source and destination path of each file being
copied.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /f
●
○ This copies Documents to D:\Backup and displays the full path of each file
as it is copied.
Command:
cmd
xcopy [Source] [Destination] /c
●
● Description: Ignores errors during the copy process and continues with the next
files.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /c
●
127
Copyright © PendemVamsi. All rights reserved.
○ This copies Documents to D:\Backup, and if any errors occur (such as file
permission issues), it ignores them and proceeds with the rest of the files.
Command:
cmd
xcopy [Source] [Destination]
●
● Description: Copies the directory structure (including subdirectories) but does not
copy the files.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup
●
○ This will copy the directory structure of Documents to D:\Backup, but no
files will be copied.
Command:
cmd
xcopy [Source] [Destination] /size:[size]
●
● Description: Copies files that meet the size criteria.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /size:1024
●
128
Copyright © PendemVamsi. All rights reserved.
○ This copies only files in Documents that are 1024 bytes (1KB) or larger to
D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /o
●
● Description: Copies files and retains the original owner and permissions.
Example:
cmd
xcopy C:\Users\YourName\Documents D:\Backup /o
●
○ This copies files and ensures the original owner and permissions are kept
intact during the copy process.
Command:
cmd
chkdsk [Drive:]
●
● Description: Checks the specified drive for errors and reports if any are found.
Example:
cmd
chkdsk C:
●
129
Copyright © PendemVamsi. All rights reserved.
○ This checks the C: drive for disk errors and displays the results.
Command:
cmd
chkdsk [Drive:] /f
●
● Description: Scans for disk errors and automatically fixes any issues it detects.
You may need to schedule a restart if the drive is in use.
Example:
cmd
chkdsk C: /f
●
○ This checks the C: drive and fixes any errors that are found.
Command:
cmd
chkdsk [Drive:] /r
●
● Description: Scans for bad sectors on the disk and attempts to recover readable
information. This option also includes the /f option for fixing errors.
Example:
cmd
chkdsk C: /r
●
○ This checks the C: drive, fixes errors, and attempts to recover any readable
data from bad sectors.
130
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /v
●
● Description: Provides a detailed list of all files that are checked during the disk
scan, showing more verbose output.
Example:
cmd
chkdsk C: /v
●
○ This checks the C: drive and displays detailed information about the check
process.
Command:
cmd
chkdsk [Drive:] /x
●
● Description: Forces the disk to dismount before checking for errors, which may
make the check faster, but it could result in data loss if applications are using the
drive.
Example:
cmd
chkdsk C: /x
●
○ This checks the C: drive by first dismounting it before performing the scan.
131
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /l:[Size]
●
● Description: Logs the results of the chkdsk scan to a file, allowing you to specify
the size of the log.
Example:
cmd
chkdsk C: /l:50
●
○ This logs the output to a file and limits the size of the log file to 50 KB.
Command:
cmd
chkdsk [Drive:] /f /r /x
●
● Description: Schedules a disk check for the next time the system is restarted, with
automatic fixes for errors and bad sector recovery.
Example:
cmd
chkdsk C: /f /r /x
●
○ This schedules a check for the C: drive on the next restart, fixing errors,
recovering bad sectors, and dismounting the drive if needed.
132
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
chkdsk [Drive:] /scan
●
● Description: Scans the file system for errors without requiring the system to be
rebooted.
Example:
cmd
chkdsk C: /scan
●
○ This scans the C: drive for file system errors without requiring a restart.
Command:
cmd
chkdsk [Drive:] /f /r
●
● Description: Checks and repairs errors, and checks for bad sectors on an external
drive or unmounted drive.
Example:
cmd
chkdsk E: /f /r
●
○ This checks and repairs errors and attempts to recover data from bad
sectors on the E: drive.
Command:
cmd
133
Copyright © PendemVamsi. All rights reserved.
chkdsk [Drive:] /i
●
● Description: Displays the status of the last check disk operation.
Example:
cmd
chkdsk C: /i
●
○ This shows the results of the last check disk run on the C: drive.
Command:
cmd
chkdsk \\[RemoteDrive]\[Path] /f
●
● Description: Checks for disk errors on a remote drive over the network.
Example:
cmd
chkdsk \\Server01\SharedDrive /f
●
○ This checks for errors on the remote network drive SharedDrive on
Server01 and fixes any detected errors.
Command:
cmd
chkdsk [Drive:] /c
●
134
Copyright © PendemVamsi. All rights reserved.
● Description: Disables the checking of cycles within the folder structure. Use this
when you know the file system is intact and you want to speed up the check.
Example:
cmd
chkdsk C: /c
●
○ This checks the C: drive without checking for cycles in the folder structure.
Command:
cmd
fc [File1] [File2]
●
● Description: Compares two files line by line and displays any differences between
them.
Example:
cmd
fc file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and shows the lines that differ
between them.
Command:
cmd
fc /a [File1] [File2]
135
Copyright © PendemVamsi. All rights reserved.
●
● Description: Compares files in ASCII mode (text files). It displays line-by-line
differences between two text files.
Example:
cmd
fc /a file1.txt file2.txt
●
○ This compares file1.txt and file2.txt in ASCII mode and displays the
differences.
Command:
cmd
fc /b [File1] [File2]
●
● Description: Compares files in binary mode, which is used for non-text (binary)
files. It compares files byte by byte.
Example:
cmd
fc /b file1.exe file2.exe
●
○ This compares file1.exe and file2.exe in binary mode, showing
byte-by-byte differences.
Command:
cmd
fc /l [File1] [File2]
●
136
Copyright © PendemVamsi. All rights reserved.
● Description: Displays the differences between files in ASCII mode, with the line
numbers of each difference.
Example:
cmd
fc /l file1.txt file2.txt
●
○ This compares file1.txt and file2.txt in ASCII mode and shows the
line numbers where differences occur.
Command:
cmd
fc /w [File1] [File2]
●
● Description: Ignores differences in whitespace (spaces or tabs) while comparing
files.
Example:
cmd
fc /w file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, ignoring any differences in
whitespace.
Command:
cmd
fc [Directory1]\* [Directory2]\*
●
● Description: Compares multiple files in two directories.
137
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
fc C:\Documents\* D:\Backup\*
●
○ This compares all files in C:\Documents\ with all files in D:\Backup\.
Command:
cmd
fc /i [File1] [File2]
●
● Description: Compares files while ignoring case differences in letters.
Example:
cmd
fc /i file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, ignoring any case differences
(e.g., "Hello" vs. "hello").
Command:
cmd
fc /n [File1] [File2]
●
● Description: Displays only the differences between files, without a summary of the
comparison.
Example:
cmd
138
Copyright © PendemVamsi. All rights reserved.
fc /n file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, showing only the lines that are
different.
Command:
cmd
fc /s [File1] [File2]
●
● Description: Compares files and displays a summary of differences, instead of
showing the entire content.
Example:
cmd
fc /s file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and provides a summary of the
differences without showing every single change.
Command:
cmd
fc /c [File1] [File2]
●
● Description: Displays differences using a specified character for line separation.
Example:
cmd
fc /c file1.txt file2.txt
139
Copyright © PendemVamsi. All rights reserved.
●
○ This compares file1.txt and file2.txt and uses a custom character to
separate the lines with differences.
Command:
cmd
comp [File1] [File2]
●
● Description: Compares two files byte by byte and displays the results, showing
any differences.
Example:
cmd
comp file1.txt file2.txt
●
○ This compares file1.txt with file2.txt and reports any byte-level
differences.
Command:
cmd
comp /d [File1] [File2]
●
● Description: Compares two files and only displays the differences, ignoring other
information.
Example:
cmd
140
Copyright © PendemVamsi. All rights reserved.
comp /d file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, showing only the differences
between the two files.
Command:
cmd
comp /a [File1] [File2]
●
● Description: Compares the files and displays a detailed list of differences between
them, including the offset and byte-by-byte differences.
Example:
cmd
comp /a file1.bin file2.bin
●
○ This compares file1.bin and file2.bin, showing detailed information
about their differences at the byte level.
Command:
cmd
comp /c [File1] [File2]
●
● Description: Compares files and stops after displaying the first difference found.
Example:
cmd
comp /c file1.txt file2.txt
141
Copyright © PendemVamsi. All rights reserved.
●
○ This compares file1.txt and file2.txt and stops after finding and
displaying the first difference.
Command:
cmd
comp /n [File1] [File2]
●
● Description: Compares two files and displays only the total number of differences.
Example:
cmd
comp /n file1.txt file2.txt
●
○ This compares file1.txt and file2.txt and shows only the number of
byte-level differences between them.
Command:
cmd
comp /i [File1] [File2]
●
● Description: Compares two text files while ignoring case differences (upper vs.
lower case).
Example:
cmd
comp /i file1.txt file2.txt
●
142
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
comp /f [File1] [File2]
●
● Description: Compares the files and displays the differences using hexadecimal
values for the byte comparison.
Example:
cmd
comp /f file1.bin file2.bin
●
○ This compares file1.bin and file2.bin, displaying the differences in
hexadecimal format.
Command:
cmd
comp [Directory1]\* [Directory2]\*
●
● Description: Compares multiple files in two directories and reports the
differences.
Example:
cmd
comp C:\Documents\* D:\Backup\*
●
○ This compares all files in C:\Documents with all files in D:\Backup.
143
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
comp /q [File1] [File2]
●
● Description: Suppresses the output if the files being compared are identical,
providing a quieter comparison.
Example:
cmd
comp /q file1.txt file2.txt
●
○ This compares file1.txt and file2.txt, and if they are identical, no
output is shown.
Command:
cmd
robocopy [Source] [Destination]
●
● Description: Copies all files from the source directory to the destination directory.
Example:
cmd
robocopy C:\Source D:\Backup
●
144
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
robocopy [Source] [Destination] /E
●
● Description: Copies all files and subdirectories, including empty directories.
Example:
cmd
robocopy C:\Source D:\Backup /E
●
○ This copies all files and subdirectories from C:\Source to D:\Backup,
including any empty directories.
Command:
cmd
robocopy [Source] [Destination] /XO
●
● Description: Copies only the files that are newer in the source directory than in the
destination directory.
Example:
cmd
robocopy C:\Source D:\Backup /XO
●
○ This copies only the newer files from C:\Source to D:\Backup, skipping
older files.
145
Copyright © PendemVamsi. All rights reserved.
4. Retry on Failure
Command:
cmd
robocopy [Source] [Destination] /R:[NumberOfRetries]
●
● Description: Sets the number of retries on failed copies. By default, robocopy
retries 1 million times, but you can specify a custom number.
Example:
cmd
robocopy C:\Source D:\Backup /R:5
●
○ This will retry copying up to 5 times if a file cannot be copied.
Command:
cmd
robocopy [Source] [Destination] /XC /XN /XO
●
● Description: Skips files that already exist at the destination. It checks for files that
are the same in both locations and skips copying them.
Example:
cmd
robocopy C:\Source D:\Backup /XC /XN /XO
●
○ This command will skip existing, newer, or unchanged files when copying
from C:\Source to D:\Backup.
146
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
robocopy [Source] [Destination] /COPYALL
●
● Description: Copies all file attributes and permissions (including timestamps and
ACLs).
Example:
cmd
robocopy C:\Source D:\Backup /COPYALL
●
○ This copies all files from C:\Source to D:\Backup, including all
permissions, attributes, and timestamps.
7. Mirror Directories
Command:
cmd
robocopy [Source] [Destination] /MIR
●
● Description: Mirrors a directory, copying all files and subdirectories from the
source to the destination, and deleting files at the destination that are no longer in
the source.
Example:
cmd
robocopy C:\Source D:\Backup /MIR
●
○ This creates an exact mirror of C:\Source in D:\Backup, deleting any files
in the destination that do not exist in the source.
147
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
robocopy [Source] [Destination] /IPG:[Delay]
●
● Description: Sets the inter-packet gap (IPG) in milliseconds to limit the bandwidth
used during file copying.
Example:
cmd
robocopy C:\Source D:\Backup /IPG:50
●
○ This limits the copying speed by introducing a 50 millisecond delay
between packets.
Command:
cmd
robocopy [Source] [Destination] /XF [FileName]
●
● Description: Excludes specific files from being copied.
Example:
cmd
robocopy C:\Source D:\Backup /XF *.log
●
○ This copies everything from C:\Source to D:\Backup, but skips any .log
files.
148
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
robocopy [Source] [Destination] /XD [DirectoryName]
●
● Description: Excludes specific directories from being copied.
Example:
cmd
robocopy C:\Source D:\Backup /XD C:\Source\Temp
●
○ This copies everything from C:\Source to D:\Backup, excluding the Temp
directory.
Command:
cmd
robocopy [Source] [Destination] /L
●
● Description: Simulates the copy operation without actually making any changes
(dry run).
Example:
cmd
robocopy C:\Source D:\Backup /L
●
○ This simulates the copying process from C:\Source to D:\Backup but
does not actually copy any files.
Command:
cmd
149
Copyright © PendemVamsi. All rights reserved.
robocopy [Source] [Destination] /LOG:[LogFile]
●
● Description: Logs the output of the copying process to a specified log file.
Example:
cmd
robocopy C:\Source D:\Backup /LOG:C:\BackupLog.txt
●
○ This copies from C:\Source to D:\Backup and logs the details to
C:\BackupLog.txt.
Command:
cmd
robocopy \\[NetworkSource] \\[NetworkDestination]
●
● Description: Uses robocopy to copy files over a network to a shared folder.
Example:
cmd
robocopy \\Server\Share D:\Backup
●
○ This copies files from the network share \\Server\Share to the
D:\Backup directory.
Command:
cmd
robocopy [Source] [Destination] /E /LEV:1
150
Copyright © PendemVamsi. All rights reserved.
●
● Description: Copies only empty directories from the source to the destination.
Example:
cmd
robocopy C:\Source D:\Backup /E /LEV:1
●
○ This copies only empty directories from C:\Source to D:\Backup.
Command:
cmd
sfc /scannow
●
● Description: Scans all protected system files and repairs any corrupted or missing
files.
Example:
cmd
sfc /scannow
●
○ This command scans all system files for integrity issues and attempts to fix
any detected corruption.
151
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
sfc /verifyonly
●
● Description: Scans protected system files but does not perform any repair
actions, useful for checking the integrity of files without making changes.
Example:
cmd
sfc /verifyonly
●
○ This command checks the system files for integrity but does not attempt
any repairs.
Command:
cmd
sfc /scanfile=[Path to File]
●
● Description: Scans a specific file for integrity issues. This command allows you to
check the status of a specific system file rather than scanning the entire system.
Example:
cmd
sfc /scanfile=C:\Windows\System32\kernel32.dll
●
○ This scans the file kernel32.dll in the System32 folder for corruption.
Command:
cmd
152
Copyright © PendemVamsi. All rights reserved.
sfc /offbootdir=[Boot Drive] /offwindir=[Windows Directory]
●
● Description: Specifies the boot directory and Windows directory when running
sfc on an offline system (such as when using Windows recovery environment).
Example:
cmd
sfc /offbootdir=D:\ /offwindir=D:\Windows
●
○ This command runs sfc on an offline Windows installation located on drive
D:.
Command:
cmd
sfc /scanfile=[FilePath] /offbootdir=[BootDrive]
/offwindir=[WindowsDir]
●
● Description: This command is used to check and repair system files on an offline
system without the need for a restart.
Example:
cmd
sfc /scanfile=C:\Windows\System32\user32.dll /offbootdir=C:\
/offwindir=C:\Windows
●
○ This checks and repairs the user32.dll file located in
C:\Windows\System32.
153
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
sfc /log
●
● Description: Displays a detailed log of the results from the sfc scan, which can
help identify issues that the tool has found and fixed.
Example:
cmd
sfc /log
●
○ This command displays a detailed log of the sfc scan results, useful for
advanced troubleshooting.
Command:
cmd
sfc /scannow /offbootdir=[Boot Drive] /offwindir=[Windows Directory]
●
● Description: Runs sfc in the Windows Recovery Environment to scan and repair
system files without starting the Windows operating system.
Example:
cmd
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
●
○ This command scans and repairs system files from the Windows Recovery
Environment.
154
Copyright © PendemVamsi. All rights reserved.
Sometimes sfc might not be able to repair the system files if the source files are also
corrupted. In such cases, the DISM (Deployment Imaging Service and Management Tool)
can be used to restore the files.
Command:
cmd
dism /online /cleanup-image /restorehealth
●
● Description: This command uses DISM to repair the Windows image and restore
missing or corrupted system files before running sfc.
Example:
cmd
dism /online /cleanup-image /restorehealth
●
○ This command repairs the system image and prepares it for sfc to
complete its repair process.
After using DISM, you can run sfc to complete the file repair process:
Command:
cmd
sfc /scannow
●
● Description: Scans and repairs system files after running DISM to restore the
Windows image.
Example:
cmd
sfc /scannow
●
155
Copyright © PendemVamsi. All rights reserved.
○ This command runs the System File Checker to fix any remaining file
integrity issues after DISM has restored the system image.
Command:
cmd
sfc /scannow /offbootdir=[Boot Drive] /offwindir=[Windows Directory]
/modules
●
● Description: Scans and repairs specific Windows modules, ensuring that all
components are working correctly.
Example:
cmd
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows /modules
●
○ This command repairs specific modules of Windows during the sfc scan.
Command:
cmd
findstr [String] [FilePath]
●
● Description: Searches for the specified string in a file and displays the matching
lines.
Example:
cmd
findstr "error" C:\Logs\logfile.txt
156
Copyright © PendemVamsi. All rights reserved.
●
○ This command searches for the string "error" in logfile.txt located in
the C:\Logs\ directory and displays all lines containing the word "error."
Command:
cmd
findstr [String1] [String2] [FilePath]
●
● Description: Searches for multiple strings in a file. Any line containing at least one
of the strings will be returned.
Example:
cmd
findstr "error" "warning" C:\Logs\logfile.txt
●
○ This searches for lines containing either "error" or "warning" in
logfile.txt.
Command:
cmd
findstr /r [RegularExpression] [FilePath]
●
● Description: Uses regular expressions to search for patterns in a file.
Example:
cmd
findstr /r "^[A-Za-z]*" C:\Logs\logfile.txt
●
157
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr /n [String] [FilePath]
●
● Description: Displays the line numbers along with the lines that match the search
string.
Example:
cmd
findstr /n "error" C:\Logs\logfile.txt
●
○ This command shows all lines containing "error" along with their line
numbers in logfile.txt.
Command:
cmd
findstr /w [String] [FilePath]
●
● Description: Searches for whole words only, ignoring partial matches.
Example:
cmd
findstr /w "error" C:\Logs\logfile.txt
●
○ This command searches for the exact word "error" in logfile.txt and
does not match words like "errors" or "erroneous."
158
Copyright © PendemVamsi. All rights reserved.
6. Case-Insensitive Search
Command:
cmd
findstr /i [String] [FilePath]
●
● Description: Searches for the string in a case-insensitive manner.
Example:
cmd
findstr /i "ERROR" C:\Logs\logfile.txt
●
○ This searches for "ERROR", "error", or any case variation of "error" in
logfile.txt.
Command:
cmd
findstr /v [String] [FilePath]
●
● Description: Excludes lines that contain the specified string.
Example:
cmd
findstr /v "error" C:\Logs\logfile.txt
●
○ This command displays all lines in logfile.txt that do not contain the
word "error."
159
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
findstr [String] [FolderPath]\*.txt
●
● Description: Searches for a string in all text files in a specified folder.
Example:
cmd
findstr "critical" C:\Logs\*.txt
●
○ This searches for the string "critical" in all .txt files within the C:\Logs\
directory.
Command:
cmd
findstr /s [String] [FolderPath]\*
●
● Description: Searches for a string in all files within a directory and its
subdirectories.
Example:
cmd
findstr /s "error" C:\Logs\*
●
○ This command searches for "error" in all files under the C:\Logs\
directory, including subdirectories.
Command:
cmd
160
Copyright © PendemVamsi. All rights reserved.
findstr /x [String] [FilePath]
●
● Description: Searches for the exact match of the entire line.
Example:
cmd
findstr /x "This is an error" C:\Logs\logfile.txt
●
○ This searches for lines that are exactly "This is an error" in logfile.txt.
Command:
cmd
findstr /c:"[String1]" /c:"[String2]" [FolderPath]\*.log
●
● Description: Searches for multiple specific strings in multiple files using the /c:
option to treat the strings as literal patterns.
Example:
cmd
findstr /c:"timeout" /c:"failure" C:\Logs\*.log
●
○ This command searches for both "timeout" and "failure" in all .log files in
the C:\Logs\ directory.
Command:
cmd
findstr /o [String] [FilePath]
161
Copyright © PendemVamsi. All rights reserved.
●
● Description: Displays only the matching string in the file, along with its offset
(position) in the line.
Example:
cmd
findstr /o "error" C:\Logs\logfile.txt
●
○ This command displays the position of the word "error" in each matching
line from logfile.txt.
Command:
cmd
more [FilePath]
●
● Description: Displays the content of a file, one page at a time. Press Enter to
advance one line at a time or Space to move to the next page.
Example:
cmd
more C:\Logs\logfile.txt
●
○ This command shows the contents of logfile.txt in the C:\Logs\
directory one page at a time.
Command:
cmd
162
Copyright © PendemVamsi. All rights reserved.
more [File1] [File2] ...
●
● Description: Displays the contents of multiple files, one page at a time.
Example:
cmd
more C:\Logs\logfile1.txt C:\Logs\logfile2.txt
●
○ This command shows the contents of both logfile1.txt and
logfile2.txt one page at a time.
While using more, you can use the following keys to navigate:
Command:
cmd
more /e [FilePath]
●
● Description: Displays the contents of the file one line at a time, waiting for user
input before showing each line.
Example:
cmd
more /e C:\Logs\logfile.txt
163
Copyright © PendemVamsi. All rights reserved.
●
○ This command will display the file content one line at a time. You will need
to press Enter to display the next line.
Command:
cmd
more /n [FilePath]
●
● Description: Displays the contents of the file with line numbers at the beginning of
each line.
Example:
cmd
more /n C:\Logs\logfile.txt
●
○ This command will display logfile.txt with line numbers, making it
easier to reference specific lines.
Command:
cmd
type [FilePath] | more
●
● Description: Uses the type command to display the contents of the file and pipes
it to more for paging, especially useful when the file is long.
Example:
cmd
type C:\Logs\logfile.txt | more
164
Copyright © PendemVamsi. All rights reserved.
●
○ This command displays the file content page by page, even if the type
command itself would display the entire file at once.
Command:
cmd
more +[Number] [FilePath]
●
● Description: Starts displaying the file from the specified line number. Use this
option to skip the first few lines and begin from a specific point in the file.
Example:
cmd
more +10 C:\Logs\logfile.txt
●
○ This command starts showing the file content from the 10th line onwards.
Command:
cmd
more /p [FilePath]
●
● Description: Pauses after each screenful of text, allowing the user to press Enter
or Space to continue.
Example:
cmd
more /p C:\Logs\logfile.txt
●
165
Copyright © PendemVamsi. All rights reserved.
○ This command pauses after each screenful, waiting for the user to continue
to the next page.
Command:
cmd
more /s [FilePath]
●
● Description: Allows you to search for a specified string while viewing the file.
Example:
cmd
more /s "error" C:\Logs\logfile.txt
●
○ This command allows searching for the word "error" while viewing the file
content.
Command:
cmd
more /c [FilePath]
●
● Description: Clears the screen before displaying each page of the file content.
Example:
cmd
more /c C:\Logs\logfile.txt
●
○ This command clears the screen each time it displays a new page of
content.
166
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
sort [FilePath]
●
● Description: Sorts the lines in the specified text file in ascending order
(alphabetically or numerically based on the content).
Example:
cmd
sort C:\Documents\data.txt
●
○ This command sorts the contents of data.txt in ascending order and
displays the output.
Command:
cmd
sort /r [FilePath]
●
● Description: Sorts the lines of the text file in reverse (descending) order.
Example:
cmd
sort /r C:\Documents\data.txt
●
○ This command sorts the contents of data.txt in descending order.
167
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
sort /u [FilePath]
●
● Description: Removes duplicate lines while sorting the file contents.
Example:
cmd
sort /u C:\Documents\data.txt
●
○ This command sorts the file contents and removes any duplicate lines,
showing only unique entries.
Command:
cmd
sort /+n [FilePath]
●
● Description: Sorts the file content starting from the nth character of each line.
Useful for sorting based on columns.
Example:
cmd
sort /+5 C:\Documents\data.txt
●
○ This command sorts the contents of data.txt, starting from the 5th
character of each line.
168
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
echo [Text] | sort
●
● Description: Sorts the input provided via the command line or piped input.
Example:
cmd
echo Apple Banana Orange | sort
●
○ This command sorts the words "Apple", "Banana", and "Orange" in
ascending order and displays the result: "Apple Banana Orange".
Command:
cmd
sort [FilePath] > [NewFilePath]
●
● Description: Redirects the sorted output to a new file, rather than displaying it on
the screen.
Example:
cmd
sort C:\Documents\data.txt > C:\Documents\sorted_data.txt
●
○ This command sorts the contents of data.txt and saves the sorted output
to sorted_data.txt.
169
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
sort [Delimiter] /+n [FilePath]
●
● Description: Sorts a file with a specified delimiter (e.g., comma or tab) starting
from the nth column.
Example:
cmd
sort , /+2 C:\Documents\data.csv
●
○ This command sorts the data.csv file based on the second column,
assuming a comma delimiter.
Command:
cmd
sort /f [FilePath]
●
● Description: Sorts the file contents in a case-insensitive manner, so "apple" and
"Apple" will be treated as equivalent.
Example:
cmd
sort /f C:\Documents\data.txt
●
○ This command sorts the contents of data.txt without considering case
sensitivity.
170
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
[Command] | sort
●
● Description: Sorts the output of any command in real-time. You can pipe any
command’s output into sort to sort it.
Example:
cmd
dir | sort
●
○ This command lists the directory contents and sorts them alphabetically.
Command:
cmd
sort [FilePath] | nl
●
● Description: Sorts the file content and displays line numbers along with the sorted
output.
Example:
cmd
sort C:\Documents\data.txt | nl
●
○ This command sorts the file data.txt and displays each line with a line
number.
171
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
xcopy [Source] [Destination] /e
●
● Description: Copies all directories and subdirectories, including empty
directories, from the source to the destination path.
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e
●
○ This command copies all files and subdirectories from Documents to
D:\Backup, including any empty subdirectories.
Command:
cmd
xcopy [Source] [Destination] /e /y
●
● Description: Copies directories and subdirectories (including empty ones) and
automatically confirms overwriting of files without prompting.
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e /y
●
172
Copyright © PendemVamsi. All rights reserved.
○ This command copies all files and directories, including empty directories,
and automatically overwrites any existing files in the destination without
confirmation.
Command:
cmd
xcopy [Source] [Destination] /e /a
●
● Description: Copies directories and subdirectories, including empty ones, and
preserves the file attributes (such as read-only, hidden, system).
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e /a
●
○ This command copies all files, subdirectories, and empty directories from
Documents to D:\Backup, preserving the file attributes.
Command:
cmd
xcopy [Source] [Destination] /e *.txt
●
● Description: Copies only specific file types (in this case .txt files) from the
source directory, including any empty subdirectories.
Example:
cmd
xcopy C:\Users\YourName\Documents\*.txt D:\Backup\ /e
●
173
Copyright © PendemVamsi. All rights reserved.
○ This command copies only .txt files from the Documents directory, along
with any empty subdirectories, to D:\Backup.
Command:
cmd
xcopy [Source] [Destination] /e /exclude:[FileWithExcludedPatterns]
●
● Description: Copies directories and subdirectories, including empty ones, but
excludes files that match the patterns specified in the exclude file.
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e /exclude:exclude.txt
●
○ This command copies all files and directories, including empty ones,
except for files matching the patterns listed in exclude.txt.
Command:
cmd
xcopy [Source] [Destination] /e /v
●
● Description: Copies directories and subdirectories, including empty ones, and
verifies that the files are copied correctly.
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e /v
●
174
Copyright © PendemVamsi. All rights reserved.
Command:
cmd
xcopy [Source] [Destination] /e /h
●
● Description: Copies all files, directories, and subdirectories, including hidden files
and folders, from the source to the destination.
Example:
cmd
xcopy C:\Users\YourName\Documents\* D:\Backup\ /e /h
●
○ This command copies all files, hidden files, subdirectories, and empty
directories from Documents to D:\Backup.
Command:
cmd
xcopy [Source1] [Source2] [Destination] /e
●
● Description: Copies multiple source directories and subdirectories (including
empty ones) into one destination directory.
Example:
cmd
xcopy C:\Users\YourName\Documents\* C:\Users\YourName\Pictures\*
D:\Backup\ /e
175
Copyright © PendemVamsi. All rights reserved.
●
○ This command copies the contents of both Documents and Pictures
directories (including empty subdirectories) to the D:\Backup directory.
1. Compress Files
Command:
cmd
compact [File/Directory Path] /c
●
● Description: Compresses the specified file or directory on an NTFS partition.
Example:
cmd
compact C:\Users\YourName\Documents\LargeFile.txt /c
●
○ This command compresses LargeFile.txt in the Documents folder,
reducing its disk usage on an NTFS partition.
2. Decompress Files
Command:
cmd
compact [File/Directory Path] /u
●
● Description: Decompresses the specified file or directory that was previously
compressed.
176
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
compact C:\Users\YourName\Documents\CompressedFile.txt /u
●
○ This command decompresses CompressedFile.txt in the Documents
folder, restoring its original size.
Command:
cmd
compact [File/Directory Path]
●
● Description: Displays the current compression status of a specified file or
directory. It shows whether the file is compressed or uncompressed.
Example:
cmd
compact C:\Users\YourName\Documents\LargeFile.txt
●
○ This command displays whether LargeFile.txt is currently compressed
or not.
Command:
cmd
compact [Directory Path] /c /s
●
● Description: Compresses all files in the specified directory and all its
subdirectories.
177
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
compact C:\Users\YourName\Documents\ /c /s
●
○ This command compresses all files in the Documents folder and its
subdirectories.
Command:
cmd
compact [Directory Path] /u /s
●
● Description: Decompresses all files in the specified directory and all its
subdirectories.
Example:
cmd
compact C:\Users\YourName\Documents\ /u /s
●
○ This command decompresses all files in the Documents folder and its
subdirectories.
Command:
cmd
compact [Directory Path] /s /q
●
● Description: Displays the compression status of all files in the specified directory
and its subdirectories without making any changes.
178
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
compact C:\Users\YourName\Documents\ /s /q
●
○ This command shows the compression status of all files in the Documents
folder and its subdirectories without modifying them.
Command:
cmd
compact [Directory Path] /c /a
●
● Description: Compresses files in the specified directory and subdirectories, but
only those that are not already compressed.
Example:
cmd
compact C:\Users\YourName\Documents\ /c /a
●
○ This command compresses only the uncompressed files in the Documents
folder and its subdirectories.
Command:
cmd
compact /i [File Path]
●
● Description: Displays detailed compression information for a specified file.
Example:
cmd
179
Copyright © PendemVamsi. All rights reserved.
compact /i C:\Users\YourName\Documents\LargeFile.txt
●
○ This command provides detailed information about the compression status
of LargeFile.txt.
Command:
cmd
compact [Directory Path] /c *.txt
●
● Description: Compresses only files with a specific file extension (e.g., .txt) in the
specified directory.
Example:
cmd
compact C:\Users\YourName\Documents\ /c *.txt
●
○ This command compresses only .txt files in the Documents folder.
Command:
cmd
compact /r [File Path]
●
● Description: Displays the compression ratio for a compressed file, showing how
much space was saved.
Example:
cmd
180
Copyright © PendemVamsi. All rights reserved.
compact /r C:\Users\YourName\Documents\LargeFile.txt
●
○ This command shows the compression ratio for LargeFile.txt,
indicating the amount of space saved by compression.
Command:
cmd
xcacls [File/Folder Path] /backup:[Backup File Path]
●
● Description: Backs up the NTFS permissions of a specified file or folder to a
backup file.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /backup:C:\Backup\permissions.bak
●
○ This command backs up the NTFS permissions of the Documents folder to
permissions.bak in the C:\Backup directory.
Command:
cmd
xcacls [File/Folder Path] /restore:[Backup File Path]
●
● Description: Restores NTFS permissions to a file or folder from a previously
created backup file.
181
Copyright © PendemVamsi. All rights reserved.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /restore:C:\Backup\permissions.bak
●
○ This command restores the NTFS permissions of the Documents folder
from the permissions.bak backup file.
Command:
cmd
xcacls [File/Folder Path]
●
● Description: Displays the current NTFS permissions of a specified file or folder.
Example:
cmd
xcacls C:\Users\YourName\Documents\
●
○ This command displays the current NTFS permissions for the Documents
folder.
4. Grant Permissions
Command:
cmd
xcacls [File/Folder Path] /grant:[UserName]:[Permission]
●
● Description: Grants specific permissions to a user or group for a file or folder.
Example:
cmd
182
Copyright © PendemVamsi. All rights reserved.
xcacls C:\Users\YourName\Documents\ /grant:JohnDoe:F
●
○ This command grants full control (F) to the user JohnDoe for the
Documents folder.
5. Revoke Permissions
Command:
cmd
xcacls [File/Folder Path] /remove:[UserName]
●
● Description: Removes the specified user’s permissions from a file or folder.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /remove:JohnDoe
●
○ This command removes all permissions for the user JohnDoe from the
Documents folder.
Command:
cmd
xcacls [Folder Path] /grant:[UserName]:[Permission]
●
● Description: Grants specific permissions recursively to all files and subfolders
within a folder.
Example:
cmd
183
Copyright © PendemVamsi. All rights reserved.
xcacls C:\Users\YourName\Documents\ /grant:JohnDoe:F
●
○ This command grants full control (F) to JohnDoe for the Documents folder
and all its subdirectories and files.
Command:
cmd
xcacls [File/Folder Path] /inheritance:r
●
● Description: Removes inherited permissions from a file or folder. After this, only
explicit permissions will apply.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /inheritance:r
●
○ This command removes inherited permissions from the Documents folder.
Command:
cmd
xcacls [File/Folder Path] /replace:[Backup File Path]
●
● Description: Replaces the current NTFS permissions on a file or folder with the
permissions from a backup file.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /replace:C:\Backup\permissions.bak
184
Copyright © PendemVamsi. All rights reserved.
●
○ This command replaces the current permissions of the Documents folder
with those from permissions.bak.
Command:
cmd
xcacls [File/Folder Path] /grant:[GroupName]:[Permission]
●
● Description: Grants specific permissions to a group for a file or folder.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /grant:AdminGroup:F
●
○ This command grants full control (F) to the AdminGroup for the Documents
folder.
Command:
cmd
xcacls [Directory Path] /backup:[Backup File Path]
●
● Description: Backs up the NTFS permissions of all files and subdirectories within
a directory.
Example:
cmd
xcacls C:\Users\YourName\Documents\ /backup:C:\Backup\permissions.bak
●
185
Copyright © PendemVamsi. All rights reserved.
○ This command backs up the permissions for all files and subfolders within
the Documents directory to permissions.bak.
cmd
Description:
Associates a drive letter with a specified directory, making the directory appear as if it
were a separate drive. This is useful for creating virtual drives for easy access to
directories.
Example:
cmd
subst X: C:\Users\YourName\Documents
This command associates the X: drive with the Documents folder located at
C:\Users\YourName\Documents. Now, you can access that folder via the X: drive.
Command:
cmd
186
Copyright © PendemVamsi. All rights reserved.
Description:
Removes the virtual drive associated with the specified drive letter.
Example:
cmd
subst X: /d
This command removes the virtual drive X:, disassociating it from the folder it was
pointing to.
The cipher command is a tool used in Windows to manage the encryption of files and
directories. It can encrypt and decrypt files, view the encryption status, securely erase
data, and create backups of encryption certificates and keys.
2. Syntax
187
Copyright © PendemVamsi. All rights reserved.
● [options]: Various command options that specify what actions you want to
perform.
● [drive:][path]: Path to the file, directory, or drive where encryption is applied.
a. /E
Example:
cipher /E C:\Users\YourName\Documents\file.txt
●
b. /D
Example:
cipher /D C:\Users\YourName\Documents\file.txt
●
c. /S:<directory>
Example:
cipher /E /S:C:\Users\YourName\Documents
●
d. /F
188
Copyright © PendemVamsi. All rights reserved.
Example:
cipher /E /F C:\Users\YourName\Documents
●
e. /R:<filename>
Example:
cipher /R:RecoveryAgent
●
f. /X
Example:
cipher /X C:\Backup
●
g. /U
● Description: Updates the encryption on all files and directories in the specified
directory.
● Use Case: Ensure that all files in a directory are properly encrypted.
Example:
189
Copyright © PendemVamsi. All rights reserved.
cipher /U C:\Users\YourName\Documents
●
h. /W:<folder>
Example:
cipher /W:C:\Users\YourName\Documents
●
i. /Q
Example:
cipher /E /Q C:\Users\YourName\Documents\file.txt
●
j. /A
Example:
cipher /A C:\Users\YourName\Documents
●
190
Copyright © PendemVamsi. All rights reserved.
a. Encrypt a File
To encrypt a specific file, use the /E option followed by the file path.
Example:
cipher /E C:\Users\YourName\Documents\file.txt
●
○ Explanation: This encrypts the file file.txt in the specified path.
b. Decrypt a File
To decrypt a previously encrypted file, use the /D option followed by the file path.
Example:
cipher /D C:\Users\YourName\Documents\file.txt
●
○ Explanation: This decrypts the file file.txt.
To encrypt a directory and all of its subdirectories, use the /E option with /S.
Example:
cipher /E /S:C:\Users\YourName\Documents
●
○ Explanation: Encrypts all files and subdirectories under Documents.
If you want to re-encrypt a file that is already encrypted, you can use the /F option.
Example:
191
Copyright © PendemVamsi. All rights reserved.
cipher /E /F C:\Users\YourName\Documents\file.txt
●
○ Explanation: Forces the encryption of file.txt, even if it’s already
encrypted.
Example:
cipher /X C:\Backup
●
○ Explanation: Backs up the encryption certificate and key to the specified
folder.
To securely erase deleted files and make them unrecoverable, use the /W option.
Example:
cipher /W:C:\Users\YourName\Documents
●
○ Explanation: Overwrites the unused disk space in Documents to prevent
file recovery.
192
Copyright © PendemVamsi. All rights reserved.
The openfiles command allows users to display information about open shared files,
as well as disconnect users who have files open on the system. It can be used to
troubleshoot file access issues or disconnect unwanted users from shared resources.
2. Syntax
a. /query
● Description: Displays a list of open shared files and folders, including the file ID,
user, and access information.
● Use Case: View which files are currently open on the system and by which users.
Example:
openfiles /query
●
b. /disconnect
Example:
193
Copyright © PendemVamsi. All rights reserved.
openfiles /disconnect /id 100
●
● Description: Displays the open files in a specific format, such as table, list, or
CSV.
● Use Case: Customizes the output format for better readability or data processing.
Example:
openfiles /query /fo table
●
d. /query /v
● Description: Displays additional details, such as the path and type of access (read
or write).
● Use Case: View detailed information about the open files.
Example:
openfiles /query /v
●
Example:
openfiles /disconnect /id 125
●
f. /help
194
Copyright © PendemVamsi. All rights reserved.
Example:
openfiles /help
●
2. Syntax
● [option]: Specifies the action you want to perform (e.g., display information,
release/renew IP, etc.).
● [parameters]: Additional arguments that refine the command (e.g., specific
network adapter details).
a. /all
195
Copyright © PendemVamsi. All rights reserved.
Example:
ipconfig /all
●
b. /release
Example:
ipconfig /release
●
c. /renew
Example:
ipconfig /renew
●
d. /flushdns
● Description: Clears the DNS resolver cache. This can resolve issues where
outdated or incorrect DNS entries are causing network problems.
196
Copyright © PendemVamsi. All rights reserved.
● Use Case: Clears the DNS cache to ensure the system uses updated DNS
information.
Example:
ipconfig /flushdns
●
e. /registerdns
● Description: Refreshes the DHCP lease and registers the computer’s name with
DNS.
● Use Case: Used when needing to update DNS records on the network.
Example:
ipconfig /registerdns
●
f. /showclassid
Example:
ipconfig /showclassid "Ethernet"
●
g. /setclassid
Example:
ipconfig /setclassid "Ethernet" 1
●
197
Copyright © PendemVamsi. All rights reserved.
h. /displaydns
Example:
ipconfig /displaydns
Example:
ping google.com
●
b. Continuous Ping
Example:
ping -t google.com
●
Example:
198
Copyright © PendemVamsi. All rights reserved.
ping -n 5 google.com
●
Example:
ping -l 1500 google.com
●
Example:
ping -6 google.com
●
● Description: Resolves and shows the hostname for the given IP address.
Example:
ping -a 8.8.8.8
●
199
Copyright © PendemVamsi. All rights reserved.
The tracert command traces the route that data packets follow from the source
computer to a destination host, showing each router (hop) along the way and measuring
the round-trip time for each hop. This information can be valuable for diagnosing
network issues, such as delays or packet loss.
General Syntax
Example:
tracert -d google.com
200
Copyright © PendemVamsi. All rights reserved.
●
Example:
tracert -h 15 google.com
●
● Description: Sets the timeout value (in milliseconds) for each hop before it is
considered a failure.
Example:
tracert -w 1000 google.com
●
d. -4 - Force IPv4
● Description: Forces the trace route to use IPv4, even if the destination host
supports IPv6.
Example:
tracert -4 google.com
●
e. -6 - Force IPv6
● Description: Forces the trace route to use IPv6, even if the destination host
supports IPv4.
Example:
201
Copyright © PendemVamsi. All rights reserved.
tracert -6 google.com
●
The netstat command provides information about network connections (both incoming
and outgoing), listening ports, and other network statistics. It can be used to display a
variety of network-related details, such as open ports, current connections, and their
associated IP addresses.
General Syntax
netstat [options]
202
Copyright © PendemVamsi. All rights reserved.
Example:
netstat -a
●
Example:
netstat -n
●
Example:
netstat -o
●
● Description: Filters the output to show connections for a specific protocol (e.g.,
TCP or UDP).
Example:
netstat -p tcp
●
203
Copyright © PendemVamsi. All rights reserved.
● Description: Displays the routing table of the system, showing the paths network
traffic takes.
Example:
netstat -r
●
● Description: Shows detailed statistics for each network protocol (TCP, UDP, ICMP,
etc.).
Example:
netstat -s
●
Example:
netstat -e
●
Example:
netstat -b
204
Copyright © PendemVamsi. All rights reserved.
The nslookup (Name Server Lookup) command is used to query Domain Name System
(DNS) to obtain information about domain names and IP addresses. It allows you to look
up domain names to find corresponding IP addresses, and vice versa, and is a helpful
tool for troubleshooting DNS-related issues.
General Syntax
205
Copyright © PendemVamsi. All rights reserved.
Example:
nslookup
● This starts the interactive mode where you can enter domain names to query.
● Description: Allows you to specify the type of DNS record you wish to look up
(e.g., A, MX, CNAME).
Example:
nslookup -type=mx example.com
● Description: Specifies the timeout duration in seconds for the DNS query. By
default, nslookup waits for 5 seconds before it times out.
Example:
nslookup -timeout=10 example.com
Example:
nslookup -debug example.com
●
206
Copyright © PendemVamsi. All rights reserved.
● Description: Allows you to specify the port number to use for querying the DNS
server. By default, DNS queries are sent over port 53.
Example:
nslookup -port=5353 example.com
Basic Syntax
hostname
207
Copyright © PendemVamsi. All rights reserved.
hostname -f
hostname -s
hostname -d
hostname -i
208
Copyright © PendemVamsi. All rights reserved.
hostname -y
hostname -I
The arp (Address Resolution Protocol) command is used to view and manipulate the
ARP table on a system. It is primarily used to map IP addresses to MAC (Media Access
Control) addresses.
Basic Syntax
209
Copyright © PendemVamsi. All rights reserved.
Usage
arp -a
● Lists all current ARP entries, showing IP addresses and their corresponding MAC
addresses.
210
Copyright © PendemVamsi. All rights reserved.
arp <hostname>
Options
Option Description
-s <IP> Add a new static ARP entry for the given IP and MAC
<MAC> addresses.
Practical Examples
1. View All ARP Entries
arp -a
211
Copyright © PendemVamsi. All rights reserved.
arp 192.168.1.1
212
Copyright © PendemVamsi. All rights reserved.
ip neigh show
● Modern systems use the ip command for viewing the ARP table.
cmd
arp -a
cmd
arp -d <IP_ADDRESS>
213
Copyright © PendemVamsi. All rights reserved.
Basic Syntax
route
route -n
Syntax:
214
Copyright © PendemVamsi. All rights reserved.
Syntax:
● Adds a static route to the host 10.0.0.5 via the gateway 192.168.1.1.
Syntax:
215
Copyright © PendemVamsi. All rights reserved.
216
Copyright © PendemVamsi. All rights reserved.
telnet 192.168.1.1
telnet example.com 80
telnet example.com 80
GET / HTTP/1.1
Host: example.com
telnet -d 192.168.1.1
217
Copyright © PendemVamsi. All rights reserved.
telnet -e ^C 192.168.1.1
telnet mail.example.com 25
The ftp command is used to transfer files between a local and a remote system over the
File Transfer Protocol. It provides an interactive text interface to manage file uploads,
downloads, and directory navigation on the remote server.
Basic Syntax
218
Copyright © PendemVamsi. All rights reserved.
Usage
1. Connect to an FTP Server
ftp <hostname_or_IP>
● Once connected, provide the required username and password when prompted.
Use commands like put to upload files or get to download files during the session.
Options
Optio Description
n
219
Copyright © PendemVamsi. All rights reserved.
Comman Description
d
220
Copyright © PendemVamsi. All rights reserved.
Practical Examples
1. Connect to an FTP Server
ftp ftp.example.com
221
Copyright © PendemVamsi. All rights reserved.
ftp -n ftp.example.com
3. Download a File
● Downloads the file example.txt from the remote server to the local system.
4. Upload a File
● Uploads the file localfile.txt from the local machine to the remote server.
222
Copyright © PendemVamsi. All rights reserved.
ftp> binary
ftp> cd /patho/directory
223
Copyright © PendemVamsi. All rights reserved.
1. net accounts
Description
Syntax
Example
● Sets the minimum password length to 8 characters and the maximum password
age to 30 days.
2. net computer
Description
Syntax
224
Copyright © PendemVamsi. All rights reserved.
Example
3. net config
Description
Syntax
Example
225
Copyright © PendemVamsi. All rights reserved.
4. net continue
Description
Syntax
Example
5. net file
Description
Syntax
Example
226
Copyright © PendemVamsi. All rights reserved.
net file
6. net group
Description
Syntax
Example
7. net help
227
Copyright © PendemVamsi. All rights reserved.
Description
Syntax
Example
8. net localgroup
Description
Syntax
Example
228
Copyright © PendemVamsi. All rights reserved.
9. net name
Description
Syntax
Example
Description
Pauses a service.
229
Copyright © PendemVamsi. All rights reserved.
Syntax
Example
Description
Syntax
Example
230
Copyright © PendemVamsi. All rights reserved.
Description
Syntax
Example
Description
Syntax
231
Copyright © PendemVamsi. All rights reserved.
Example
net session
Description
Syntax
Example
232
Copyright © PendemVamsi. All rights reserved.
Description
Starts a service.
Syntax
Example
Description
Syntax
233
Copyright © PendemVamsi. All rights reserved.
Example
Description
Stops a service.
Syntax
Example
234
Copyright © PendemVamsi. All rights reserved.
Description
Syntax
Example
Description
Syntax
Example
235
Copyright © PendemVamsi. All rights reserved.
Description
Syntax
Example
236
Copyright © PendemVamsi. All rights reserved.
Description
Syntax
Example
net view
1. General Commands
237
Copyright © PendemVamsi. All rights reserved.
netsh
netsh -c <context>
netsh reset
Examples
●
●
●
2. Interface Context
Description
238
Copyright © PendemVamsi. All rights reserved.
Syntax
Examples
●
●
●
Set IP to DHCP:
239
Copyright © PendemVamsi. All rights reserved.
netsh interface ip set address name="Ethernet" source=dhcp
●
3. Firewall Context
Description
Syntax
Examples
●
●
240
Copyright © PendemVamsi. All rights reserved.
●
4. WLAN Context
Description
Syntax
Examples
●
241
Copyright © PendemVamsi. All rights reserved.
●
●
5. IPSec Context
Description
Syntax
Examples
●
242
Copyright © PendemVamsi. All rights reserved.
●
●
6. Routing Context
Description
Syntax
Examples
●
243
Copyright © PendemVamsi. All rights reserved.
netsh routing ip add persistentroute destination=192.168.2.0
mask=255.255.255.0 gateway=192.168.1.1 metric=1
●
●
7. Diagnostics Context
Description
Syntax
Examples
●
244
Copyright © PendemVamsi. All rights reserved.
netsh diag ping ipaddress=8.8.8.8
●
nbtstat is a Windows command-line utility used to display and troubleshoot NetBIOS over
TCP/IP (NetBT) statistics and connections. It provides information about NetBIOS names,
sessions, and caches.
1. General Syntax
nbtstat [options]
Where [options] are specific flags or parameters used to perform tasks like listing the
name table, cache, or active sessions.
Command Description
nbtstat -A Displays the NetBIOS name table of a remote machine using its
<IP> IP address.
245
Copyright © PendemVamsi. All rights reserved.
nbtstat -c Displays the contents of the NetBIOS name cache, which maps
NetBIOS names to IP addresses.
nbtstat -n Lists local NetBIOS names that have been registered on the
machine.
nbtstat -s Displays NetBIOS sessions and their statuses for the client.
nbtstat -S Displays the current NetBIOS sessions and their status with IP
addresses.
nbtstat -RR Sends a name release request to WINS servers and re-registers
the names.
3. Examples
Command:
nbtstat -a <hostname>
Example:
246
Copyright © PendemVamsi. All rights reserved.
nbtstat -a RemotePC
Description:
Displays the NetBIOS name table for the machine RemotePC.
Command:
nbtstat -A <IP>
Example:
nbtstat -A 192.168.1.10
Description:
Shows the NetBIOS name table for the machine at IP address 192.168.1.10.
Command:
nbtstat -c
247
Copyright © PendemVamsi. All rights reserved.
Example:
nbtstat -c
Description:
Lists all entries in the local NetBIOS name cache.
Command:
nbtstat -n
Example:
nbtstat -n
Description:
Displays local NetBIOS names registered by the machine.
Command:
248
Copyright © PendemVamsi. All rights reserved.
nbtstat -r
Example:
nbtstat -r
Description:
Shows the count of NetBIOS names resolved by broadcast or via WINS.
Command:
nbtstat -R
Example:
nbtstat -R
Description:
Clears the NetBIOS name cache and reloads it.
249
Copyright © PendemVamsi. All rights reserved.
Command:
nbtstat -s
Example:
nbtstat -s
Description:
Shows all active NetBIOS sessions with hostnames.
Command:
nbtstat -S
Example:
nbtstat -S
250
Copyright © PendemVamsi. All rights reserved.
Description:
Lists all active NetBIOS sessions and displays their IP addresses.
Command:
nbtstat -RR
Example:
nbtstat -RR
Description:
Sends a name release request to WINS servers and re-registers all NetBIOS names
1. General Syntax
systeminfo [options]
251
Copyright © PendemVamsi. All rights reserved.
Where [options] are flags or parameters used to modify or customize the output.
Command/Optio Description
n
/u <username> Runs the command with the specified username (for remote
machines).
/p <password> Specifies the password for the username (for remote machines).
/fi <filter> Filters the output based on specified criteria (e.g., OS, memory).
/nh No header, used with /fo to exclude column headers in the output.
3. Examples
Command:
252
Copyright © PendemVamsi. All rights reserved.
systeminfo
Example:
systeminfo
Description:
Displays detailed information about the local computer system, including OS version,
manufacturer, memory, and more.
Command:
systeminfo /s <hostname>
Example:
systeminfo /s 192.168.1.10
253
Copyright © PendemVamsi. All rights reserved.
Description:
Fetches and displays system information for the remote machine with the IP address
192.168.1.10.
Command:
Example:
Description:
Fetches system information for a remote computer and runs the command using the
provided username and password.
Command:
Example:
254
Copyright © PendemVamsi. All rights reserved.
Description:
Filters and displays only the information related to the operating system. Other filters can
be used, like "Memory" or "Host Name."
Command:
Example:
Description:
Displays the output in a list format. Other available formats include TABLE and CSV.
Command:
255
Copyright © PendemVamsi. All rights reserved.
Example:
Description:
Displays the output in CSV format but without the header row.
Command:
systeminfo /?
Example:
systeminfo /?
Description:
Displays help information about the systeminfo command and its options.
256
Copyright © PendemVamsi. All rights reserved.
1. General Syntax
tasklist [options]
Where [options] are flags or parameters used to modify or filter the output of the
command.
Command/Optio Description
n
/u <username> Runs the command using the specified username (for remote
machines).
/p <password> Specifies the password for the username (for remote machines).
/m <module> Lists all tasks that are using a specific module or DLL.
257
Copyright © PendemVamsi. All rights reserved.
/fi <filter> Filters the output based on specified criteria (e.g., process name,
PID).
/nh Excludes the column headers in the output (used with /fo).
3. Examples
Command:
tasklist
Example:
tasklist
258
Copyright © PendemVamsi. All rights reserved.
Description:
Displays a list of all currently running processes on the local computer.
Command:
tasklist /s <hostname>
Example:
tasklist /s 192.168.1.10
Description:
Displays a list of running processes on a remote machine at IP address 192.168.1.10.
Command:
Example:
259
Copyright © PendemVamsi. All rights reserved.
Description:
Displays all running processes on the local computer or a remote machine while using
the provided username and password.
Command:
tasklist /m <module>
Example:
tasklist /m kernel32.dll
Description:
Displays all tasks that are using the specified module (in this case, kernel32.dll).
Command:
260
Copyright © PendemVamsi. All rights reserved.
tasklist /v
Example:
tasklist /v
Description:
Displays detailed information about each running process, including memory usage and
additional process details.
Command:
Example:
Description:
Filters the process list to display only processes named chrome.exe.
261
Copyright © PendemVamsi. All rights reserved.
Command:
Example:
Description:
Displays information about the process with the specified Process ID (PID).
Command:
Example:
262
Copyright © PendemVamsi. All rights reserved.
Description:
Displays the output in a list format. Other available formats include TABLE and CSV.
Command:
Example:
Description:
Displays the output in CSV format, excluding the header row.
Command:
Example:
263
Copyright © PendemVamsi. All rights reserved.
Description:
Terminates the process notepad.exe and any associated child processes.
Command:
tasklist /?
Example:
tasklist /?
Description:
Displays help information about the tasklist command and its available options.
264
Copyright © PendemVamsi. All rights reserved.
Basic Syntax
Usage
1. Terminate a Process by Image Name
265
Copyright © PendemVamsi. All rights reserved.
Options
266
Copyright © PendemVamsi. All rights reserved.
Option Description
/fi <filter> Allows you to filter tasks based on specific criteria (e.g., status eq
running).
Practical Examples
1. Terminate a Process by Image Name
267
Copyright © PendemVamsi. All rights reserved.
268
Copyright © PendemVamsi. All rights reserved.
Filter Options
The /fi option allows you to specify various filters to narrow down the list of processes.
Some common filters include:
Filter Description
269
Copyright © PendemVamsi. All rights reserved.
1. General Syntax
270
Copyright © PendemVamsi. All rights reserved.
msconfig
When you launch msconfig, you will find several tabs to configure the system:
1. General Tab: Choose the type of startup you want (Normal, Diagnostic, or
Selective startup).
2. Boot Tab: Configure boot settings, including advanced options and Safe Mode.
3. Services Tab: Manage services that start with Windows (you can disable or enable
specific services).
4. Startup Tab: Manage programs that start automatically when Windows starts (in
Windows 7 and later, this is replaced by the Task Manager).
5. Tools Tab: Provides shortcuts to various system tools for advanced configuration.
The msconfig utility itself does not have specific command-line arguments, but it has
several configurable options once opened through the utility's interface.
Command/Optio Description
n
271
Copyright © PendemVamsi. All rights reserved.
/boot Opens the Boot tab for configuring boot options, like Safe Mode.
ools Opens the Tools tab for accessing various system tools.
4. Examples
Command:
msconfig
Example:
msconfig
Description:
This command opens the System Configuration Utility window in Normal startup mode,
where you can configure startup programs, services, and boot options.
272
Copyright © PendemVamsi. All rights reserved.
Command:
msconfig /selective
Example:
msconfig /selective
Description:
This opens the System Configuration Utility in Selective Startup mode, where you can
manually choose which services and startup programs to enable or disable.
Command:
msconfig /diagnostic
Example:
msconfig /diagnostic
273
Copyright © PendemVamsi. All rights reserved.
Description:
This opens the System Configuration Utility in Diagnostic Startup mode, which only
loads essential system services and drivers, making it useful for troubleshooting.
Command:
msconfig /boot
Example:
msconfig /boot
Description:
This opens the Boot tab where you can configure boot options like Safe Mode, boot
logging, and other advanced boot settings.
Command:
msconfig /services
Example:
274
Copyright © PendemVamsi. All rights reserved.
msconfig /services
Description:
This opens the Services tab where you can manage which services run at startup. You
can disable or enable specific services to troubleshoot or optimize system performance.
Command:
msconfig /startup
Example:
msconfig /startup
Description:
This opens the Startup tab (replaced by Task Manager in Windows 8 and later), where
you can manage startup programs and prevent unnecessary programs from running at
startup.
Command:
275
Copyright © PendemVamsi. All rights reserved.
msconfig ools
Example:
msconfig ools
Description:
This opens the Tools tab in msconfig, providing shortcuts to various system tools like
Event Viewer, System Restore, Command Prompt, etc.
Note: Modifying the registry can be risky. Always back up your registry before making
changes to prevent system instability.
regedit [options]
276
Copyright © PendemVamsi. All rights reserved.
The regedit command is primarily used for accessing, exporting, importing, and
modifying the Windows registry.
This is the most common usage of regedit to launch the Windows Registry Editor.
regedit
● Opens the GUI where you can browse and modify registry keys and values.
Example:
regedit /e "C:\Backup\myregistry.reg"
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft"
●
○ Exports the Microsoft registry key under HKEY_LOCAL_MACHINE to a file.
277
Copyright © PendemVamsi. All rights reserved.
Import a .reg file back into the registry. This is typically used for restoring settings or
applying registry tweaks:
regedit /s <filename>
Example:
regedit /s "C:\Backup\myregistry.reg"
●
○ Imports the myregistry.reg file silently without any prompts.
regedit /d <key_path>
278
Copyright © PendemVamsi. All rights reserved.
Example:
regedit /d "HKEY_CURRENT_USER\Software\MyApp"
●
○ Deletes the MyApp registry key under HKEY_CURRENT_USER.
Important Notes:
● Be cautious when deleting registry keys. Deleting critical keys can cause system
issues.
● Use regedit to perform manual clean-ups of orphaned registry entries.
5. Silent Export:
regedit /e <filename> /s
Example:
regedit /e "C:\Backup\system.reg" /s
●
○ Exports the registry silently to system.reg.
6. Silent Import:
279
Copyright © PendemVamsi. All rights reserved.
regedit /s <filename>
Example:
regedit /s "C:\Backup\system.reg"
●
○ Imports the registry settings from system.reg without user interaction.
7. Force Operation:
Use /f to force operations like export or import, even if the file already exists.
regedit /e "C:\Backup\myregistry.reg" /f
Example:
regedit /e "C:\Backup\myregistry.reg" /f
●
○ Forces the export even if the file myregistry.reg already exists.
regedit /s "HKEY_LOCAL_MACHINE\Software"
280
Copyright © PendemVamsi. All rights reserved.
Example:
regedit /s "HKEY_LOCAL_MACHINE\Software"
●
○ This command opens the Software registry key under
HKEY_LOCAL_MACHINE without launching the GUI.
You can open the Registry Editor with full administrative privileges using the following
steps:
regedit
● This ensures that the registry editor opens with full access to modify all registry
keys and values.
10. Access Registry via Command Prompt with Full Administrative Privileges:
You can also access the Registry Editor through Command Prompt with administrative
access:
281
Copyright © PendemVamsi. All rights reserved.
3.
○ This gives you full access to edit any registry key, as you are operating in
Administrator mode.
Syntax:
Syntax:
Options:
282
Copyright © PendemVamsi. All rights reserved.
Example:
Query the last 5 events from the System log in text format:
Syntax:
Options:
Example:
283
Copyright © PendemVamsi. All rights reserved.
Syntax:
wevtutil el
Example:
wevtutil el
Syntax:
wevtutil gl <LogName>
Options:
284
Copyright © PendemVamsi. All rights reserved.
Example:
wevtutil gl Security
Syntax:
wevtutil cl <LogName>
Options:
Example:
wevtutil cl System
285
Copyright © PendemVamsi. All rights reserved.
This subcommand is used to set properties on event logs, such as maximum size and
retention policy.
Syntax:
Options:
Example:
Syntax:
286
Copyright © PendemVamsi. All rights reserved.
Options:
Example:
This subcommand retrieves information about event log publishers, which are
responsible for writing events to the logs.
Syntax:
wevtutil gp <PublisherName>
Example:
wevtutil gp Microsoft-Windows-Security-Auditing
287
Copyright © PendemVamsi. All rights reserved.
wevtutil cl Security
wevtutil el
288
Copyright © PendemVamsi. All rights reserved.
Here's an overview of the actions available within services.msc, including both GUI actions
and command-line equivalents:
Or, search for services.msc in the Windows search bar and click on the result.
1. Start a Service
Command-Line Equivalent:
289
Copyright © PendemVamsi. All rights reserved.
Or using sc:
sc start <ServiceName>
2. Stop a Service
Command-Line Equivalent:
Or using sc:
sc stop <ServiceName>
3. Pause a Service
Command-Line Equivalent:
290
Copyright © PendemVamsi. All rights reserved.
Command-Line Equivalent:
5. Restart a Service
Command-Line Equivalent:
Or using sc:
291
Copyright © PendemVamsi. All rights reserved.
Service Configuration
6. Change Startup Type
You can change the Startup Type of a service to one of the following:
To change this:
● Right-click on the service, select Properties, and change the Startup type under the
General tab.
For example:
● auto (Automatic)
● manual
● disabled
292
Copyright © PendemVamsi. All rights reserved.
You can view the dependencies of a service (services that depend on this service, and services
that this service depends on):
● Right-click on the service and select Properties, then go to the Dependencies tab.
293