Header image  
DOS, UNIX Commands  
line decor
  HOME :: BUSINESS :: COMPUTING :: LIFESTYLE :: PASTIME ::
line decor
   
 DOS command and its equivalent on UNIX.:: A website with Linux Man pages... http://www.ss64.com/bash/
 
       

DESCRIPTION DOS UNIX
Change file protection attrib chmod
Change file to a hidden file - rename file with prefix "." ATTRIB +h or -h mv file .file
Create a file or Directory link assign ln
Backup backup tar (backup to floppy tar -cvf /dev/fd0 files, mdir, mcopy, doswrite -a file (AIX)
Execute script from within batch shell CALL
COMMAND /C (DOS), CMD (NT)
source script (cshrc)
. script (bash)
clear current screen cls clear / ctrl-l
Change working Directory cd cd
Display directory location chdir pwd
Display free disk space chkdsk df (df -k Space remaining on filesystem), du -s
Compare files comp / fc diff
Copy file copy cp -piv
Display date and time date, time date
Delete file del / erase rm
Delete directory and files in directory

deltree (win 95 & +), rmidr /s (windows NT)

rm -R, rmdir
Display list of files dir/w dir ls / ls -l
List directories contents by reverse time of modification/creation dir *.* /o-d ls -tr
List files and size dir *.* /v /os ls -ls
List directory/sub-directory contents recursively dir /s ls -R
List hiden files dir /aa ls -a
List command history doskey /h history
Set Command alias doskey name=command alias name=command
Edit to text edit <filename.txt>, notepad <filename.txt> vi,pico, gnp, xedit, xemacs, dtpad
Total to partition a hard drive fdisk fdisk
Find a word in file find / findstr grep / fgrep
Format drive format fdformat, mformat, mount, umount, mke2fs
print host name of computer hostname hostname
Get help help man / apropos
Display / configue network interface IPCONFIG (NT)
WINIPCFG (Win 95...)
ifconfig
Show free memory on system mem free, top
Create directory mkdir / md mkdir
Rename or Move a file move / rename mv
Show system info (Command borrowed from AIX) msd lsdev
List services net help start chkconfig --list |grep on
Send pop-up to a MS/Windows PC
Send message to another Unix/Linux user.
NET SEND <node-name> <message> (NT) smbclient -M MS-Windows-host-name, talk
show mounted shares/filesystems net shares df
Start/stop service/daemon NET STARTservice-name
NET STOPservice-name
service service-name start, service service-name stop
print DNS info for host NBTSTAT (Netbios info: -n, -c)
NBTSTAT -a host-name
NBTSTAT -A IP-address
nslookup host-name, host host-name
Display contents of file type cat
Display file with pauses type filename | more more / less <filename>
Change directory cd cd
chdir
List a file more < file more file
Make directory md mkdir
Display search path for executables.
Set PATH environment variable.
PATH
PATH %PATH%;C:\DIR
echo $PATH
PATH=$PATH:/dir
send packet to a network host ping ping
Display print queue print lpq
Print file print lpr
Reboot system reboot shutdown -r now
Rename file rename / ren mv -iv
Restore files from floppy restore a:\files tar -xvf /dev/fd0 files
mdir, mcopy
dosread -a file (AIX only)
Delete directory rmdir / rd rmdir
print routing table route print route -n
Check and repair hard drive file system SCANDISK
DEFRAG C:
fsck, debugfs
Show environment variables set set and env
Set environment variables set variable setenv (for C shell) / export var=val (for Korn shell)
sort data alpha or numerical sort sort
List executable name, process ID number and memory usage of active processes TASKLIST (WIN2K, XP) ps -aux
top
Show routes and router hops to given destination tracert traceroute
List directory recursively tree ls -R
copy all file structure xcopy cp -R
OS/Shell version ver uname -a, echo $shell, cat /etc/issue
Start Windows win startx
zip / pkzip tar and zip Compress and uncompress files/directories. Use tar to create compilation of a directory before compressing. Linux also has compress, gzip

 

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
/ - 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 filename
if [ -e filename ] if-test
If file exists.
ERRORLEVEL $? exit status/return code
PAUSE sleep sleep for specified interval
 

 

 

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 Firsst serial port
Equivalent Linux and MS/Windows GUI Applications:

MS/Windows Command Linux Command Description
C:\WINDOWS\cmd gnome-terminal
konsole
Command Text Terminal
C:\WINDOWS\explorer nautilus --no-desktop File browser
c:\Program Files\Internet Explorer\iexplore firefox
mozilla
Web browser
C:\WINDOWS\notepad
C:\Program Files\Windows NT\Accessories\wordpad
gedit Text editor
C:\Program Files\Microsoft Office\Office10\winword
excel
powerpnt
oowriter
oocalc
ooimpress
MS/Office and Open Office suites (ooffice)
C:\Program Files\Adobe\Acrobat 7.0\Reader\acrord32 acroread Adobe PDF viewer
mspaint tuxpaint
xfig
gimp
Graphics and painting program
C:\Program Files\WinZip\winzip32 file-roller File compress / decompress / pack / unpack
taskmgr ksysguard
qps
gnome-system-monitor
xosview
Process and system load monitor
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.

alias dir="echo 'Use the command: ls -lF'"  
alias tree="echo 'Use the command: ls -R'"  
alias del="echo 'Use the command: rm -iv'"  
alias move="echo 'Use the command: mv -iv'"  
alias rename="echo 'Use the command: mv -iv'"  
alias copy="echo 'Use the command: cp -piv'"  
alias type="echo 'Use the command: cat'"  
alias cls="echo 'Use the command: clear'"  
alias mem="echo 'Use the command: free'"  
alias ver="echo 'Use the command: uname -a'"  
alias A:="echo 'Use the command: mdir a:'"  
alias a:="A:"  alias C:="echo 'No C drive in Linux. 
Go to your home directory with the command: cd'"  
alias c:="C:"  

 

Flavor Product uname -r Released
Microsoft
- IRIX
AT&T SVR4 (System V Release 4)
Berkeley Software FreeBSD
- NetBSD
Hewlett Packard HP-UX
SunSoft SunOS 5.8
Solaris
IBM AIX
Linux Red Hat 9 2.4.20-6smp
Red Hat Enterprise Linux 2.4.21-4.ELsmp
Mandrake, Caldera, etc.

 

Shell Command Default
Prompt
Initialization File History
MSDOS cmd > AUTOEXEC.BAT Began as CP/M from Gary Kildall. Purchased by Microsoft in the mid 1970's for the IBM PC. Ended at version 6.22 (7.1 within OEM Windows 95B)
PCDOS cmd > AUTOEXEC.BAT Jointly developed by Microsoft and IBM until version 5.
- DRDOS > AUTOEXEC.BAT Developed by Digital Research, then purchased by Novell, then Caldera/Lineo in 1999.
Bourne
Shell
sh

&

bsh

$ .profile Developed at AT&T by Stephen R. Bourne in the early 1970s. It was the original and official shell distributed by AT&T and its successor, Unix System Laboratories, now owned by Novell. Considered the fastest, most portable, and easiest shell to learn, it lacked command history and command editing.
Shell scripts developed for public use are usually written in the Bourne shell language and assume a System V Release 1 environment.
Bourne
Again
Shell
bash $ .profile & .bash_profile Created for use in the GNU project started by Richard Stallman of the Free Software Foundation (FSF) to replace all commercial UNIX utilities with freely distributable copyleft. Written by Brian Fox from Sunday, January 10, 1988 until 1993 when Chet Ramey became the official maintainer.
C csh % .login .cshrc (for settings) Developed by William Joy (later Sun Microsystems' chief technology officer) and others at UC Berkeley during the early 1980s for C programming flexiblity. Provides the most shortcuts, but is slower than other shells.
Korn ksh $ - Developed by David Korn in the early 1980s. It combines many of the best features of earlier command processors, so is considered a superset of the Bourne shell.
POSIX sh $ - IEEE Std 1003.1 and IEEE Std 1003.2 supported by SunOS and Solaris
Microsoft Shell msh > - Product code named "MONAD" in the 2004 Longhorn release of Windows provides manipulation of .NET objects and new WinFS type queries. Introduces user-declared System.Management.Automation namespace "commandlets" like unix pipes and "-whatif" directive for testing them.

 

Feature sh csh ksh python

Aliasing

- Yes Yes

Arithmetic expressions

- Yes Yes

Array variables

- Yes Yes

Assignment id=string

Yes - Yes

case statement

Yes - Yes

cdpath searches

SysV

Yes Yes
-clobber overwrite protect - Yes Yes

Command aliases

- Yes Yes

echo -n option

- Yes -

export command

Yes - Yes

foreach statement

- Yes -

getopts built-in command

- - Yes
History of commands - !n fc

glob command

- Yes -

Hash table problems, rehash and unhash commands

- Yes -

Job control (bg, fg, ...)

- Yes Yes

let command

- - Yes

limit, unlimit commands

- Yes -

nice shell built-in

- Yes -

nohup shell built-in

- Yes -

notify shell built-in

- Yes -

onintr command

- Yes -

print command

- - Yes

pushd, popd commands

- Yes -

RANDOM shell variable

- - Yes
repeat last command - !! -
Restricted version rsh - rksh

select statement

- - Yes

setenv, unsetenv commands

- Yes -

SHELL variable specifies command to execute scripts

- Yes -

switch statement

- Yes -

until statement

Yes - Yes

set -x

Yes - Yes

set optionname

- Yes -

Set-uid scripts

- - Yes

Shell functions

SysV

- Yes

Substring selectors :x

- Yes -

trap command

Yes - Yes

typeset command

- - Yes

ulimit command

Yes - Yes

Undefined variable is an error

- Yes -

! special character

- Yes -

@ command

- Yes -

$(...) command expression

- - Yes

*(...) wildcards

- - Yes

{...} wildcards

- Yes -

|& coprocessing

- - Yes

>& redirection

- Yes -

 

 

Function UNIX command DOS command
Find commands apropos to given text "HTTP" apropos "HTTP"
Get a short description of the command "print" whatis print
Read the manual on the command "print"
Linux Man Pages on User commands, Sysadmin, devices, File Formats, System Calls, Libc.
man print help print
Search manual (whatis database on the MANPATH) for topics beginning with the word &auot;printing" man -k print
Clear screen. clear cls
What version of the kernel am I using? uname -r ver
What directory is the shell located? (e.g., /bin/bash) echo $SHELL
What distribution am I using? (e.g., RedHat Linux 9) cat /etc/issue

 

Action UNIX stty DOS
Alternative to Enter Ctrl-J or Ctrl-M
Retrieve last command Esc-K from vi F3
Backspace: Erase last character typed Ctrl-H or # Backspace key
Kill all the way back to the prompt (without executing it) @ or Ctrl-U or Ctrl-X Ctrl-C
Stop Ctrl-Z or q -
Exit / End of file Ctrl-D Ctrl-Z
Scroll forward spacebar
Scroll back up arrow
Stop scrolling Ctrl-S
Resume scrolling Ctrl-Q Ctrl-Q
Swap Command line to KDE Alt+F8
Swap KDE to Command line Ctrl+Alt+F1

 

Action UNIX options & filespec DOS filespec & options
Reboot reboot shutdown -r now
Shut down (halt) a system gracefully - shutdown -h now
Elapsed time (and other statistics) accumulated since last reboot uptime NET STATISTICS
List installed patches showrev -p
patchadd -p
-

 

Action UNIX options & filespec DOS filespec & options
View computers on a network: ? NET VIEW
List shares on a given machine: ? NET SHARE
List user accounts on a given machine: ? NET USER
List user sessions on a given machine: ? NET SESSION
Add computer “homer” to the PDC on the local domain: ? net computer \\homer /add

 

Action UNIX options & filespec DOS filespec & options
List Windows services/UNIX daemons: ? NET HELP START
Start and stop services: ? NET START service

NET STOP service

Pause and continue started services: ? NET PAUSE service

NET CONTINUE service

 

Function UNIX command DOS command
Total Disk Usage (in 512 byte blocks) du -s chkdsk
Disk Usage for directories -in kilobytes df -kah -
Disk Usage for each file du -lR -a -
Disk Quota information DQinfo -
Disk Quota allocation DQalloc -
Disk Quota removal DQrm -
Repartition FAT disk Linux fips.exe

 

Function Linux Microsoft
Kernel root
/boot
"WINNT" or "WINDOWS"
Executables /usr/bin
/usr/lib
/usr/include
/usr/share
/usr/doc
"Program Files"
Drivers /dev Win.../System32
hosts file /etc Win.../System32/Drivers/Etc
One for each User /usr
/user
"Documents and Settings"
Log files /var -
Temporary work files /tmp Temp

 

Action UNIX options & filespec DOS filespec & options
Check current Print Working Directory pwd cd
Return to user's home folder cd
cd ~
Make directory mkdir proj1 mkdir proj1
Remove empty directory rmdir /usr/sam rmdir
or rd
Remove directory -recursively rm -r deltree

 

Action UNIX options & filespec DOS filespec & options
List last access dates of files, with hidden files ls -l -a
List files by reverse date ls -t -r *.* dir *.exe /o-d
List files verbosely by size of file ls -l -s *.* dir *.* /v /os
List files recursively including contents of other directories ls -R *.* dir *.* /s
List file types in color ls -flai --color  
List number of lines in folder wc -l *.xtuml  
List files with x anywhere in the name ls | grep x

 

Linux UNIX File Type Color test
blank - Regular/normal file White -f
/ d Directory/folder Blue -d
*   Program or executable script Green -x
| p Named (fifo) Pipe -p
@ l Symbolic link Aqua -h
=   Socket
  b Block special file -b
  c Character special file -c

 

Action UNIX options & filespec DOS filespec & options
Page the contents a screen at a time: spacebar forward, B for Backward, Q to Quit less   afilename  
Peek at the first and last n lines head -n file
tail -n file
TYPE x.txt | MORE
Create new (blank) file touch afilename
Copy old.file to new.file
-p preserve file attributes (e.g. ownership and edit dates)
-r copy recursively through directory structure
-a archive, combines the flags -p -R and -d
cp old.file new.file Copy old.file new.*
Move old.file (-i interactive flag prompts before overwriting files) mv -i old.file /tmp Copy old.file /tmp
del old.file
Remove file (-intention) rm -i sam.txt del sam.txt
Find and (blindly) remove files in the system with file types of tmp which haven't been accessed in the last 10 days find / -name "*.tmp" -atime +10 -exec rm {} \; -
Find and prompt user mike to OK removal of files in the system with file types of tmp find /usr/home/mike -name "*.tmp" -ok rm {} \; -
Find and print user files in the system with file types of txt find /usr/home -depth -name "*.tmp" -print edit file.txt

 

Redirection & Piping Action UNIX
Read STDIN file feed.txt and output STDOUT to file x.txt and STDERR to file err.txt There is no space between the number and >. Specifying the same file for both input and output erases that file. readnews 0>feed.txt 1>x.txt 2>err.txt
outputs to nowhere Do not use vi or touch commands on /dev/null. This turns it into a file, which confuses Linux start-up scripts. readnews > /dev/null
count entries starting with "a" from a listing ls -l | grep d? | wc
input file schedule into the mail program to output file acctng mail acctng < schedule
Appends output of command to the bottom of AppendedFile. command >> AppendedFile
Concatenate 3 files and pipe to line printer and tee (replicate) it to the screen as well. cat file.1 file.2 file.3 | tee lp

 

Action UNIX options & filespec DOS filespec & options
View a file vi file.txt
EMACS
edit file.txt
Edit file pico myfile edit myfile
view file starting at line number 39 more +39 whatever.txt  
Format text for printer troff file.txt
nroff file.txt
 
Compact (defragment) files   compact
Concatenate files cat file1 file2 to standard output. copy file2 >>file1
Counts -lines, -words, and -characters in a file wc -l  
Displays line-by-line differences between pairs of text files. diff  
calculator bc  
calendar for September, 1752 (when leap years began) cal 9 1752

 

Code Permission Octal Decimal
r-- Read only 0100 4
-w- Write only 0010 2
--x eXecute only 0001 1
rwx Read, Write, eXecute 0111 7

 

- u
user
g
group
o
other
ls -l - rwx r-x r--
chmod binary   4+2+1 4+0+1 4+0+0
chmod octal   7 5 4
umask binary   0+0+0 0+2+0 0+2+1
umask octal   0 2 3