HLUG TWiki > HLUG > PresentationCalendar > TopicalVacation > WordPlay > ClassThreeNotes TWiki webs:
AIX| Classes | HALBOD | HLUG | Helpdesk | Library | Main | Samba | TWiki |
HLUG . { Home | Changes | Index | Search | Go }

Mud Diving: First Steps with Linux Utilities

Our class, this time around, is really the first peek we take at the wealth of utilities available to you, on your Linux box. If you walk away from reading this thinking it was all too easy, congradulations, you have reached a new stage in your Linux learning. You are probably ready for a greater challenge. Still, we'll continue our steady pace, so as not to miss anything, and enjoy the scenery along the way. In our next class, we'll cover typing and editing text, so I'll handle reading text in this one. It all boils down to understanding what plain-text is, and how Linux relies upon it.

Here's a technical definition of plain-text, or ASCII, as it is often referred to.

Acronym for the American Standard Code for Information Interchange. Pronounced ask-ee, ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another.

Reference: http://www.webopedia.com/TERM/A/ASCII.html

By using this standard to store all the Linux system information, it is easy open, manipulate, and share these files. The files take up minimal space, and lack any formatting information common to commercial document formats. This is helpful because most Linux utilities can operate on plain text, so lists, letters, notes, and anything else written in plain text can be enlisted in any computing tasks you can cook up.By knowing that your computer's files are a vast alphabet soup of ASCII sequences, it helps to demystify your PC a bit more, as well as to pique your curiosity about what you can do with all that information. Now that you visualize this, let's talk about tools that help you read these plain-text files in various capacities. This stuff is actually pretty easy. What we are doing is very similar to the way a web browser works.

See cat Spit

Instead of browsing HTML files, we are browsing ASCII files. We don't want to edit, just view. In Linux, there are two ways to do this. This first, is the Spartan way, and involves using "cat." "cat" is short for concatenate, and all it does is empty the contents of any file onto your screen. Assuming you can read the text as it streams by, this solution should be good enough. You can try this command out by typing the following command.

cat filename

Not much of a looker, but technically it works. the reason why "cat" stuck around is that even though it's output is too quick for you, is that it is just right for the computer to read. For this reason, "cat" is often used to feed other programs. Remember it's all plain-text, so as far as the computer is concerned, someone is giving it ASCII codes to read, and operate on. It's not much of a perk as a newbie, but later on, "cat" can be very helpful, when combined with other tools.

Less is more, only more...

Luckily, the great *NIX fore-parents saw the need for something better, something more. So "they" wrote a program called "more." "more" spills files onto the screen, one page at a time. Tthat way you can follow along. Problem is, "more" can't scroll back and forth through pages, or search for keywords. Clearly, "more" was not enough. So, some folks got tired of "more," deciding that they truly needed more(huh?). Well, the name "more" was taken up, so they called it "less." Go figure. "less" let's you scroll back and forth through pages, as well as many other fancy options. It is quite handy. Try reading some stuff using these utilities.

more filename

less filename

I know, it is simply too gratifying:)

Heads or Tails

Sometimes, you want to browse. Other times, you just want to skim. Well, in Linux you can skim the starts, or ends of files, using two utilities called head, and tail. This can be useful if you have an idea of what you are looking for, but need to eyeball the file a bit. Let's give these two utilities a spin.

head filename tail filename

Both use essentially the same syntax, and display ten lines of text, by default. By using the "-n" format, you can adjust that amount. Also the contents of a file can be monitored by using the "-f" option. Whenever text is appended to a file, the utility will display that change. This can be handy for log files, which I consider fine literature.

As you can see, with a simple primer, we are well on our way to dumpster diving through our filesystem, reading exciting configuration files, and README's. Most importantly, we've learned that by using these techniques, we avoid manipulating files, even accidentally, during our browisng of their contents. Next time, we'll get into text editors, and typing our hearts away.

-- AaronEstrada - 03 Nov 2004

Topic ClassThreeNotes . { Edit | Attach | 5B%5EA-Za-z%5D">Ref-By | Printable | Diffs | r1.1 | More }
Revision r1.1 - 03 Nov 2004 - 20:59 GMT - AaronEstrada
Parents: PresentationCalendar > TopicalVacation > WordPlay
Copyright © 2003-2007 by the contributing authors