Terms of Use For FixedByVonnie

By proceeding to access fixedByVonnie.com, you expressly acknowledge, and agree to, all of the following:

fixedByVonnie.com is a personal website and blog owned by Security Plus Pro LLC, which is being presented for informational purposes only. The views on this website are solely those of the website owner (and not those of any employer or of any professional associations affiliated with the website owner).  Any views expressed in this website and any information presented on this website, or in any of its blog entries, should not be relied on for any purpose whatsoever other than as the personal opinions of the website owner.  The website owner expressly disclaims any and all liability for any information presented on this site.  The owner of this website and its blog posts shall not be held liable, and shall be held harmless, for any errors or omissions in any information or representations contained in this website, or in any of its blog entries.  The website owner also expressly disclaims any liability for the current or future availability of any such information. The website owner makes no representations as to the accuracy or completeness of any information on this website or which may be found by following any link on this website. The website owner shall not be held liable for any losses, injuries, damages, claims, or causes of action, from the display or use of any information on this website or in any of its blog entries. If you use the information on this website, or on any of its blog entries, you do so solely at your own risk.

Laughing at Linux: Command Line Basics (Part 2 of 5) - fixedByVonnie

Laughing at Linux: Command Line Basics (Part 2 of 5)

If you read the previous tutorial in this Linux series then you should have no problem opening the terminal and using ls, cat and echo.

ls lists files, cat lists inside files and echo prints whatever you type after it.

Today we’re going to talk about globs and then we’ll finish up with $PATH and history.

globs are pretty cool and it’s the single thing that separates the Linux tyros from the Linux pros.  If you master this little concept you’ll instantly boost your Linux acumen.

Globs of Filters

Check this out.

Let’s say I’ve got two files in my Documents folder.

  • MyInfo
  • Todo.txt

If I type ls I’ll see both files.  No surprises here.

What do you think is going to happen when I type this:

ls *.txt

Linux Globs

I know this isn’t particularly exciting because you can type dir *.txt in Windows and you get the same result.

But watch this.

I’m going to change things up a little bit.  Let’s create two new Todo lists and rename the first one to Todo1.txt.  Here’s what the file structure looks like right now:

Linux File Manager

Now we can use the “?” character to match any single character.

ls Todo?.txt

The Question Mark

The star matches any amount of characters but the question mark only matches any one character.

Using the * and ? filters is known as globbing.  So now you know how to glob haha.

One super special variable: $PATH

In the previous guide I showed you how to define and echo variables to the screen but today I need to show you one super special variable.  It’s called $PATH.

It’s a built into Linux and looks like a bunch of craziness but let’s look at it for a second.

$PATH is a special variable that lists that folders where the shell searches for commands.

You can see it with the echo command:

echo $PATH

Linux $PATH


Here’s what the command interpreter muses to himself when you enter a command called hahaha.

  • Alright, I see the user wants to run a command named hahaha.  First I’ll check /usr/local/sbin for the entered command.
  • Dang, I don’t see it there.  Okay, so I’ll check /usr/local/bin next.
  • It’s not there either so let me check: /usr/sbin
  • Ooops, where is this thing?  Let me check /usr/bin
  • Ahhh, I’ll check /sbin next
  • And then /bin
  • And then /usr/games
  • And then /usr/local/games
  • Since I don’t see hahaha in any of the folders listed in $PATH I’m giving up with an error.

My point is that every command has to live somewhere.  ls has a home.  cat has a home.  echo has a home.  Where is that home?  That depends on the command, but you can check that out by using the which command.

For example, if I type:

which ls

I’ll see the path where ls lives.

Linux which command

So when the command interpreter sees a crazy command like hahaha it searches all the folders in the path list.  If it doesn’t find the command there it says “No command found”.

The only place Linux looks for commands are the folders listed in $PATH.

Remembering what you typed

I’m going to close out with a really cool feature that most Linux beginners aren’t aware of.  It’s called history.

After typing a bunch of command you may want to go back and see what you typed 10 minutes ago.  One way to do that is to keep pressing the up arrow.

But a better option is to type


This will show you all the commands you typed for the given session.

Linux History

If you only want to see the last 10 commands you can type:

history 10

To clear your history type

history -c

The Bottom Line

I hope you’re starting to get the hang of Linux.  If you’re still confused about things it’s because you’ve been reading my tutorials but you haven’t actually typed this commands in a live Linux shell.

You can’t learn Linux by reading about it.  You absolutely must do Linux.  Linux doesn’t respect readers.

That’s why you should read my beginning guide on setting up Linux in Virtualbox so you can follow along.  I’ll only take a few hours to get your Linux box up and running.  And once we set it up you’ll never need to configure it again.

I strongly suggest you go through that guide so you can follow along and really get comfortable with this nimble operating system.



Connect with Vonnie on Twitter

Posted in Linux Tagged with: