UNIX

2.0 Working With Files

2.1 Filenames

Regardless of where they reside (see Section 10.0, "Directory Structure"), your files must have names, and there are conventions for naming files. Giving your files logical names that describe their contents will help you identify them. Filenames that contain spaces are problematic on UNIX; they should be avoided. Several naming conventions aid organization despite this limitation. One of the most common is using capitalization or underscores to separate words (for example: fileOfText or file_of_data). Also, periods are often used to separate files into categories. For example, two files containing articles of text might be called article1.text and article2.text. This practice facilitates dealing with a group of files all at once: if the name of every file containing text ends with .text, they might all be referenced as a group by the single name *.text. (The asterisk is a "wildcard" that stands for any combination of characters.)

2.2 Listing Files

One of the most commonly used commands is ls, which lists information about files (including their names). The ls command may be used without any flags or arguments by typing ls and pressing RETURN; this will print on the screen the list of all files in the current directory. With the addition of flags and arguments, the ls command can be made to display more vital information about the files in question. Try using the -l and -a switch. ls -l will display the long file listing (includes important info about the file owner,the group and rwx permissions. ls -a will display any hidden files (usually begining with "." such as .profile or .login)



Next Section Previous Section Contents