Navigating and Searching with the Shell

Use the cd command (built into the shell) to navigate through the Ubuntu file system. This command is generally used with a specific directory location, or pathname like this:

Under Ubuntu, the cd command can also be used with several shortcuts. For example, to quickly move up to the parent (higher-level) directory, use the cd command like this:

To return to one's home directory from anywhere in the Linux file system, use the cd command like this:

You can also use the $home shell environment variable to accomplish the same thing. Type this command and press Enter to return to your home directory:

You can accomplish the same thing by using the tilde (~) like this:

Linux also includes a number of GNU commands you can use to search the file system. These include

• whereis command Returns the location of the command and its man page.

• whatis command Returns a one-line synopsis from the command's man page.

• locate file Returns locations of all matching file(s); an extremely fast method of searching your system because locate searches a database containing an index of all files on your system. However, this database (about 4MB in size and named slocate.db under the /var/lib/slocate directory) is built daily at 4:20 a.m. by default, and will not contain pathnames to files created during the workday or in the evening. If you do not keep your machine on constantly, you can run the updatedb command as the super-user to manually start the building of the database.

• apropos subject Returns a list of commands related to subject.

Was this article helpful?

0 0

Post a comment