A little UNIX and PicoFile NamesFor every file you create, you must supply a name. In Unix, the following characters have special meaning, so you should avoid using them in file names:/ \ " ` ' * | ! ? ~ $ < > & File names may be between 1 and 255 characters long, but you will find that short, descriptive names are easiest to use. File names should not contain spaces. Instead of spaces, use underscores or periods to separate names made of multiple words, as follows: mail.Jan annual_report unix_tips Also, Unix distinguishes between uppercase and lowercase letters. For example, Unix would treat these as three different files: project1 Project1 PROJECT1 Create a File With a Text EditorPico is a text editor that permits you enter, edit, and re-arrange text in files.
To create a new file using the Pico text editor, enter: pico file Note: the p in the pico command is lowercase. This starts the Pico text editor and opens a blank file. Pico assigns to that file the name you specify. Use your keyboard to add text to the file. To save a file and exit the Pico text editor:
To re-open and edit a file with the Pico text editor, enter: pico file Where file is the name of the file you want to edit.
List Your FilesTo list the files in your current directory, use the ls (list) command. At the system prompt (e.g., dante%), enter:ls Your list might resemble the following: mail murphy.law phone.dir sport.quote To Move to Another Directorycd myChildDirectory cd .. moves to the immediate parent directoryCopy a FileTo copy a file, use the cp (copy) command. Enter:cp file1 file2 This creates a copy of file1 and names it file2. To copy a file to a different directory, enter: cp file directory This creates a copy of the file you specify in directory the you specify. Change the Name of a FileTo change the name of a file, use the mv (move) command. Enter:mv file1 file2 This changes the name of file1 to file2. View a FileTo view a file, use the more command. Enter:more file This starts the more program, which lets you view the file you specify one screen at a time. Use <Spacebar> to scroll forward one screen, <Return> to scroll forward one line, and q to quit the more program. To search for a word in the file, type / followed by the word and then press <Return>. Delete a FileTo delete a file, use the rm (remove) command. Enter:rm file This permanently removes the file you specify. Make a DirectoryTo make a directory, use the mkdir (make directory) command. Enter:mkdir directory This will make a directory with the name you specify
Delete a DirectoryYou can use the rmdir (remove directory) command to delete a directory. Before you can delete a directory, it must be empty of all files.To delete a directory, enter: rmdir directory Determine Your Current DirectoryIf you forget the name of your current directory, you can use the pwd (print working directory) command.To display the name of your current directory, enter: pwd For a user with the userid "jjaudubon," who is working in their home directory, the pwd command display would look something like this: /ua19/S0/jjaudubon File and Directory Permissions and AccessYou decide who can use your files and directories by setting permissions. Each file and directory has three types of permissions:
You set these permissions for three classes of users:
You can view the permissions of your files using the ls -l command. The ls -l command lists the contents of your directory in long format. For example:
The first character indicates file type: a - (hyphen) indicates an ordinary file, and a d indicates a directory. Unix considers the next nine characters as three sets of three. The first set of three determines the owner's permissions, the second set determines the group's permissions, and the third set determines all others' permissions. If you wish to change the permissions of a file or directory, you can use the chmod (change mode) command. The chmod command uses a number code. Each permission setting corresponds to a number between 0 and 7. For each file or directory, you assign three numbers between 0 and 7.
The following shows how the permissions correspond to each number code:
To change the permissions of a file, enter: chmod code file Where code is the three-digit number corresponding to the permissions you desire. Note: When you set permissions for a file that you want others to use, you must make sure that your directories along the pathname leading to the file also have the appropriate permissions.
|