Equivalent UNIX and DOS commands
As a seasoned techie I have had the pleasure of running with PCs before the days of Microsoft Windows (DOS DOS DOS) when edlin was the only text editor available. If you are new to UNIX/Linux from a PC background you can use this post to see some of the similarities between Windows DOS commands and the equivalent UNIX/Linux commands.
DOS / UNIX Commands
Action | DOS | UNIX |
---|---|---|
change directory | CD | cd |
change file protection | ATTRIB | chmod |
compare files | COMP | diff |
copy file | COPY | cp |
Copy all files of a directory recursively | XCOPY | cp -R |
delete file | DEL | rm |
delete directory |
RMDIR RD |
rmdir |
Remove all directories and files below given directory | RMDIR /S DELTREE | rm -R |
directory list --list files and size -- lisr directory/sub directory -- list hidden files |
DIR DIR /V /OS DIR /S DIR /AA |
ls ls -ls ls -R ls -a |
List directory recursively | TREE | ls -R |
edit a file | EDIT | pico |
environment | SET | printenv |
find string in file | FIND | grep |
help | HELP | man |
make directory | MD | mkdir |
move file | MOVE | mv |
rename file | REN | mv |
show date and time | DATE, TIME | date |
show disk space | CHKDSK | df |
show file | TYPE | cat |
show file by screens | TYPE FILENAME | MORE | more |
sort data | SORT | sort |
Check and repair hard drive file system | SCANDISK DEFRAG | fsck debugfs |
Shouw routes and router hops to given network destination | TRACERT | traceroute |
Display/configure network interface | IPCONFIG WINIPCFG | ifconfig |
List command history | DOSKEY /H | history |
Online help/manuals | HELP COMMAND /? | man |
Look for a word in files given in command line | FIND FINDSTR | grep |
Change file permissions/ownershop | ATTRIB | chmod chown chgrp |
List executable name,process id | TASKLIST | ps -efa ps aux top |
Print routing table | ROUTE PRINT | route -n |
Clear screen | CLS | clear |
Text/Line Editor | EDLIN | ed ex vi |
Start graphical desktop | WIN | startx |
Change command prompt | PROMPT | export PS1= |
Create a file link | ASSIGN | ln ln -s |
Start a job in the background | START COMMAND /C | command & |
Display date/time | DATE /T TIME /T | date |
I might add some more commands at a later date, but I guess a search on the web will give more that I am listing
There is a document available @ ftp://www-uxsup.csx.cam.ac.uk/pub/doc/redhat/redhat6.2/gsg-62/ch-doslinux.html which provides more DOS/UNIX commands
For more indepth UNIX/Linux equiv, follow this link to the UNIX/Linux Rosetta Stone http://bhami.com/rosetta.html
Batch file/Shell Script
Batch file Operator | Shell script equivalent | Meaning |
---|---|---|
% | $ | command-line parameter prefix |
/ | - | command option flag |
\ | / | directory path separator |
== | = | (equal-to) string comparison test |
!==! | != | (not equal-to) string comparison test |
| | | | pipe |
@ | set +v | do not echo current command |
* | * | filename "wild card" |
> | > | file redirection (overwrite) |
>> | >> | file redirection (append) |
< | < | redirect stdin |
%VAR% | $VAR | environmental variable |
REM | # | comment |
NOT | ! | negate following test |
NUL | /dev/null | "black hole" for burying command output |
ECHO | echo | echo (many more option in Bash) |
ECHO. | echo | echo blank line |
ECHO OFF | set +v | do not echo command(s) following |
FOR %%VAR IN (LIST) DO | for var in [list]; do | "for" loop |
:LABEL | none (unnecessary) | label |
GOTO | none (use a function) | jump to another location in the script |
PAUSE | sleep | pause or wait an interval |
CHOICE | case or select | menu choice |
IF | if | if-test |
IF EXIST FILENAME | if [ -e filename ] | test if file exists |
IF !%N==! | if [ -z "$N" ] | if replaceable parameter "N" not present |
CALL | source or . (dot operator) | "include" another script |
COMMAND /C | source or . (dot operator) | "include" another script (same as CALL) |
SET | export | set an environmental variable |
SHIFT | shift | left shift command-line argument list |
SGN | -lt or -gt | sign (of integer) |
ERRORLEVEL | $? | exit status |