ag@linux:~$

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

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:

  1. pico: pico is often not installed on modern systems. nano is the free editor based on it and works the same way, so use nano thisfile.txt. On CentOS-family systems you may need to install it first (sudo yum install nano, or sudo dnf install nano on newer releases).

  2. grep example fixed. The original example was grep this word or phrase thisfile.txt. Without quotes, grep searches only for this and treats word, or and phrase as file names. Put a phrase with spaces in quotes:

    Terminal window
    grep "this word or phrase" thisfile.txt
  3. Formatting a diskette. The original said “ormformat”, which was a typo for “or mformat”. Floppy disks are rarely used now. mke2fs creates an ext2 file system; for a USB stick or new disk today you would usually use a mkfs command such as mkfs.ext4 on the correct partition. These commands erase data, so check the device name first (see my post on fdisk and mounting).

  4. time is different on Linux. In MS-DOS, time shows or sets the clock. On Linux, date shows the time, but time is also a real command: it measures how long another command takes to run (for example time ls). Do not mix them up.

Other small differences worth knowing:

  • Linux commands and file names are case-sensitive: File.txt and file.txt are two different files.
  • Linux uses forward slashes in paths (/home/user), Windows uses backslashes (C:\Users).
  • On Windows, cd on its own also shows the current directory, just like chdir. On Linux, cd on its own takes you to your home directory; use pwd to see where you are.
  • Most Linux commands also accept --help (for example ls --help), which is the closest match to /?.
  • free -h shows memory in human-readable units (MiB/GiB).
  • rm does not use a Recycle Bin. A deleted file is gone, so double-check before pressing Enter.
  • date can set the clock only when run as root (or with sudo). On modern systemd systems, timedatectl is the usual way to view and set the time and time zone.