What’s happening under the hood when a user types ls -l into the shell or a command-line interpreter??

Image for post
Image for post
Trying to eliminate some of the blurred lines that come with typing commands into the shell.

Before we dive in, here are some need-to-knows to help you follow along. I will be operating on a UNIX/UNIX-like operating system. The shell being referenced is the Bourne Again Shell (BASH). It may also be referred to as sh or /bin/sh.

The shell is an executable program(/bin/sh), utilized by a user, to interact with and/or manipulate a computer’s operating system. The shell must be invoked, via a terminal, which is a program that opens a window to allow user or file input, for the system to execute.

If it’s determined, that standard input is connected to the terminal (via isatty), a prompt is printed. The prompt is the value stored to the environment variable PS1(prompt string 1) and is one of the only environment variable available by default in the shell. When a prompt is displayed, the shell is in interactive mode, and ready for the user to enter commands, for the shell to execute. …


Image for post
Image for post

Why Use A “C” Library

The question that software engineers ask the most often, is “why?”. Why do we do the things we do? Why do this? Why do that? Which leads me to ask this next question; why use “C” libraries? What’s the real benefit?

The answer to that question begins with; efficiency. When we find ourselves often creating programs that utilize the same few functions, wouldn’t it be in our best interest to organize these functions collectively in one spot, where we can quickly resource them as they are needed? For this purpose, we queue the “C” libraries!

These libraries can be thought of as a collection of object files, that are linked during the compilation process. …


Image for post
Image for post

After reading this, you should be able to understand the process it takes to compile a C program using gcc as your compiler!

What is gcc exactly? GCC is a component of the “GNU toolchain” for developing and writing operating systems. More specifically, GCC stands for “GNU Compiler Collection”.

There are 4 main components in the compiler; a preprocessor, a compiler, an assembler and a linker.

PREPROCESSOR

First step writing any C program. It is our source code and the file with extension of .c. (e.g. main.c). Preprocessor generates an intermediate file with assembly code.

COMPILER

Converts .c file into assembly code/language. Which is still not broken down enough for the computer to understand. Computers only understand binary language. (e.g. …


Image for post
Image for post

If you’re someone who came here wanting to learn about a shortcut in Linux a little bit more about links on Linux, great! Let me try to break things down a little! Let’s start by thinking of our links in UNIX, as a “pointer” to a file or directory. Creating a link is like creating a shortcut. The shortcut points us directly to the file/directory we want to access.

More specifically, there are TWO types of links that we can use!

HARD LINKS

SYMBOLIC LINKS (also known as ‘soft’ links)

The main difference in these two links is the action taken when the source file/directory that the link is pointing to has been moved or removed. I will discuss the specifics behind what each link does when the source file/directory has been moved/removed and cases in which we would use each link.


Image for post
Image for post

If you came here looking for tips on how to find seashell on the seashore, well… you’re probably going to be pretty disappointed. If you came here looking for a way to navigate to your C files in your shell, then you’re going to have a great time!

The person who will benefit most from the information in this post will be a novice, to intermediate novice, user on a UNIX-like system, like Linux! It is meant to explain to someone who is very new to using a CMI like shell. So, if that’s you, come right in!

So, first you may be want to know, what is “the shell? The shell is a program that allows users to use the keyboard to enter commands to be read by the operating system. This used to be the only way things were done on UNIX-like systems like Linux. …

About

Bre Rickner

Student at Holberton School

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store