DEV Community

Cover image for So... Linux?
Enmanuel de la Nuez
Enmanuel de la Nuez

Posted on • Updated on

So... Linux?

Introduction

Did you know Linux is the most popular operating system in the world? It is! For servers and supercomputers. The millions of server computers hosting the websites we visit are more than likely running a version of Linux. In this post, we'll learn what Linux is and where it comes from, vocabulary, and commands you need to start navigating this exciting platform.

What is Linux?

Linux is an operating system, just like Windows or Apple's mac OS. Operating systems are collection of software that manage the different devices and applications in your computer. These bits of software take care of processes like shutting down your computer, booting it up, and giving your programs an interface to interact with devices like your keyboard and mouse.

Learning to use a Linux system is a great opportunity to get familiar with the command line, the most explicit way to communicate with your machine. Additionally, as you experiment with different projects, you will start to learn about repositories, package management, file permissions, user management, and much more. Package management and repositories are concepts you might already be familiar with if you have any experience using npm and GitHub.

Why is Linux so Popular?

Linux distinguishes itself in the world of enterprise computing, big data, and science (think supercomputers!). Why?

  • Linux is free. Free in multiple ways, you don't need to pay to use Linux and you're free to view, edit, and distribute the source code. When you buy a computer with Windows or macOS, the cost of creating and maintaining these operating systems is included in the price.
  • Linux is flexible. Linux is used in a lot of different types of computers. Think smart toasters and refrigerators, other IoT devices, internet routers, Android smartphones, the list goes on and on. You can probably install Linux on your laptop or desktop today and be up and running with little set up! More on this at the end. This flexibility is possible because a Linux operating system is designed to be the sum of many different tools that do one job and do it well. You could piece together a version of Linux that works for your device and is optimized for your needs.

The Unix Philosophy

Linux is a 'Unix-like' operating system, meaning much of it is derived from the Unix operating system and generally follows Unix's design principles. An ideal Unix program is simple, modular, and extensible. Unix programs do a few tasks really well and are designed to work well with other programs without depending on too many others. The system is made strong by the collaboration of the programs that compose it, not because the programs themselves are super powerful.

My favorite thing about Linux is that everything is a file somewhere in the system. Those commands and programs you run in the terminal? Files. The icons in your desktop that let you quickly open your favorite apps? Files. What about the repositories your system checks for application updates? Written in a file! All of which you can mess around with. The transparency! The power! Its beautiful. Imagine one day set up your own Linux installation with everything you want, and nothing that you don't, while having full autonomy over your system... Pretty cool, right?

These principles really speak to Linux's flexibility. No wonder it's used in for so many applications!

Everything is a File, Here is Where They Live

I want to show you a typical system tree, or file system hierarchy in a Linux installation. Read more about tree-like data structures in my other post! If you're following along in your own Linux system, note that you may have additional or fewer directories. If you want to learn more these directories (folders) in detail, run man hier in your Linux terminal and read away! Personally, I keep my search engine of choice nearby to look up the many words I don't know the meaning of.

/ this is the root directory (folder), the root of the tree (yes, the data structure 😄)

/bin contains binaries, executable programs the system needs to boot

/boot contains the kernel and files needed while the machine boots

/dev contains device nodes, instructions/interfaces to use with physical devices connected to machine

/etc contains system-wide configuration files (pronounced etsy). Big software packages like gtk, python, and X11 store configuration files here as well.

/home contains directories for system users (each user's Downloads, Pictures, etc.)

/lib contains libraries shared by core programs necessary to boot the machine

/lost+found contains data misplaced during a system crash or as a result of drive errors

/media contains mount points for media devices like USBs, CDs, and DVDs.

/mnt is a mount point for a temporary file system (like the one you might use to build your installation)

/opt contains additional packages for programs. In my machine, Google Chrome and the Minecraft Launcher keep files here.

/proc contains files related to the kernel and running processes

/tmp contains temporary files that may be created while executing a program

/usr contains a secondary, read-only system tree for sharing with some programs or to be mounted on other Linux systems. Many of the directories above exist here containing additional files.

/var contains files that vary in size at different times like logs and backups

If you use Linux frequently, at one point or another you'll find that you need to edit or write files in some odd directory. I hope knowing what these names generally refer to can help you out!

Command Line Basics

Earlier I said 'the most explicit way you can communicate with your Linux machine is the command line' and I meant it. Let's learn some basic command line or terminal commands that will allow you to start familiarizing yourself with your system. If you currently develop with a graphical user interface you may find that doing things from the terminal is faster and safer (ish).

There is a program between you and the terminal called the shell. A shell is a program that interprets text commands and sends them to your operating system to execute. The most common shell program is called Bash, which comes included in most Linux installations. For macOS users, Apple recently switched the shell program to zsh. macOS is actually a Unix-like operating system as well. You too can change your shell!

The Structure of a Terminal Command

I won't share too many commands in this post, its long enough already and learning patterns is more important. Generally, terminal commands follow a very similar and predictable structure:

program_name [--optional flags] [optional arguments]

Flags can come after arguments and are often shortened to just one letter and one dash, e.g. -f. Flags are options that change the way a program behaves. -h or --help are common flags that will tell a program you want to see which flags are available to you.

Arguments are often files but can be strings and numbers too.

You can call a program from any directory in your system and you can use a file from any directory in your system as an argument. You can do this because to name a file you can use a relative or absolute path. Relative paths are relative to your current directory, which you can refer to with .. Absolute paths start at the root of the system / and name every directory to get to the desired file.

Navigation

  • pwd prints the directory you're currently in (print working directory)

  • cd changes the directory to your specified argument. If you provide no arguments it will by default take you to your user's directory, which you can refer to in paths with ~. . and .. represent your current and parent directories respectively and are also valid arguments.

  • ls lists the files in the directory you specify as an argument, which by default is .. The -a flag comes in handy for seeing hidden files. You can hide files by starting their name with a ., e.g. .gitignore to reduce clutter.

ls -a ~/Documents

File Manipulation

  • mv moves a file or directory to your specified directory.
mv fun-letter.text ~/Documents/letters/

You can also use mv to rename files and directories:

mv fun-letter.txt hilarious-letter.txt

Like moving it to itself with a new name!

  • cp makes a copy of a file in a specified directory. Use the -r flag to copy directories, and you can rename files and directories with cp similarly to how we did it with mv.

  • mkdir makes new directories where the names are your arguments. You can also make directories inside directories that don't exist yet with the -p flag.

mkdir -p code/web-stuff/html notes
  • touch makes new files where the names are your arguments.

You will soon find yourself wanting to do more complicated things, so read more on these commands and keep a cheat-sheet 😉.

Linux for Everyday Use

I won't say 2020 is going to be the year for Linux in the desktop, but I will share that there are many Linux distributions ready to go out of the box and with simple installation methods. If you are attracted to the power of the shell, are concerned about privacy using other operating systems, or you just like hacking around, Linux might be for you. As a developer this is also a great platform because its made with other developers in mind. Distributions, versions of Linux like Ubuntu, Linux Mint, and Fedora can get you up and running quickly. These 'distros' are accompanied by huge communities full of people willing to help. Just remember to back up any important files!

Thanks for reading! I appreciate any comments and feedback :)

Cover photo by Pixabay from Pexels

Top comments (26)

Collapse
 
ghost profile image
Ghost

I won't say 2020 is going to be the year for Linux in the desktop

But you have to, we have been saying it for a decade, is tradition!.

Collapse
 
alvaromontoro profile image
Alvaro Montoro • Edited

For a decade? They were saying that already when I started using Linux in the late 1990s/early 2000s.

Collapse
 
ghost profile image
Ghost

But that was nonsense, because clearly THIS is the year of the Linux desktop.

And those where really optimistic, when I used Mandrake 9.1 many years ago, almost none knew about Linux, half of the HW didn't worked, no big vendors sold machines with it and most of the distros, if not all, couldn't even play mp3.

I'm not even sure I would like the year of the Linux desktop to come, most users don't care about freedom, customization. good design or privacy. What would happen if all Windows users came to our side?, what would happen when 90% of now Linux users stop caring about those attributes?, things like when Ubuntu got bashed because it got Amazon ads in their main menu, wouldn't happen anymore, blobs would start to proliferate, we would have scenarios like Nvidia, where the FOSS alternative is almost unusable but nobody cares because the blob just works, everything would be chaos and horror and fire would fall from the skies!, or not, who knows. Hopefully we'll have Slackware with its awesome shitty website, the mighty Gentoo and all the Linux craziness.

As Ian Malcolm said, "Weirdness cannot be contained. Wirdness breaks free. Weirdness... finds a way", long live FOSS

Collapse
 
dharshann profile image
Dharshan Bharathuru • Edited

Oh Pleaseeee!!!!

Am I the only one seeing this post as complete mislead!!? First of all, LINUX is not an operating system, it is just a kernel(a teeny-tiny but very important part) of an OS. GNU/LINUX is the complete Operating System suite. GNU(most of the OS) + Linux (part of the OS, Kernal)

Do give credit to GNU as well, which worked 95% on the so called Operating System you are talking about.

gnu.org/gnu/linux-and-gnu.en.html

Collapse
 
leob profile image
leob • Edited

Yes it would have been good to point out GNU (and things like desktop managers, Gnome, KDE etc) ... but talking about giving credit, Linus Torvalds isn't even being mentioned in the article! For the rest, in my opinion this article is a very nice overview for the Linux n00b :-)

Collapse
 
igormp profile image
Igor Moura

Well, every GNU thing can be easily replaced, while you can't easily replace the linux kernel itself for anything better. Also, one could argue that even the Desktop Environment plays a bigger role than the GNU software.

Collapse
 
dharshann profile image
Dharshan Bharathuru • Edited

I completely agree with the adaptability and different flavours. But we should not forget the effort of GNU team put in making a FOSS Operating System against all proprietary giants at that time. And am not dis-honouring the contribution of Linus Torvalds as well, he has done a tremendous job. What we should not do is praise or give credit only to Linux or Torvalds. Please give credits to GNU as well.

When Mr. Torvalds made his kernel FOSS, there was a similar project called HURD going on with GNU to replace Unix kernel.

What I actually mean is , people who write/speak about Linux Operating System and don't know/mention about GNU, they should revise their knowledge base!!

Thread Thread
 
igormp profile image
Igor Moura

HURD was, and still is, not really useful for anything.

I don't think GNU deserves any other mention that what it already has in the license files and some package names.

Even in the link you posted they base relevance on line of code amount. If we go by that metric, then even a web browser deserves way more credits than GNU itself due to their higher LoC amont, but we don't see anyone calling their systems Chrome/Linux or Firefox/BSD.

Thread Thread
 
dharshann profile image
Dharshan Bharathuru

I do think GNU deserves a mention.

If Linux was solely developed, and not combined with an OS like suite(which was already present) no one would have used it. Or if GNU tried (still trying to write a completely Free kernel) it would have been ages to see a Free and Open Source Operating System. By the time we all would have became slaves to big tech conglomerate.

A complete FOSS OS is true now because of both GNU and Linux so they does deserve mentioning.

Collapse
 
abdelrahmanahmed profile image
Wahdan

The only drawback in linux is that you can’t play popular games on it😓, thats why i have windows along with linux

Collapse
 
myterminal profile image
Mohammed Ismail Ansari

Try this if you haven't yet: github.com/ValveSoftware/Proton.

The best part of this is that you just have to check a checkbox labelled "Enable SteamPlay for all titles" under Settings after which Steam restarts and then you have access to thousands of Windows games on your Linux machine. Since Valve introduced Proton, things have been turned around in the world of Linux gaming.

As we're discussing games on Linux, I could'nt skip mentioning gamingonlinux.com.

Collapse
 
shaunagordon profile image
Shauna Gordon

Which games have you been unable to play, specifically?

Collapse
 
abdelrahmanahmed profile image
Wahdan • Edited

League of legends
Starcraft 2

Thread Thread
 
shaunagordon profile image
Shauna Gordon • Edited

I can't speak to League of Legends, because I don't play it. On a quick search, it looks like a new "anticheat" method that Riot is introducing is fundamentally incompatible with Linux, because it's kernel level, though 😠 . Honestly, even as a Windows gamer, I'd push back heavily on this new method they're looking to implement, because that's draconian as hell. It is, for all intents and purposes, a rootkit with more privileges than the system administrator account. and it runs even when the game is not, and is not removed when you uninstall their games (instead, you have to uninstall it separately).

Starcraft 3 doesn't exist, but Starcraft 2 plays just fine.

One thing I've noticed over the years is that Linux is the canary in the gaming coal mine, especially at this point. Pretty much any game that isn't actively dis-supported (ie - support and compatibility actively removed) and is simply not written specifically for Linux but uses fairly standard libraries and methods and such, work out of the box. Hell, I played Borderlands 3 the week it launched on Steam without much problem.

So when a game doesn't work on Linux, even if it's not officially supported, 9 times out of 10, it's because the company actively did something to break it. Very often lately, it's been "anti-cheat" software that's overly invasive -- and considering how much flak Acti-Blizz got for Warden being invasive when they first launched it and all of the Acti-Blizz games work just fine on Linux, and Warden pales in comparison to things like Riot's new one, that's saying a ton.

In my opinion, even if you're a die-hard Windows gamer who couldn't possibly care less about the state of gaming on Linux, it's worth seeing what games cannot run at all under Linux, because they're few and far enough between these days that there's a very good chance it's a dead canary and there's something that the publisher is doing that is ethically sketchy.

Collapse
 
mkenzo_8 profile image
mkenzo_8

You can play games, if some is not supported is not Linux's fault but it's maker

Collapse
 
abdelrahmanahmed profile image
Wahdan

Yes i know that, unfortunately not a few companies are doing this 😓

Collapse
 
sm0ke profile image
Sm0ke

Thanks! Such an impressive and visionary work to code an OS 20yrs ago and don't have to change anything all these years.

My favorite learning Linux project is Linux From Scratch - learned a tone 15yrs ago.
TUX
Such a cute ... guy!

Collapse
 
terkwood profile image
Felix Terkhorn

Nicely done, thanks!

Collapse
 
andrewrothman profile image
Andrew Rothman

Great intro to Linux!

Collapse
 
boris profile image
Boris Quiroz

I've been using Linux since 1998, and nothing to say to your post but "good work!" I wish I'd had have this kind of document 22 years ago :D

Collapse
 
mccurcio profile image
Matt Curcio

Hey E,
Loved: 'man hier'. That was totally new to me. And I thought I had been using Linux a while. ;)

Collapse
 
bu profile image
Burak Sümer

Free as in freedom. I love that.

Collapse
 
briveira profile image
Bernardo Riveira

It is! For servers and supercomputers.

And cell phones! Android is based on linux kernel.