|
|
To change to a new directory, type cd (change directory) and the pathname of the directory you want to change to, then press <Enter>:
$You tell cd which directory to change to by giving it an argument. You can use either a relative or an absolute (starting with ``/'') pathname as an argument to cd.pwd
/u/susannah $cd /usr/adm
$pwd
/usr/adm
If you type cd with no arguments, you go to your home directory:
$You can also change to your home directory by saying cd $HOME:pwd
/etc $cd
$pwd
/u/susannah
$Try moving around some directories now:pwd
/usr/lib $cd $HOME
$pwd
/u/susannah
/usr/spool/lp/requests: Permission denied
.
(/usr/spool/lp/requests is a directory the computer uses
to store printer requests temporarily.)
$pwd
/u/susannah $cd /etc
$pwd
/etc $cd default; pwd
/etc/default $cd /usr/spool/lp/requests
/usr/spool/lp/requests: Permission denied $pwd
/etc/default $cd; pwd
/u/susannah
Q: Why do I have to press <Enter> after every command?
A:
The carriage return you type at the end of a command line
tells the computer to process the command.
Q: What does the ``;'' do between two commands?
A: The semicolon (;) is a command separator. It tells the computer that the next word is the start of a separate command, instead of an argument for the previous command.
$ cd; pwd
This says ``change directory, print working directory.''
$ cd pwd
This says ``change to the directory named pwd.''
Semicolons allow you to put more than one command on a line before you press <Enter> to have all the commands processed.
Q:
What does the message Permission denied
mean?
A:
The UNIX system uses file and directory
permissions
to control who can look at, and who can change, files.
These permissions are discussed in
``Protecting files and directories''.
When you see the message Permission denied
it means the
permissions on a directory are set so you cannot go into the
directory.
This is frequently the case for system directories, such
as /usr/spool/lp/requests, and for other people's home directories.
Q: What happens if I misspell a directory name?
A: If you misspell a directory name, the computer may attempt to guess what you meant. Type y to accept its guess and change to the directory, or n to return to the prompt:
$cd /etv
cd /etc?y
$pwd
/etc