C Programming Tutorial 8 – Intro to UNIX/Linux – Part 3

Don’t forget to read the last blog on Intro to UNIX/Linux Part 2! Are you new here? Start from the beginning of the series!

This is going to be the last video about Linux.  The first thing I want to talk about is how to make directories.  We make directories like this:

This is easier to remember than some commands because it is short for “make directory.”

The next thing I want to talk about is auto completion.  The easiest way to explain this would be to create a bunch of directories:

Now when you type cd p and press tab, it will jump to pumpernickel.  If you have two words that start with P, it will go for the only one that matches.

Now if you type cd pu and press tab, it will go to plump.  If you type cd and press tab, nothing happens. That’s because it doesn’t know which one you want.  If you press tab again, it will display all of the options available to you.

The next thing we are going to talk about is echo.  Echo is a command that can be used to get things to display in the terminal.  This is strictly Linux here so this is different than how we did this in C.

We can direct this output to a file:

When we do it again though, you can see cat shows the same thing.  That’s because every time we run this command it deletes everything in the file.  If we want to append to the end of the file, we need to use >>.

Sometimes commands can use the < symbol to get input from a file.  We’re not going to discuss this, but I thought it would be useful to share in case you are interested in researching it.

We can also use the greater than symbol to direct other commands:

You can see that this displays a ton of stuff at once, so if we have a huge text file we can actually scroll through the content using less.

Now you are scrolling using the arrow keys, but how do you get out?  You have to use q.


The last thing that I have to share is that if you are in the terminal and it seems to break and won’t accept any commands, I’m going to give you a fix. For example, try typing in cat by itself and press enter.

You can see that it keeps going and going and going.  That’s because the command is waiting for extra information.  Well we don’t want to give the terminal extra information. So to get out of this never ending trap, hold control and press c.

This is going to come in super handy when you start writing code and writing programs that you can’t get out of!

Did you enjoy this blog! Read the next one about Variables, Expressions, and Statements!

Leave a Reply

Your email address will not be published. Required fields are marked *