You can use various commands to display the current directory, view the contents of a directory, and change directories.
The following sections describe basic terms used in conjunction with directories.
Directory
A directory is a list of references to objects, which can include files, sub-directories, and symbolic links. Each reference consists of two components: a name and a number. The name of the object is used to identify and access the object. The number specifies the inode in which information about the object is stored.
Inode
An inode is a list of information relating to a particular object (for example, file, directory, or symbolic link). The information held by the inode includes the type of object about which the inode holds information, permissions, ownership information, and the locations in which data is stored.
The pwd command identifies the directory that you are currently accessing.
To display the current working directory, perform the pwd command.
$ pwd/export/home/user1
You can use the ls command to display the contents of a directory. To list the files and directories within the specified directory, perform the ls command without arguments.
The syntax for the ls command is:
ls -options filename
To list the contents of the user1 directory, perform the ls command.
$ lsdante dir2 dir5 file.3 file3 fruit2 dante_1 dir3 file.1 file1 file4 practice dir1 dir4 file.2 file2 fruit tutor.vi
You can view a hierarchy of the files and directories in the /export/home/user1 directory, as The image shows.

To display the contents of a specific directory within the current working directory, perform the ls command followed by a directory name.
$ ls dir1coffees fruit trees
To display the contents of a directory that is not in the current working directory, perform the ls command with the complete path to that directory.
$ ls /export/home/user1/dir2beans notes $
Displaying Hidden Files
Some files are hidden from view when you use the ls command. Hidden files often contain information that customizes your work environment. You can use the ls -a command to list all files in a directory, including hidden files. The file names of hidden files begin with a period (.).
To display hidden files, perform the ls -a command.
$ ls -a. dir2 .dtprofile file2 practice .. dir3 file.1 file3 .sh_history dante dir4 file.2 file4 .solregis dante_1 dir5 file.3 fruit .TTauthority dir1 .dt file1 fruit2 tutor.vi
A single period (.) represents the current working directory. The double period (..) represents the parent directory, which contains the current working directory.
Displaying a Long List
You can use the ls -l command to view detailed information about the contents of a directory. The output of the ls -l command displays a long listing of file information as The image shows.

For a long listing of the contents of the user1 directory, perform the ls -l command, from the user1 directory.
$ ls -ltotal 90 -rw-rw—- 1 user1 staff 1319 Mar 14 10:12 dante -rw-rw—- 1 user1 staff 368 Mar 14 10:12 dante_1 drwxr-xr-x 5 user1 staff 512 Mar 14 10:12 dir1 drwxr-xr-x 4 user1 staff 512 Mar 14 10:12 dir2 drwxr-xr-x 3 user1 staff 512 Mar 14 10:12 dir3 drwxr-xr-x 2 user1 staff 512 Mar 14 10:12 dir4 drwxr-xr-x 2 user1 staff 512 Mar 14 10:12 dir5 -rw-rw—- 1 user1 staff 0 Mar 14 10:12 file.1 -rw-rw—- 1 user1 staff 0 Mar 14 10:12 file.2 -rw-rw—- 1 user1 staff 0 Mar 14 10:12 file.3 -rw-rw—- 1 user1 staff 1610 Mar 14 10:12 file1 -rw-rw—- 1 user1 staff 105 Mar 14 10:12 file2 -rw-rw—- 1 user1 staff 218 Mar 14 10:12 file3 -rw-rw—- 1 user1 staff 137 Mar 14 10:12 file4 -rw-rw—- 1 user1 staff 57 Mar 14 10:12 fruit -rw-rw—- 1 user1 staff 57 Mar 14 10:12 fruit2 drwxr-xr-x 2 user1 staff 512 Mar 14 10:12 practice -rwx–x–x 1 user1 staff 28738 Mar 14 10:12 tutor.vi
To view detailed information on the contents of the dir1 directory, perform the ls -l dir1 command from the user1 directory.
$ ls -l dir1total 6 drwxr-xr-x 2 user1 staff 512 Feb 22 14:51 coffees drwxr-xr-x 2 user1 staff 512 Feb 22 14:51 fruit drwxr-xr-x 2 user1 staff 512 Feb 22 14:51 trees
The image shows the list of directories and files in the dir1 directory.

Displaying Individual Directories
You can use the ls -ld command to view detailed information about a directory without viewing its contents.
To obtain detailed directory information for the dir1 directory, perform the ls -ld command.
$ ls -ld dir1drwxr-xr-x 5 user1 staff 512 Feb 22 14:51 dir1 $
Displaying a Recursive List
You can use the ls -R command to display the contents of a directory and the contents of all of the directory’s subdirectories. This type of list is known as a recursive list.
To view a recursive list of the contents of the dir1 directory, perform the ls -R dir1 command.
$ ls -R dir1dir1: coffees fruit trees dir1/coffees: beans brands nuts dir1/coffees/beans: beans dir1/fruit: dir1/trees:
You can use either the ls -F command or the file command to display file types.
Using the ls -F Command
The table shows the symbols used in the ls -F command output.
| Symbol | File Type |
|---|---|
/ |
Directory |
* |
Executable |
| (None) | Plain text file or American Standard Code for Information Interchange (ASCII) |
@ |
Symbolic link |
The following example shows the output of the ls -F command.
$ ls -Fdante dir2/ dir5/ file.2 file3 fruit2 dante_1 dir3/ file.1 file2 file4 practice/ dir1/ dir4/ file1 file.3 fruit tutor.vi $
| Note: A symbolic link is a special type of file that points to another file or directory. |
Using the file Command
You can use the file command to determine certain file types. If you know the file type, you can decide which command or program to use to read the file.
| Note: Normally, in the UNIX environment file suffixes do not indicate the file type unless it was generated by an application, such as StarOffice (.sxw) or Framemaker (.fm). |
The output from the file command can be one of the following:
- Text - Text files include American Standard Code for Information Interchange (ASCII) text, English text, command text, and executable shell scripts.
- Data - Data files are created by programs. The file command indicates the type of data file, such as a FrameMaker document, if the type is known. The file command indicates that the file is a data file if the type is unknown.
- Executable or binary - Executable files include 32-bit executable and extensible linking format (ELF) code files and other dynamically linked executable files. Executable files are commands or programs.
The syntax for the file command is:
file filenames
To view the file type for the dante file, perform the file command and specify the name of the file.
$ file dantedante: English text
When working within the directory hierarchy, you always have a current working directory. When you initially log in to the system, the current directory is set to your home directory. You can change your current working directory at any time by using the cd command.
The syntax for the cd command is:
cd directory
When you perform the cd command without options or arguments, the current working directory changes to your home directory.
To change directories from the user1 directory to the dir1 directory, perform the cd command:
$ pwd/export/home/user1 $ cd dir1 $ pwd /export/home/user1/dir1
Using Path Name Abbreviations
You can use path name abbreviations to easily navigate or refer to directories on the command line. The table shows the path name abbreviations.
| Symbol | Path Name |
|---|---|
. |
Current or working directory |
.. |
Parent directory, the directory directly above the current working directory |
To move to the parent directory for dir1, perform the cd .. command.
$ pwd/export/home/user1/dir1 $ cd ..
Confirm the current working directory by using the pwd command.
$ pwd/export/home/user1
The image shows the dir1 directory and its parent directory, the user1 directory.
You can move up multiple levels of the directory hierarchy by using the cd .. command followed by a slash (/).
$ pwd/export/home/user1 $ cd ../../.. $ pwd / $
Moving Around the Directory Hierarchy
You can either use a relative path name or an absolute path name to move around the directory hierarchy.
A relative path name lists the directories in the path relative to the current working directory. An absolute path name lists all the directories in the path, starting with the root (/) directory.
To change directories using a relative path name, perform the cd command with the path name that starts from the current working directory, user1.
$ cd$ cd dir1 $ pwd /export/home/user1/dir1 $ cd ../dir2 $ pwd /export/home/user1/dir2 $ cd $ cd dir1/coffees $ pwd /export/home/user1/dir1/coffees
To change directories using an absolute path name, perform the cd command with the complete path name from the root (/) directory.
$ cd$ cd /export/home/user1/dir1/coffees $ pwd /export/home/user1/dir1/coffees $
Returning to Your Home Directory
The home directory of a regular user is where the user is placed after logging in. The user can create and store files in the home directory.
| Note: The directory named /export/home is the default directory that contains the home directories of regular users. However, you can configure systems to use the /home directory, instead of the /export/home directory, as the default directory that holds the home directories of regular users. |
Often the name of a user’s home directory is the same as the user’s login name. For example, if your user login name is user1, your home directory would be export/home/user1 or /home/user1.
You can return to your home directory by using two methods:
- Perform the cd command without arguments.
$ cd$ pwd /export/home/user1
- Perform the cd command with the absolute path name to your home directory.
$ cd /export/home/user1
To navigate to a user’s home directory, perform the cd command with a tilde (~) character in front of the user name. The tilde (~) character is an abbreviation that equates to the absolute path name of the user.
| Note: The ~ character is a shell facility and is not available in all shells. |
$ cd ~user1$ pwd /export/home/user1
You can also use the tilde (~) to represent your home directory in a relative path. The tilde (~) in the following example represents the user1 home directory.
$ cd ~/dir1/fruit
You can also use the tilde (~) character to navigate to another user’s home directory.
$ cd ~user2$ pwd /export/home/user2 $ cd $ pwd /export/home/user1




May 30th, 2008 at 10:39 am
Wonderful and informative web site.I used information from that site its great.
May 30th, 2008 at 2:32 pm
Hello admin, nice site ! Good content, eautiful design, thank !