<<

. 6
( 69 .)



>>


– A warning tells you that
¤ Click the red Close button.
EXIT FROM THE SHELL ABORT WINDOW CLOSURE WHEN
COMMANDS ARE RUNNING there are commands running.
„ Type exit in the Terminal – The Terminal window
– A command such as top ¤ Click Cancel to stop the
window. closes.
is currently running. window from closing.
– The shell terminates.
„ Click the red Close – The Terminal window
button. remains open.




14
1
GET STARTED WITH UNIX




You can add or remove applications from the list of
The Terminal application
commands that the Terminal application automatically
maintains a list of commands that
terminates when you close a window in the Terminal
it terminates if you close a
Inspector window; the list is found in the Processes group
Terminal window while those
of settings. Click the name of the application and then click
commands are running. Those
the Remove button. If you need to add an application to the
commands are rlogin, slogin,
list, simply click Add and type the name of the application.
telnet, and ssh. Each of these is
Be sure to click Use Settings as Defaults to save your
an application that lets you
Window settings. You can also set the Terminal application
connect to another computer and
to prompt you each time you attempt to close a window
run commands as if you were
without typing exit first; or you can set it to never ask you. If
sitting at that computer.
you often connect to another computer via telnet or ssh ”
secure shell ” you may want to remove those applications
from the list to avoid accidentally disconnecting.




Terminal




Window Settings...




– A warning tells you that › To apply this configuration
TERMINATE RUNNING CONFIGURE TERMINAL TO
COMMANDS AND CLOSE CLOSE WINDOWS WHEN
there are commands running. to all Terminal windows, click
THE WINDOW YOU EXIT THE SHELL
Use Settings as Defaults.
¤ Click Terminate to close
– A command such as top „ In a new Terminal
ˇ Click the red Close button
the window and end all of the window, click Terminal ➪
is currently running.
commands for this window. to close the Terminal window.
Window Settings.
„ Click the red Close – The Terminal window – The Terminal window
¤ Click Shell from the
button.
closes. closes.
scroll-down menu.
‹ Click the Close the
window radio button.
15
UNIX FOR MAC



LIST FILES
your filename contains spaces or punctuation symbols

W
hen you are working in the Unix shell, everything
beyond a period, underscore, or dash, you need to place
is represented by a file within the file-based
quotation marks around that filename when you specify it
structure. The file structure is composed of
in a shell command.
directories, which are special types of files that can contain
other files, including other directories. The commands you
When you open a Terminal window, your shell opens in a
type are files as well ” called executable files ” with the
specific directory known as your Home directory. This is
exception of those commands built directly into the shell
unique to each user on your computer, and Unix uses your
application. In fact, your shell itself is an executable file.
Home directory to store the files, which you create using
the various programs you run.
If you are familiar with the Mac OS X operating system, you
are also familiar with the file-structure concept ” everything
The command ls shows you the contents of the current
is stored in folders. The folders of the Aqua interface are the
directory in which you are working. You can use the option
directories of the shell interface ” folders and directories are
-F after the ls command to add an additional marker to
interchangeable terms. The term directory has it roots in Unix,
indicate each type of file. A forward slash (/) after a
while the word folder comes from the Mac OS graphical
filename indicates a directory and an asterisk (*) indicates
interface lineage.
an executable file.
Each file within a directory has a unique name. These names
can contain letters, numbers, symbols, and even spaces,
meaning you can have multiword filenames. However, if



LIST FILES




– The shell displays a list of
¤ Type ls and press Return.
SHOW FILE LIST LIST FILES WITH FILE TYPE
files.
„ Open a Terminal window. „ Type ls -F and press
– The shell displays a list of
– A forward slash indicates a
Return.
files.
directory.

16
2
WORK WITH FILES




SHOW HIDDEN FILES
You can make it more obvious which files are directories

Y
ou can use the -A option with the ls command to
by combining the -A option with the -F option. When you
list hidden files. Computers do not always display
type the command ls -A -F to get a listing of all files, a
all files to the user. They do not do this to deceive
forward slash (/) appears after each directory name. You can
you, but rather to help reduce the visual clutter in file
also combine these options together and type the
listings. Hidden files are usually special files, set apart
command as ls -AF. This command lists hidden files and
from the files that Unix users create and update. They
highlights directories at the same time.
may be configuration files or files that establish your shell
environment. However, there are times that you may need
You can run the ls command with an argument specifying
to see a listing of all of your files, both hidden and normal,
the name of a file or directory. If you give a directory
while working with Unix.
name, you see a listing of the contents of that directory. If
the argument is an ordinary file, only the name of the file
Unix hides files by giving them a filename starting with a
appears. If you specify a filename or directory that does not
period (.). Most commands, including the ls command,
exist, the ls command tells you that there is no such file or
ignore these files. You cannot see them in a normal file
directory.
listing. They also do not appear in the Mac OS X Finder.
However, you can list them along with the visible files by
using the ls -A command.




SHOW HIDDEN FILES




– The shell displays the
„ Type ls -A and press ¤ Type ls -A -F and press ‹ Type ls -AF Library and
Return. Return. press Return. contents of the Library
directory, indicating hidden
– The shell displays hidden – The shell identifies the files and directories.
files. directories with a forward
slash.
17
UNIX FOR MAC




SHOW FILE ATTRIBUTES
directories that reference that file. These references, also

Y
ou can show the attributes of each file, including the
called links, include the directory containing the file itself,
owner, permissions, and file size, by using the -l
so each file has at least one reference. For directories, the
option with the ls command. Each file or directory
reference represents the number of files within each
has certain attributes that control who owns it and who can
directory. The third and fourth columns show the user and
access it. All files have an owner, who is usually the user
group associated with the file. The fifth column shows the
who created the file. For example, you are the owner of the
size of the file in characters or bytes. The sixth column
files in your Home directory. You can also associate a file
shows the date and time the file was last modified. The final
with a certain group; groups are collections of users to
column shows the name of the file.
whom you can grant access privileges as a group.
If you want to examine an individual file, you can give the
When you type the ls -l command, you see one line for
filename as an argument to the ls -l command. Using the
each file in the current directory, appearing in columns. The
ls -l command on a directory lists the contents of the
first column indicates the file mode; it looks like a series of
directory, although you can use the -d option to request the
dashes and seemingly random letters such as d, r, w, and x.
attributes of the directory without the directory contents.
The next column shows the number of other files or

SHOW FILE ATTRIBUTES




– The file mode lists the file – The owner and group – The time and date of the
LIST FILES AND ATTRIBUTES
permissions. indicate file ownership. last modification is shown.
„ Type ls -l and press
– The references count is the – The size of the file is – Files are listed in order by
Return.
number of links to the file. expressed in bytes. filename.
– The shell displays the file
attributes.




18
2
WORK WITH FILES

The file mode indicates the file type and permissions. The first
character is a d for a directory, or a dash for a normal file. The
other nine letters are read in sets of three. The first set represents
the permissions for the file owner, the middle set represents access
by anyone in the file's group, and the last set is for all other users.
The first letter in each set, r, controls read access for the set of
users. The second letter, w, controls write access. The last letter, x,
designates execution access or, for a directory, access to directory
files. Dashes in the mode field indicate that the corresponding
permission is not set for the associated set. For example, rw-
indicates that the users can read and write, but not execute the file.

<<

. 6
( 69 .)



>>