First, create a text file called about_emacs by entering the following at a command prompt:emacs about_emacs After pressing [Enter], you'll see the Emacs text editor screen, as shown in Figure A. Note that the screen is divided into three main areas, the Edit area where text is typed, the Mode line where status information is displayed, and the Echo area, where commands are entered and prompts and messages from Emacs are displayed.
| Figure A |
![]() |
Pressing [Enter] saves the file about_emacs to the directory Emacsdemo. Now let's switch from the text editor to Dired. Press [Ctrl]X, then D. At the prompt in the Echo area, type the name of the directory you want to display as in the following:Dired (directory): /home/Mary/Emacsdemo
After pressing [Enter], the Edit area will display the directory listing, as shown in Figure B.
| Figure B |
![]() |
Next, you'll need to open about_emacs from the directory list. Position the cursor on the last line within about_emacs by either pressing the N (new line) key, press the down arrow to get to the line, or simply click on the line with your mouse. Once the cursor is positioned, press the E key to open the file and return to edit mode. Now add the date to the file, as shown in Figure C.
| Figure C |
![]() |
To return to Dired, press [Ctrl]X, then press the D key. The directory list is displayed as shown in Figure D.
| Figure D |
![]() |
| Figure E |
![]() |
To create a new directory with Dired, press the Plus symbol key (+). You will then be prompted for the directory name in the Echo area. For this example, call the new directory backup. After pressing [Enter] the backup directory will be added to the listing, as shown in Figure F.
| Figure F |
![]() |
To use Dired to copy the file about_emacs to the backup directory, first position the cursor anywhere within the filename. Then, press [Shift]C. A prompt will appear in the Echo area asking for the name of the directory where you want the file to be copied, which for this example is the backup directory (Figure G).
| Figure G |
To rename a file, first position the cursor over the filename (in this example, about_emacs), and then press [Shift]R. A prompt will appear in the Echo area, asking for the new name; for this example, you would enter about_emacs_v1, as shown below:Rename about_emacs to :/home/Mary/Emacsdemo/backup/about_emacs_vl
After pressing [Enter], the new name will appear in the listing (Figure I).
| Figure I |
![]() |
To change a file's group permissions, move the cursor to the filename, in this case, about_emacs_v1, and press [Shift]G. You'll receive a prompt in the Echo area asking for the new group. Enter the name of that group at the prompt, as shown in Figure J.
| Figure J |
| Figure K |
![]() |
Dired also lets you view a file without going back into Edit mode. To do so, position the cursor over the name of the file you want to view, and press V to display the contents of the file in read-only mode. To return to the directory listing, press Q (quit). You can also print a file by positioning the cursor over the name of the file you want to print, and pressing [Shift]P. Deleting a file
You can also use Dired to delete files from a directory list. First, flag each file to be deleted by positioning the cursor over the name of the file you want deleted and pressing D. (If you mark a file for deletion by mistake, pressing U will clear the D.) Three files flagged for deletion are shown in Figure L.
| Figure L |
![]() |
Dired lets you execute shell commands on any file or directory within a directory list by positioning the cursor on the file or directory (in this example, backup), and then press [Shift]1. The Echo area will then prompt for the command you want to use; in this example, ls is used to list the contents of the backup directory to the file backuplist as shown in Figure M.
| Figure M |
To get back to Edit mode from Dired, press Q. With a little practice, I've found working with Dired and the Emacs text editor a lot quicker and easier than having to work with two or more terminal windows to create, edit, and manage files and directories.















