├── LICENSE ├── Contribution.md ├── CodeOfConduct.md └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Srikrishna Uprety 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Contribution.md: -------------------------------------------------------------------------------- 1 | # Contributing to This Project 2 | 3 | Thank you for your interest in contributing to this project! We welcome contributions from the community to make this project better. 4 | 5 | ## Getting Started 6 | 7 | 1. Fork the repository on GitHub. 8 | 2. Clone the forked repository to your local machine. 9 | 3. Create a new branch for your contributions: `git checkout -b feature/your-feature-name` 10 | 4. Make your changes and commit them with descriptive commit messages. 11 | 5. Push your changes to your fork: `git push origin feature/your-feature-name` 12 | 6. Submit a pull request to the main repository's `main` branch. 13 | 14 | ## Contribution Guidelines 15 | 16 | - Please follow the project's Writing style and conventions. 17 | - Ensure your changes are well-documented. 18 | - Write clear and concise commit messages. 19 | - If you're adding a new Command, provide information for it in `Readme.md` file. 20 | - Test your changes thoroughly. 21 | 22 | ## Code of Conduct 23 | 24 | Please review and adhere to our [Code of Conduct](CodeOfConduct.md). Be respectful and considerate to all contributors and maintain a positive and welcoming environment. 25 | 26 | Thank you for contributing to this project! Your help is greatly appreciated. -------------------------------------------------------------------------------- /CodeOfConduct.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to make participation in our community a harassment-free and inclusive experience for everyone. We are committed to providing a welcoming and respectful environment for all. 4 | 5 | ## Our Standards 6 | 7 | Examples of behavior that contributes to creating a positive environment include: 8 | 9 | - Being respectful and considerate of others. 10 | - Using welcoming and inclusive language. 11 | - Focusing on what is best for the community. 12 | - Being open to constructive feedback. 13 | - Showing empathy towards other community members. 14 | 15 | ## Unacceptable Behavior 16 | 17 | Examples of unacceptable behavior include: 18 | 19 | - Harassment, insults, or derogatory comments. 20 | - Discrimination, racism, or sexism. 21 | - Trolling, insulting/derogatory comments, and personal or political attacks. 22 | - Public or private harassment. 23 | - Publishing others' private information, such as physical or electronic addresses, without explicit permission. 24 | - Any conduct that could reasonably be considered inappropriate in a professional setting. 25 | 26 | ## Enforcement 27 | 28 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting us. All complaints will be reviewed and investigated, and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. 29 | 30 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned with this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 31 | 32 | ## Attribution 33 | 34 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). 35 | 36 | Thank you for helping to make this project a welcoming and respectful space for all. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows Command Prompt (CMD) Commands Guide 2 | 3 | ## Introduction 4 | 5 | Welcome! This guide collects commonly used (and some advanced) native Windows Command Prompt (cmd.exe) commands to help with file management, networking, diagnostics, automation, and system administration. 6 | 7 | Focus: Classic CMD commands (not full PowerShell coverage). Where a command is deprecated or superseded, a note is included. Many commands require an elevated (Administrator) prompt. 8 | 9 | ## How to Read & Use This Guide 10 | 11 | Tips: 12 | - Use `command /?` for built‑in help (often includes switches not listed here). 13 | - Prefix with `runas /user:Administrator` or open an elevated terminal when access is denied. 14 | - Combine commands with `&&` (only run next if success) or `||` (run next if failure). 15 | - Use quotes around paths containing spaces: `"C:\Program Files\App"`. 16 | 17 | Legend: 18 | - (Admin) means the command typically needs elevation. 19 | - (Deprecated) indicates the command is legacy; prefer the noted alternative. 20 | 21 | ## Table of Contents 22 | 23 | 1. File & Directory Management 24 | 2. Text, Search & Comparison 25 | 3. Permissions, Security & Ownership 26 | 4. Disk, Volume & Filesystem Tools 27 | 5. Networking & Connectivity 28 | 6. System Information & Diagnostics 29 | 7. Services, Processes & Scheduling 30 | 8. Boot, Recovery & Integrity 31 | 9. User & Account Management 32 | 10. Environment & Session Utilities 33 | 11. Scripting & Flow Control (Batch) 34 | 12. Miscellaneous & Console UX 35 | 13. Quick Task Examples 36 | 37 | --- 38 | ## 1. File & Directory Management 39 | 40 | - `dir` – List directory contents (switches: `/a`, `/s`, `/b`, `/o`) 41 | - `cd` / `chdir` – Change or show current directory 42 | - `md` / `mkdir` – Create directory(ies) 43 | - `rd` / `rmdir` – Remove directory (use `/s /q` for recursive quiet) 44 | - `copy` – Copy files (simple) 45 | - `xcopy` – Extended copy (legacy; prefer `robocopy` for reliability) 46 | - `robocopy` – Robust Copy (retry logic, mirroring, multithread via `/MT`) 47 | - `move` – Move/rename file(s) 48 | - `ren` / `rename` – Rename file or directory 49 | - `del` / `erase` – Delete file(s) (`/f /s /q` options) 50 | - `forfiles` – Select files by date/age/mask for actions 51 | - `type` – Display file contents 52 | - `more` – Paginate output (`command | more`) 53 | - `cls` – Clear screen 54 | - `tree` – Visual directory tree 55 | - `fsutil` (Admin) – Low‑level filesystem info (use cautiously) 56 | - `subst` – Map a path to a virtual drive letter 57 | - `pushd` / `popd` – Temporarily switch (and restore) directories 58 | - `attrib` – View/change file attributes (+R +H +S +A) 59 | - `where` – Locate executable(s) in PATH 60 | - `comp` – Byte compare (basic) 61 | - `fc` – File compare (text/binary diff) 62 | - `copy con file.txt` – Quick inline file creation (Ctrl+Z to end) 63 | 64 | ## 2. Text, Search & Comparison 65 | 66 | - `find` – Search for a string in a file (basic) 67 | - `findstr` – Advanced text search with regex-like syntax 68 | - `sort` – Sort input or a file 69 | - `more` – Paginate output (listed above) 70 | - `fc` – Compare files (relisted for context) 71 | - `type` – Output file content (relisted) 72 | 73 | ## 3. Permissions, Security & Ownership 74 | 75 | - `icacls` – View/modify NTFS ACLs (replaces legacy `cacls` / `xcacls`) 76 | - `takeown` (Admin) – Take ownership of files/folders 77 | - `cipher` – Encrypt/Decrypt (EFS) + wipe free space (`/w`) 78 | - `whoami /groups` – Show group memberships 79 | - `runas` – Run a program as another user 80 | - `openfiles /query` (Admin) – List open network files 81 | 82 | ## 4. Disk, Volume & Filesystem Tools 83 | 84 | - `chkdsk` (Admin) – Check disk for errors 85 | - `diskpart` (Admin) – Disk partition manager (dangerous if misused) 86 | - `format` (Admin) – Format volumes 87 | - `label` – Change volume label 88 | - `mountvol` – Manage volume mount points 89 | - `vol` – Display volume label & serial 90 | - `defrag` – Defragment drives 91 | - `fsutil` (Admin) – (Also in section 1) advanced operations 92 | - `cleanmgr` – Disk Cleanup utility launcher 93 | - `compact` – Compress/uncompress NTFS files 94 | - `sfc /scannow` (Admin) – System File Checker 95 | - `dism /online /cleanup-image /restorehealth` (Admin) – Repair component store 96 | 97 | ## 5. Networking & Connectivity 98 | 99 | - `ipconfig` – Adapter configuration (`/all`, `/release`, `/renew`, `/flushdns`) 100 | - `ping` – Echo test 101 | - `tracert` – Route path to destination 102 | - `pathping` – Trace + packet loss statistics 103 | - `arp -a` – ARP cache 104 | - `nbtstat` – NetBIOS over TCP/IP diagnostics 105 | - `netstat` – Active connections (`-a -n -o` common flags) 106 | - `nslookup` – DNS queries (interactive mode available) 107 | - `route print` – Routing table 108 | - `route add|delete` – Edit routes 109 | - `getmac` – Display MAC addresses 110 | - `hostname` – Show machine name 111 | - `telnet` – (Optional feature) legacy remote console (Deprecated) 112 | - `ftp` – (Deprecated for secure use; prefer SFTP) basic file transfer 113 | - `net` – Umbrella command: `net use`, `net share`, `net view`, etc. 114 | - `net use` – Map/unmap network drives 115 | - `net view` – List network devices/shares 116 | - `net share` – Manage shared folders 117 | - `net session` – List or close sessions 118 | - `net time` – Query time server (legacy) 119 | - `netsh` – Network shell (`interface`, `wlan`, `firewall`, `advfirewall`) 120 | - `netsh wlan show profiles` – Saved Wi‑Fi profiles 121 | - `netdom` (Domain) – Domain trust & join operations 122 | - `certutil -urlcache * delete` – Clear URL cache (diagnostics/security) 123 | 124 | ## 6. System Information & Diagnostics 125 | 126 | - `systeminfo` – OS + hardware summary 127 | - `ver` – Windows version 128 | - `set` – Show environment variables 129 | - `driverquery` – Installed drivers list 130 | - `msinfo32` – System Information GUI 131 | - `wmic` (Deprecated) – WMI queries (use PowerShell CIM/WMI cmdlets) 132 | - `dxdiag` – DirectX diagnostics 133 | - `tasklist` – Running processes 134 | - `tasklist /svc` – Map services to processes 135 | - `eventvwr` – Event Viewer (GUI) 136 | - `wevtutil` (Admin) – Query/clear event logs 137 | - `perfmon` – Performance Monitor GUI 138 | - `powercfg /energy` (Admin) – Power diagnostics report 139 | - `gpresult /r` – Group Policy resultant set 140 | - `echo %ERRORLEVEL%` – Last command exit code 141 | 142 | ## 7. Services, Processes & Scheduling 143 | 144 | - `taskkill /PID /F` – Force terminate process 145 | - `sc query` – Service status 146 | - `sc start|stop|config` – Control services 147 | - `services.msc` – Services GUI 148 | - `schtasks /create` – Schedule tasks 149 | - `schtasks /query /fo LIST /v` – View tasks verbose 150 | - `timeout /t ` – Delay execution 151 | - `start` – Launch a program/window (`start "Title" command`) 152 | 153 | ## 8. Boot, Recovery & Integrity 154 | 155 | - `bcdedit` (Admin) – Boot configuration 156 | - `bootrec` (Recovery Env) – Repair boot records 157 | - `reagentc /info` – Windows Recovery Environment (WinRE) status 158 | - `sfc /scannow` (Admin) – System file scan (listed earlier) 159 | - `dism /online /cleanup-image /restorehealth` – Component store repair (listed earlier) 160 | 161 | ## 9. User & Account Management 162 | 163 | - `net user` – List/create/modify local users 164 | - `net localgroup` – Local group membership 165 | - `net group` (Domain) – Domain group management 166 | - `whoami` – Current user & SID info 167 | - `whoami /priv` – Privileges list 168 | - `runas /user:` – Execute under another account 169 | - `control userpasswords2` – Advanced user GUI 170 | - `lusrmgr.msc` – Local Users & Groups (not in Home editions) 171 | 172 | ## 10. Environment & Session Utilities 173 | 174 | - `set` – Display/set session environment variables 175 | - `setx` – Persist environment variables (new sessions only) 176 | - `path` – View/edit PATH (session) 177 | - `title` – Set console window title 178 | - `color` – Set console colors 179 | - `mode con` – Console dimensions and buffer 180 | - `echo` – Output text / toggle command echoing 181 | - `pause` – Wait for user keystroke 182 | - `call` – Invoke another batch file and return 183 | - `exit` – Exit CMD / set errorlevel: `exit /b 1` 184 | 185 | ## 11. Scripting & Flow Control (Batch) 186 | 187 | - `for` – Iterate (files, strings, numbers); `for /?` for forms 188 | - `if` – Conditional execution (string, errorlevel, exist) 189 | - `goto` – Jump to label 190 | - `choice` – Prompt for user selection, sets `%ERRORLEVEL%` 191 | - `shift` – Shift batch parameters `%1..%9` 192 | - `set /a` – Arithmetic operations 193 | - `rem` or `::` – Comments 194 | - `>`, `>>` – Redirect (overwrite / append) 195 | - `2>&1` – Merge stderr into stdout 196 | - `|` – Pipe output to another command 197 | 198 | ## 12. Miscellaneous & Console UX 199 | 200 | - `help` – Built-in help index 201 | - `assoc` – File extension associations 202 | - `ftype` – File type command mapping 203 | - `time` – Show/set system time 204 | - `date` – Show/set system date 205 | - `shutdown /s /t 0` – Immediate shutdown 206 | - `shutdown /r /t 0` – Immediate restart 207 | - `shutdown /h` – Hibernate 208 | - `shutdown /l` – Log off 209 | - `shutdown /a` – Abort pending shutdown 210 | - `msconfig` – System Configuration GUI 211 | - `mmc` – Microsoft Management Console 212 | - `taskmgr` – Task Manager 213 | - `clip` – Redirect output to clipboard (e.g., `ipconfig | clip`) 214 | 215 | ## 13. Quick Task Examples 216 | 217 | Create a directory tree and move files: 218 | ``` 219 | md logs\archived && move *.log logs\ 220 | ``` 221 | 222 | Find lines containing ERROR (case-insensitive) in all `.txt` files: 223 | ``` 224 | findstr /i /n /s /c:"ERROR" *.txt 225 | ``` 226 | 227 | Mirror a directory to backup (with logging): 228 | ``` 229 | robocopy C:\Source D:\Backup /MIR /R:2 /W:2 /LOG:backup.log 230 | ``` 231 | 232 | Kill a hung process by name: 233 | ``` 234 | taskkill /IM notepad.exe /F 235 | ``` 236 | 237 | List top TCP listeners: 238 | ``` 239 | netstat -ano | findstr LISTENING 240 | ``` 241 | 242 | Set a persistent environment variable (new sessions only): 243 | ``` 244 | setx APP_ENV production 245 | ``` 246 | 247 | Generate a power efficiency report (HTML): 248 | ``` 249 | powercfg /energy /output energy-report.html 250 | ``` 251 | 252 | Flush DNS cache: 253 | ``` 254 | ipconfig /flushdns 255 | ``` 256 | 257 | ## Deprecated / Legacy Notes 258 | 259 | - `wmic` – Deprecated; prefer PowerShell CIM cmdlets. 260 | - `telnet`, `ftp` – Insecure; use SSH/SFTP alternatives. 261 | - `xcopy` – Superseded for most tasks by `robocopy`. 262 | - `deltree` – Removed after Windows 9x era (use `rd /s`). 263 | - `xcacls` / `cacls` – Deprecated; use `icacls`. 264 | 265 | ## Safety Disclaimer 266 | Commands like `diskpart`, `format`, `bcdedit`, `bootrec`, `dism`, and `sfc` can cause system instability or data loss if misused. Always verify targets and consider backing up important data. 267 | 268 | --- 269 | ### Contribution 270 | We welcome contributions! If you'd like to contribute to this project, please check out our [Contribution Guidelines](Contribution.md). 271 | 272 | ### Code of Conduct 273 | Please review our [Code of Conduct](CodeOfConduct.md) before participating in this project. 274 | 275 | ## License 276 | This project is licensed under the [License](LICENSE). --------------------------------------------------------------------------------