If you are new to Linux/UNIX
<<< Previous |  | Next >>>

# Files and filenames

Under most operating systems (including UNIX), there is the concept of a file, which is just a bundle of information given a name (called a filename). Examples of files might be your history term paper, an e-mail message, or an actual program that can be executed. Essentially, anything saved on disk is saved in an individual file.

## Filenames

Files are identified by their filenames. For example, the file containing your conference talk might be saved with the filename `talk.txt`. There is no standard format for file names as there is under MS-DOS and some other operating systems; in general, a filename can contain any character (except the / character–see the discussion of path names below) and is limited to 256 characters in length.

| IMPORTANT
| Unlike MS-DOS, the filenames in UNIX are case-sensitive: `myfile.txt` and `MyFile.txt` are considered as two different files.

You should also be aware of several UNIX conventions; while they are not mandatory, it is usually a good idea to follow them.

- It is customary to use the format `filename.extension` for filenames, where the extension indicates the file type; for example, the extension `txt` is usually used for plain text files, while the extension `jpeg` is used for graphics in JPEG format, and so on. In particular, the `GNOME File Manager` (`Nautilus`) uses extensions to determine file type. You can view or change file extensions recognized by `GNOME` by selecting the section Document Handlers->MIME types in `GNOME Control Center`. Note that the standard convention in UNIX is that the executables (i.e., the program files) have no extension at all.

- Files and directories whose names begin with a dot (.) are usually configuration files, that is, files which keep settings and preferences for various applications. For example, GNOME keeps all its settings in various files in the directories `.gnome` and `.gnome-desktop` in the user's home directory. Since most of the time you do not need to edit these files manually, or even know their precise names and locations, `Nautilus` usually doesn't show these files. You can change this setting as described in Nautilus manual.

- Files with names ending with tilde (~) are usually backup files created by various applications. For example, when you edit a file `myfile.txt` with `emacs`, it saves the previous version in the file `myfile.txt~`.

## Wildcards

When entering commands from the command line, you can use so-called wildcards instead of an exact filename. The most common wildcard is *, which matches any sequence of symbols (including an empty string). For example, the command ls *.txt will list all the files with the extension `txt`, and the command rm chapter* will remove all files with the names starting with `chapter` (ls and rm are UNIX commands for listing and removing files). Another useful wildcard is ?, which matches any single symbol: for example, rm chapter?.txt will remove files `chapter1.txt, chapter2.txt` , but not `chapter10.txt`

Most new GNOME users prefer using the `GNOME File Manager` for operations with files, rather than working from the command line. Wildcards can also be used in `Nautilus` in the file selection and view filter dialogs.

## Using spaces, commas, etc. in file names

As was mentioned above, a file name may contain not only letters and numbers, but also spaces, commas, etc. — any characters other than slash (/). However, if you are using commands typed on the command line, you should be careful when dealing with such files. To avoid problems, it is advised that you enclose filenames that contain anything other than letters, numbers, and dots, in single quotes: to delete file `My File`, you should type rm 'My File' rather than rm My File.

Of course, if you are only using graphical tools such as GNOME File Manager, than you do not need to worry about this: to delete file `My File`, just drag it to the trash can.

<<< Previous | Home | Next >>>
Users |  | Directories and paths