Appendix D. A Comparison of Common DOS and Linux Commands

Many Linux commands typed at a shell prompt are similar to the commands you would type in DOS. In fact, some commands are identical.

This appendix provides common commands used at the DOS prompt in Windows and their counterparts in Linux. Basic examples of how the command are used at the Linux shell prompt are also provided. Note that these commands usually have a number of options. To learn more about each command, read its associated man page (for example, type man ls at the shell prompt to read about the ls command).

Command's PurposeMS-DOSLinuxBasic Linux Example
Copies filescopycpcp thisfile.txt /home/thisdirectory
Moves filesmovemvmv thisfile.txt /home/thisdirectory
Lists filesdirlsls
Clears screenclsclearclear
Closes shell promptexitexitexit
Displays or sets datedatedatedate
Deletes filesdelrmrm thisfile.txt
"Echoes" output to the screenechoechoecho this message
Edits text fileseditgedit([a])gedit thisfile.txt
Compares the contents of filesfcdiffdiff file1 file2
Finds a string of text in a filefindgrepgrep word or phrase thisfile.txt
Formats a disketteformat a: (if diskette is in A:)mke2fs/sbin/mke2fs /dev/fd0 (/dev/fd0 is the Linux equivalent of A:)
Displays command helpcommand /?man or infoman command
Creates a directorymkdirmkdirmkdir directory
Views contents of a filemoreless([b])less thisfile.txt
Renames a filerenmv([c])mv thisfile.txt thatfile.txt
Displays your location in the file systemchdirpwdpwd
Changes directories with a specified path (absolute path)cd pathnamecd pathnamecd /directory/directory
Changes directories with a relative ..
Displays the timetimedatedate
Shows amount of RAM in usememfreefree
a. Gedit is a graphical text editor; other editors you can use in place of Gedit include nano and vi.
b. The more pager can also be used to page through a file one screen at a time.
c. The mv command can both move a file and, if you want to rename a file in the same directory, "move" that file to the same directory with a new name.

Table D-1. Similar Commands