What Happens When You Type ls *.c In Your Terminal

Yago Martinez-Falero Hein
3 min readSep 14, 2020

This a very basic explanation of a commonly used command in your computer terminal. If you’re a complete beginner, after reading this article you should be able to understand perfectly what “ls *.c” does and even some other commands too 🤘.

What is a computer terminal?

When you open it and type a few commands, it really looks like your starting to hack into someone's computer (at least that’s how I felt the first time). Sadly, it isn’t the case…

I see it as a way to manage your computer’s files and folders without a mouse and a “command” such as ls *.c is an action you perform on your computer. Just as “right-click + copy” for example.

Well don’t be scared but when you open your computer terminal, it looks something like this:

Nothing to do with a regular desktop…

What does ls mean?

Let’s take the example of the Desktop! Typically, when you look at it, you instantly see what folders or files you have. You can double-click and see what subfolders you have or open files.

Well… When I move to my desktop in my terminal this what I see:

Hum… 🧐 Sucks! It looks like nothing happened…

That’s absolutely normal! The command “cd” allowed me to move to my Desktop but now is when “ls” will be handy! It will allow me to see what folders and files I have in my desktop and will look like this:

As you can see I just typed ls and the terminal gave me a list of folders (in blue) and files (in green). And that’s what the command ls does!

What does *.c do?

So far it looks like the terminal isn’t quite a useful tool right? Well, let me tell you: it is… And it’s super powerful.

Let’s take the following example:

You are a bit lazy and you could not bother to classify your files properly in folders and sub-folders. Thus, your desktop looks a bit like this:

Now, you just coded a program in C language and now you have to send it to your colleague. You know the file extension is a “.c” but you completely forgot what name you gave to that damn file and when you saved it!

If this were you, you’d probably not be a joyful and happy person right now.

But there’s is an easy way out:

That’s it! Your file whats named “damn_file.c” and you found it using “ls *.c”

To translate this command in English it will be like saying:

  • ls -> List the files…
  • * -> … ending with…
  • .c -> … the extension “.c”

--

--

Yago Martinez-Falero Hein

👨🏼‍💻 Entrepreneur and software engeneer // Former employee at TheFamily.co // 👨🏼‍🎓 Holberton School & Reverse Origins