.. dos + unix



show a comparison between DOS (COMMAND.COM and WinNT CMD.EXE shell commands) and the equivalent Linux/Unix or Bash shell commands.


💡 tri (dos - unix) possible et liens wiki

Command Comparison

DOS Command UNIX Command Action
DIR ls -l (-a all files)
df -k
list directory contents
(space remaining on filesystem)
DIR *.* /o-d
DIR *.* /os

DIR /s
DIR /aa
ls -tr
ls -lS
ls -l | sort +4n
ls -R
ls -a
list dir. contents by reverse time
list files and size
list files and size (Solaris)
list directory/sub-directory contents recursively.
list hidden files
TREE ls -R list directory recursivly
CD cd change directory
MKDIR
MD
mkdir make a new directory
SUBST ln create a file or directory link
RMDIR
RD
rmdir remove a directory
CHDIR pwd display directory location
DEL
ERASE
rm -iv remove a file
RMDIR /S (NT)
DELTREE (Win 95...)
rm -R remove all directories and files below given directory
COPY cp -piv copy a file
XCOPY cp -R copy all file of directory recursivly
RENAME or MOVE mv -iv rename/move a file
TYPE cat display contents of a file
type display the command name's path
MORE more view the contents of a text file one screen
DIR fic.txt /s find find a file (fic.txt) in your computer
find . -name fic.txt -print
HELP or COMMAND /? man online manuals
CLS clear
ctrl-l
clear screen
EXIT
EXIT0
exit
exit 0
exit a shell
FIND
FINDSTR
grep look for a word in files given in command line
find . -name *.htm -exec grep WORD {} \;
findstr /C:"word1 word2" file
findstr /S /C:"word1 word2" file - + subdir
findstr /I /S /C:"word1 word2" file - + ignore up/low
COMP diff compare two files and show differences
FC diff, vimdiff compare two files and show differences
SET set and env list all environment variables
SET variable=value
echo %variable%
set

export variable=value
echo $variable

Set environment variables
show environment variables
ECHO text echo text echo text to screen
SET variable setenv (for C shell) or export VAR=val (for Korn shell. Also VAR=val) set environment variables
PATH
PATH %PATH%;C:\DIR
echo $PATH
PATH=$PATH:/dir
display search path for executables.
set PATH environment variable
PROMPT $p$g export PS1='\h(\u)\W> ' set user command prompt.
DATE or TIME date show date. (also set date - DOS only)
DOSKEY /h history list command history
DOSKEY NAME=command alias NAME=command set command alias
BREAK ON trap trap ctrl-break / Trap signals.
SORT sort sort data alphabetically/numerically
EDLIN ed line mode editor
EDIT filename.txt vi edit a file
BACKUP files A:\ tar -cvf /dev/fd0 files
save files to floppy
RESTORE A:\ files tar -xvf /dev/fd0 files
read files from floppy
ATTRIB [+r|-r] [+a|-a] [+s|-s] [path\file] /s chmod change file permissions. DOS: +:set to -:remove r:Read only a:Archive s:System /s:recursively
ATTRIB +h or -h mv file .file change file to a hidden file - rename file with prefix "."
PRINT lp, lpr print a file
CALL
COMMAND /C (DOS), CMD (NT)
source script (cshrc)
. script (bash)
sh script
execute script from within batch shell
MEM free
top
show free memory on system
TASKLIST (WIN2K,...) ps -aux
top
list executable name, process ID number and memory usage of active processes
MSD msinfo32 lsmod ?? show system info
SCANDISK
DEFRAG C:
fsck
check and repair file system
CHDISK du -s disk usage
FDISK fdisk tool to partition a hard drive
SUBST V: C:\directory\path mount mount a drive letter to a folder/directory on your hard drive
FORMAT mkfs format drive file system
VER uname -a
echo $SHELL
cat /etc/issue
operating system/shell version
pkzip tar and zip compress and uncompress files/directories. Use tar to create compilation of a directory before compressing. Linux also has compress, gzip
HOSTNAME hostname print host name of computer
PING ping send packets to a network host
TRACERT traceroute show routes and router hops to given network destination
IPCONFIG (NT)
WINIPCFG (Win 95...)
ifconfig
display/configure network interface
NETSTAT netstat network statistics
NBTSTAT (Netbios info: -n, -c)
NBTSTAT -A IP-address
nslookup host-name
host host-name
print DNS info for host
NBTSTAT -a hostname lookup NetBIOS names
ROUTE PRINT route -n print routing table
NET HELP START chkconfig --list |grep on list services
NET STARTservice-name
NET STOPservice-name
service service-name start
service service-name stop
start/stop service/daemon
NET SHARES df, mount show mounted shares/filesystems
REBOOT shutdown -r now reboot system

To find out how to do something on UNIX simply type "man -k subject_matter". This will do a key word search for all commands dealing with the subject matter. Then use the appropriate command.
Online manuals are available on all the commands by typing "man command_name"

Shell Descriptor/Operators

DOS Descriptor/Operator UNIX or Bash Descriptor/Operator Description
\ / directory path delimiter
.\ ./ current directory
..\ ../ parent directory
ctrl-z ctrl-d end of file/close shell
ctrl-c ctrl-c interrupt/process break
* * file name wild card
? ? single character wild card
%VAR% $VAR variable prefix
%1 %2 %3 $1 $2 $3 first, second and third shell command line arguments
/ - command line option flag prefix
| | pipe
> > stdout redirection
>> >> stdout redirection overwrite
< < stdin redirection

Shell Script Operators

DOS Operator UNIX (or Bash) Operator Description
@
ECHO OFF
set +v set verbose mode off. -v: Echo each line of shell script as it is executed
% $ command line argument prefix. DOS: %1 Bash: $1 for firs argument
REM # comment (= not processed)
== = string "equal to" comparison
!==! != string "not equal to" comparison
NOT ! negative of test expression
CHOICE case case/switch statement
IF

IF EXIST C:\filename

IF NOT EXIST C:\filename

if [[ test-resulting ]];
then
...
elif ...;
then
...
else
...
fi

if [ -e /dir/filename ];
then

if [ ! -e /dir/filename ];
then

if-test

if file exists

if file does not exist

GOTO ABC
...
:ABC
goto ABC
...
:ABC
branch
FOR ... IN ... DO

FOR %%fff IN (C:\dir\*.*)
DO echo %%fff

for file in list;
do ...;
done

for (( expr1; expr2; expr3; ))
do ...;
done

for loop
ERRORLEVEL $? exit status/return code
PAUSE sleep sleep for specified interval

Bash shell aliases for DOS users:

The following are bash shell aliases which can be added to the system profile or the user's personal profile ($HOME/.bashrc) to correct and help DOS users on Linux.


Devices

DOS Device Linux Device Description
NUL /dev/null send into nothingness
CON stdin stdin from console
PRN
LPT1
/dev/lp0 first printer device
COM1 /dev/ttyS0 first serial port