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.

ImportantIMPORTANT
 

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.

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 from GMC 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. For example, if you have a file named My file, and you want to delete it, typing rm My file will not give the desired effect: the command rm will assume that you want to remove files My and file. At best, it will give you an error message; at worst (if you do have a file named My) it will remove a wrong file. The right way to do this is to enclose the file name in single quotes: rm 'My File'. The same should be done for file names containing any symbols that are normally considered as "separators", or have some special meaning; this includes comma (,), star (*), question mark (?), and more. To be on the safe side, quote in this way all file names that contain anything other than letters, numbers, and dots.

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.