A Quick Introduction to Unix/Listing Files and Directories< A Quick Introduction to Unix
Listing files and directoriesEdit
When you log in, 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.
Some files will usually have been created by the System Administrator when your account was created. If no files are visible in your home directory, you will simply return to the Unix prompt.
ls lists only those files whose name does not begin with a dot (.) Files beginning with a dot are hidden files and usually contain program configuration information. They are hidden because they are typically generated by other programs and not directly edited by users.
To list all the files in your home directory, including those whose names begin with a dot, type
% ls -a
The -a in the command is an example of an option. Options change the behaviour of commands. Test the output of ls -l and of ls -la.
Another useful option is -t which displays the directory contents newest first by timestamp.
- Shells and subshells
- Directory Structure
- Changing Directories
- Listing Files and Directories
- Files and Processes
- Exercises 1
- Creating Directories
- Creating Files
- Special Directories
- Exercises 2
- Copying Files
- Moving Files
- Deleting Files
- Exercises 3
- Searching Text Files
- More grep examples
- Permissions on Files and Directories
- Editing Text
- Exercises 4
- My First Shell Script
- Job Control
- Environment Variables