How to open and view the contents of a file on a computer

Updated: 06/07/2019 by Computer Hope

A file may be compiled or created only to be viewed by a particular program. The examples below are used to open a plain text file. If the file looks like garbage when opened, the program being used is not capable of viewing it. Make sure the program you need to open the file is installed and associated with the file type. If you don't know what program to use, determine the file extension and review our file extensions page for a listing of associated programs.

Below is a list of how to view the contents of a plain text file for each of the major operating systems.

Microsoft Windows users

Double-click the file that you want to open. The program the file is associated with will open and the file will be opened in that program.


You can open multiple files, such as Word documents, Excel spreadsheets, plain text files, PDF files, and more, at the same time. The associated programs will open each file and display them on the computer screen.

If the file is unassociated with a program, you will receive an "Open With" prompt. If you don't know which program to use, try using WordPad or Notepad.

If the file is associated with a program, but you want to open it with a different program, hold down the Shift key and right-click the file. Select Open With from the drop-down menu that appears, and then select the program you want to use to open the file.

Open with

Alternative method

  1. Open the program you want to use to view the file. For example, if you wanted to view the file in Microsoft Word, you would open it first.
  2. Once the program is opened, from the File menu, select Open or use the keyboard shortcut Ctrl+O.
  3. In the Open window, browse to the location of the file, select the file, and then click OK or Open.

Windows users can also use the methods mentioned below to open a file using the Windows command line.

MS-DOS and Windows command line users

List files

If you need to view a list of available files in the current directory, you can use the dir command.

Edit command

Locate the file that you want to view. The example below, we will be opening the file autoexec.bat in the current directory.

edit autoexec.bat

If the file does not exist, was entered improperly, or is empty, a blank window similar to the example below is shown.

MS-DOS Editor edit command window

Once you have edited the file or typed the information for the file, click File, and choose Exit. If you do not have a mouse, see the edit command page for keyboard shortcuts and other navigation tips.

After clicking exit, if any changes were made, you'll be asked if you want to save the file. Click Yes to finalize your changes.

  • See our edit command page for further information on this command.

Start command

New, 64-bit versions of Windows no longer support the edit command. You can also use the start command to open a file in a text editor, such as Notepad, using a command similar to the example below.

start notepad hope.txt

In the example above, if the file "hope.txt" did not exist in the current directory, you will be prompted to create a new file.

The start command can also be used to open any file on your computer. For example, if you have Microsoft Word installed on the computer and want to open a Word document from the command line, you would enter the following:

start hope.doc

Type command

If you only want to view the contents of the file, you can also use the type command:

type hope.txt

In the example above, the command would display all of the contents of the hope.txt to the file. If the file is a large file, it will keep scrolling unless you press the pause key. For large files, you can also pipe the command to more as shown in the example below.

type hope.txt | more

In the previous example, the type command displays the contents one page at a time. Pressing the Enter key will advance the output one line at a time and pressing the spacebar advances one page at a time.

  • In MS-DOS, you can also use the type command to display the contents of a text file.

Copy con

If you cannot use any of the methods above, you can also use copy con to create a file.

copy con hope.txt

Once you have entered the above command, the hope.txt file will be created.

After you have typed all the lines, you want to be in the file, press and hold Ctrl+Z. After ^Z is shown on the screen, press Enter to save the file.


The copy con method only creates a basic file. It does not allow you to edit a file or go back and fix any errors that may have been made while creating the line.

macOS users

On a Mac computer, you can double-click a file to open the file in the software program associated with the type of file you are opening. Once the file is opened, you can view the contents of the file and make changes to it.

You can also open a file by selecting it on the desktop, or in the Finder application. Then press the Command key + down arrow key.

Microsoft Windows Explorer

Windows users have an extra utility in the way of Explorer. Any file you need to find can be searched through it. Press the Windows key and "E" at the same to access Windows Explorer.

Unix and Linux users

List files

If you need to view a list of available files in the current directory, you can use the ls command.

Opening, creating, editing, and viewing files in Linux

Because of all the available options for each of the different Linux variants we've given this section a page of its own: