Linux Basics: Looking Around with ls

Erika Caoili
3 min readSep 17, 2019

--

Let’s take a deeper look into probably the most used Linux command by examining ls *.c

Tux is the official penguin character of the Linux kernal. Designed by Larry Ewing in 1996.

Background: what is Linux?

Linux was first developed by Linus Torvalds and it was released about 30 years ago. It’s a free high performance open source operating system that closely resembles Unix, but not exactly. An operating system or OS is the main software that operates on the computer.

Importance: why use Linux?

Linux supports most hardware than other operating systems and it offers many distributions like Debian, Fedora, and Ubuntu. There are no prerequisites to studying Linux and it’s a perfect place to start to understand all Unix like operating systems.

We are familiar with Graphical user interfaces (GUI) and the many tasks it can do, but the command line is even MORE powerful. The command line is like a chef in the kitchen with abundant ingredients and tools. GUIs are like Blue Apron food subscriptions with limited items (or features) to create straightforward meals.

Graphical user interface in a Mac OS

The command line is a direct interaction with the computer system with a box of tools waiting to be directed by the user.

Let’s take a look with the simple command of ls. It simply means, to list files and directories. It allows you to look around the Linux system or the shell. When you type commands like ls on a keyboard, the shell — a program executes the commands. It’s how the user interacts with the OS. On most Linux systems, the default shell is called bash.

The terminal or command line showing how the ls command works.

Let’s take a look at ls *.c

The following command not only lists files, but it is paired with an * and the asterisk means that it’s a wild card. The use of the wild card matches any character the user is substituting in order to have flexibility and efficiency while searching for a specific output. For example, look at the terminal below.

The ls *.c lists all the files that end with .c. The wild card is paired with other characters to find a desired result, in this case, the command shows all files ending with .c.

The terminal shows the ls command results. The ls *.c command shows the desired search because of the wild card.

Summary of the ls *.c command

  1. The ls command by itself will list files and directories. Note: It can be paired with options to search or list more things efficiently. For example, try the commands ls -l, ls -a, and ls -la.
  2. * is a wild card and is a highly useful powerful tool to pair with other characters to search for specific things. It is used to substitute for an array of characters in a search. Look at the above example to examine further.
  3. .c is a string paired with the character to find all files that end with .c. You can alter the string to your desired search.
  4. If no files or directories end in .c, the terminal will print: “ls: cannot access *.c: No such file or directory”
  5. Now, go forth and take a tour in your shell!

--

--