Seventh Friday Linux Lesson

Tagged as Linux

Written on 2007-06-29 19:06:00

Okay, folks. I have a confession. My Linux Lessons are so under par. Seriously. I was looking at a site just the other day that did a much better job of presenting concepts in a sensible order and getting users familiar with the command prompt. Oh, well. There's still plenty to be done here so on I go. Today we're going to be looking at a few simple things that might go missed at the command prompt but are insanely great. If there is really a concept today it's on shortcuts and things like tab completion.

So, let's start with a few basics. If you're at a command prompt and press the Up Arrow you'll cycle through the commands you entered last. That's history. If you're midway though typing a command or a directory and you hit the Tab key, the system will try to autocomplete it for you. That is, if you're typing "cd /home/user/Desktop" and once you've typed "cd /home/user/D" you hit tab, as long as there is no other directory that starts with a capital d in "/home/user" it will finish typing "esktop" for you. This ends up being useful for all kinds of things. Especially when something is several directories deep but you don't feel like typing or remembering whatever you typed earlier. Additionally, one should always remember that "." is equivalent to the directory you're currently in, as in "cd .", and ".." is equivalent to a directory one above the directory you're in such that "cd .." while in "/home/user/Desktop" would move you to "/home/user". Finally, how about a command? Typing "pwd" will print the present working directory to let you know where you are in the system. This, in conjunction with tools like "ls" and "cd" will help you navigate the filesystem in a sensible manner.

Finally, I'm going to talk about "|" today. That's shift-backslash. The wonderful thing about "|" is that it feeds the output of one command into a second command. For example, "ls /home/user/Desktop | wc -l" would use "wc" the word count program to count the number of lines in "/home/user/Desktop". You end up putting two commands together to get a count of the number of files in that directory. You could also use something like "grep" to find a file like so: "ls /home/user/Desktop | grep *.doc" and list all your documents. This simple combination allows for some fantastically complex things which I'll be exploring in the coming weeks. For now, I hope you enjoyed the friday Linux Lesson and (if I'm lucky) the next Linux Lesson will be found here and also on "". Have a good one folks.
comments powered by Disqus

Unless otherwise credited all material Creative Commons License by Brit Butler