12.07.2015 Views

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Shell Basics 107every command you have ever typed is saved. If you cannot find the command you arelooking for, it may not be in your command history anymore.TIPIf the terminal screen is starting to look cluttered or you just want what is on thescreen to go away, type the command clear to clear the screen and place the promptat the top of the screen.If you are familiar with the Emacs editor (refer to the “Editing Text Files” section later inthis chapter), you might know a few of its shortcuts to delete a word, jump to the beginningof a line, and jump to the end of a line. These shortcuts are also available on thecommand line courtesy of the bash shell. To delete the word in front of the cursor, pressAlt+D. To move the cursor to the beginning of the line, press Ctrl+A. Press Ctrl+E to movethe cursor to the end of the line. To clear the line from the cursor back to the prompt,press Ctrl+U.4These shortcuts can be used in conjunction with the up and down arrows to scroll throughyour command history or the Ctrl+R shortcut to perform a reverse lookup. Why is thisuseful? If you mistyped a long command and don’t want to retype the entire command,just press the up arrow, and use the editing shortcuts to find the typing error, remove it,and replace it with the correct characters. After you have a little practice with it, it will befaster than retyping the entire command. This method is also useful if you are experimentingwith different command-line arguments to the same command. Try one argument,then press the up arrow to try a different argument without having to retype everything.Finding FilesThere are two invaluable commands that can be used to find files on the filesystem:locate and find.The locate command is the easier of the two to use. Just type the command followed bypart or all of the filename you are searching for such as locate .odt to find allOpenOffice.org text files or locate compare to find all filenames that contain the wordcompare. Notice that no wildcard characters are used. It is assumed that what you typemay only be part of the filename you are looking for.The only catch to this command is that it relies on the generation of a database file so itcan quickly display results. The locate command is provided by the mlocate package,which also provides the cron script /etc/cron.daily/mlocate.cron to automaticallygenerate this database daily. If you are looking for a file created that same day, it might notappear in the locate results if the database hasn’t been updated since the file was created.The find command is a bit more complicated to use and takes longer to produce resultsbecause it does not rely on a database to produce results. Because it takes longer, it ispossible to specify a specific directory to look in. The basic syntax is as follows:find -name

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!