Statistically, 96% of the humans watching this video are not using Linux. And that's just like really sad, because it's a superior, free, open source operating system, but only has a 4% share of the PC market. Luckily though, 96% of the non-human bots watching this video are using Linux, because it is the dominant OS on the server.
If you're a programmer or developer, you need to know Linux. That's where your code will eventually run and fail, and if you can't SSH into a Linux terminal and fix it, you are screwed. In today's video, you'll learn everything you need to know about Linux by looking at 101 essential concepts over the next 10 minutes.
If you survive until the end, you should magically grow a neckbeard and be able to technobabble like an Arch user. Before one can understand Linux, though, one must recognize what came before it, Unix, an operating system developed at AT&T Bell Labs in the 70s. Its development led to a standardization called POSIX, or Portable Operating System Interface, to ensure that different systems would be compatible with each other.
Its influence remains strong today, with macOS, Android, FreeBSD, and most Linux distros being POSIX compliant. In 1987, an OS called Minix for academic use was developed. but redistribution of its code was restricted. This inspired a Finnish computer science student named Linus Torvald to develop Linux in 1991. Importantly, it's free open-source software, licensed under GPL 2.0.
And by free, I mean free as in freedom. It's free to distribute, modify, and make money off of. Now, what I'm referring to as Linux is in fact not an operating system, but rather an operating system kernel.
It's written in the C programming language, and is the black magic that sits between your software applications and the hardware. When you hit the power button on your computer, the bootloader, which is usually Grub, will load the Linux kernel into random access memory. From there, it detects hardware and starts the init system, which is typically a tool called SystemD, although alternatives do exist. Once initialized, the kernel will start up applications in user space, which will typically bring the user to a login screen. As the user starts doing stuff, the kernel has a lot of responsibility.
It allocates and deallocates memory for processes. and can even create virtual memory to use more memory than is physically available by tapping into your hard drive. Speaking of the hard drive, the kernel also provides a virtual file system to interact with files on different systems. The fourth extended file system is the most common default on Linux, but it's not the only option. The kernel also interacts with all these peripheral devices via drivers.
Pretty cool, but you can't just walk up and mess around with the kernel. and that's because it's surrounded by the CPU's protection ring. At ring 0, we have the kernel with the highest level of privilege, while most of us normies in user space live in ring 3, with the lowest level of privilege. But often, you'll want to do something that requires access to the kernel, like write a file to the file system.
And that's where system calls come in. In this C code here, you'll notice that I'm making a syscall to write, which will transition from ring 3 to ring 0. to output some text to the console. However, Write itself is not a system call.
It's actually a wrapper provided by glibc, which is the GNU standard library for C and provides all kinds of wrappers for making system calls that can do almost anything on your OS. But wait a minute, what is GNU? It's pronounced GNU, and it's a project that predates the Linux kernel itself and was started all the way back in 1983 by Richard Stallman.
It provides all the core utilities for Linux, which are all the software utilities that make the kernel useful to humans. The best way to start exploring these core libs is to open up the terminal, which is a graphical user interface that allows you to send commands via the shell. Now, they call this thing a shell because it provides a layer of protection between user space and the kernel.
There are many different flavors of shells, but the most common is Bash. Let's say hello to the Linux kernel by running the GNU shell utility echo and providing a string argument to it. This command takes our message and prints it to the standard output.
Pretty simple, but what actually happened under the hood is that a system call was made to the kernel, which checked permissions and managed drivers to turn those 1s and 0s into pixels on the screen. As an end user though, I don't care. My friend told me about a cool command called touch, but I have no idea what it does. The cool thing about Linux is that you can pull up the manual for any command by hitting up my main man, man. It looks like this command is used to create a new file.
Man, isn't that cool? Let's go ahead and try it out now by creating a new text file. It looks like nothing happened, but I promise it worked. I can prove it by using the ls command to list out the files in this directory. And there it is.
And we can read the file contents with the cat command. But again, nothing happens because there's no data in this file. However, there is a bunch of metadata, like timestamps, that we can access with the stat command.
The stat rhymes with cat, and when we run it, we know this file's birth time, when it was modified, and when it was last accessed. That's useful. but we can also get more information from the ls command by appending flags to it like the l flag to list more details and the h flag to make them human readable when we run that command we can now see the exact size of every file and we can also combine flags in linux to make this command more concise i don't want an empty file though so i'm just going to remove it with the rm command. The cool thing about the Linux terminal is that it's really easy to combine commands.
Like I can take echo and use this angle bracket to redirect its output to a new file. In addition, I can flip this angle bracket around to also redirect the input of a file. That's cool, but pipes are even cooler.
They allow you to take the output of one command and pass it off to another command. Like for example, if we have a log file of our broken code, we might first use cat to read that file, but then we could pipe the output to sort. which would sort it line by line, and then unique to remove any duplicates.
There's so much more we could do just from the terminal, but if you find yourself doing the same thing over and over again, it might be time to write a bash script in its own dedicated file. But to create that file, we'll use an interactive text editor. If you have a few years to spare, you could try learning Vim, or if you have no life at all, you could try Emacs, but I'm going to create this file with Nano, a minimal text editor built into most Linux distros. At the top of the file, we'll add a shebang that tells Linux to use the bash interpreter.
Then we can add as much bash code as we want here. Like we might use echo, and then read to read a value from the standard input, and then echo to once again echo it back. And now if we save this file, we can execute it by simply entering the file path in the terminal. And that brings us to the halfway mark.
Unfortunately, 100 topics is not nearly enough to cover the entire Linux ecosystem. If your goal is to become an Apex Alpha Linux gigachad, check out my brand new full Linux course for Fireship Pro members. The course contains over 30 videos of hands-on Linux topics, along with quizzes for regular dopamine hits, that will help you master the fundamentals of Linux quickly.
But most importantly, it will teach you how to spin up your own virtual private server to self-host your own applications. But one major drawback of using Linux is that it might trigger an existential crisis, and you might ask yourself, who am I? When you enter that command, it's going to return your Linux username.
In addition, every user has a unique UID that can be viewed with the id command. My ID is 1000, but there is one special user with a UID of 0 called Root, aka admin, superuser, or daddy. root has the highest level of privilege and you can switch to the root user with the su command or prefix any command with sudo to run it with elevated privilege any user can be granted sudo privilege and you can check your privilege right now by running sudo flag l in addition to users linux also has groups groups have group ids and make it easier to manage permissions for multiple Before we talk about permissions, though, let's explore the file system. By default, we're in our home directory, which is like a personal workspace for the user you're logged in as.
We might make a new directory here using the makejur command, then use cd to change directories into it. Now run pwd to print the current working directory. But now let's venture outside of our home into the root of the file system by running cd slash. If you hit ls here, you'll find a bunch of critical directories that you need to know about, like boot contains the Linux kernel itself, Dev contains external devices like hard drives, etc contains config files, and var contains log files.
The most interesting directory here, though, is bin, which holds your binaries, and spin for system binaries. You see, when you run a command like ls, Linux looks for an executable binary on your system to execute. The thing is, binaries not only live here, but also under the user system resources directory, and potentially anywhere you want on the file system. And that begs the question, how does Linux know where to find the right binary? Well, that's where path comes in.
It's a special environment variable that contains paths to directories separated by colons. When you enter a command, Linux will search through the path for a matching binary in each directory and execute the first one it finds. Its value is set on the system by default, but it's common to customize it by using the export keyword, which will set the value for an environment variable.
The most common technique is to update the path for an individual user by customizing the bashrc file, which itself is a script that will run before every terminal session. And now that we're inside this file, we can also do things like customize the ps1 environment variable to change the terminal prompt to look more like a mega hardcore hacker when coding at Starbucks, which is a proven way to attract a mate as a Linux user. But now it's time to talk about file permissions. Use ls flag l on any file to view permissions and notice these cryptic nine characters. These are called symbolic permissions.
The first triplet represents the owner, the middle the group, and the last triplet is for everyone else. Each one contains a letter that represents read, write, and execute privileges. If the letter is present, it means access granted, but if there's a dash, it means permission denied. These can also be represented as numbers in octal notation. For example, 777 lets anybody do anything to a file.
I know 777 is good on slot machines, but in Linux, it's generally a bad idea, because you want to always follow the principle of least privilege. Grant access to things only when necessary, and trust no one. Now, you can modify the permissions on a file with the chmod command. Like here, I'm using it to grant read access to a document for everybody. We can also change the owner of a file with chown, or assign groups with chgroup.
And now that we know what all these things mean, permissions aren't so cryptic. Now, Anytime you run a command or execute a program, it creates a process on the CPU, which is managed by the Linux kernel. You can view these processes with the ps command. And notice how each one has a unique process ID, along with the user who created it.
Or better yet, use htop to get an interactive breakdown of processes that can be filtered. Some of these are just system daemons that run in the background. We all have our daemons.
In fact, if you have a long-running script, you can even create your own background process by adding an ampersand to the end of it. Or if you want a script to run on a specific schedule, like a reminder to do something at 4.20pm today, you can accomplish that by adding your script to the cron tab. That's cool, but occasionally you'll have a bad process that needs to be killed.
The kill command can do that by gracefully sending a sigterm signal to the process. If that doesn't do the trick though, use the 9 flag to forcefully kill it with sigkill. We've barely scratched the surface, but so far everything we've looked at is pretty standard on most Linux machines.
Other utilities you should know about include grep, for searching through text, Zed for modifying text, Gzip for making files smaller, and TAR for archiving directories. But the Linux experience varies wildly when talking about different distros. A Linux distribution is just a complete operating system built on the Linux kernel.
And each distro has a highly opinionated set of default software for their target audience. Some are designed for beginners, others for hardcore hackers, and everything in between. Distros can have different package managers to install new software, like apt yum and pacman and they might also have different release schedules like some have a predictable fixed release date while others have ruling releases that keep their software on the cutting edge at all times and one thing we didn't even talk about is desktop environments if using linux as a pc your distro will have a default desktop environment like gnome or kde plasma and that makes a huge difference in the experience some distro families you should know about include slackware the original gangster from the 90s debian the most popular distro overall famous for its open philosophy and ease of use, Red Hat, the distro of choice and enterprise for its long-term support plans, and finally, the Arch family.
If someday you find yourself saying, I use Arch by the way unironically, it means you've embraced the paradox of complexity and simplicity, and your operating system is no longer just a tool, but a reflection of your own dominance and mastery over the digital world. Thanks for watching, check out the full course if you want to go deeper, and I will see you in the next one.