history 8 of 36
Windows (MS-DOS) vs Linux Commands: A Side-by-Side Table
A table of everyday MS-DOS/Windows Command Prompt commands and their Linux equivalents, such as copy and cp, dir and ls, del and rm, with examples.
Written
- Linux basics
- Written for CentOS
From my Linux study notes, 2013. Some commands and versions here are old, so please reuse them carefully. Anything marked "added later", and the notes at the end, explain what has changed since.
When I started on Linux (CentOS) after years of using Windows, it helped to see which Linux command does the same job as the MS-DOS command I already knew. This is the table I used.
MS-DOS and Linux command equivalents
| Command’s purpose | MS-DOS | Linux | Basic Linux example |
|---|---|---|---|
| Copies files | copy |
cp |
cp thisfile.txt /home/thisdirectory |
| Moves files | move |
mv |
mv thisfile.txt /home/thisdirectory |
| Lists files | dir |
ls |
ls |
| Clears screen | cls |
clear |
clear |
| Closes prompt window | exit |
exit |
exit |
| Displays or sets date | date |
date |
date |
| Deletes files | del |
rm |
rm thisfile.txt |
| “Echoes” output on the screen | echo |
echo |
echo this message |
| Edits files with simple text editor | edit |
pico (see note 1) |
pico thisfile.txt |
| Compares the contents of files | fc |
diff |
diff file1 file2 |
| Finds a string of text in a file | find |
grep |
grep "this word or phrase" thisfile.txt (see note 2) |
| Formats a diskette | format a: (if diskette is in A:) |
mke2fs (or mformat) |
/sbin/mke2fs /dev/fd0 (/dev/fd0 is the Linux equivalent of A:) (see note 3) |
| Displays command help | command /? |
man |
man command |
| Creates a directory | mkdir |
mkdir |
mkdir directory |
| View a file | more |
less |
less thisfile.txt |
| Renames a file | ren |
mv |
mv thisfile.txt thatfile.txt |
| Displays your location in the file system | chdir |
pwd |
pwd |
| Changes directories with a specified path (absolute path) | cd pathname |
cd pathname |
cd /directory/directory |
| Changes directories with a relative path | cd .. |
cd .. |
cd .. |
| Displays the time | time |
date |
date (see note 4) |
| Shows amount of RAM and use | mem |
free |
free |
The original version of this table had small footnote links ([a] to [e]) pointing to an old copy of the Red Hat Linux 7.2 Getting Started Guide. Those links have been removed; the useful points are covered in the notes below.
Notes on the table
I checked each pairing. They are correct, with these clarifications:
-
pico:picois often not installed on modern systems.nanois the free editor based on it and works the same way, so usenano thisfile.txt. On CentOS-family systems you may need to install it first (sudo yum install nano, orsudo dnf install nanoon newer releases). -
grepexample fixed. The original example wasgrep this word or phrase thisfile.txt. Without quotes,grepsearches only forthisand treatsword,orandphraseas file names. Put a phrase with spaces in quotes:Terminal window grep "this word or phrase" thisfile.txt -
Formatting a diskette. The original said “ormformat”, which was a typo for “or
mformat”. Floppy disks are rarely used now.mke2fscreates an ext2 file system; for a USB stick or new disk today you would usually use amkfscommand such asmkfs.ext4on the correct partition. These commands erase data, so check the device name first (see my post on fdisk and mounting). -
timeis different on Linux. In MS-DOS,timeshows or sets the clock. On Linux,dateshows the time, buttimeis also a real command: it measures how long another command takes to run (for exampletime ls). Do not mix them up.
Other small differences worth knowing:
- Linux commands and file names are case-sensitive:
File.txtandfile.txtare two different files. - Linux uses forward slashes in paths (
/home/user), Windows uses backslashes (C:\Users). - On Windows,
cdon its own also shows the current directory, just likechdir. On Linux,cdon its own takes you to your home directory; usepwdto see where you are. - Most Linux commands also accept
--help(for examplels --help), which is the closest match to/?. free -hshows memory in human-readable units (MiB/GiB).rmdoes not use a Recycle Bin. A deleted file is gone, so double-check before pressing Enter.datecan set the clock only when run as root (or withsudo). On modern systemd systems,timedatectlis the usual way to view and set the time and time zone.