Windows常用命令大全,收藏你就是Windows极客!

admin 2024年7月14日18:08:53评论7 views字数 5851阅读19分30秒阅读模式

点击上方网络技术干货圈选择设为星标

优质文章,及时送达

Windows常用命令大全,收藏你就是Windows极客!

转载请注明以下内容:

来源:公众号【网络技术干货圈】

作者:圈圈

ID:wljsghq

Windows操作系统提供了许多实用的命令行工具,通过命令行界面(Command Prompt)或Windows PowerShell,用户可以执行各种任务,如文件管理、系统维护、网络配置等。掌握这些命令不仅能提高工作效率,还能帮助用户解决许多复杂的问题。本系列文章将详细介绍Windows操作系统中的常用命令,帮助你成为Windows极客!

Windows常用命令大全,收藏你就是Windows极客!

基础命令

dir

  • 用途: 列出目录中的文件和子目录。
  • 用法: dir [drive:][path][filename] [/a[[:]attributes]] [/o[[:]sortorder]] [/t[[:]timefield]] [/s] [/b] [/l] [/n] [/x] [/c] [/4]
  • 示例:
dir C:Users
Windows常用命令大全,收藏你就是Windows极客!

cd

  • 用途: 改变当前目录。
  • 用法: cd [/d] [drive:][path]
  • 示例:
cd C:Windows
Windows常用命令大全,收藏你就是Windows极客!

copy

  • 用途: 复制文件到指定位置。
  • 用法: copy [/y | /-y] [source] [destination]
  • 示例:
copy C:file.txt D:

move

  • 用途: 移动文件或重命名文件/目录。
  • 用法: move [/y | /-y] [source] [destination]
  • 示例:
move C:file.txt D:

del

  • 用途: 删除一个或多个文件。
  • 用法: del [/p] [/f] [/s] [/q] [/a[[:]attributes]] names
  • 示例:
del C:file.txt

md / mkdir

  • 用途: 创建新目录。
  • 用法: md [drive:]path
  • 示例:
md C:NewFolder

rd / rmdir

  • 用途: 删除目录。
  • 用法: rd [/s] [/q] [drive:]path
  • 示例:
rd C:OldFolder

文件和目录管理

attrib

  • 用途: 显示或更改文件属性。
  • 用法: attrib [+r|-r] [+a|-a] [+s|-s] [+h|-h] [drive:][path][filename] [/s [/d]]
  • 示例:
attrib +r C:file.txt

xcopy

  • 用途: 复制文件和目录树。
  • 用法: xcopy source [destination] [/a | /m] [/d[:date]] [/p] [/s] [/e] [/v] [/w] [/c] [/i] [/q] [/f] [/l] [/g] [/h] [/r] [/t] [/u] [/k] [/n] [/o] [/x] [/y] [/-y] [/z] [/exclude:file1[+file2][+file3]...]
  • 示例:
xcopy C:source D:destination /s /e

robocopy

  • 用途: 高级复制文件和目录,具有更多选项。
  • 用法: robocopy source destination ...] [options]
  • 示例:
robocopy C:source D:destination /mir

tree

  • 用途: 图形方式显示目录结构。
  • 用法: tree [drive:][path] [/f] [/a]
  • 示例:
tree C: /f
Windows常用命令大全,收藏你就是Windows极客!

ren / rename

  • 用途: 重命名文件和目录。
  • 用法: ren [drive:][path] filename1 filename2
  • 示例:
ren C:oldname.txt newname.txt

系统管理

tasklist

  • 用途: 显示当前运行的所有进程。
  • 用法: tasklist [/s [computer] [/u [domain]user [/p
    输入密码查看隐藏内容

    ]]] [/m [module] | /svc | /v] [/fi [filter]] [/fo {TABLE | LIST | CSV}] [/nh]
  • 示例:
tasklist
Windows常用命令大全,收藏你就是Windows极客!

taskkill

  • 用途: 终止进程。
  • 用法: taskkill [/s [computer] [/u [domain]user [/p
    输入密码查看隐藏内容

    ]]] { [/fi [filter]] [/pid [processid] | /im [imagename]]} [/f] [/t]
  • 示例:
taskkill /pid 1234 /f

chkdsk

  • 用途: 检查磁盘并修复文件系统错误。
  • 用法: chkdsk [volume[[path]filename]] [/f] [/v] [/r] [/x] [/i] [/c] [/l[:size]]
  • 示例:
chkdsk C: /f

sfc

  • 用途: 扫描并修复系统文件。
  • 用法: sfc [/scannow] [/verifyonly] [/scanfile=file] [/verifyfile=file] [/offbootdir=offbootdir /offwindir=offwindir]-示例:
sfc /scannow

shutdown

  • 用途: 关机、重启或注销计算机。
  • 用法: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /m \computer [/t xxx] [/c "comment"] [/f] [/d [p|u:]xx:yy]]
  • 示例:
shutdown /s /t 0

systeminfo

  • 用途: 显示计算机的详细配置信息和操作系统属性。
  • 用法: systeminfo [/s [computer] [/u [domain]user [/p
    输入密码查看隐藏内容

    ]]] [/fo {TABLE | LIST | CSV}] [/nh]
  • 示例:
systeminfo
Windows常用命令大全,收藏你就是Windows极客!

网络相关命令

ipconfig

  • 用途: 显示所有当前TCP/IP网络配置值。
  • 用法: ipconfig [/allcompartments] [/all] [/renew [adapter]] [/release [adapter]] [/renew6 [adapter]] [/release6 [adapter]] [/flushdns] [/registerdns] [/displaydns] [/showclassid adapter] [/setclassid adapter [classid]] [/showclassid6 adapter] [/setclassid6 adapter [classid]]
  • 示例:
ipconfig /all
Windows常用命令大全,收藏你就是Windows极客!

ping

  • 用途: 通过发送ICMP回显请求检测网络连接。
  • 用法: ping [-t] [-a] [-n count] [-l size] [-f] [-i ttl] [-v tos] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] target_name
  • 示例:
ping baidu.com
ping 192.168.1.1 -t
Windows常用命令大全,收藏你就是Windows极客!

tracert

  • 用途: 跟踪数据包到达目标主机的路径。
  • 用法: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name
  • 示例:
tracert baidu.com
Windows常用命令大全,收藏你就是Windows极客!

netstat

  • 用途: 显示网络连接、路由表、接口统计等信息。
  • 用法: netstat [-a] [-e] [-n] [-o] [-p proto] [-r] [-s] [-t] [-x] [-y] [interval]
  • 示例:
netstat -an
Windows常用命令大全,收藏你就是Windows极客!

nslookup

  • 用途: 查询DNS信息。
  • 用法: nslookup [-option] [hostname] [server]
  • 示例:
nslookup baidu.com
Windows常用命令大全,收藏你就是Windows极客!

net

  • 用途: 用于网络命令的一个通用命令,可以执行许多网络管理任务。
  • 用法: net [accounts | computer | config | continue | file | group | help | helpmsg | localgroup | name | pause | print | send | session | share | start | statistics | stop | time | use | user | view]
  • 示例:
net user
net share
Windows常用命令大全,收藏你就是Windows极客!

磁盘管理

diskpart

  • 用途: 磁盘分区管理。
  • 用法: diskpart
  • 示例: 进入diskpart后,可以使用以下子命令:
list disk
select disk 0
list partition
create partition primary size=10000

format

  • 用途: 格式化磁盘。
  • 用法: format volume [/fs:file-system] [/v:label] [/q] [/a:size] [/c] [/x] [/p:count] [/s:state] [/f:size]
  • 示例:
format D: /fs:ntfs

diskcopy

  • 用途: 复制整个磁盘的内容。
  • 用法: diskcopy [drive1:] [drive2:]
  • 示例:
diskcopy A: B:

vol

  • 用途: 显示磁盘卷标和序列号。
  • 用法: vol [drive:]
  • 示例:
vol C:

label

  • 用途: 创建、改变或删除磁盘卷标。
  • 用法: label [drive:][label]
  • 示例:
label C: NewLabel

用户管理

net user

  • 用途: 添加、删除或更改用户账户。
  • 用法: net user [username
    输入密码查看隐藏内容

    [options]] [/domain]
  • 示例:
net user newuser password /add

net localgroup

  • 用途: 添加、显示或修改本地组。
  • 用法: net localgroup [groupname [username [ ...]] [/add | /delete] [/domain]]
  • 示例:
net localgroup administrators newuser /add

runas

  • 用途: 以其他用户身份运行程序。
  • 用法: runas [/profile] [/env] [/netonly] /user:UserAccountName program
  • 示例:

    runas /user:administrator cmd

其他有用命令

echo

  • 用途: 显示消息,或打开/关闭命令回显。
  • 用法: echo [on | off] [message]
  • 示例:
echo Hello, World!
Windows常用命令大全,收藏你就是Windows极客!

type

  • 用途: 显示文件内容。
  • 用法: type [drive:][path]filename
  • 示例:
type C:file.txt

find

  • 用途: 搜索文本文件中的字符串。
  • 用法: find [/v] [/c] [/n] [/i] "string" [[drive:][path]filename[ ...]]
  • 示例:
find "search text" C:file.txt

sort

  • 用途: 排序输入。
  • 用法: sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec recordbytes]
  • 示例:
type C:file.txt | sort

fc

  • 用途: 比较两个文件或文件集,并显示它们之间的差异。
  • 用法: fc [/a] [/b] [/c] [/l] [/lbn] [/n] [/t] [/u] [/w] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2
  • 示例:
fc C:file1.txt C:file2.txt

cls

  • 用途: 清除命令提示符窗口。
  • 用法: cls
  • 示例:
cls

prompt

  • 用途: 改变命令提示符。
  • 用法: prompt [text]
  • 示例:
prompt $p$g

批处理和脚本

批处理文件(Batch file)是包含一系列命令的文本文件,通过执行批处理文件,可以自动化执行多个命令。这些文件的扩展名通常为.bat.cmd

基本批处理命令

  • echo: 显示消息或打开/关闭命令回显。
echo Hello, World!
  • @: 在批处理文件中抑制命令回显。
@echo off
  • rem: 注释行。
rem This is a comment
  • pause: 暂停批处理文件的执行并显示提示信息。
pause
  • if: 条件判断。
if exist C:file.txt echo File exists
  • goto: 跳转到标签。
goto label
:label
  • call: 调用另一个批处理文件。
call anotherbatchfile.bat
  • exit: 退出批处理文件。
exit

以下是一个简单的批处理文件示例,展示了如何使用上述命令:

@echo off
echo Starting the batch file
rem Check if a file exists
if exist C:file.txt (
    echo File exists
else (
    echo File does not exist
)
pause
echo End of batch file
exit

总结

基础命令

命令 解释
dir 列出目录中的文件和子目录
cd 改变当前目录
copy 复制文件到指定位置
move 移动文件或重命名文件/目录
del 删除一个或多个文件
md/mkdir 创建新目录
rd/rmdir 删除目录

文件和目录管理

命令 解释
attrib 显示或更改文件属性
xcopy 复制文件和目录树
robocopy 高级复制文件和目录
tree 图形方式显示目录结构
ren/rename 重命名文件和目录

系统管理

命令 解释
tasklist 显示当前运行的所有进程
taskkill 终止进程
chkdsk 检查磁盘并修复文件系统错误
sfc 扫描并修复系统文件
shutdown 关机、重启或注销计算机
systeminfo 显示计算机的详细配置信息和操作系统属性

网络相关命令

命令 解释
ipconfig 显示所有当前TCP/IP网络配置值
ping 通过发送ICMP回显请求检测网络连接
tracert 跟踪数据包到达目标主机的路径
netstat 显示网络连接、路由表、接口统计等信息
nslookup 查询DNS信息
net 用于网络命令的一个通用命令,可以执行许多网络管理任务

磁盘管理

命令 解释
diskpart 磁盘分区管理
format 格式化磁盘
diskcopy 复制整个磁盘的内容
vol 显示磁盘卷标和序列号
label 创建、改变或删除磁盘卷标

用户管理

命令 解释
net user 添加、删除或更改用户账户
net localgroup 添加、显示或修改本地组
runas 以其他用户身份运行程序

---END---
重磅!网络技术干货圈-技术交流群已成立
扫码可添加小编微信,申请进群。
一定要备注:工种+地点+学校/公司+昵称(如网络工程师+南京+苏宁+猪八戒),根据格式备注,可更快被通过且邀请进群
Windows常用命令大全,收藏你就是Windows极客!
▲长按加群

Windows常用命令大全,收藏你就是Windows极客!

原文始发于微信公众号(网络技术干货圈):Windows常用命令大全,收藏你就是Windows极客!

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年7月14日18:08:53
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Windows常用命令大全,收藏你就是Windows极客!https://cn-sec.com/archives/2952943.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息