0% found this document useful (0 votes)
9 views293 pages

Windows Commands

Uploaded by

higip48535
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views293 pages

Windows Commands

Uploaded by

higip48535
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 293

Copyright © PendemVamsi. All rights reserved.

Introduction to Windows Commands(part-1)

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.

8.2. Append Output to an Existing File​ 27


9. Recursive Directory Listing​ 28
9.1. List Files and Folders in Subdirectories Recursively​ 28
9.2. List Files in All Subdirectories Including Hidden​ 28
10. List Files with Specific Time​ 28
10.1. List Files Modified After a Specific Date​ 28
10.2. List Files Based on Last Accessed Time​ 28
11. Pagination and Formatting​ 28
11.1. Show Directory Listing One Page at a Time​ 28
11.2. Display Results in Columns​ 28
12. Displaying File Ownership​ 28
12.1. List Files with Owner Information​ 28
12.2. List Files in Long Format with Ownership​ 28
13. Filtering Files by Size​ 29
13.1. Display Files Larger than a Specific Size​ 29
13.2. Display Files Smaller than a Specific Size​ 29
14. Displaying Time and Date​ 29
14.1. Display Directory Files and Folders with Date and Time​ 29
14.2. Display Directory Files Sorted by Date Modified​ 29
15. File Grouping and Counting​ 29
15.1. Display Directory Grouped by File Types​ 29
15.2. Count Total Number of Files in a Directory​ 29
16. Special File Listings​ 29
16.1. Display Only Executable Files​ 29
16.2. Display Only Directories​ 29
17. Displaying Long Listing with File Sizes​ 30
17.1. List Files with Detailed File Sizes​ 30
17.2. Display File Sizes in Bytes​ 30
18. Directory Size Calculation​ 30
18.1. List Files and Calculate Total Size​ 30
18.2. Calculate Size of Directory and Files​ 30
19. Listing Files with Permissions​ 30
19.1. List Files with Detailed Permissions​ 30
19.2. List Files in Directory with Group Permissions​ 30
20. Excluding Files from Listing​ 30
20.1. Exclude Files Matching Specific Pattern​ 30
20.2. Exclude Directories from Listing​ 31
2. cd - Change the current directory.​ 31
1.1 Change to a Specific Directory​ 31
1.2 Change to the Root Directory​ 31
2. Directory Navigation with Drive Letters​ 31

2
Copyright © PendemVamsi. All rights reserved.

2.1 Change to a Directory on Another Drive​ 31


2.2 Change to a Directory Using a Relative Path​ 31
3.1 Navigate Up One Directory Level​ 31
3.2 Navigate to the Previous Directory​ 32
4. Viewing Current Directory​ 32
4.1 Display the Current Directory Path​ 32
5. Error Handling and Special Cases​ 32
5.1 Attempt to Change to a Nonexistent Directory​ 32
5.2 Change Directory with Spaces in Path​ 32
6. Switching Between Drives​ 32
6.1 Switch to Another Drive​ 32
3. mkdir - Create a new directory.​ 33
1.1 Create a Single Directory​ 33
1.2 Create a Directory with a Path​ 33
2. Creating Multiple Directories​ 33
2.1 Create Multiple Directories at Once​ 33
2.2 Create Directories with Nested Structure​ 34
3. Directory Creation with Spaces in Names​ 34
3.1 Create a Directory with Spaces in the Name​ 34
3.2 Create Multiple Directories with Spaces​ 34
4. Error Handling and Special Cases​ 35
4.1 Attempt to Create an Existing Directory​ 35
4.2 Invalid Characters in Directory Name​ 35
5. Creating Parent Directories (with /p Option)​ 35
5.1 Create Parent Directories if They Do Not Exist​ 35
6. Viewing Created Directories​ 36
6.1 List Created Directories​ 36
7. Creating Hidden Directories​ 36
7.1 Create a Hidden Directory​ 36
4. rmdir - Remove a directory.​ 37
1.1 Remove an Empty Directory​ 37
1.2 Remove a Directory with a Full Path​ 37
2. Removing Non-Empty Directories​ 37
2.1 Remove a Directory and Its Contents (with /s option)​ 37
2.2 Remove a Directory and Its Contents with a Full Path (with /s option)​ 38
3. Forcing Removal​ 38
3.1 Force Removal without Confirmation (with /q option)​ 38
3.2 Force Removal with Full Path​ 38
4. Error Handling and Special Cases​ 39
4.1 Attempt to Remove a Non-Empty Directory Without /s Option​ 39
4.2 Attempt to Remove a Directory That Doesn't Exist​ 39

3
Copyright © PendemVamsi. All rights reserved.

5. Viewing Directory After Removal​ 39


5.1 List Remaining Directories​ 39
6. Removing Hidden Directories​ 40
6.1 Remove a Hidden Directory​ 40
5. copy - Copy files or directories.​ 40
1.1 Copy a File to Another Location​ 40
1.2 Copy a File with a New Name​ 40
2. Copy Multiple Files​ 41
2.1 Copy All Files from a Directory​ 41
2.2 Copy Files with a Specific Extension​ 41
3. Overwriting Files​ 42
3.1 Overwrite Existing Files without Confirmation​ 42
3.2 Prompt Before Overwriting​ 42
4. Copying Files with Hidden or System Attributes​ 42
4.1 Copy Hidden Files​ 42
4.2 Copy System Files​ 43
5. Copy Files Across Different Drives​ 43
5.1 Copy a File Between Different Drives​ 43
6. Using Wildcards​ 43
6.1 Copy Files Using Wildcards​ 43
6. move - Move files or directories​ 44
1.1 Move a File to Another Location​ 44
1.2 Move a File with a New Name​ 44
2. Moving Directories​ 44
2.1 Move a Directory to Another Location​ 44
2.2 Move a Directory to a New Location with a New Name​ 45
3. Overwriting Existing Files​ 45
3.1 Move and Overwrite Files Without Confirmation​ 45
3.2 Prompt Before Overwriting Files​ 45
4. Using Wildcards​ 46
4.1 Move Files Using Wildcards​ 46
5. Moving Files Across Different Drives​ 46
5.1 Move a File Between Different Drives​ 46
6. Moving Files with Hidden or System Attributes​ 47
6.1 Move Hidden Files​ 47
6.2 Move System Files​ 47
7. del - Delete files.​ 47
2.1 Delete Multiple Files with Wildcards​ 47
2.2 Delete All Files in a Folder​ 48
3. Deleting Files with Confirmation​ 48
3.1 Prompt Before Deleting Files​ 48

4
Copyright © PendemVamsi. All rights reserved.

4. Deleting Read-Only Files​ 48


4.1 Force Deletion of Read-Only Files​ 48
5. Deleting Files Without Confirmation​ 49
5.1 Delete Files Without Asking for Confirmation​ 49
5.2 Delete All Files in a Folder Without Confirmation​ 49
6. Deleting Hidden or System Files​ 49
6.1 Delete Hidden Files​ 49
6.2 Delete System Files​ 50
7. Deleting Files in Subdirectories​ 50
7.1 Delete Files in All Subdirectories​ 50
7.2 Delete Files in Subdirectories Without Asking for Confirmation​ 50
8. Deleting Files with Specific Extensions​ 51
8.1 Delete All Files with a Specific Extension​ 51
9. Using del with Batch Files​ 51
9.1 Delete Files Using a Batch File​ 51
8. ren - Rename files or directories​ 51
1.1 Rename a Single File​ 51
2. Rename Files with Wildcards​ 52
2.1 Rename Multiple Files with a Pattern​ 52
2.2 Rename Files with Wildcards (Specific Part of Filename)​ 52
3. Rename Directory or Folder​ 52
3.1 Rename a Directory​ 52
4. Handling Spaces in Filenames​ 53
4.1 Rename a File or Folder with Spaces in Its Name​ 53
5. Batch Rename Files Using a Batch File​ 53
5.1 Rename Multiple Files in a Folder​ 53
6. Rename Multiple Files with Different Extensions​ 54
6.1 Rename All Files with a Specific Extension​ 54
7. Rename Files by Removing Specific Characters​ 54
7.1 Remove Specific Part of Filename​ 54
9. type Command: Display the Contents of a Text File​ 54
9.1 Display the Entire Contents of a Text File​ 54
9.2 Combine and Display Multiple Files​ 55
9.3 Redirect Output to Another File​ 55
9.4 Append Contents to an Existing File​ 56
10. find - Search for a specific string in a file.​ 56
1. Search for a Specific String in a File​ 56
2. Search for a String in All Files of a Folder​ 57
3. Search for a String with Case Sensitivity​ 57
4. Search for a String in All Files (Recursive Search)​ 58
5. Display Only Matching Filenames​ 58

5
Copyright © PendemVamsi. All rights reserved.

6. Search for Multiple Strings​ 58


7. Search for Exact Matches​ 59
8. Search for String in Compressed Files​ 59
9. Show Only Files with Match in Their Name​ 60
10. Search in All Files Inside a Folder (Recursive)​ 60
11. Find Files Based on Modified Date​ 61
12. Display Lines Matching a Specific String​ 61
13. Search for Specific Keywords​ 61
14. Search for a Specific String in Specific Files​ 62
15. Show Lines Matching Specific Pattern​ 62
16. Display Files with Larger Content​ 63
17. Search for Specific Line Length​ 63
18. Find Occurrences Using Word Boundaries​ 64
19. Limit Search Output to First Few Lines​ 64
20. Search for Specific File Extension​ 64
21. Display Lines Containing Any of Multiple Strings​ 65
22. Search for Files with No Matches​ 65
11. attrib - Change file attributes.​ 66
1. Change File Attributes​ 66
2. Set the Read-Only Attribute​ 66
3. Remove the Read-Only Attribute​ 67
4. Set the Hidden Attribute​ 67
5. Remove the Hidden Attribute​ 67
6. Set the System Attribute​ 68
7. Remove the System Attribute​ 68
8. Set the Archive Attribute​ 69
9. Remove the Archive Attribute​ 69
10. Set All Attributes (Read-Only, Hidden, System, Archive)​ 70
11. Remove All Attributes (Read-Only, Hidden, System, Archive)​ 70
12. View File Attributes​ 70
12. tree - Display directory structure as a tree.​ 71
1. Basic Command Usage​ 71
2. Display the Directory Structure with File Names​ 71
3. Display the Directory Structure in Color​ 72
4. Display Only the Directory Structure (No Files)​ 72
5. Display the Directory Structure in a Specific Format (ASCII vs. Extended Characters)​
73
6. Display the Directory Structure for All Subdirectories​ 73
7. Limit the Depth of the Directory Tree​ 74
8. Redirect Output to a File​ 74
9. Display the Directory Structure for a Remote Server (using a network drive)​ 75

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.

10. Display Differences Using a Different Character for Line Separation​ 94


16. comp - Compare the contents of two files.​ 94
1. Basic Command Usage​ 94
2. Compare Files and Display Only Differences​ 95
3. Display Detailed Information About Differences​ 95
4. Compare Files and Report the First Difference Only​ 96
5. Compare Files and Display Only the Number of Differences​ 96
6. Compare Files and Ignore Case Differences​ 97
7. Compare Files and Display Hexadecimal Values​ 97
8. Compare Multiple Files in a Directory​ 98
9. Display No Output If Files Are Identical​ 98
17. robocopy - Robust file and directory copying tool.​ 99
2. Rename Files with Wildcards​ 99
2.1 Rename Multiple Files with a Pattern​ 99
2.2 Rename Files with Wildcards (Specific Part of Filename)​ 99
3. Rename Directory or Folder​ 99
3.1 Rename a Directory​ 100
4. Handling Spaces in Filenames​ 100
4.1 Rename a File or Folder with Spaces in Its Name​ 100
5. Batch Rename Files Using a Batch File​ 100
5.1 Rename Multiple Files in a Folder​ 100
6. Rename Multiple Files with Different Extensions​ 101
6.1 Rename All Files with a Specific Extension​ 101
7. Rename Files by Removing Specific Characters​ 101
7.1 Remove Specific Part of Filename​ 101
10. find - Search for a specific string in a file.​ 101
1. Search for a Specific String in a File​ 102
2. Search for a String in All Files of a Folder​ 102
3. Search for a String with Case Sensitivity​ 102
4. Search for a String in All Files (Recursive Search)​ 103
5. Display Only Matching Filenames​ 103
6. Search for Multiple Strings​ 104
7. Search for Exact Matches​ 104
8. Search for String in Compressed Files​ 104
9. Show Only Files with Match in Their Name​ 105
10. Search in All Files Inside a Folder (Recursive)​ 105
11. Find Files Based on Modified Date​ 106
12. Display Lines Matching a Specific String​ 106
13. Search for Specific Keywords​ 107
14. Search for a Specific String in Specific Files​ 107
15. Show Lines Matching Specific Pattern​ 107

8
Copyright © PendemVamsi. All rights reserved.

16. Display Files with Larger Content​ 108


17. Search for Specific Line Length​ 108
18. Find Occurrences Using Word Boundaries​ 109
19. Limit Search Output to First Few Lines​ 109
20. Search for Specific File Extension​ 110
21. Display Lines Containing Any of Multiple Strings​ 110
22. Search for Files with No Matches​ 110
11. attrib - Change file attributes.​ 111
1. Change File Attributes​ 111
2. Set the Read-Only Attribute​ 111
3. Remove the Read-Only Attribute​ 112
4. Set the Hidden Attribute​ 112
5. Remove the Hidden Attribute​ 113
6. Set the System Attribute​ 113
7. Remove the System Attribute​ 113
8. Set the Archive Attribute​ 114
9. Remove the Archive Attribute​ 114
10. Set All Attributes (Read-Only, Hidden, System, Archive)​ 115
11. Remove All Attributes (Read-Only, Hidden, System, Archive)​ 115
12. View File Attributes​ 116
12. tree - Display directory structure as a tree.​ 116
1. Basic Command Usage​ 116
2. Display the Directory Structure with File Names​ 117
3. Display the Directory Structure in Color​ 117
4. Display Only the Directory Structure (No Files)​ 118
5. Display the Directory Structure in a Specific Format (ASCII vs. Extended Characters)​
118
6. Display the Directory Structure for All Subdirectories​ 119
7. Limit the Depth of the Directory Tree​ 119
8. Redirect Output to a File​ 120
9. Display the Directory Structure for a Remote Server (using a network drive)​ 120
10. View the Directory Tree with Directories Only (No Files)​ 121
13. xcopy - Extended copy command with more options.​ 121
1. Basic Command Usage​ 121
2. Copy Files and Subdirectories​ 122
3. Copy Files, Including Empty Subdirectories​ 122
4. Copy Hidden and System Files​ 122
5. Copy Only Files That Are Newer​ 123
6. Prompt Before Overwriting​ 123
7. Copy Files and Preserve File Attributes​ 124
8. Copy Files Over a Network (Using UNC Path)​ 124

9
Copyright © PendemVamsi. All rights reserved.

9. Display Progress of File Copying​ 125


10. Exclude Files Based on Criteria​ 125
11. Display a Brief Summary​ 126
12. Copy a Directory and All Files, with Detailed Output​ 126
13. Copy Files with File Attributes and Ignore Errors​ 127
14. Copy Files with Dateime Criteria​ 127
15. Copy Files Based on File Size​ 128
16. Copy Files Overwriting All Files in the Destination​ 128
14. chkdsk - Check and repair disk errors.​ 129
1. Basic Command Usage​ 129
2. Check and Repair Disk Errors​ 129
3. Check for Bad Sectors and Repair Them​ 130
4. Display Detailed Information About the Disk Check​ 130
5. Check for Disk Errors Without Making Changes​ 131
6. Check for Errors and Log Results to a File​ 131
7. Schedule a Disk Check on Next System Restart​ 132
8. Check for File System Integrity​ 132
9. Check for Errors on External or Unmounted Drives​ 133
10. Display the Status of the Last Disk Check​ 133
11. Check for Errors on Remote Disk (Network Drive)​ 134
12. Check for Specific File System Integrity Issues​ 134
15. fc - Compare two files or sets of files.​ 135
1. Basic Command Usage​ 135
2. Compare Files in ASCII Mode​ 135
3. Compare Files in Binary Mode​ 136
4. Display Differences with Line Numbers​ 136
5. Ignore Whitespace Differences​ 137
6. Compare Multiple Files in a Directory​ 137
7. Ignore Case Differences​ 137
8. Display Only the Differences (No Summary)​ 138
9. Compare Files and Display a Summary of Differences​ 138
10. Display Differences Using a Different Character for Line Separation​ 139
16. comp - Compare the contents of two files.​ 139
1. Basic Command Usage​ 139
2. Compare Files and Display Only Differences​ 140
3. Display Detailed Information About Differences​ 140
4. Compare Files and Report the First Difference Only​ 141
5. Compare Files and Display Only the Number of Differences​ 141
6. Compare Files and Ignore Case Differences​ 142
7. Compare Files and Display Hexadecimal Values​ 142
8. Compare Multiple Files in a Directory​ 143

10
Copyright © PendemVamsi. All rights reserved.

9. Display No Output If Files Are Identical​ 143


17. robocopy - Robust file and directory copying tool.​ 144
1. Basic Command Usage​ 144
2. Copy Files and Subdirectories​ 144
3. Copy Only Newer Files​ 145
4. Retry on Failure​ 145
5. Skip Existing Files​ 146
6. Copy Files with Permissions​ 146
7. Mirror Directories​ 147
8. Limit the Bandwidth Used During Copying​ 147
9. Exclude Specific Files​ 148
10. Exclude Specific Directories​ 148
11. Perform a Dry Run​ 149
12. Copy Files with Logging​ 149
13. Use Robocopy for Network Copying​ 150
14. Copy Empty Directories Only​ 150
18. sfc - System File Checker to repair corrupted system files.​ 151
1. Basic Command Usage​ 151
2. Check System Files Without Repairing​ 151
3. Scan a Specific File​ 152
4. Set the Log File Location​ 152
5. Check and Repair System Files Without a Restart​ 153
6. View Detailed Logs of the Scan​ 153
7. Troubleshoot Problems Using the Windows Recovery Environment​ 154
8. Repair System Files Using DISM​ 154
9. Repair Missing or Corrupt Files Using sfc After DISM​ 155
10. Repair Windows Modules with SFC​ 155
19. findstr - Search for specific strings in files.​ 156
1. Basic Command Usage​ 156
2. Search Multiple Strings​ 156
3. Search Using Regular Expressions​ 157
4. Display Line Numbers of Matches​ 157
5. Search for Whole Words Only​ 158
6. Case-Insensitive Search​ 158
7. Exclude Certain Strings (Invert Match)​ 159
8. Search for Strings in Multiple Files​ 159
9. Search for Strings Across All Files in a Directory​ 160
10. Match Full Lines Only​ 160
11. Search for Multiple Strings in Multiple Files​ 161
12. Display Only Matching Strings​ 161
20. more - Display the contents of a text file one page at a time.​ 162

11
Copyright © PendemVamsi. All rights reserved.

1. Basic Command Usage​ 162


2. Display the Content of Multiple Files​ 162
3. Navigate Through the File​ 163
4. View Long Files Line-by-Line​ 163
5. Display File Content with Line Numbers​ 163
6. View the Contents of a File Without Pausing​ 164
7. Skip to the End of the File​ 164
8. Pause After Each Screenful​ 165
9. Search for Text While Viewing​ 165
10. Customize the Paging Behavior​ 166
21. sort - Sort the contents of a text file.​ 166
1. Basic Command Usage​ 166
2. Sort in Reverse Order (Descending)​ 167
3. Sort Without Removing Duplicate Lines​ 167
4. Sort Output by Column​ 168
5. Sort the Contents of Standard Input (Piped Input)​ 168
6. Redirect Sorted Output to a New File​ 169
7. Sort by Specific Fields in the File (Delimited Data)​ 169
8. Sort with Case Insensitivity​ 170
9. View Sorted Output in Real-Time Using Piping​ 170
10. View Sorted Content with Line Numbers​ 171
22. xcopy /e - Copy directories and subdirectories, including empty ones.​ 171
1. Basic Command Usage​ 171
2. Copy Directories and Subdirectories, Suppressing Confirmation​ 172
3. Copy Directories and Subdirectories with File Attributes​ 172
4. Copy Specific File Types with Subdirectories​ 173
5. Exclude Certain Files During Copying​ 173
6. Copy Files and Directories with Verification​ 174
7. Copy Files and Directories, Including Hidden Files​ 174
8. Copy Multiple Source Directories to One Destination​ 175
23. compact - Compress or decompress files on an NTFS partition.​ 175
1. Compress Files​ 176
2. Decompress Files​ 176
3. Display Compression Status​ 176
4. Compress All Files in a Directory and Subdirectories​ 177
5. Decompress All Files in a Directory and Subdirectories​ 177
6. Show All Files with Compression Status in a Directory​ 178
7. Compress Only Files That Are Not Already Compressed​ 178
8. Display Compression Information for a File​ 179
9. Compress Files with Specific File Extensions​ 179
10. Show the File Compression Ratio​ 180

12
Copyright © PendemVamsi. All rights reserved.

24. xcaccls - Backup and restore NTFS permissions.​ 180


1. Backup NTFS Permissions​ 180
2. Restore NTFS Permissions from a Backup​ 181
3. Display Current NTFS Permissions​ 181
4. Grant Permissions​ 182
5. Revoke Permissions​ 182
6. Set Permissions Recursively​ 183
7. Remove Inherited Permissions​ 183
8. Replace Permissions with a Backup​ 184
9. Grant Permissions to a Group​ 184
10. Backup Permissions for All Files in a Directory​ 185
25. subst - Associate a drive letter with a directory.​ 185
25.1. Remove a Virtual Drive​ 186
26. cipher - Display or alter file encryption on NTFS volumes.​ 187
1. Overview of the cipher Command​ 187
2. Syntax​ 187
3. Command Options and Their Functions​ 187
a. /E​ 187
b. /D​ 188
c. /S:<directory>​ 188
d. /F​ 188
e. /R:<filename>​ 189
f. /X​ 189
g. /U​ 189
h. /W:<folder>​ 189
i. /Q​ 190
j. /A​ 190
4. Detailed Use Cases and Examples​ 190
a. Encrypt a File​ 190
b. Decrypt a File​ 191
c. Encrypt All Files in a Folder​ 191
d. Force Encryption of Already Encrypted Files​ 191
e. Create a Backup of the Encryption Certificate​ 191
f. Securely Wipe Free Space​ 192
28. openfiles - Display or disconnect open shared files and folders.​ 192
1. Overview of the openfiles Command​ 192
3. Command Options and Their Functions​ 193
a. /query​ 193
b. /disconnect​ 193
c. /query /fo [format]​ 193
d. /query /v​ 193

13
Copyright © PendemVamsi. All rights reserved.

e. /disconnect /id [fileID]​ 194


f. /help​ 194
30. ipconfig - Display network configuration information.​ 194
1. Overview of the ipconfig Command​ 194
3. Command Options and Their Functions​ 195
a. /all​ 195
b. /release​ 195
c. /renew​ 196
d. /flushdns​ 196
e. /registerdns​ 196
f. /showclassid​ 197
g. /setclassid​ 197
h. /displaydns​ 197
31. ping - Test network connectivity.​ 197
a. Basic Network Connectivity Test​ 197
b. Continuous Ping​ 198
c. Specifying the Number of Echo Requests​ 198
d. Customizing Packet Size​ 198
e. Using IPv6 for Ping​ 198
f. Resolving Hostnames from IP​ 199
g. Setting the "Don't Fragment" Flag​ 199
32. tracert - Trace the route to a remote host.​ 199
1. Overview of the tracert Command​ 199
What is the tracert Command?​ 199
2. Syntax of tracert Command​ 199
General Syntax​ 199
3. Common Options for tracert Command​ 200
a. -d - Do Not Resolve Hostnames​ 200
b. -h [max_hops] - Set Maximum Hops​ 200
c. -w [timeout] - Set Timeout for Each Reply​ 200
d. -4 - Force IPv4​ 201
e. -6 - Force IPv6​ 201
33. netstat - Display network statistics.​ 201
1. Overview of the netstat Command​ 201
What is the netstat Command?​ 201
2. Syntax of netstat Command​ 202
General Syntax​ 202
3. Common Options for netstat Command​ 202
a. -a - Display All Connections and Listening Ports​ 202
b. -n - Show Numerical Addresses​ 202
c. -o - Show PID (Process ID)​ 203

14
Copyright © PendemVamsi. All rights reserved.

d. -p [protocol] - Show Connections for Specific Protocol​ 203


e. -r - Display Routing Table​ 203
f. -s - Display Network Statistics for Each Protocol​ 203
g. -e - Display Ethernet Statistics​ 204
h. -b - Show Executable Involved in Creating Connections​ 204
34. nslookup - Look up IP addresses and domain names.​ 204
1. Overview of the nslookup Command​ 204
What is the nslookup Command?​ 204
2. Syntax of nslookup Command​ 205
General Syntax​ 205
3. Common Options for nslookup Command​ 205
a. Without any Arguments​ 205
b. -type=type - Specify Query Type​ 205
c. -timeout=seconds - Set Query Timeout​ 206
d. -debug - Show Debugging Information​ 206
e. -port=port - Specify Port Number​ 206
35. hostname - Display or set the computer's hostname.​ 206
1. Display the Current Hostname​ 207
2. Set a New Hostname (Requires Root Privileges)​ 207
3. Display Fully Qualified Domain Name (FQDN)​ 207
4. Display the Short Hostname​ 207
5. Display the Domain Name​ 208
6. Get the IP Address of the Hostname​ 208
7. Display Network Node (NIS/YP) Domain Name​ 208
8. Show All IP Addresses Associated with the Host​ 208
36. arp - Display and modify the ARP cache.​ 209
1. Display the ARP Table​ 209
2. Add a New ARP Entry​ 209
3. Delete an ARP Entry​ 210
4. Show Specific ARP Entry​ 210
Options​ 210
Practical Examples​ 211
1. View All ARP Entries​ 211
2. Add a Static ARP Entry​ 211
3. Remove an ARP Entry​ 211
4. Lookup a Specific Host​ 212
ARP Cache Management​ 212
View the ARP Cache in Linux​ 212
Flush the Entire ARP Cache​ 212
List ARP Cache Entries in Windows​ 213
Delete ARP Entry in Windows​ 213

15
Copyright © PendemVamsi. All rights reserved.

37. route - Display or modify the routing table.​ 213


1. View the Current Routing Table​ 213
2. View the Routing Table with Numeric Addresses​ 214
3. Add a Static Route for a Network​ 214
4. Add a Static Route to a Host​ 214
5. Remove a Network Route​ 215
6. Remove a Host Route​ 215
7. Add a Default Gateway​ 216
8. Delete the Default Gateway​ 216
38. telnet - Connect to remote hosts using Telnet.​ 216
1. Connect to a Remote Host on Port 23 (Default Telnet Port)​ 216
2. Connect to a Remote Server on a Specific Port​ 216
3. Send a Manual HTTP Request​ 217
4. Enable Debugging Mode​ 217
5. Specify a Custom Escape Character​ 217
6. Test an SMTP Server​ 218
39. ftp - Transfer files to/from remote FTP servers.​ 218
Usage​ 218
1. Connect to an FTP Server​ 218
2. Authenticate on the Server​ 219
3. Upload or Download Files​ 219
Options​ 219
Common Commands Within an FTP Session​ 219
Practical Examples​ 221
1. Connect to an FTP Server​ 221
2. Log in Without Automatic Authentication​ 221
3. Download a File​ 222
4. Upload a File​ 222
5. Download Multiple Files​ 222
6. Upload Multiple Files​ 222
7. Enable Binary Transfer Mode​ 223
8. Change Directory on the Server​ 223
40. net - Manage network resources.​ 223
1. net accounts​ 223
Description​ 223
Syntax​ 223
Example​ 224
2. net computer​ 224
Description​ 224
Syntax​ 224
Example​ 224

16
Copyright © PendemVamsi. All rights reserved.

3. net config​ 225


Description​ 225
Syntax​ 225
Example​ 225
4. net continue​ 225
Description​ 225
Syntax​ 225
Example​ 226
5. net file​ 226
Description​ 226
6. net group​ 226
7. net help​ 227
8. net localgroup​ 228
9. net name​ 228
10. net pause​ 229
11. net print​ 230
Description​ 230
Syntax​ 230
Example​ 230
12. net send (Deprecated)​ 230
13. net session​ 231
14. net share​ 232
15. net start​ 232
16. net statistics​ 233
17. net stop​ 233
18. net time​ 234
19. net use​ 235
20. net user​ 235
21. net view​ 236
41. netsh - Network Shell for configuring network-related settings.​ 237
1. General Commands​ 237
2. Interface Context​ 238
3. Firewall Context​ 239
4. WLAN Context​ 240
Examples​ 241
5. IPSec Context​ 241
6. Routing Context​ 242
7. Diagnostics Context​ 243
nbtstat - Display statistics and current connections using NetBIOS over TCP/IP.​ 244
1. General Syntax​ 244
2. Commands and Descriptions​ 245

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.

3. Terminate a Process by PID (Process ID)​ 265


4. Terminate a Process and Its Child Processes​ 265
5. Terminate Multiple Processes​ 266
Options​ 266
Practical Examples​ 267
1. Terminate a Process by Image Name​ 267
2. Forcefully Terminate a Process​ 267
3. Terminate a Process by PID​ 267
4. Terminate Multiple Processes​ 268
5. Terminate a Process and Its Child Processes​ 268
6. Use a Filter to Terminate a Process​ 268
7. Terminate Processes on a Remote Computer​ 268
Filter Options​ 269
Example: Use Filter to Terminate a Process​ 269
58. msconfig - System Configuration Utility.​ 270
1. General Syntax​ 270
2. Key Sections in msconfig​ 270
3. Commands and Options​ 271
4. Examples​ 271
4.1 Open msconfig in Normal Startup Mode​ 271
4.2 Open msconfig in Selective Startup Mode​ 272
4.3 Open msconfig in Diagnostic Startup Mode​ 273
4.4 Access Boot Configuration Settings​ 273
4.5 Access System Services Settings​ 274
4.6 Access Startup Configuration​ 274
4.7 Access System Tools​ 275
59. regedit - Registry Editor.​ 276
Overview of regedit Commands​ 276
Key Options and Commands​ 276
1. Open the Registry Editor GUI:​ 276
2. Export Registry Keys to a .reg File:​ 277
Additional Export Options:​ 277
3. Import Registry File:​ 277
Additional Import Options:​ 278
4. Delete Registry Keys or Values:​ 278
Important Notes:​ 278
5. Silent Export:​ 278
6. Silent Import:​ 279
7. Force Operation:​ 279
8. Open a Specific Registry Hive:​ 280
9. Open the Registry Editor with Full Access:​ 280

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

File and Directory Commands:


1.​ dir - List files and directories in the current directory.

2.​ cd - Change the current directory.

3.​ mkdir - Create a new directory.

4.​ rmdir - Remove a directory.

20
Copyright © PendemVamsi. All rights reserved.

5.​ copy - Copy files or directories.

6.​ move - Move files or directories.

7.​ del - Delete files.

8.​ ren - Rename files or directories.

9.​ type - Display the contents of a text file.

10.​ find - Search for a specific string in a file.

11.​ attrib - Change file attributes.

12.​ tree - Display directory structure as a tree.

13.​ xcopy - Extended copy command with more options.

14.​ chkdsk - Check and repair disk errors.

15.​ fc - Compare two files or sets of files.

16.​ comp - Compare the contents of two files.

17.​ robocopy - Robust file and directory copying tool.

18.​ sfc - System File Checker to repair corrupted system files.

19.​ findstr - Search for specific strings in files.

20.​ more - Display the contents of a text file one page at a time.

21.​ sort - Sort the contents of a text file.

22.​ xcopy /e - Copy directories and subdirectories, including empty ones.

23.​ compact - Compress or decompress files on an NTFS partition.

24.​ xcaccls - Backup and restore NTFS permissions.

25.​ subst - Associate a drive letter with a directory.

26.​ deltree - Delete a directory and its subdirectories.

27.​ cipher - Display or alter file encryption on NTFS volumes.

28.​ fsutil - File system utility for managing various file system settings.

21
Copyright © PendemVamsi. All rights reserved.

29.​ openfiles - Display or disconnect open shared files and folders.

Network Commands:
30.​ ipconfig - Display network configuration information.

31.​ ping - Test network connectivity.

32.​ tracert - Trace the route to a remote host.

33.​ netstat - Display network statistics.

34.​ nslookup - Look up IP addresses and domain names.

35.​ hostname - Display or set the computer's hostname.

36.​ arp - Display and modify the ARP cache.

37.​ route - Display or modify the routing table.

38.​ telnet - Connect to remote hosts using Telnet.

39.​ ftp - Transfer files to/from remote FTP servers.

40.​ net - Manage network resources.

41.​ netsh - Network Shell for configuring network-related settings.

42.​ net use - Connect or disconnect a computer from shared resources.

43.​ net view - Display a list of available network resources.

44.​ net share - Create, delete, or manage shared folders.

45.​ net session - View and manage network sessions.

46.​ net time - Synchronize the computer's time with a network server.

47.​ netdom - Domain-related management tool.

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.

51.​ ipconfig /release - Release the current DHCP configuration.

22
Copyright © PendemVamsi. All rights reserved.

52.​ ipconfig /renew - Renew the DHCP configuration.

53.​ netsh firewall - Configure the Windows Firewall.

54.​ netstat -a - Display all active network connections and listening ports.

System Information and Management:


55.​ systeminfo - Display detailed system information.

56.​ tasklist - List running processes.

57.​ taskkill - Terminate processes or applications.

58.​ msconfig - System Configuration Utility.

59.​ regedit - Registry Editor.

60.​ eventvwr - Event Viewer.

61.​ services.msc - Services management console.

62.​ shutdown - Shut down or restart the computer.

63.​ gpupdate - Update Group Policy settings.

64.​ ver - Display the Windows version.

65.​ systeminfo - Display detailed system information.

66.​ gpresult - Display Group Policy settings for the current user.

67.​ powercfg - Configure power management settings.

68.​ bcdedit - Boot Configuration Data Editor for managing boot options.

69.​ dxdiag - DirectX Diagnostic Tool for troubleshooting DirectX issues.

70.​ driverquery - List installed device drivers.

71.​ msinfo32 - System Information utility.

72.​ mmc - Microsoft Management Console for creating custom management tools.

73.​ taskmgr - Task Manager for managing running processes.

74.​ perfmon - Performance Monitor for system monitoring.

23
Copyright © PendemVamsi. All rights reserved.

75.​ wmic - Windows Management Instrumentation Command-line tool.

76.​ schtasks - Schedule tasks to run at specific times or events.

User Account Management:


77.​ net user - Manage user accounts.

78.​ net group - Manage user groups.

79.​ net localgroup - Manage local groups.

80.​ whoami - Display the current user.

81.​ runas - Run a program as another user.

82.​ control userpasswords2 - User Accounts control panel.

Disk and Storage Management:


83.​ diskpart - Disk Partitioning tool.

84.​ format - Format a disk drive.

85.​ defrag - Defragment disk drives.

86.​ diskmgmt.msc - Disk Management console.

87.​ cleanmgr - Disk Cleanup utility.

Miscellaneous Commands:
88.​ cls - Clear the screen.

89.​ echo - Display text on the screen.

90.​ date - Display or set the system date.

91.​ time - Display or set the system time.

92.​ help - Get help on commands.

93.​ color - Change the console text and background color.

94.​ assoc - Display or modify file extension associations.

24
Copyright © PendemVamsi. All rights reserved.

95.​ shutdown - Shutdown or restart the computer.

96.​ shutdown /s - Shutdown the computer (immediate).

97.​ shutdown /r - Restart the computer (immediate).

98.​ shutdown /h - Hibernate the computer (if supported).

1.​ dir - List files and directories in the current


directory.
1.1. List Files in Current Directory

●​ Command: dir

1.2. List Files with Detailed Information

●​ Command: dir /q

1.3. List Files with Hidden and System Files

●​ Command: dir /a

1.4. List Files in Long Format

●​ Command: dir /w

2. Listing Specific File Types

2.1. List All .txt Files

●​ Command: dir *.txt

2.2. List All Files with Specific Extension (e.g., .jpg)

●​ Command: dir *.jpg

25
Copyright © PendemVamsi. All rights reserved.

2.3. List Files in Subdirectories

●​ Command: dir /s

3. Sorting Directory Listings

3.1. Sort by File Size

●​ Command: dir /o:s

3.2. Sort by Date and Time

●​ Command: dir /o:d

3.3. Sort in Reverse Order

●​ Command: dir /o:-d

4. Displaying File Attributes

4.1. Display File Attributes with File Names

●​ Command: dir /a

4.2. Display Only Directories

●​ Command: dir /ad

4.3. Display Only Hidden Files

●​ Command: dir /ah

5. Advanced File Listing

5.1. List Files with Summary

●​ Command: dir /b

5.2. List Files with Directory Count

26
Copyright © PendemVamsi. All rights reserved.

●​ Command: dir /s /b

5.3. Display File Names Only

●​ Command: dir /b /a-d

6. Directory Navigation

6.1. List Files in Parent Directory

●​ Command: dir ..

6.2. List Files in a Specific Directory

●​ Command: dir C:\Windows

7. File Searching

7.1. Search for a File in Current Directory

●​ Command: dir filename*

7.2. Search for Files with Wildcards

●​ Command: dir *.*

7.3. Search for Files in Subdirectories

●​ Command: dir /s filename

8. Redirecting Output

8.1. Redirect Output to a Text File

●​ Command: dir > output.txt

8.2. Append Output to an Existing File

●​ Command: dir >> output.txt

27
Copyright © PendemVamsi. All rights reserved.

9. Recursive Directory Listing

9.1. List Files and Folders in Subdirectories Recursively

●​ Command: dir /s /b

9.2. List Files in All Subdirectories Including Hidden

●​ Command: dir /s /ah

10. List Files with Specific Time

10.1. List Files Modified After a Specific Date

●​ Command: dir :w

10.2. List Files Based on Last Accessed Time

●​ Command: dir :a

11. Pagination and Formatting

11.1. Show Directory Listing One Page at a Time

●​ Command: dir /p

11.2. Display Results in Columns

●​ Command: dir /w

12. Displaying File Ownership

12.1. List Files with Owner Information

●​ Command: dir /q

12.2. List Files in Long Format with Ownership

28
Copyright © PendemVamsi. All rights reserved.

●​ Command: dir /q /s

13. Filtering Files by Size

13.1. Display Files Larger than a Specific Size

●​ Command: dir /s /o:-s /b

13.2. Display Files Smaller than a Specific Size

●​ Command: dir /s /o:+s /b

14. Displaying Time and Date

14.1. Display Directory Files and Folders with Date and Time

●​ Command: dir :c

14.2. Display Directory Files Sorted by Date Modified

●​ Command: dir /o:d

15. File Grouping and Counting

15.1. Display Directory Grouped by File Types

●​ Command: dir /o:g

15.2. Count Total Number of Files in a Directory

●​ Command: dir /s /a-d | find /c /i "file"

16. Special File Listings

16.1. Display Only Executable Files

●​ Command: dir *.exe

29
Copyright © PendemVamsi. All rights reserved.

16.2. Display Only Directories

●​ Command: dir /ad

17. Displaying Long Listing with File Sizes

17.1. List Files with Detailed File Sizes

●​ Command: dir /s /b /o:s

17.2. Display File Sizes in Bytes

●​ Command: dir /s /o:s /q

18. Directory Size Calculation

18.1. List Files and Calculate Total Size

●​ Command: dir /s /a

18.2. Calculate Size of Directory and Files

●​ Command: dir /s

19. Listing Files with Permissions

19.1. List Files with Detailed Permissions

●​ Command: dir /q

19.2. List Files in Directory with Group Permissions

●​ Command: dir /q /a

20. Excluding Files from Listing

20.1. Exclude Files Matching Specific Pattern

30
Copyright © PendemVamsi. All rights reserved.

●​ Command: dir /a-d | findstr /v "*.exe"

20.2. Exclude Directories from Listing

●​ Command: dir /a /b | findstr /v /c:"\."

2.​ cd - Change the current directory.


1.1 Change to a Specific Directory

●​ 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.

1.2 Change to the Root Directory

●​ 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:\.

2. Directory Navigation with Drive Letters

2.1 Change to a Directory on Another Drive

●​ 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.

2.2 Change to a Directory Using a Relative 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.

3.1 Navigate Up One Directory Level

●​ 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.

3.2 Navigate to the Previous Directory

●​ Command: cd -
●​ Description: Navigates to the last visited directory. This command works similarly
to using a back button in a file explorer.

4. Viewing Current Directory

4.1 Display the Current Directory Path

●​ Command: cd
●​ Description: Displays the full path of the current working directory.

5. Error Handling and Special Cases

5.1 Attempt to Change to a Nonexistent 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."

5.2 Change Directory with Spaces in Path

●​ Command: cd "C:\Program Files\My Application"


●​ Description: If the directory path contains spaces, enclose the path in double
quotes to avoid errors.

6. Switching Between Drives

6.1 Switch to Another Drive

●​ 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:.

3.​ mkdir - Create a new directory.


1.1 Create a Single Directory

●​ Command: mkdir MyFolder


●​ Description: Creates a new directory named MyFolder in the current working
directory.

Example:​


mkdir MyFolder

●​ Result: A folder named MyFolder will be created in the current directory.

1.2 Create a Directory with a Path

●​ Command: mkdir C:\Users\YourName\Documents\NewFolder


●​ Description: Creates a directory NewFolder at the specified path.

Example:​


mkdir C:\Users\YourName\Documents\NewFolder

●​ Result: The folder NewFolder will be created inside Documents.

2. Creating Multiple Directories

2.1 Create Multiple Directories at Once

●​ Command: mkdir Folder1 Folder2 Folder3


●​ Description: Creates Folder1, Folder2, and Folder3 in the current working
directory.

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.

2.2 Create Directories with Nested Structure

●​ Command: mkdir ParentFolder\ChildFolder1


ParentFolder\ChildFolder2
●​ Description: Creates a parent folder with child folders inside it.

Example:​


mkdir ParentFolder\ChildFolder1 ParentFolder\ChildFolder2

●​ Result: A folder ParentFolder will be created with two child folders


ChildFolder1 and ChildFolder2.

3. Directory Creation with Spaces in Names

3.1 Create a Directory with Spaces in the Name

●​ Command: mkdir "My New Folder"


●​ Description: Creates a folder with spaces in its name by enclosing the name in
double quotes.

Example:​


mkdir "My New Folder"

●​ Result: A folder named My New Folder will be created in the current directory.

3.2 Create Multiple Directories with Spaces

●​ Command: mkdir "Folder 1" "Folder 2" "Folder 3"


●​ Description: Creates multiple directories with spaces in their names. The names
should be enclosed in double quotes.

Example:​

34
Copyright © PendemVamsi. All rights reserved.


mkdir "Folder 1" "Folder 2" "Folder 3"

●​ Result: Three directories (Folder 1, Folder 2, and Folder 3) will be created in


the current directory.

4. Error Handling and Special Cases

4.1 Attempt to Create an Existing Directory

●​ Command: mkdir ExistingFolder


●​ Description: If the directory already exists, an error message will be displayed.

Example:​


mkdir ExistingFolder

●​ Error: "The directory already exists."

4.2 Invalid Characters in Directory Name

●​ Command: mkdir My*Folder


●​ Description: Throws an error if the directory name contains invalid characters, like
*, ?, |, etc.

Example:​


mkdir My*Folder

●​ Error: "The directory name is invalid."

5. Creating Parent Directories (with /p Option)

5.1 Create Parent Directories if They Do Not Exist

●​ Command: mkdir C:\NewFolder\SubFolder\ChildFolder


●​ Description: Creates parent directories if they do not exist. This is useful when
creating a deeply nested folder structure.

35
Copyright © PendemVamsi. All rights reserved.

Example:​


mkdir C:\NewFolder\SubFolder\ChildFolder

●​ Result: If C:\NewFolder and C:\NewFolder\SubFolder do not exist, they will be


created along with ChildFolder.

6. Viewing Created Directories

6.1 List Created Directories

●​ 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.

7. Creating Hidden Directories

7.1 Create a Hidden Directory

●​ Command: mkdir C:\Users\YourName\Documents\.HiddenFolder


●​ Description: While Windows doesn't treat directories starting with a period (.) as
hidden by default, this is useful for Unix-like systems or if you want to manually
hide the folder.

Example:​


mkdir C:\Users\YourName\Documents\.HiddenFolder

●​ Result: A hidden directory .HiddenFolder will be created inside Documents.

36
Copyright © PendemVamsi. All rights reserved.

4.​ rmdir - Remove a directory.


1.1 Remove an Empty Directory

●​ Command: rmdir [DirectoryName]


●​ Description: Removes an empty directory. If the directory contains files or
subdirectories, it will not be removed.

Example:​


rmdir MyFolder

●​ Result: The folder MyFolder will be removed, but only if it's empty.

1.2 Remove a Directory with a Full Path

●​ Command: rmdir C:\Users\YourName\Documents\OldFolder


●​ Description: Removes the specified directory at the given path. It must be empty
to be removed.

Example:​


rmdir C:\Users\YourName\Documents\OldFolder

●​ Result: The empty directory OldFolder located in Documents will be removed.

2. Removing Non-Empty Directories

2.1 Remove a Directory and Its Contents (with /s option)

●​ Command: rmdir /s [DirectoryName]


●​ Description: Removes a directory and all of its contents, including subdirectories
and files. Be cautious, as this action is permanent.

Example:​


rmdir /s OldFolder

●​ Result: The OldFolder and everything inside it will be removed.

37
Copyright © PendemVamsi. All rights reserved.

2.2 Remove a Directory and Its Contents with a Full Path (with /s option)

●​ Command: rmdir /s C:\Users\YourName\Documents\OldFolder


●​ Description: Removes the directory at the specified path and all of its contents.

Example:​


rmdir /s C:\Users\YourName\Documents\OldFolder

●​ Result: The folder OldFolder and everything within it will be deleted from
Documents.

3. Forcing Removal

3.1 Force Removal without Confirmation (with /q option)

●​ Command: rmdir /s /q [DirectoryName]


●​ Description: Removes a directory and its contents without asking for
confirmation. This can be useful for automating the process in scripts.

Example:​


rmdir /s /q OldFolder

●​ Result: The OldFolder and its contents will be removed without any prompts or
confirmation messages.

3.2 Force Removal with Full Path

●​ Command: rmdir /s /q C:\Users\YourName\Documents\OldFolder


●​ Description: Removes the specified directory and its contents without any
confirmation prompts.

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.

4. Error Handling and Special Cases

4.1 Attempt to Remove a Non-Empty Directory Without /s Option

●​ Command: rmdir MyFolder


●​ Description: Attempts to remove a directory that is not empty will result in an
error.

Example:​


rmdir MyFolder

●​ Error: "The directory is not empty."

4.2 Attempt to Remove a Directory That Doesn't Exist

●​ Command: rmdir NonExistentFolder


●​ Description: An error will occur if the specified directory does not exist.

Example:​


rmdir NonExistentFolder

●​ Error: "The system cannot find the path specified."

5. Viewing Directory After Removal

5.1 List Remaining Directories

●​ 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.

6. Removing Hidden Directories

6.1 Remove a Hidden Directory

●​ Command: rmdir /s /q C:\Users\YourName\Documents\.HiddenFolder


●​ Description: Hidden directories can be removed in the same way as regular
directories by specifying the full path. Ensure that hidden folder attributes are
removed if necessary.

Example:​


rmdir /s /q C:\Users\YourName\Documents\.HiddenFolder

●​ Result: The hidden directory .HiddenFolder will be removed along with all its
contents.

Here is the copy command guide that you can copy:

5.​ copy - Copy files or directories.


1.1 Copy a File to Another Location

●​ Command: copy [SourceFile] [Destination]


●​ Description: Copies a file from the source location to the specified destination.

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.

1.2 Copy a File with a New Name

40
Copyright © PendemVamsi. All rights reserved.

●​ Command: copy [SourceFile] [NewFileName]


●​ Description: Copies a file and gives it a new name in the destination folder.

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.

2. Copy Multiple Files

2.1 Copy All Files from a Directory

●​ Command: copy [SourceFolder]\* [Destination]


●​ Description: Copies all files from the source folder to the specified destination
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.

2.2 Copy Files with a Specific Extension

●​ Command: copy [SourceFolder]\*.ext [Destination]


●​ Description: Copies all files of a specific extension from the source folder to the
destination folder.

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

3.1 Overwrite Existing Files without Confirmation

●​ Command: copy /y [SourceFile] [Destination]


●​ Description: Copies a file and overwrites any existing file in the destination
without asking for confirmation.

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.

3.2 Prompt Before Overwriting

●​ Command: copy /-y [SourceFile] [Destination]


●​ Description: Prompts for confirmation before overwriting any existing file in the
destination.

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.

4. Copying Files with Hidden or System Attributes

4.1 Copy Hidden Files

●​ Command: copy /h [SourceFile] [Destination]


●​ Description: Copies hidden files along with other files.

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.

4.2 Copy System Files

●​ Command: copy /s [SourceFile] [Destination]


●​ Description: Copies system files along with regular files.

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.

5. Copy Files Across Different Drives

5.1 Copy a File Between Different Drives

●​ Command: copy [SourceFile] [DestinationDrive]:\


●​ Description: Copies a file from one drive to another.

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

6.1 Copy Files Using Wildcards

●​ Command: copy [SourceFolder]\[Wildcard] [Destination]


●​ Description: Uses wildcards (*, ?) to copy multiple files matching the pattern.

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.

6.​ move - Move files or directories


1.1 Move a File to Another Location

●​ Command: move [SourceFile] [Destination]


●​ Description: Moves a file from the source location to the specified destination.

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.

1.2 Move a File with a New Name

●​ Command: move [SourceFile] [DestinationFile]


●​ Description: Moves a file to the destination folder and optionally renames it.

Example:​


move C:\Users\YourName\Documents\File1.txt D:\Backup\File1_Moved.txt

●​ Result: The file File1.txt will be moved and renamed as File1_Moved.txt in


the Backup folder.

2. Moving Directories

2.1 Move a Directory to Another Location

●​ Command: move [SourceDirectory] [Destination]

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.

2.2 Move a Directory to a New Location with a New Name

●​ Command: move [SourceDirectory] [DestinationFolder]\NewFolderName


●​ Description: Moves a directory and renames it in the destination folder.

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.

3. Overwriting Existing Files

3.1 Move and Overwrite Files Without Confirmation

●​ Command: move /y [SourceFile] [Destination]


●​ Description: Moves a file and overwrites any existing file in the destination without
asking for confirmation.

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.

3.2 Prompt Before Overwriting Files

●​ Command: move /-y [SourceFile] [Destination]

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

4.1 Move Files Using Wildcards

●​ Command: move [SourceFolder]\[Wildcard] [Destination]


●​ Description: Moves files matching the wildcard pattern from the source folder to
the destination folder.

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.

5. Moving Files Across Different Drives

5.1 Move a File Between Different Drives

●​ Command: move [SourceFile] [DestinationDrive]:\


●​ Description: Moves a file from one drive to another.

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.

6. Moving Files with Hidden or System Attributes

6.1 Move Hidden Files

●​ Command: move /h [SourceFile] [Destination]


●​ Description: Moves hidden files along with regular files.

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.

6.2 Move System Files

●​ Command: move /s [SourceFile] [Destination]


●​ Description: Moves system files along with regular files.

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.

7.​ del - Delete files.


2.1 Delete Multiple Files with Wildcards

●​ Command: del [FilePath]\[Wildcard]


●​ Description: Deletes multiple files matching a wildcard pattern.

Example:​

47
Copyright © PendemVamsi. All rights reserved.


del C:\Users\YourName\Documents\*.txt

●​ Result: Deletes all .txt files from the Documents folder.

2.2 Delete All Files in a Folder

●​ Command: del [FolderPath]\*.*


●​ Description: Deletes all files in the specified folder, but does not delete subfolders.

Example:​


del C:\Users\YourName\Documents\*.*

●​ Result: Deletes all files in the Documents folder.

3. Deleting Files with Confirmation

3.1 Prompt Before Deleting Files

●​ Command: del /p [FilePath]


●​ Description: Prompts for confirmation before deleting each file.

Example:​


del /p C:\Users\YourName\Documents\File1.txt

●​ Result: Asks for confirmation before deleting File1.txt.

4. Deleting Read-Only Files

4.1 Force Deletion of Read-Only Files

●​ Command: del /f [FilePath]


●​ Description: Forces deletion of read-only files, if they exist.

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.

5. Deleting Files Without Confirmation

5.1 Delete Files Without Asking for Confirmation

●​ Command: del /q [FilePath]


●​ Description: Deletes files quietly, without asking for confirmation.

Example:​


del /q C:\Users\YourName\Documents\File1.txt

●​ Result: Deletes File1.txt without any confirmation prompt.

5.2 Delete All Files in a Folder Without Confirmation

●​ Command: del /q [FolderPath]\*.*


●​ Description: Deletes all files in the specified folder without confirmation.

Example:​


del /q C:\Users\YourName\Documents\*.*

●​ Result: Deletes all files in the Documents folder without confirmation.

6. Deleting Hidden or System Files

6.1 Delete Hidden Files

●​ Command: del /h [FilePath]


●​ Description: Deletes hidden files along with regular files.

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.

6.2 Delete System Files

●​ Command: del /s [FilePath]


●​ Description: Deletes system files as well as regular files.

Example:​


del /s C:\Users\YourName\Documents\SystemFile.sys

●​ Result: Deletes the system file SystemFile.sys from the Documents folder.

7. Deleting Files in Subdirectories

7.1 Delete Files in All Subdirectories

●​ Command: del /s [FolderPath]\*.*


●​ Description: Deletes all files in the specified folder and its subdirectories.

Example:​


del /s C:\Users\YourName\Documents\*.*

●​ Result: Deletes all files in the Documents folder and its subdirectories.

7.2 Delete Files in Subdirectories Without Asking for Confirmation

●​ Command: del /q /s [FolderPath]\*.*


●​ Description: Deletes all files in the specified folder and its subdirectories without
confirmation.

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.

8. Deleting Files with Specific Extensions

8.1 Delete All Files with a Specific Extension

●​ Command: del [FolderPath]\*.ext


●​ Description: Deletes all files with the specified extension in the given folder.

Example:​


del C:\Users\YourName\Documents\*.log

●​ Result: Deletes all .log files from the Documents folder.

9. Using del with Batch Files

9.1 Delete Files Using a Batch File

●​ Command: Use del within a batch file (.bat) to delete files.

Example (Batch File):​


batch​

del C:\Users\YourName\Documents\File1.txt

●​ Result: The batch file will delete File1.txt from the Documents folder when
executed.

8.​ ren - Rename files or directories


1.1 Rename a Single File

51
Copyright © PendemVamsi. All rights reserved.

●​ Command: ren [OldFileName] [NewFileName]


●​ Description: Renames a single file or directory from an old name to a new name.

Example:​


ren C:\Users\YourName\Documents\oldFile.txt newFile.txt

●​ Result: Renames oldFile.txt to newFile.txt in the Documents folder.

2. Rename Files with Wildcards

2.1 Rename Multiple Files with a Pattern

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Renames multiple files in a folder using wildcards to match a pattern.

Example:​


ren C:\Users\YourName\Documents\*.txt *.doc

●​ Result: Renames all .txt files in the Documents folder to .doc.

2.2 Rename Files with Wildcards (Specific Part of Filename)

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Renames files by replacing part of the filename using wildcards.

Example:​


ren C:\Users\YourName\Documents\*2020*.txt *2021*.txt

●​ Result: Renames all .txt files containing 2020 in their filename to 2021.

3. Rename Directory or Folder

3.1 Rename a Directory

●​ Command: ren [OldFolderName] [NewFolderName]

52
Copyright © PendemVamsi. All rights reserved.

●​ Description: Renames a directory (folder) from an old name to a new name.

Example:​


ren C:\Users\YourName\Documents\oldFolder newFolder

●​ Result: Renames the folder oldFolder to newFolder in the Documents directory.

4. Handling Spaces in Filenames

4.1 Rename a File or Folder with Spaces in Its Name

●​ Command: ren "[Old File/Folder Name]" "[New File/Folder Name]"


●​ Description: Renames a file or folder that contains spaces in its name. Enclose the
file or folder name in quotes.

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.

5. Batch Rename Files Using a Batch File

5.1 Rename Multiple Files in a Folder

●​ Command: Use ren in a batch file (.bat) to rename multiple files in a folder.

Example (Batch File):​


batch​

ren C:\Users\YourName\Documents\file1.txt file1_renamed.txt

ren C:\Users\YourName\Documents\file2.txt file2_renamed.txt

●​ Result: Renames file1.txt to file1_renamed.txt and file2.txt to


file2_renamed.txt in the Documents folder.

53
Copyright © PendemVamsi. All rights reserved.

6. Rename Multiple Files with Different Extensions

6.1 Rename All Files with a Specific Extension

●​ Command: ren [FolderPath]\*.ext [NewPattern].ext


●​ Description: Renames all files with a specific extension in the folder.

Example:​


ren C:\Users\YourName\Documents\*.jpg *.png

●​ Result: Renames all .jpg files in the Documents folder to .png.

7. Rename Files by Removing Specific Characters

7.1 Remove Specific Part of Filename

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Removes a specific part of a filename using wildcards.
●​ Example:​


ren C:\Users\YourName\Documents\*old*.* *new*.*

9. type Command: Display the Contents of a Text File


9.1 Display the Entire Contents of a Text File

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.

9.2 Combine and Display Multiple Files

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.

9.3 Redirect Output to Another File

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.

9.4 Append Contents to an Existing File

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.

10.​ find - Search for a specific string in a file.


1. Search for a Specific String in a File

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

●​

2. Search for a String in All Files of a Folder

Command:​
cmd​

find "[SearchString]" C:\Folder\*.*

●​
●​ Description: Searches for the string in all files within a folder.

Example:​
cmd​

find "error" C:\Folder\*.*

●​

3. Search for a String with Case Sensitivity

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.

4. Search for a String in All Files (Recursive Search)

Command:​
cmd​

find "[SearchString]" /s [Directory]

●​
●​ Description: Searches in the folder and all subdirectories.

Example:​
cmd​

find "error" /s C:\logs

●​

5. Display Only Matching Filenames

Command:​
cmd​

findstr /m "[SearchString]" C:\logs\*.*

●​
●​ Description: Lists only the filenames that contain the matching string.

Example:​
cmd​

findstr /m "error" C:\logs\*.*

●​

6. Search for Multiple Strings

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"

●​

7. Search for Exact Matches

Command:​
cmd​

findstr /x "[SearchString]" [FilePath]

●​
●​ Description: Searches for the exact match of the string.

Example:​
cmd​

findstr /x "error" C:\logs\logfile.txt

●​

8. Search for String in Compressed Files

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

●​

9. Show Only Files with Match in Their Name

Command:​
cmd​

dir | findstr /i "[SearchString]"

●​
●​ Description: Displays files with the search string in their names.

Example:​
cmd​

dir | findstr /i "error"

●​

10. Search in All Files Inside a Folder (Recursive)

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.

11. Find Files Based on Modified Date

Command:​
cmd​

dir :W | find "[SearchString]"

●​
●​ Description: Finds files based on their modified date.

Example:​
cmd​

dir :W | find "01/12/2023"

●​

12. Display Lines Matching a Specific String

Command:​
cmd​

findstr /n "[SearchString]" [FilePath]

●​
●​ Description: Displays the line numbers of matching lines.

Example:​
cmd​

findstr /n "error" C:\logs\logfile.txt

●​

13. Search for Specific Keywords

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

●​

14. Search for a Specific String in Specific Files

Command:​
cmd​

findstr "[SearchString]" C:\logs\logfile1.txt

●​
●​ Description: Searches specific files for the desired string.

Example:​
cmd​

findstr "error" C:\logs\logfile1.txt

●​

15. Show Lines Matching Specific Pattern

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

●​

16. Display Files with Larger Content

Command:​
cmd​

dir /S | findstr /c:"[SearchString]"

●​
●​ Description: Displays files larger than a specific size.

Example:​
cmd​

dir /S | findstr /c:"500MB"

●​

17. Search for Specific Line Length

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.

18. Find Occurrences Using Word Boundaries

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

●​

19. Limit Search Output to First Few Lines

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

●​

20. Search for Specific File Extension

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

●​

21. Display Lines Containing Any of Multiple Strings

Command:​
cmd​

findstr "[String1]\|[String2]" [FilePath]

●​
●​ Description: Displays lines matching any of the specified strings.

Example:​
cmd​

findstr "error\|warning" C:\logs\logfile.txt

●​

22. Search for Files with No Matches

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

11.​ attrib - Change file attributes.


1. Change File Attributes

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.

2. Set the Read-Only Attribute

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.

3. Remove the Read-Only Attribute

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

●​

4. Set the Hidden Attribute

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

●​

5. Remove the Hidden Attribute

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

●​

6. Set the System Attribute

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

●​

7. Remove the System Attribute

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

●​

8. Set the Archive Attribute

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

●​

9. Remove the Archive Attribute

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.

●​

10. Set All Attributes (Read-Only, Hidden, System, Archive)

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

●​

11. Remove All Attributes (Read-Only, Hidden, System, Archive)

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

●​

12. View File Attributes

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

12.​ tree - Display directory structure as a tree.


1. Basic Command Usage

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.

2. Display the Directory Structure with File Names

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.

3. Display the Directory Structure in Color

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.

4. Display Only the Directory Structure (No Files)

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.

5. Display the Directory Structure in a Specific Format (ASCII vs. Extended


Characters)

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

●​

6. Display the Directory Structure for All Subdirectories

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.

7. Limit the Depth of the Directory Tree

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.

8. Redirect Output to a File

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.

9. Display the Directory Structure for a Remote Server (using a network


drive)

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

13.​ xcopy - Extended copy command with more


options
1. Basic Command Usage

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.

2. Copy Files and Subdirectories

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.

3. Copy Files, Including Empty Subdirectories

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.

4. Copy Hidden and System Files

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.

5. Copy Only Files That Are Newer

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.

6. Prompt Before Overwriting

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.

7. Copy Files and Preserve File Attributes

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.

8. Copy Files Over a Network (Using UNC Path)

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.

9. Display Progress of File Copying

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.

10. Exclude Files Based on Criteria

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.

11. Display a Brief Summary

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.

12. Copy a Directory and All Files, with Detailed Output

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.

13. Copy Files with File Attributes and Ignore Errors

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.

14. Copy Files with Dateime Criteria

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.

○​ This will copy the directory structure of Documents to D:\Backup, but no


files will be copied.

15. Copy Files Based on File Size

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.

16. Copy Files Overwriting All Files in the Destination

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.

14.​ chkdsk - Check and repair disk errors.


1. Basic Command Usage

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.

2. Check and Repair Disk Errors

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.

3. Check for Bad Sectors and Repair Them

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.

4. Display Detailed Information About the Disk Check

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.

5. Check for Disk Errors Without Making Changes

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.

6. Check for Errors and Log Results to a File

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.

7. Schedule a Disk Check on Next System Restart

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.

8. Check for File System Integrity

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.

9. Check for Errors on External or Unmounted Drives

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.

10. Display the Status of the Last Disk Check

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.

11. Check for Errors on Remote Disk (Network 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.

12. Check for Specific File System Integrity Issues

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.

15.​ fc - Compare two files or sets of files.

1. Basic Command Usage

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.

2. Compare Files in ASCII Mode

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.

3. Compare Files in Binary Mode

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.

4. Display Differences with Line Numbers

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.

5. Ignore Whitespace Differences

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.

6. Compare Multiple Files in a Directory

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\.

7. Ignore Case Differences

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").

8. Display Only the Differences (No Summary)

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.

9. Compare Files and Display a Summary of Differences

Command:​
cmd​

fc /s [File1] [File2]

●​

93
Copyright © PendemVamsi. All rights reserved.

●​ 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.

10. Display Differences Using a Different Character for Line Separation

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.

16.​ comp - Compare the contents of two files.

1. Basic Command Usage

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.

2. Compare Files and Display Only 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.

3. Display Detailed Information About Differences

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.

4. Compare Files and Report the First Difference Only

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.

5. Compare Files and Display Only the Number of Differences

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.

6. Compare Files and Ignore Case Differences

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").

7. Compare Files and Display Hexadecimal Values

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.

8. Compare Multiple Files in a Directory

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.

9. Display No Output If Files Are Identical

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.

17.​ robocopy - Robust file and directory copying


tool.
2. Rename Files with Wildcards

2.1 Rename Multiple Files with a Pattern

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Renames multiple files in a folder using wildcards to match a pattern.

Example:​


ren C:\Users\YourName\Documents\*.txt *.doc

●​
●​ Result: Renames all .txt files in the Documents folder to .doc.

2.2 Rename Files with Wildcards (Specific Part of Filename)

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Renames files by replacing part of the filename using wildcards.

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.

3. Rename Directory or Folder

3.1 Rename a Directory

●​ Command: ren [OldFolderName] [NewFolderName]


●​ Description: Renames a directory (folder) from an old name to a new name.

Example:​


ren C:\Users\YourName\Documents\oldFolder newFolder

●​
●​ Result: Renames the folder oldFolder to newFolder in the Documents directory.

4. Handling Spaces in Filenames

4.1 Rename a File or Folder with Spaces in Its Name

●​ Command: ren "[Old File/Folder Name]" "[New File/Folder Name]"


●​ Description: Renames a file or folder that contains spaces in its name. Enclose the
file or folder name in quotes.

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.

5. Batch Rename Files Using a Batch File

5.1 Rename Multiple Files in a Folder

●​ Command: Use ren in a batch file (.bat) to rename multiple files in a folder.

100
Copyright © PendemVamsi. All rights reserved.

Example (Batch File):​


batch​

ren C:\Users\YourName\Documents\file1.txt file1_renamed.txt

ren C:\Users\YourName\Documents\file2.txt file2_renamed.txt

●​
●​ Result: Renames file1.txt to file1_renamed.txt and file2.txt to
file2_renamed.txt in the Documents folder.

6. Rename Multiple Files with Different Extensions

6.1 Rename All Files with a Specific Extension

●​ Command: ren [FolderPath]\*.ext [NewPattern].ext


●​ Description: Renames all files with a specific extension in the folder.

Example:​


ren C:\Users\YourName\Documents\*.jpg *.png

●​
●​ Result: Renames all .jpg files in the Documents folder to .png.

7. Rename Files by Removing Specific Characters

7.1 Remove Specific Part of Filename

●​ Command: ren [FolderPath]\[OldPattern] [NewPattern]


●​ Description: Removes a specific part of a filename using wildcards.

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.

10.​ find - Search for a specific string in a file.


1. Search for a Specific String in a File

Command:​
cmd​

find "[SearchString]" [FilePath]

●​
●​ Description: Finds the specified string in the given file.

Example:​
cmd​

find "error" C:\logs\logfile.txt

●​

2. Search for a String in All Files of a Folder

Command:​
cmd​

find "[SearchString]" C:\Folder\*.*

●​
●​ Description: Searches for the string in all files within a folder.

Example:​
cmd​

find "error" C:\Folder\*.*

●​

3. Search for a String with Case Sensitivity

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

●​

4. Search for a String in All Files (Recursive Search)

Command:​
cmd​

find "[SearchString]" /s [Directory]

●​
●​ Description: Searches in the folder and all subdirectories.

Example:​
cmd​

find "error" /s C:\logs

●​

5. Display Only Matching Filenames

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\*.*

●​

6. Search for Multiple Strings

Command:​
cmd​

findstr "[String1]" [FilePath] | findstr "[String2]"

●​
●​ Description: Finds multiple strings in a file.

Example:​
cmd​

findstr "error" C:\logs\logfile.txt | findstr "warning"

●​

7. Search for Exact Matches

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.

8. Search for String in Compressed Files

Command:​
cmd​

findstr "[SearchString]" [CompressedFile.zip]

●​
●​ Description: Allows searching inside compressed files (ZIP).

Example:​
cmd​

findstr "error" C:\logs\logfile.zip

●​

9. Show Only Files with Match in Their Name

Command:​
cmd​

dir | findstr /i "[SearchString]"

●​
●​ Description: Displays files with the search string in their names.

Example:​
cmd​

dir | findstr /i "error"

●​

10. Search in All Files Inside a Folder (Recursive)

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\*.*

●​

11. Find Files Based on Modified Date

Command:​
cmd​

dir :W | find "[SearchString]"

●​
●​ Description: Finds files based on their modified date.

Example:​
cmd​

dir :W | find "01/12/2023"

●​

12. Display Lines Matching a Specific String

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

●​

13. Search for Specific Keywords

Command:​
cmd​

find "[Keyword]" [FilePath]

●​
●​ Description: Finds lines that contain a specific keyword.

Example:​
cmd​

find "success" C:\logs\logfile.txt

●​

14. Search for a Specific String in Specific Files

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.

15. Show Lines Matching Specific Pattern

Command:​
cmd​

findstr /r "^.{5}$" [FilePath]

●​
●​ Description: Finds lines that match a pattern.

Example:​
cmd​

findstr /r "^.{5}$" C:\logs\logfile.txt

●​

16. Display Files with Larger Content

Command:​
cmd​

dir /S | findstr /c:"[SearchString]"

●​
●​ Description: Displays files larger than a specific size.

Example:​
cmd​

dir /S | findstr /c:"500MB"

●​

17. Search for Specific Line Length

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

●​

18. Find Occurrences Using Word Boundaries

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

●​

19. Limit Search Output to First Few Lines

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

●​

20. Search for Specific File Extension

Command:​
cmd​

find "[SearchString]" C:\*.txt

●​
●​ Description: Searches specific file types (e.g., .txt).

Example:​
cmd​

find "error" C:\logs\*.txt

●​

21. Display Lines Containing Any of Multiple Strings

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.

22. Search for Files with No Matches

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

●​

11.​ attrib - Change file attributes.


1. Change File Attributes

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.

2. Set the Read-Only Attribute

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

●​

3. Remove the Read-Only Attribute

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

●​

4. Set the Hidden Attribute

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

●​

5. Remove the Hidden Attribute

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

●​

6. Set the System Attribute

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

●​

7. Remove the System Attribute

Command:​
cmd​

attrib -s [FilePath]

●​
●​ Description: Removes the system attribute from a file or directory.

Example:​
cmd​

attrib -s C:\Windows\System32\example.dll

●​

8. Set the Archive Attribute

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.

9. Remove the Archive Attribute

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

●​

10. Set All Attributes (Read-Only, Hidden, System, Archive)

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

●​

11. Remove All Attributes (Read-Only, Hidden, System, Archive)

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

●​

12. View File Attributes

Command:​
cmd​

attrib [FilePath]

●​
●​ Description: Displays the current attributes of a file or directory.

Example:​
cmd​

attrib C:\Documents\example.txt

●​

12.​ tree - Display directory structure as a tree.


1. Basic Command Usage

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.

2. Display the Directory Structure with File Names

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.

3. Display the Directory Structure in Color

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.

4. Display Only the Directory Structure (No Files)

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.

5. Display the Directory Structure in a Specific Format (ASCII vs. Extended


Characters)

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

●​

6. Display the Directory Structure for All Subdirectories

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.

7. Limit the Depth of the Directory Tree

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.

8. Redirect Output to a File

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.

9. Display the Directory Structure for a Remote Server (using a network


drive)

Command:​
cmd​

tree \\[ServerName]\[ShareName]

●​

120
Copyright © PendemVamsi. All rights reserved.

●​ 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

●​
●​ Description: Shows only the directories in a tree format without displaying any
files.

Example:​
cmd​

tree C:\Users\YourName\Documents /a /d

●​

13.​ xcopy - Extended copy command with more


options.
1. Basic Command Usage

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.

2. Copy Files and Subdirectories

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.

3. Copy Files, Including Empty Subdirectories

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.

4. Copy Hidden and System Files

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.

5. Copy Only Files That Are Newer

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.

6. Prompt Before Overwriting

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.

7. Copy Files and Preserve File Attributes

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.

8. Copy Files Over a Network (Using UNC Path)

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.

9. Display Progress of File Copying

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.

10. Exclude Files Based on Criteria

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.

11. Display a Brief Summary

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.

12. Copy a Directory and All Files, with Detailed Output

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.

13. Copy Files with File Attributes and Ignore Errors

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.

14. Copy Files with Dateime Criteria

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.

15. Copy Files Based on File Size

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.

16. Copy Files Overwriting All Files in the Destination

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.

14.​ chkdsk - Check and repair disk errors.


1. Basic Command Usage

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.

2. Check and Repair Disk Errors

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.

3. Check for Bad Sectors and Repair Them

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.

4. Display Detailed Information About the Disk Check

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.

5. Check for Disk Errors Without Making Changes

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.

6. Check for Errors and Log Results to a File

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.

7. Schedule a Disk Check on Next System Restart

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.

8. Check for File System Integrity

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.

9. Check for Errors on External or Unmounted Drives

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.

10. Display the Status of the Last Disk Check

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.

11. Check for Errors on Remote Disk (Network 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.

12. Check for Specific File System Integrity Issues

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.

15.​ fc - Compare two files or sets of files.


1. Basic Command Usage

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.

2. Compare Files in ASCII Mode

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.

3. Compare Files in Binary Mode

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.

4. Display Differences with Line Numbers

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.

5. Ignore Whitespace Differences

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.

6. Compare Multiple Files in a Directory

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\.

7. Ignore Case Differences

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").

8. Display Only the Differences (No Summary)

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.

9. Compare Files and Display a Summary of Differences

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.

10. Display Differences Using a Different Character for Line Separation

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.

16.​ comp - Compare the contents of two files.


1. Basic Command Usage

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.

2. Compare Files and Display Only 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.

3. Display Detailed Information About Differences

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.

4. Compare Files and Report the First Difference Only

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.

5. Compare Files and Display Only the Number of Differences

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.

6. Compare Files and Ignore Case Differences

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.

○​ This compares file1.txt and file2.txt while ignoring any case


differences (e.g., "HELLO" vs. "hello").

7. Compare Files and Display Hexadecimal Values

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.

8. Compare Multiple Files in a Directory

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.

9. Display No Output If Files Are Identical

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.

17.​ robocopy - Robust file and directory copying


tool.
1. Basic Command Usage

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.

○​ This command copies all files from C:\Source to D:\Backup.

2. Copy Files and Subdirectories

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.

3. Copy Only Newer Files

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.

5. Skip Existing Files

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.

6. Copy Files with Permissions

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.

8. Limit the Bandwidth Used During Copying

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.

9. Exclude Specific Files

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.

10. Exclude Specific Directories

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.

11. Perform a Dry Run

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.

12. Copy Files with Logging

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.

13. Use Robocopy for Network Copying

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.

14. Copy Empty Directories Only

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.

18.​ sfc - System File Checker to repair corrupted


system files.

1. Basic Command Usage

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.

2. Check System Files Without Repairing

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.

3. Scan a Specific File

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.

4. Set the Log File Location

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:.

5. Check and Repair System Files Without a Restart

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.

6. View Detailed Logs of the Scan

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.

7. Troubleshoot Problems Using the Windows Recovery Environment

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.

8. Repair System Files Using DISM

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.

9. Repair Missing or Corrupt Files Using sfc After DISM

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.

10. Repair Windows Modules with SFC

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.

19.​ findstr - Search for specific strings in files.


1. Basic Command Usage

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."

2. Search Multiple Strings

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.

3. Search Using Regular Expressions

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.

○​ This searches for lines starting with any alphabetic characters in


logfile.txt.

4. Display Line Numbers of Matches

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.

5. Search for Whole Words Only

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.

7. Exclude Certain Strings (Invert Match)

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."

8. Search for Strings in Multiple Files

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.

9. Search for Strings Across All Files in a 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.

10. Match Full Lines Only

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.

11. Search for Multiple Strings in Multiple Files

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.

12. Display Only Matching Strings

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.

20.​ more - Display the contents of a text file one


page at a time.
1. Basic Command Usage

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.

2. Display the Content of Multiple Files

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.

3. Navigate Through the File

While using more, you can use the following keys to navigate:

●​ Enter: Display one line at a time.


●​ Space: Display one page at a time.
●​ Q: Quit and exit the more command.
●​ /: Search for a string in the file (e.g., /error to find "error").
●​ B: Go back one page.

4. View Long Files Line-by-Line

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.

5. Display File Content with Line Numbers

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.

6. View the Contents of a File Without Pausing

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.

7. Skip to the End of the File

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.

8. Pause After Each Screenful

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.

9. Search for Text While Viewing

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.

10. Customize the Paging Behavior

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.

21.​ sort - Sort the contents of a text file.


1. Basic Command Usage

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.

2. Sort in Reverse Order (Descending)

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.

3. Sort Without Removing Duplicate Lines

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.

4. Sort Output by Column

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.

5. Sort the Contents of Standard Input (Piped Input)

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".

6. Redirect Sorted Output to a New File

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.

7. Sort by Specific Fields in the File (Delimited Data)

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.

8. Sort with Case Insensitivity

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.

9. View Sorted Output in Real-Time Using Piping

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.

10. View Sorted Content with Line Numbers

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.

22.​ xcopy /e - Copy directories and


subdirectories, including empty ones.
1. Basic Command Usage

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.

2. Copy Directories and Subdirectories, Suppressing Confirmation

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.

3. Copy Directories and Subdirectories with File Attributes

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.

4. Copy Specific File Types with Subdirectories

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.

5. Exclude Certain Files During Copying

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.

6. Copy Files and Directories with Verification

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.

○​ This command copies files and subdirectories, including empty directories,


from Documents to D:\Backup and verifies that each file is copied
correctly.

7. Copy Files and Directories, Including Hidden Files

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.

8. Copy Multiple Source Directories to One Destination

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.

23.​ compact - Compress or decompress files on


an NTFS partition.

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.

3. Display Compression Status

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.

4. Compress All Files in a Directory and Subdirectories

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.

5. Decompress All Files in a Directory and 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.

6. Show All Files with Compression Status in a Directory

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.

7. Compress Only Files That Are Not Already Compressed

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.

8. Display Compression Information for a File

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.

9. Compress Files with Specific File Extensions

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.

10. Show the File Compression Ratio

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.

24.​ xcaccls - Backup and restore NTFS


permissions.
1. Backup NTFS Permissions

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.

2. Restore NTFS Permissions from a Backup

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.

3. Display Current NTFS Permissions

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.

6. Set Permissions Recursively

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.

7. Remove Inherited Permissions

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.

8. Replace Permissions with a Backup

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.

9. Grant Permissions to a Group

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.

10. Backup Permissions for All Files in a Directory

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.

25.​ subst - Associate a drive letter with a


directory.
Command:

cmd

subst [Drive Letter]: [Directory Path]

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.

25.1. Remove a Virtual Drive

Command:

cmd

186
Copyright © PendemVamsi. All rights reserved.

subst [Drive Letter]: /d

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.

26.​ cipher - Display or alter file encryption on


NTFS volumes.

1. Overview of the cipher Command

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

cipher [options] [drive:][path]

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.

3. Command Options and Their Functions

a. /E

●​ Description: Encrypts the specified file or directory.


●​ Use Case: Encrypt files and folders to protect sensitive data.

Example:​


cipher /E C:\Users\YourName\Documents\file.txt

●​

b. /D

●​ Description: Decrypts the specified file or directory.


●​ Use Case: Decrypt files or folders that were previously encrypted.

Example:​


cipher /D C:\Users\YourName\Documents\file.txt

●​

c. /S:<directory>

●​ Description: Encrypts all subdirectories within the specified directory.


●​ Use Case: Encrypt all files and subdirectories under a given directory.

Example:​


cipher /E /S:C:\Users\YourName\Documents

●​

d. /F

188
Copyright © PendemVamsi. All rights reserved.

●​ Description: Forces the encryption or decryption of files that are already


encrypted or decrypted.
●​ Use Case: Re-encrypt files that are already encrypted.

Example:​


cipher /E /F C:\Users\YourName\Documents

●​

e. /R:<filename>

●​ Description: Creates a recovery agent certificate and key.


●​ Use Case: Create a recovery certificate and key that can be used to recover
encrypted files.

Example:​


cipher /R:RecoveryAgent

●​

f. /X

●​ Description: Back up the encryption certificate and key.


●​ Use Case: Save the encryption certificate and key for later use or recovery.

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>

●​ Description: Overwrites unused disk space to securely erase deleted files.


●​ Use Case: Securely wipe free space to make sure deleted files cannot be
recovered.

Example:​


cipher /W:C:\Users\YourName\Documents

●​

i. /Q

●​ Description: Suppresses the display of the status messages. Quiet mode.


●​ Use Case: Use this option when you want to run the command without showing
the progress or results.

Example:​


cipher /E /Q C:\Users\YourName\Documents\file.txt

●​

j. /A

●​ Description: Displays all files in the directory, including encrypted files.


●​ Use Case: View both encrypted and unencrypted files in a directory.

Example:​


cipher /A C:\Users\YourName\Documents

●​

190
Copyright © PendemVamsi. All rights reserved.

4. Detailed Use Cases and Examples

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.

c. Encrypt All Files in a Folder

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.

d. Force Encryption of Already Encrypted Files

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.

e. Create a Backup of the Encryption Certificate

To create a backup of the encryption certificate, use the /X option.

Example:​


cipher /X C:\Backup

●​
○​ Explanation: Backs up the encryption certificate and key to the specified
folder.

f. Securely Wipe Free Space

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.

28.​ openfiles - Display or disconnect open


shared files and folders.

1. Overview of the openfiles Command

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

openfiles [option] [parameters]

●​ [option]: Specifies the action you want to perform.


●​ [parameters]: Additional arguments that define the target files or user actions.

3. Command Options and Their Functions

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

●​ Description: Disconnects an open file or folder that is currently being accessed by


a user.
●​ Use Case: Disconnect a user from a shared file or folder to resolve issues or
lockouts.

Example:​

193
Copyright © PendemVamsi. All rights reserved.


openfiles /disconnect /id 100

●​

c. /query /fo [format]

●​ 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

●​

e. /disconnect /id [fileID]

●​ Description: Disconnects a file based on its ID.


●​ Use Case: Disconnect a specific open file based on its ID to free resources or
resolve conflicts.

Example:​


openfiles /disconnect /id 125

●​

f. /help

194
Copyright © PendemVamsi. All rights reserved.

●​ Description: Displays help information for the openfiles command.


●​ Use Case: Get more information about how to use the openfiles command.

Example:​


openfiles /help

●​

30.​ ipconfig - Display network configuration


information.
1. Overview of the ipconfig Command

The ipconfig command is used to display the current network configuration of a


computer’s network interfaces. It provides valuable information for troubleshooting
connectivity issues, checking IP address assignments, and managing network adapters.

2. Syntax

ipconfig [option] [parameters]

●​ [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).

3. Command Options and Their Functions

a. /all

195
Copyright © PendemVamsi. All rights reserved.

●​ Description: Displays detailed information about all network interfaces on the


system, including physical (MAC) addresses, DHCP status, DNS servers, and
more.
●​ Use Case: Useful for troubleshooting and obtaining detailed network
configuration data.

Example:​


ipconfig /all

●​

b. /release

●​ Description: Releases the current IP address configuration for the specified


network adapter.
●​ Use Case: Used to disconnect from the network and drop the current IP
configuration.

Example:​


ipconfig /release

●​

c. /renew

●​ Description: Renews the IP address for the specified network adapter.


●​ Use Case: Typically used after releasing the IP to obtain a new IP address from a
DHCP server.

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

●​ Description: Displays the DHCP Class ID for a specified adapter.


●​ Use Case: Used for troubleshooting DHCP issues.

Example:​


ipconfig /showclassid "Ethernet"

●​

g. /setclassid

●​ Description: Configures a DHCP Class ID for a specified network adapter.


●​ Use Case: Used when manually setting the DHCP Class ID on a network adapter.

Example:​


ipconfig /setclassid "Ethernet" 1

●​

197
Copyright © PendemVamsi. All rights reserved.

h. /displaydns

●​ Description: Displays the current DNS resolver cache contents.


●​ Use Case: Useful for checking the entries cached on the system by the DNS
resolver.

Example:​


ipconfig /displaydns

31.​ ping - Test network connectivity.

a. Basic Network Connectivity Test

●​ Description: Verifies if a system is reachable by pinging a target host.

Example:​


ping google.com

●​

b. Continuous Ping

●​ Description: Continuously pings a host until manually stopped (Ctrl + C).

Example:​


ping -t google.com

●​

c. Specifying the Number of Echo Requests

●​ Description: Sends a specific number of Echo Requests to the target host.

Example:​

198
Copyright © PendemVamsi. All rights reserved.


ping -n 5 google.com

●​

d. Customizing Packet Size

●​ Description: Customizes the size of the packets being sent.

Example:​


ping -l 1500 google.com

●​

e. Using IPv6 for Ping

●​ Description: Forces the ping to use IPv6 instead of IPv4.

Example:​


ping -6 google.com

●​

f. Resolving Hostnames from IP

●​ Description: Resolves and shows the hostname for the given IP address.

Example:​


ping -a 8.8.8.8

●​

g. Setting the "Don't Fragment" Flag

●​ Description: Ensures the packet is not fragmented during transmission.


●​ Example:​


ping -f google.com

199
Copyright © PendemVamsi. All rights reserved.

32.​ tracert - Trace the route to a remote host.

1. Overview of the tracert Command

What is the tracert Command?

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.

2. Syntax of tracert Command

General Syntax

tracert [hostname or IP address] [options]

●​ [hostname or IP address]: The domain name (e.g., google.com) or IP address (e.g.,


8.8.8.8) of the target host.
●​ [options]: Additional flags or parameters to modify the behavior of the command.

3. Common Options for tracert Command

a. -d - Do Not Resolve Hostnames

●​ Description: Prevents the command from resolving IP addresses to hostnames,


which speeds up the trace.

Example:​


tracert -d google.com

200
Copyright © PendemVamsi. All rights reserved.

●​

b. -h [max_hops] - Set Maximum Hops

●​ Description: Specifies the maximum number of hops (routers) to trace before


stopping.

Example:​


tracert -h 15 google.com

●​

c. -w [timeout] - Set Timeout for Each Reply

●​ 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

●​

33.​ netstat - Display network statistics.

1. Overview of the netstat Command

What is the netstat Command?

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.

2. Syntax of netstat Command

General Syntax

netstat [options]

●​ [options]: Flags or parameters that modify the output of the command.

3. Common Options for netstat Command

a. -a - Display All Connections and Listening Ports

●​ Description: Shows all active connections and listening ports.

202
Copyright © PendemVamsi. All rights reserved.

Example:​


netstat -a

●​

b. -n - Show Numerical Addresses

●​ Description: Displays addresses and port numbers in numerical format instead of


resolving them to hostnames.

Example:​


netstat -n

●​

c. -o - Show PID (Process ID)

●​ Description: Displays the process ID (PID) associated with each connection or


listening port.

Example:​


netstat -o

●​

d. -p [protocol] - Show Connections for Specific Protocol

●​ Description: Filters the output to show connections for a specific protocol (e.g.,
TCP or UDP).

Example:​


netstat -p tcp

●​

e. -r - Display Routing Table

203
Copyright © PendemVamsi. All rights reserved.

●​ Description: Displays the routing table of the system, showing the paths network
traffic takes.

Example:​


netstat -r

●​

f. -s - Display Network Statistics for Each Protocol

●​ Description: Shows detailed statistics for each network protocol (TCP, UDP, ICMP,
etc.).

Example:​


netstat -s

●​

g. -e - Display Ethernet Statistics

●​ Description: Displays Ethernet statistics, such as the number of bytes, packets,


and errors.

Example:​


netstat -e

●​

h. -b - Show Executable Involved in Creating Connections

●​ Description: Displays the executable (program) associated with each connection


or listening port.

Example:​


netstat -b

204
Copyright © PendemVamsi. All rights reserved.

34.​ nslookup - Look up IP addresses and domain


names.
1. Overview of the nslookup Command

What is the nslookup Command?

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.

The nslookup command is commonly used to:

●​ Resolve domain names to IP addresses.


●​ Query DNS records (e.g., A records, MX records).
●​ Troubleshoot DNS server issues.
●​ Verify the availability of a domain name.

2. Syntax of nslookup Command

General Syntax

nslookup [domain-name] [dns-server]

●​ [domain-name]: The domain name you want to look up.


●​ [dns-server]: (Optional) The DNS server to use for the lookup. If not specified, the
default DNS server of the system will be used.

3. Common Options for nslookup Command

a. Without any Arguments

205
Copyright © PendemVamsi. All rights reserved.

●​ Description: Running nslookup without any arguments enters interactive mode,


allowing you to perform multiple queries.

Example:​


nslookup

●​ This starts the interactive mode where you can enter domain names to query.

b. -type=type - Specify Query Type

●​ 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

●​ This command queries the MX (Mail Exchange) records for example.com.

c. -timeout=seconds - Set Query Timeout

●​ 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

●​ This sets the timeout to 10 seconds for the query.

d. -debug - Show Debugging Information

●​ Description: Provides detailed debugging information about the DNS query


process, including the query’s result and the DNS server's response.

Example:​


nslookup -debug example.com

●​

206
Copyright © PendemVamsi. All rights reserved.

e. -port=port - Specify Port Number

●​ 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

35.​ hostname - Display or set the computer's


hostname.
The hostname command is used to display or set the system's hostname, which
identifies the system on a network.

Basic Syntax

hostname [OPTION] [NEW_HOSTNAME]

1. Display the Current Hostname

hostname

●​ Outputs the system's current hostname.

2. Set a New Hostname (Requires Root Privileges)

207
Copyright © PendemVamsi. All rights reserved.

sudo hostname new-hostname

●​ Temporarily sets the hostname until the next reboot.

3. Display Fully Qualified Domain Name (FQDN)

hostname -f

4. Display the Short Hostname

hostname -s

5. Display the Domain Name

hostname -d

6. Get the IP Address of the Hostname

hostname -i

208
Copyright © PendemVamsi. All rights reserved.

7. Display Network Node (NIS/YP) Domain Name

hostname -y

8. Show All IP Addresses Associated with the Host

hostname -I

36.​ arp - Display and modify the ARP cache.

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

arp [OPTION] [hostname]

209
Copyright © PendemVamsi. All rights reserved.

Usage

1. Display the ARP Table

arp -a

●​ Lists all current ARP entries, showing IP addresses and their corresponding MAC
addresses.

2. Add a New ARP Entry

sudo arp -s <IP_ADDRESS> <MAC_ADDRESS>

●​ Manually adds a static ARP entry to the table.

3. Delete an ARP Entry

sudo arp -d <IP_ADDRESS>

●​ Removes a specific entry for the given IP address.

4. Show Specific ARP Entry

210
Copyright © PendemVamsi. All rights reserved.

arp <hostname>

●​ Displays the ARP entry for the specified hostname or IP address.

Options

Option Description

-a Display all ARP entries or a specific one if the hostname is


[hostname] provided.

-d Delete the ARP entry for the specified IP address.


<IP_ADDRESS>

-s <IP> Add a new static ARP entry for the given IP and MAC
<MAC> addresses.

-v Enable verbose mode to show additional details.

-n Display numerical addresses instead of resolving hostnames.

Practical Examples
1. View All ARP Entries

arp -a

211
Copyright © PendemVamsi. All rights reserved.

●​ Shows the ARP cache with associated IP-MAC address mappings.

2. Add a Static ARP Entry

sudo arp -s 192.168.1.10 00:14:22:01:23:45

●​ Maps the IP 192.168.1.10 to the MAC address 00:14:22:01:23:45.

3. Remove an ARP Entry

sudo arp -d 192.168.1.10

●​ Deletes the ARP cache entry for the IP address 192.168.1.10.

4. Lookup a Specific Host

arp 192.168.1.1

●​ Displays the ARP information for the IP address 192.168.1.1.

ARP Cache Management


View the ARP Cache in Linux

212
Copyright © PendemVamsi. All rights reserved.

ip neigh show

●​ Modern systems use the ip command for viewing the ARP table.

Flush the Entire ARP Cache

sudo ip -s -s neigh flush all

List ARP Cache Entries in Windows

cmd

arp -a

Delete ARP Entry in Windows

cmd

arp -d <IP_ADDRESS>

37.​ route - Display or modify the routing table.


The route command is used to view and manipulate the IP routing table. It allows
network administrators to define and manage static routes for a system to determine how
packets are sent across a network.

213
Copyright © PendemVamsi. All rights reserved.

Basic Syntax

route [OPTION] [COMMAND] [TARGET]

1. View the Current Routing Table

route

●​ Displays the system’s current routing table.

2. View the Routing Table with Numeric Addresses

route -n

●​ Displays the routing table without resolving IP addresses to hostnames.

3. Add a Static Route for a Network

Syntax:

sudo route add -net <NETWORK> netmask <NETMASK> gw <GATEWAY>

214
Copyright © PendemVamsi. All rights reserved.

sudo route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1

●​ Adds a static route to the 192.168.2.0/24 network via the gateway


192.168.1.1.

4. Add a Static Route to a Host

Syntax:

sudo route add -host <IP_ADDRESS> gw <GATEWAY>

sudo route add -host 10.0.0.5 gw 192.168.1.1

●​ Adds a static route to the host 10.0.0.5 via the gateway 192.168.1.1.

5. Remove a Network Route

Syntax:

sudo route del -net <NETWORK> netmask <NETMASK>

sudo route del -net 192.168.2.0 netmask 255.255.255.0

215
Copyright © PendemVamsi. All rights reserved.

●​ Deletes the route to the 192.168.2.0/24 network.

6. Remove a Host Route

sudo route del -host 10.0.0.5

●​ Deletes the route to the host 10.0.0.5.

7. Add a Default Gateway

sudo route add default gw 192.168.1.1

●​ Sets 192.168.1.1 as the default gateway for the system.

8. Delete the Default Gateway

sudo route del default

●​ Removes the default gateway.

38.​ telnet - Connect to remote hosts using


Telnet.
1. Connect to a Remote Host on Port 23 (Default Telnet Port)

216
Copyright © PendemVamsi. All rights reserved.

telnet 192.168.1.1

●​ Connects to the host with IP 192.168.1.1 on the default Telnet port.

2. Connect to a Remote Server on a Specific Port

telnet example.com 80

●​ Connects to example.com on port 80 to test HTTP services.

3. Send a Manual HTTP Request

telnet example.com 80

GET / HTTP/1.1

Host: example.com

●​ Sends an HTTP request to example.com and retrieves the response.

4. Enable Debugging Mode

telnet -d 192.168.1.1

217
Copyright © PendemVamsi. All rights reserved.

●​ Enables debugging to show connection details while connecting to 192.168.1.1.

5. Specify a Custom Escape Character

telnet -e ^C 192.168.1.1

●​ Sets the escape character to Ctrl + C.

6. Test an SMTP Server

telnet mail.example.com 25

●​ Connects to an SMTP server on port 25 to test mail server communication.

39.​ ftp - Transfer files to/from remote FTP


servers.

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

ftp [OPTIONS] [hostname or IP address]

218
Copyright © PendemVamsi. All rights reserved.

Usage
1. Connect to an FTP Server

ftp <hostname_or_IP>

●​ Connects to the specified FTP server.

2. Authenticate on the Server

●​ Once connected, provide the required username and password when prompted.

3. Upload or Download Files

Use commands like put to upload files or get to download files during the session.

Options

Optio Description
n

-v Enables verbose mode, displaying detailed responses from the FTP


server.

-n Prevents automatic login upon connection.

-i Disables interactive prompts for each file transfer.

219
Copyright © PendemVamsi. All rights reserved.

-g Disables wildcard expansion in filenames.

-d Enables debugging to show all FTP commands sent to the server.

-p Enables passive mode for data transfer.

Common Commands Within an FTP Session

Comman Description
d

open Connects to a different FTP server.

close Disconnects from the current FTP server.

quit Exits the FTP session.

get Downloads a file from the remote server to the local


machine.

mget Downloads multiple files using wildcards (e.g., mget


*.txt).

put Uploads a file from the local machine to the remote


server.

mput Uploads multiple files using wildcards (e.g., mput


*.csv).

ls Lists files and directories on the remote server.

220
Copyright © PendemVamsi. All rights reserved.

dir Displays a detailed listing of files and directories.

pwd Shows the current working directory on the remote


server.

cd Changes the directory on the remote server.

lcd Changes the local working directory.

delete Deletes a file on the remote server.

mkdir Creates a directory on the remote server.

rmdir Removes a directory on the remote server.

ascii Switches to ASCII transfer mode (for text files).

binary Switches to binary transfer mode (for binary files).

status Displays the current FTP settings.

Practical Examples
1. Connect to an FTP Server

ftp ftp.example.com

221
Copyright © PendemVamsi. All rights reserved.

●​ Connects to the server ftp.example.com.

2. Log in Without Automatic Authentication

ftp -n ftp.example.com

●​ Connects without auto-login; credentials must be entered manually.

3. Download a File

ftp> get example.txt

●​ Downloads the file example.txt from the remote server to the local system.

4. Upload a File

ftp> put localfile.txt

●​ Uploads the file localfile.txt from the local machine to the remote server.

5. Download Multiple Files

ftp> mget *.jpg

222
Copyright © PendemVamsi. All rights reserved.

●​ Downloads all files with the .jpg extension.

6. Upload Multiple Files

ftp> mput *.csv

●​ Uploads all .csv files to the remote server.

7. Enable Binary Transfer Mode

ftp> binary

●​ Ensures files are transferred in binary mode to prevent corruption.

8. Change Directory on the Server

ftp> cd /patho/directory

●​ Navigates to the specified directory on the remote server.

40.​ net - Manage network resources.


The net command is used in Windows to manage network resources, services, user
accounts, and more. It provides a suite of subcommands to perform administrative tasks
on local and remote computers.

223
Copyright © PendemVamsi. All rights reserved.

1. net accounts

Description

Manages user account policies and password settings.

Syntax

net accounts [/minpwlen:length] [/maxpwage:days]


[/lockoutthreshold:number] [/domain]

Example

net accounts /minpwlen:8 /maxpwage:30

●​ Sets the minimum password length to 8 characters and the maximum password
age to 30 days.

2. net computer

Description

Adds or removes computers from a domain.

Syntax

224
Copyright © PendemVamsi. All rights reserved.

net computer \\<computername> {/add | /del}

Example

net computer \\Workstation01 /add

●​ Adds Workstation01 to the domain.

3. net config

Description

Displays or modifies network service configurations.

Syntax

net config [server | workstation]

Example

net config workstation

●​ Displays configuration details for the workstation service.

225
Copyright © PendemVamsi. All rights reserved.

4. net continue

Description

Resumes a paused service.

Syntax

net continue <service_name>

Example

net continue "Print Spooler"

●​ Resumes the Print Spooler service.

5. net file

Description

Lists or closes open files on a network.

Syntax

net file [ID] [/close]

Example

226
Copyright © PendemVamsi. All rights reserved.

net file

net file 1234 /close

●​ Lists open files and closes the file with ID 1234.

6. net group

Description

Manages global groups on a domain.

Syntax

net group <groupname> [/add | /delete] [/domain]

Example

net group "Sales Team" /add /domain

●​ Adds the group Sales Team to the domain.

7. net help

227
Copyright © PendemVamsi. All rights reserved.

Description

Provides help for net commands.

Syntax

net help <command>

Example

net help user

●​ Displays help for the net user command.

8. net localgroup

Description

Manages local user groups.

Syntax

net localgroup <groupname> [/add | /delete] [/domain]

Example

228
Copyright © PendemVamsi. All rights reserved.

net localgroup "Administrators" JohnDoe /add

●​ Adds JohnDoe to the Administrators group.

9. net name

Description

Manages messaging names.

Syntax

net name [name] [/add | /delete]

Example

net name Support /add

●​ Adds the messaging name Support.

10. net pause

Description

Pauses a service.

229
Copyright © PendemVamsi. All rights reserved.

Syntax

net pause <service_name>

Example

net pause "Print Spooler"

●​ Pauses the Print Spooler service.

11. net print

Description

Displays or controls print jobs.

Syntax

net print \\<computername>\<sharename>

Example

net print \\Server01\Printer1

230
Copyright © PendemVamsi. All rights reserved.

●​ Displays print jobs for the printer Printer1 on Server01.

12. net send (Deprecated)

Description

Sends messages to other users or computers.

Syntax

net send <name> <message>

Example

net send JohnDoe "Meeting at 3 PM"

●​ Sends the message to JohnDoe.

13. net session

Description

Lists or ends active sessions.

Syntax

231
Copyright © PendemVamsi. All rights reserved.

net session [\\<computername>] [/delete]

Example

net session

net session \\Workstation02 /delete

●​ Lists active sessions and ends the session for Workstation02.

14. net share

Description

Manages shared resources.

Syntax

net share [sharename] [=path] [/delete]

Example

net share PublicShare=C:\Public

net share PublicShare /delete

232
Copyright © PendemVamsi. All rights reserved.

●​ Shares the folder C:\Public and deletes the share.

15. net start

Description

Starts a service.

Syntax

net start <service_name>

Example

net start "Print Spooler"

●​ Starts the Print Spooler service.

16. net statistics

Description

Displays network statistics for workstation or server.

Syntax

net statistics [workstation | server]

233
Copyright © PendemVamsi. All rights reserved.

Example

net statistics workstation

●​ Displays statistics for the workstation service.

17. net stop

Description

Stops a service.

Syntax

net stop <service_name>

Example

net stop "Print Spooler"

●​ Stops the Print Spooler service.

18. net time

234
Copyright © PendemVamsi. All rights reserved.

Description

Synchronizes or displays the network time.

Syntax

net time [\\<computername>] [/set] [/yes]

Example

net time \\Server01 /set /yes

●​ Synchronizes the system time with Server01.

19. net use

Description

Manages connections to network resources.

Syntax

net use [drive:] \\<computername>\<sharename> [/delete]

Example

235
Copyright © PendemVamsi. All rights reserved.

net use Z: \\Server01\SharedFolder

net use Z: /delete

●​ Maps the shared folder to drive Z: and deletes the mapping.

20. net user

Description

Manages user accounts.

Syntax

net user <username> [password | *] [/add | /delete]

Example

net user JohnDoe password123 /add

net user JohnDoe /delete

●​ Adds and deletes the user JohnDoe.

21. net view

236
Copyright © PendemVamsi. All rights reserved.

Description

Lists shared resources or computers.

Syntax

net view [\\<computername>]

Example

net view

net view \\Server01

●​ Displays shared resources or computers.

41.​ netsh - Network Shell for configuring


network-related settings.
netsh (Network Shell) is a powerful command-line utility for managing and configuring
network-related settings on a Windows machine. It supports various contexts like
interface, firewall, IP, routing, and more.

1. General Commands

These commands are used to navigate or reset netsh configurations.

Syntax and Commands

237
Copyright © PendemVamsi. All rights reserved.

netsh

netsh show commands

netsh <context> show help

netsh -c <context>

netsh reset

Examples

Enter netsh interactive mode:​




netsh

●​

Show available commands in a context:​




netsh interface show commands

●​

Reset network settings:​




netsh int ip reset

●​

2. Interface Context

Description

238
Copyright © PendemVamsi. All rights reserved.

Manages network interfaces, including enabling/disabling interfaces, configuring IP


addresses, and viewing interface details.

Syntax

netsh interface show interface

netsh interface set interface name="<InterfaceName>" admin=enabled

netsh interface ip set address name="<InterfaceName>" source=dhcp

netsh interface ip set address name="<InterfaceName>" source=static


addr=<IP> mask=<SubnetMask> gateway=<Gateway>

Examples

List all interfaces:​




netsh interface show interface

●​

Enable a specific interface:​




netsh interface set interface name="Ethernet" admin=enabled

●​

Set a static IP:​




netsh interface ip set address name="Ethernet" source=static
addr=192.168.1.10 mask=255.255.255.0 gateway=192.168.1.1

●​

Set IP to DHCP:​

239
Copyright © PendemVamsi. All rights reserved.


netsh interface ip set address name="Ethernet" source=dhcp

●​

3. Firewall Context

Description

Manages Windows Firewall rules and configurations.

Syntax

netsh advfirewall show allprofiles

netsh advfirewall set allprofiles state on

netsh advfirewall firewall add rule name="<RuleName>" dir=in


action=allow protocol=TCP localport=<Port>

netsh advfirewall firewall delete rule name="<RuleName>"

Examples

Enable Windows Firewall:​




netsh advfirewall set allprofiles state on

●​

Add a firewall rule:​




netsh advfirewall firewall add rule name="Allow_HTTP" dir=in
action=allow protocol=TCP localport=80

●​

240
Copyright © PendemVamsi. All rights reserved.

Delete a firewall rule:​




netsh advfirewall firewall delete rule name="Allow_HTTP"

●​

4. WLAN Context

Description

Manages wireless network settings, including profiles, connections, and configurations.

Syntax

netsh wlan show profiles

netsh wlan connect name="<ProfileName>"

netsh wlan set hostednetwork mode=allow ssid=<SSID> key=<Password>

netsh wlan start hostednetwork

netsh wlan stop hostednetwork

Examples

Show all saved Wi-Fi profiles:​




netsh wlan show profiles

●​

Connect to a specific Wi-Fi network:​




netsh wlan connect name="HomeWiFi"

241
Copyright © PendemVamsi. All rights reserved.

●​

Create a Wi-Fi hotspot:​




netsh wlan set hostednetwork mode=allow ssid=MyHotspot key=Password123

netsh wlan start hostednetwork

●​

5. IPSec Context

Description

Configures IP Security policies for network traffic.

Syntax

netsh ipsec static show policy

netsh ipsec static add policy name="<PolicyName>"


description="<Description>"

netsh ipsec static delete policy name="<PolicyName>"

Examples

Show all IPSec policies:​




netsh ipsec static show policy

●​

Add a new IPSec policy:​



242
Copyright © PendemVamsi. All rights reserved.

netsh ipsec static add policy name="SecurePolicy" description="Secure


Traffic Policy"

●​

Delete an IPSec policy:​




netsh ipsec static delete policy name="SecurePolicy"

●​

6. Routing Context

Description

Configures static routes and routing-related settings.

Syntax

netsh routing ip show config

netsh routing ip add persistentroute destination=<IP>


mask=<SubnetMask> gateway=<Gateway> metric=<Metric>

netsh routing ip delete persistentroute destination=<IP>

Examples

Show routing configuration:​




netsh routing ip show config

●​

Add a static route:​


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

●​

Delete a static route:​




netsh routing ip delete persistentroute destination=192.168.2.0

●​

7. Diagnostics Context

Description

Performs network diagnostics and troubleshooting.

Syntax

netsh diag show test

netsh diag ping ipaddress=<IP>

netsh diag connect ipaddress=<IP>

Examples

Run a full diagnostics test:​




netsh diag show test

●​

Ping a specific IP:​


244
Copyright © PendemVamsi. All rights reserved.


netsh diag ping ipaddress=8.8.8.8

●​

nbtstat - Display statistics and current


connections using NetBIOS over TCP/IP.

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.

2. Commands and Descriptions

Command Description

nbtstat -a Displays the NetBIOS name table of a remote machine, specified


<hostname> by <hostname>.

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 -r Displays the count of NetBIOS names resolved by broadcast and


via WINS.

nbtstat -R Purges and reloads the NetBIOS name cache.

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

3.1 View the NetBIOS Name Table of a Remote Machine by Hostname

Command:

nbtstat -a <hostname>

Example:

246
Copyright © PendemVamsi. All rights reserved.

nbtstat -a RemotePC

Description:​
Displays the NetBIOS name table for the machine RemotePC.

3.2 View the NetBIOS Name Table of a Remote Machine by IP Address

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.

3.3 Display the NetBIOS Name Cache

Command:

nbtstat -c

247
Copyright © PendemVamsi. All rights reserved.

Example:

nbtstat -c

Description:​
Lists all entries in the local NetBIOS name cache.

3.4 List Local NetBIOS Names

Command:

nbtstat -n

Example:

nbtstat -n

Description:​
Displays local NetBIOS names registered by the machine.

3.5 Show Name Resolution Statistics

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.

3.6 Purge and Reload the NetBIOS Name Cache

Command:

nbtstat -R

Example:

nbtstat -R

Description:​
Clears the NetBIOS name cache and reloads it.

249
Copyright © PendemVamsi. All rights reserved.

3.7 Display Current NetBIOS Sessions (with Hostnames)

Command:

nbtstat -s

Example:

nbtstat -s

Description:​
Shows all active NetBIOS sessions with hostnames.

3.8 Display Current NetBIOS Sessions (with IP Addresses)

Command:

nbtstat -S

Example:

nbtstat -S

250
Copyright © PendemVamsi. All rights reserved.

Description:​
Lists all active NetBIOS sessions and displays their IP addresses.

3.9 Release and Re-register NetBIOS Names

Command:

nbtstat -RR

Example:

nbtstat -RR

Description:​
Sends a name release request to WINS servers and re-registers all NetBIOS names

55.​ systeminfo - Display detailed system


information.
systeminfo is a command-line tool that provides detailed information about the
computer system's configuration, including OS version, memory, disk space, network
adapters, and more.

1. General Syntax

systeminfo [options]

251
Copyright © PendemVamsi. All rights reserved.

Where [options] are flags or parameters used to modify or customize the output.

2. Commands and Options

Command/Optio Description
n

systeminfo Displays detailed system information about the local computer.

/s <hostname> Specifies a remote computer (hostname or IP address) to retrieve


system information.

/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).

/fo <format> Specifies the output format (TABLE, LIST, CSV).

/nh No header, used with /fo to exclude column headers in the output.

/? Displays help information for the command.

3. Examples

3.1 Display Basic System Information

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.

3.2 Display System Information for a Remote Computer

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.

3.3 Display System Information with Specific User Credentials

Command:

systeminfo /s <hostname> /u <username> /p <password>

Example:

systeminfo /s 192.168.1.10 /u Administrator /p P@ssw0rd

Description:​
Fetches system information for a remote computer and runs the command using the
provided username and password.

3.4 Filter Output Based on a Specific Criterion

Command:

systeminfo /fi "<filter>"

Example:

254
Copyright © PendemVamsi. All rights reserved.

systeminfo /fi "OS"

Description:​
Filters and displays only the information related to the operating system. Other filters can
be used, like "Memory" or "Host Name."

3.5 Display Output in a Specific Format

Command:

systeminfo /fo <format>

Example:

systeminfo /fo list

Description:​
Displays the output in a list format. Other available formats include TABLE and CSV.

3.6 Exclude Headers in the Output

Command:

255
Copyright © PendemVamsi. All rights reserved.

systeminfo /fo <format> /nh

Example:

systeminfo /fo csv /nh

Description:​
Displays the output in CSV format but without the header row.

3.7 Display Help Information

Command:

systeminfo /?

Example:

systeminfo /?

Description:​
Displays help information about the systeminfo command and its options.

256
Copyright © PendemVamsi. All rights reserved.

56.​ tasklist - List running processes.


tasklist provides a snapshot of all running processes on a machine, which can be
useful for system monitoring, troubleshooting, or process management. It allows you to
filter the list of tasks based on various criteria, such as memory usage or process name.

1. General Syntax

tasklist [options]

Where [options] are flags or parameters used to modify or filter the output of the
command.

2. Commands and Options

Command/Optio Description
n

tasklist Displays a list of currently running processes on the local


computer.

/s <hostname> Specifies the name or IP address of a remote machine to query


tasks.

/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.

/v Displays verbose information about each process (including


memory usage).

/fi <filter> Filters the output based on specified criteria (e.g., process name,
PID).

/fo <format> Specifies the output format (TABLE, LIST, CSV).

/nh Excludes the column headers in the output (used with /fo).

Terminates the specified process along with any child processes.

/? Displays help information for the command.

3. Examples

3.1 Display All Running Processes

Command:

tasklist

Example:

tasklist

258
Copyright © PendemVamsi. All rights reserved.

Description:​
Displays a list of all currently running processes on the local computer.

3.2 Display All Running Processes on a Remote 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.

3.3 Display All Running Processes for a Specific User

Command:

tasklist /u <username> /p <password>

Example:

259
Copyright © PendemVamsi. All rights reserved.

tasklist /u Administrator /p P@ssw0rd

Description:​
Displays all running processes on the local computer or a remote machine while using
the provided username and password.

3.4 Display Processes Using a Specific Module

Command:

tasklist /m <module>

Example:

tasklist /m kernel32.dll

Description:​
Displays all tasks that are using the specified module (in this case, kernel32.dll).

3.5 Display Detailed Process Information (Verbose Output)

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.

3.6 Filter the Process List by Name

Command:

tasklist /fi "imagename eq <process_name>"

Example:

tasklist /fi "imagename eq chrome.exe"

Description:​
Filters the process list to display only processes named chrome.exe.

261
Copyright © PendemVamsi. All rights reserved.

3.7 Filter the Process List by PID

Command:

tasklist /fi "pid eq <PID>"

Example:

tasklist /fi "pid eq 1234"

Description:​
Displays information about the process with the specified Process ID (PID).

3.8 Display Output in a Specific Format

Command:

tasklist /fo <format>

Example:

tasklist /fo list

262
Copyright © PendemVamsi. All rights reserved.

Description:​
Displays the output in a list format. Other available formats include TABLE and CSV.

3.9 Exclude Headers from Output

Command:

tasklist /fo <format> /nh

Example:

tasklist /fo csv /nh

Description:​
Displays the output in CSV format, excluding the header row.

3.10 Terminate a Process

Command:

tasklist /fi "imagename eq <process_name>"

Example:

263
Copyright © PendemVamsi. All rights reserved.

tasklist /fi "imagename eq notepad.exe"

Description:​
Terminates the process notepad.exe and any associated child processes.

3.11 Display Help Information

Command:

tasklist /?

Example:

tasklist /?

Description:​
Displays help information about the tasklist command and its available options.

57.​ taskkill - Terminate processes or


applications.
The taskkill command in Windows is used to terminate processes by their process ID
(PID) or image name. This command allows you to stop applications and processes from
running on your system.

264
Copyright © PendemVamsi. All rights reserved.

Basic Syntax

taskkill [/f] [/im <imagename>] [/pid <pid>] [] [/fi <filter>]

●​ /f: Forces the process to terminate.


●​ /im <imagename>: Specifies the image name of the process to be terminated
(e.g., notepad.exe).
●​ /pid <pid>: Specifies the process ID to be terminated.
●​ : Terminates the specified process and all its child processes.
●​ /fi <filter>: Specifies a filter to select a set of tasks, such as processes
running as a certain user.

Usage
1. Terminate a Process by Image Name

taskkill /im notepad.exe

●​ Terminates all processes named notepad.exe.

2. Forcefully Terminate a Process

taskkill /f /im notepad.exe

265
Copyright © PendemVamsi. All rights reserved.

●​ Forcefully terminates notepad.exe without prompting for confirmation.

3. Terminate a Process by PID (Process ID)

taskkill /pid 1234

●​ Terminates the process with PID 1234.

4. Terminate a Process and Its Child Processes

taskkill /im notepad.exe

●​ Terminates notepad.exe along with any child processes spawned by it.

5. Terminate Multiple Processes

taskkill /im notepad.exe /im calc.exe

●​ Terminates both notepad.exe and calc.exe processes.

Options

266
Copyright © PendemVamsi. All rights reserved.

Option Description

/f Forcefully terminates the process, ignoring any warning or prompt.

/im Specifies the name of the executable (image) of the process to


<imagename> terminate.

/pid <pid> Specifies the PID of the process to terminate.

Terminates the specified process and all of its child processes.

/fi <filter> Allows you to filter tasks based on specific criteria (e.g., status eq
running).

/s Specifies the remote computer to execute the command on.


<computer>

/u Specifies the username to use for authentication on the remote


<username> computer.

/p Specifies the password to use for authentication.


<password>

Practical Examples
1. Terminate a Process by Image Name

taskkill /im firefox.exe

267
Copyright © PendemVamsi. All rights reserved.

●​ Terminates all instances of firefox.exe.

2. Forcefully Terminate a Process

taskkill /f /im chrome.exe

●​ Forcefully terminates chrome.exe without asking for confirmation.

3. Terminate a Process by PID

taskkill /pid 4567

●​ Terminates the process with PID 4567.

4. Terminate Multiple Processes

taskkill /f /im notepad.exe /im mspmsnsv.exe

●​ Forcefully terminates both notepad.exe and mspmsnsv.exe.

5. Terminate a Process and Its Child Processes

268
Copyright © PendemVamsi. All rights reserved.

taskkill /im explorer.exe

●​ Terminates explorer.exe and any processes launched by it, including Windows


Explorer.

6. Use a Filter to Terminate a Process

taskkill /fi "status eq running" /f

●​ Forcefully terminates all processes with a running status.

7. Terminate Processes on a Remote Computer

taskkill /s remotePC /u user /p password /im notepad.exe

●​ Terminates the notepad.exe process on the remote computer remotePC using


the specified user credentials.

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.

status eq Filters processes that are currently running.


running

status eq Filters processes that are currently stopped.


stopped

imagename eq Filters processes by their image name (e.g., imagename eq


<name> chrome.exe).

pid eq <pid> Filters processes by their PID.

username eq Filters processes by the user who is running them.


<name>

Example: Use Filter to Terminate a Process

taskkill /fi "imagename eq notepad.exe"

●​ Terminates all processes named notepad.exe.

58.​ msconfig - System Configuration Utility.


msconfig is a tool that helps you configure the startup environment of the system. It
allows users to modify startup programs, system services, boot options, and more. It is
often used to troubleshoot performance issues or diagnose system problems by
controlling which programs and services are loaded during startup.

1. General Syntax

270
Copyright © PendemVamsi. All rights reserved.

msconfig

This command will open the System Configuration Utility window.

2. Key Sections in 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.

3. Commands and Options

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

msconfig Opens the System Configuration Utility window.

/selective Opens msconfig in Selective Startup mode, allowing you to


choose which services and programs to disable.

/diagnostic Opens msconfig in Diagnostic Startup mode, loading only


essential services and drivers.

271
Copyright © PendemVamsi. All rights reserved.

/boot Opens the Boot tab for configuring boot options, like Safe Mode.

/services Opens the Services tab for managing services.

/startup Opens the Startup tab for managing startup programs.

ools Opens the Tools tab for accessing various system tools.

4. Examples

4.1 Open msconfig in Normal Startup Mode

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.

4.2 Open msconfig in Selective Startup Mode

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.

4.3 Open msconfig in Diagnostic Startup Mode

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.

4.4 Access Boot Configuration Settings

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.

4.5 Access System Services 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.

4.6 Access Startup Configuration

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.

4.7 Access System Tools

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.

59.​ regedit - Registry Editor.


The regedit tool in Windows allows users to view and modify the Windows registry,
which can significantly impact system behavior. Below is a comprehensive guide of
commands and options related to regedit, including how to gain full access and
perform various operations.

Note: Modifying the registry can be risky. Always back up your registry before making
changes to prevent system instability.

Overview of regedit Commands


General Syntax:

regedit [options]

276
Copyright © PendemVamsi. All rights reserved.

The regedit command is primarily used for accessing, exporting, importing, and
modifying the Windows registry.

Key Options and Commands

1. Open the Registry Editor GUI:

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.

2. Export Registry Keys to a .reg File:

To back up the registry or specific keys:

regedit /e <filename> <key_path>

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.

Additional Export Options:

●​ /s - Silent mode, no confirmation.


●​ /f - Forces the export even if the file already exists.

3. Import Registry File:

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.

Additional Import Options:

●​ /f - Forces import, overwriting any conflicting registry keys.

4. Delete Registry Keys or Values:

To delete a registry key or value:

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:

Export the registry or specific keys silently (no UI confirmation).

regedit /e <filename> /s

Example:​


regedit /e "C:\Backup\system.reg" /s

●​
○​ Exports the registry silently to system.reg.

6. Silent Import:

Import registry settings without any user confirmation (silent mode).

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.

8. Open a Specific Registry Hive:

Use regedit to open a specific registry hive (e.g., HKEY_LOCAL_MACHINE) directly.

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.

9. Open the Registry Editor with Full Access:

You can open the Registry Editor with full administrative privileges using the following
steps:

●​ Open Command Prompt as Administrator (right-click > Run as Administrator).


●​ Then enter:

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:

1.​ Press Windows + R to open the Run dialog.


2.​ Type cmd and press Ctrl + Shift + Enter to run Command Prompt as administrator.

In the Command Prompt window, type:​




regedit

281
Copyright © PendemVamsi. All rights reserved.

3.​
○​ This gives you full access to edit any registry key, as you are operating in
Administrator mode.

60.​ eventvwr - Event Viewer.


Description: The wevtutil utility is used to manage event logs and event log
subscriptions. It provides a set of commands that allow for querying, exporting, and
clearing event logs, among other tasks.

Syntax:

wevtutil <subcommand> [options]

Common wevtutil Subcommands and Options

1. qe (Query Event Logs)

This subcommand is used to query event logs based on specific criteria.

Syntax:

wevtutil qe <LogName> [/f:<Format>] [/c:<NumberOfEvents>] [/rd:<Days>]


[/k:<Key>]

Options:

●​ <LogName>: Name of the log (e.g., System, Application).


●​ /f:<Format>: Specifies the output format. Options are text or xml.

282
Copyright © PendemVamsi. All rights reserved.

●​ /c:<NumberOfEvents>: Specifies the number of events to return.


●​ /rd:<Days>: Filters events generated within the last specified number of days.
●​ /k:<Key>: Filters events containing the specified keyword.

Example:

Query the last 5 events from the System log in text format:

wevtutil qe System /f:text /c:5

2. epl (Export Event Logs)

This subcommand is used to export event logs to a file in XML format.

Syntax:

wevtutil epl <LogName> <FileName>

Options:

●​ <LogName>: Name of the log (e.g., Application, Security).


●​ <FileName>: Path and filename for the exported log (e.g., C:\Logs\log.xml).

Example:

Export the Application log to a file named app_log.xml:

wevtutil epl Application C:\Logs\app_log.xml

283
Copyright © PendemVamsi. All rights reserved.

3. el (List Event Logs)

This subcommand lists all available event logs on the system.

Syntax:

wevtutil el

Example:

List all event logs on the system:

wevtutil el

4. gl (Get Log Information)

This subcommand provides detailed information about a specified event log.

Syntax:

wevtutil gl <LogName>

Options:

284
Copyright © PendemVamsi. All rights reserved.

●​ <LogName>: Name of the log (e.g., System, Security).

Example:

Get detailed information about the Security log:

wevtutil gl Security

5. cl (Clear Event Logs)

This subcommand is used to clear an event log.

Syntax:

wevtutil cl <LogName>

Options:

●​ <LogName>: Name of the log (e.g., Application, System).

Example:

Clear the System log:

wevtutil cl System

285
Copyright © PendemVamsi. All rights reserved.

6. sl (Set Log Properties)

This subcommand is used to set properties on event logs, such as maximum size and
retention policy.

Syntax:

wevtutil sl <LogName> /ms:<MaxSize> [/rt:<RetentionPolicy>]

Options:

●​ <LogName>: Name of the log (e.g., System, Application).


●​ /ms:<MaxSize>: Specifies the maximum size (in bytes) of the log file.
●​ /rt:<RetentionPolicy>: Specifies the retention policy (e.g., AutoBackup).

Example:

Set the maximum size of the Application log to 20 MB:

wevtutil sl Application /ms:20971520

7. sd (Set Security Descriptor)

This subcommand is used to set security descriptors for event logs.

Syntax:

wevtutil sd <LogName> <SecurityDescriptor>

286
Copyright © PendemVamsi. All rights reserved.

Options:

●​ <LogName>: Name of the log (e.g., System, Security).


●​ <SecurityDescriptor>: Security descriptor in the standard SDDL (Security
Descriptor Definition Language) format.

Example:

Set the security descriptor for the Application log:

wevtutil sd Application D:(A;;0x1f01ff;;;SY)(A;;0x1f01ff;;;BA)

8. gp (Get Publisher Information)

This subcommand retrieves information about event log publishers, which are
responsible for writing events to the logs.

Syntax:

wevtutil gp <PublisherName>

Example:

Get information about a specific event log publisher:

wevtutil gp Microsoft-Windows-Security-Auditing

287
Copyright © PendemVamsi. All rights reserved.

Additional wevtutil Usage Examples

Exporting System Log to an XML File:

wevtutil epl System C:\Logs\system_log.xml

Query the Last 10 Events from Application Log:

wevtutil qe Application /f:text /c:10

Clear the Security Log:

wevtutil cl Security

List All Available Logs:

wevtutil el

288
Copyright © PendemVamsi. All rights reserved.

61.​ services.msc - Services management


console.
services.msc is a Microsoft Management Console (MMC) snap-in that provides a graphical
interface for managing Windows services. While there are no direct command-line commands
for services.msc itself, you can manage the services using several actions within the
Services window, and also via command-line tools like net, sc, and PowerShell.

Here's an overview of the actions available within services.msc, including both GUI actions
and command-line equivalents:

How to Access services.msc

To open the Services window (via services.msc):

1.​ Press Win + R to open the Run dialog.


2.​ Type services.msc and press Enter.

Or, search for services.msc in the Windows search bar and click on the result.

Actions Available in services.msc

1. Start a Service

You can start a service that is currently stopped:

●​ Right-click on the service and select Start.

Command-Line Equivalent:

net start <ServiceName>

289
Copyright © PendemVamsi. All rights reserved.

Or using sc:

sc start <ServiceName>

2. Stop a Service

You can stop a running service:

●​ Right-click on the service and select Stop.

Command-Line Equivalent:

net stop <ServiceName>

Or using sc:

sc stop <ServiceName>

3. Pause a Service

You can pause a service temporarily:

●​ Right-click on the service and select Pause.

Command-Line Equivalent:

290
Copyright © PendemVamsi. All rights reserved.

sc control <ServiceName> pause

4. Resume a Paused Service

You can resume a paused service:

●​ Right-click on the service and select Resume.

Command-Line Equivalent:

sc control <ServiceName> continue

5. Restart a Service

You can restart a service (stop and start):

●​ Right-click on the service and select Restart.

Command-Line Equivalent:

net stop <ServiceName> && net start <ServiceName>

Or using sc:

sc stop <ServiceName> && sc start <ServiceName>

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:

●​ Automatic: Starts the service when the system boots.


●​ Manual: Starts the service when needed by another process.
●​ Disabled: The service is completely disabled and will not start.

To change this:

●​ Right-click on the service, select Properties, and change the Startup type under the
General tab.

Command-Line Equivalent: To change the startup type of a service:

sc config <ServiceName> start= <StartupType>

For example:

sc config <ServiceName> start= automatic

Where <StartupType> can be:

●​ auto (Automatic)
●​ manual
●​ disabled

7. View Service Dependencies

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy