Changing directories (cd), Changing your current directory, Example file structure – HP NonStop G-Series User Manual

Page 114

Advertising
background image

Note that in the file structure in

Figure 6

, the /project, /project2, and /reports directories

are located one level below your home directory and that the /status directory is located one
level below the /reports directory.

Figure 6 Example File Structure

As for filenames, the maximum length of a directory name is 248 bytes (the default length).

Note that there is no symbol or other notation that automatically distinguishes between a filename
and a directory name, so you may find it useful to establish your own naming conventions to
designate files and directories.

You can use the ls -F command to distinguish between filenames and directory names when the
contents of your current directory are listed. For more information on this command, see

“Displaying

Directories (ls -F)” (page 116)

.

Changing Directories (cd)

The cd (change directory) command changes your current (working) directory. By using the cd
command and specifying the proper pathname, you can move to any directory in the file system
from any other directory in the file system.

Before you can change your current directory to another directory, you must have permission to
access the new directory. For information about directory permissions, see

Chapter 10 (page 121)

.

The general format of the cd command is as follows:

cd pathname

The pathname entry can either be the absolute pathname or the relative pathname of the directory
that you want to set as your current directory.

If you enter the cd command without a pathname, the system returns you to your home directory.

To check the name of your current directory, enter the pwd (print working directory) command.

Changing Your Current Directory

In the following example, which shows you how to change directories, you first enter the pwd
command to display the name (which is also the pathname) of your current directory. You then
use the cd command to change your current directory.

First return to your home directory, if necessary, by entering the cd command without a pathname.
Next, enter the pwd command to verify that your home directory is your current directory (remember
that the name of your home directory will appear instead of /u/uname):

$ cd

$ pwd

/u/uname

Next, enter the cd command with the relative pathname project2 to change your current directory
from your home directory to /project2:

$ cd project2

Enter pwd again to verify that /project2 is the current directory. Then, enter cd to return to your
home directory:

114

Managing Directories

Advertising
This manual is related to the following products: