收集了一些常用命令行在Windows和Linux环境下的对照表,部分命令需要管理员权限运行。
功能名称 | Windows | Linux |
打印当前目录 | cd | pwd |
列出当前目录文件 | dir | ls -l |
复制一个文件到另一个文件 | copy file.txt copy.txt | cp file.txt copy.txt |
删除一个文件 | erase file.txt | rm file.txt |
打印当前文件内容到屏幕 | type file.txt | cat file.txt (只打印原始文件) strings file.txt(只打印字符内容) |
打印一个文本,逐个屏幕打印。按回车键打印下一行。 | type file.txt | more |
将文本写入一个文件 | echo "Four score" > 1.txt | echo "Four score" > 1.txt |
追加文本到一个文件结尾 | echo "new text" >> 1.txt | echo "new text" >> 1.txt |
合并两个文件 | type 1.txt 2.txt > 3.txt | cat 1.txt 2.txt > 3.txt |
打印当前使用用户名 | whoami | whoami |
隐藏命令行错误信息 | comand parm 2>nul | YOUR COMMAND 2>/dev/null |
查找一个文件,在当前文件系统中 | dir c:\ /b/s | find "file" |
查看当前所有环境变量 | set | env |
查看一个环境变量 | set Path | echo %Path% |
执行一个可执行文件 | file.exe | ./file |
查看计算机的网络连接 | netstat -nao netstat -naob (与上相同,多了个进程名,需要管理员权限运行) | netstat -ant netstat -pant (与上相同,多了个进程名,需要root权限运行) |
过滤指定端口进程 | netstat -naob | findstr port |
查看运行中的进程 | tasklist wmic process list full (Same, more info) | ps -aux |
获取指定进程ID的详细信息 | wmic process where ProcessID=45 | ps -Flww -p 45 |
打印主机名 | hostname | hostname |
ping一个IP地址4次 | ping 192.168.1.200 | ping -c4 192.168.1.200 |
查看计算机IP地址 | ipconfig | ip addr |
查看命令行帮助信息 | cd /? | man cd(更详细) cd --help (简洁) |
查看可执行文件环境变量目录 | echo %PATH% | echo $PATH |