A Linux file name has two parts, the actual name and the extension, usually following the name and separated with a `.'. For example, dataset1.dat tells us that this is a data file containing data from the first experiment. There are many file types in Unix, some simply text files, like documents, some other text files written in a programming language, other files containing code better understood by the kernel than the user (usually executable files), compressed files, still picture, audio, figure files, and so on. Below I will list several file types, with brief decriptions and extensions.
Besides looking at the extension, you can find other information about
the file by doing a directory listing of that file using the command
ls -al (ls will be described in more detail later).
% ls -al outline.ps
-rw-rw-r- 1 vjacobs physgs94 52232 May 21 10:05 outline.ps
There's a lot of information here about the file. At the far left, there is the group of letters and dashes: -rw-rw-r-. This strange looking thing is actually a set of 10 spaces which can be occupied by a letter or a dash. The first space tells you whether the file you are looking at is actually a file or a directory. If it's a file, - is written; if it's a directory, d is written. The remaining 9 spaces describe who can access the file and how it can be accessed. The first three spaces after directory describe user (that's you!) access; the next three, group access (members of the network who have common interests); the last three, access for everybody else. The three spaces always describe read access, write access, and excute access in that order. For example, r-x means that somebody can read or execute your file, but not write (i.e. edit or delete) it. Therefore, in our example above, -rw-rw-r- means that this is a file rather than a directory, and that the user and group can read, write, but not execute the file, while others can only read the file. The 1 following that access info just says that this is one file (if it were a directory, this number would count the number of files, not counting subdirectories, in that directory).
The next two strings vjacobs and physgs94 describe the user (me right now) and the group I'm a part of (namely the physics graduate students entering in 1994). The number 52232 gives the number of bytes the file contains (because an ASCII character is exactly 8 bits or one byte long, this number also is the number of characters in a text file), so you have an idea of its size. The next bit, May 21 10:05 lists the date and time that the file was created. Finally, we have the name of the file, outline.ps.
Here's another directory listing:
drwxrwxr-x 2 vjacobs physgs94 512 Oct 31 1996 mus/
Here is one other directory listing:
% ls -al
drwxrwxr-x 2 vjacobs physgs94 512 May 27 1998 ./
drwxr-xr-x 39 vjacobs physgs94 3072 May 27 1998 ../
Issuing the command ls -al without a filename lists all the files in a directory. This directory seems to have no regular files, and yet is not empty, containing the unusual directories . and ... These directories appear in every directory, because they say something about the current directory. That is, `.' represents the current directory; so the 2 in its listing tells us that there are two files in the current directory, namely `.' and `..'. `..' represents the parent directory. Its listing states that there are 39 files in the parent directory. While these two directories are special, they can be used like ordinary directories in the commands that follow. For example, cd .. means change directory to the parent directory.
Exercise 2: Change directories to /home/vastro/tutorial and view its contents. What can you find out about all its files? How many files are in this directory? Who can and cannot access which files?