Historically, there is one special command to find out what files are in a directory, and also one trick to find out what files are in a directory. The command to produce a directory listing is called ls, short for list. On a SuSE 5.3 Linux system, there are 31 options to this command with both single letter and long word versions. We can list only subdirectories, we can sort by creation time, by modification time or by access time. We can invert the sense of any kind of sorting. And a bunch of other options.
But the default way to use the list command, produces a listing of all the files in the current directory that do not start with a leading period (or dot, '.') in alphabetical order (upper case preceeding lower case). This business about ignoring files which start with a leading dot is to allow us to ``hide'' user configuration files and directories in each user's home directory. For example, the login (only) start-up file for the c shell (csh) is .login and the start-up file for the Bourne again shell (bash) is .profile.
If we give one or more names (or patterns) to the ls command, it will produce listings for those files or directories (a directory being just a special kind of file).
If we do a complete (-a or -all option) listing, we will always see a file called ``.'', and a file called ``..''. These are not real files, but rather they are symbolic representations of where we are now, and what our parent directory is. If we are in /home/Igor, and we ask for a listing of ``.''
ls .(which means our current working directory, or here), we will get the same listing as if we just asked for the default listing. As far as the ls command goes, this is a useless sort of symbol, but it comes in handy later on.
If we are in /home/Igor, and we ask for a listing of ``..'', we will get a listing for /home, which is our parent directory.
ls .. IgorProceeding or following Igor could be directories for other ``users''. A common directory here is ``ftp'', but this is always true.
The other common option to the ls command is (-l -format=long -format=verbose). You can guess from the two different long word versions of this command, that some kind of long (verbose/complete) listing will be produced. Typically the first line is total N, where N is how many blocks of storage are used. After that, we get a number of lines which can look like:
drwxr-xr-x 2 Igor users 1024 May 29 17:13 directory1 -rw-r--r-- 1 Igor users 12345 Sep 17 20:18 file1 -rwxr-xr-x 1 Igor users 17 Aug 2 09:13 file2 -rw-rw-rw- 1 Igor users 962 Jun 4 12:20 file3
The first 10 characters on these lines describes the file. If the first character is a d, the file is actually a directory. If the first character is a -, it is an ordinary file. There are other things which can appear in this first character (a l) will be explained later.
Then we have 9 character positions, which are usually filled with one of -rwx. These are the permissions of the file.
Next, we have a number. This number is a count of the ``links'' (hard) to the file in question. Another thing to be explained later.
Following that is the name (or number) of the owner of the file, and the group (or number) of the file. The owner of a file is kind of obvious, but it is possible for the systems administrator to have different users belong to different groups (by default), and also that any single user might belong to more than one group. More to follow.
Next we have a file size, in this case in bytes. Then we have some kind of date (for files which are quite old, the format of the date drops the time but shows the year).
Last, we have the name of the file.