8.14 Some Useful Commands Related to File System Hierarchy

   

8.14 Some Useful Commands Related to File System Hierarchy

If you understand file system hierarchy, it will not be difficult for you to find a file in UNIX. However, there are some useful commands to help you in your file search.

The which Command

If you want to find out in which directory an executable file or command is located, you can use the which command. For example, if you want to see in which directory the ls command is located, use the following procedure.

 $  which ls  /usr/bin/ls $ 

The which command finds all files that are located in your search path .

The whereis Command

Another command is whereis , which can search and locate source, binary, and manual pages. The following command shows two files that can be used as the cat command and the path to the manual page for the command.

 $  whereis cat  cat: /sbin/cat /usr/bin/cat /usr/share/man/man1.Z/cat.1 $ 

More on the man Command

You can also use the man -k command to search all man pages related to a keyword. The command below searches man pages and shows all commands related to mkdir .

 $  man -k mkdir  dosmkdir(1)             - make a DOS directory mkdir(1)                - make a directory mkdir(2)                - make a directory file mkdirp(), rmdirp()(3G)  - create, remove directories in a path nis_server, nis_mkdir, nis_rmdir, nis_servstate, nis_stats, nis_getservlist, nis_freeservlist, nis_freetags(3N) - miscellaneous NIS+ functions nismkdir(1)             - create NIS+ directories stmkdirs(1)             - Utility to build Scalable Type fonts.dir and charsets. dir files $ 

Before you can use this command, you must create the /usr/share/lib/whatis file using the catman command. This file contains a list of all manual pages, with a short description of each command.

In the above listing generated by the man -k mkdir command, you can see that there is a number specified in parentheses after the name of a command. This number shows the section of the manual pages in which that entry is found. For example, you can see that both sections 1 and 2 contain a manual entry for mkdir . When you use the man mkdir command, the first manual page found by the man command is displayed. If you want to display a particular manual page, you need to specify the section as the argument to the man command. As an example, to display the manual page for mkdir in Section 2, you need to use the man 2 mkdir command instead of man mkdir .


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net