A Quick Introduction to Unix/Listing Files and Directories
Listing files and directories
When you login you are in your home directory. This directory is associated with your userid, for example, ccaajim, and it is where your personal files and subdirectories are stored.
To find out what is in a directory you can type
The ls command lists the contents of your current working directory.
There may be no files visible in your home directory, in which case you will return to the Unix prompt but some files will usually have been created by the System Administrator when your account was created.
ls does not list quite all the files in your home directory but only those ones whose name does not begin with a dot (.) Files beginning with a dot are hidden files and usually contain important program configuration information. They are hidden because you should not change them unless you are very familiar with Unix.
To list all files in your home directory including those whose names begin with a dot, type
% ls -a
As you can see, ls -a lists files that are normally hidden.
ls can take options, for example -a is an example of an option. Options change the behaviour of commands. Test the output of ls -l and of ls -la.
Another very useful option is -t which displays the directory contents newest first by timestamp.
- Shells and subshells
- Directory Structure
- Files and Processes
- Listing Files and Directories
- Exercises 1
- Creating Directories
- Creating Files
- Changing Directories
- Special Directories
- Exercises 2
- Copying Files
- Moving Files
- Deleting Files
- Exercises 3
- Searching Text Files
- Permissions on Files and Directories
- Editing Text
- Exercises 4
- My First Shell Script
- Job Control
- Environment Variables