Windows versus Linux commands
表 1 列出了 Windows 和 Linux 命令的一些不同。
| Command's Purpose | MS-DOS | Linux | Basic Linux Example |
|---|---|---|---|
| Lists files | dir | ls | ls |
| Displays the contents of a text file | type or more | cat or more or less | cat thisfile.txt |
| Copies files | copy or xcopy | cp | cp thisfile.txt /home/thisdirectory |
| Renames a file | ren | mv | mv thisfile.txt thatfile.txt |
| Moves files | move | mv | mv thisfile.txt /home/thisdirectory |
| Deletes files | del or erase | rm | rm thisfile.txt |
| Creates link | mklink | ln | ln -s thisfile.txt thatfile.txt |
| Displays the location of files | where | locate or which | locate myfile.txt |
| Compares the contents of files | fc | diff | diff file1 file2 |
| Finds a string of text in a file | find or findstr | grep | grep word or phrase thisfile.txt |
| Sort input | sort | sort | sort thisfile.txt |
| Displays your location in file system | cd or chdir | pwd | pwd |
| Changes directories | cd pathname | cd pathname | cd /path/to/directory |
| Creates a directory | mkdir or md | mkdir | mkdir directory |
| Displays a directory structure | tree | find | find . |
| Sets file permissions | attrib | chmod or chown | chmod u+x myscript.sh |
| Displays a environment variable | set var or echo %var% |
echo $var | echo $var |
| Sets environment variable | set var=xxx | export var=xxx | export var=xxx |
| Lists environment variables | set | env | env |
| Displays PATH | path or set path |
echo $PATH | echo $PATH |
| Displays running tasks | tasklist | ps -ef | ps |
| Kills a running process | taskkill | kill | kill pid |
| Defines aliases | doskey (doskey ls=dir /B $*) |
alias | alias ll='ls -l' |
| Changes the command prompt text | prompt | export PS1=xx | export PS1="\u@\h \w> " |
| Clears screen | cls | clear | clear |
| Closes shell prompt | exit | exit | exit |
| Displays or sets date or time | date or time | date | date |
| Displays OS version | ver | uname -a | uname -a |
| Displays command help | command /? | man or info | man command |
参考:
Windows Command-Line Reference
A Comparison of Common DOS and Linux Commands
Windows DOS vs. Unix commands