Codecademy Courses Introduction To Linux
Codecademy Courses Introduction To Linux
com/courses/introduction-to-linux
Introduction - What is Linux?
Welcome to the Introduction to Linux course! For this first section, we
will share what makes Linux so special and why you should learn it.
Welcome to the Introduction to Linux course here on Codecademy! Linux is a
highly useful type of operating system to learn - its impact on open-source
technology and how lightweight it is have made Linux extremely relevant!
Throughout this course, you will learn what Linux is exactly, its history and ethos,
and how to set up your own running instance of Linux. From there, we will
introduce open-source applications within Linux that make it similar to
proprietary operating systems like Windows and MacOS.
We’ll go over special commands in the Linux shell to compress and extract files
and reach networks and how to write Bash scripts to automate tasks. If you need
to refresh yourself on Bash, take our Learn the Command Line course first!
We will also share how to manage users, groups, and permissions in a Linux
environment.
By the end of the course, you’ll be prepared to navigate and customize your own
Linux environment with ease!
Learn
What Is Linux?
Introduction to Linux
Welcome to the world of Linux and open-source software! In this lesson, we will
learn about the Linux Operating System, its history, and its applications. Linux
has had an incredible impact on modern technology as a lightweight operating
system for low-power devices to highly sophisticated supercomputers. Linux runs
on over 95% of web servers. Today, Linux runs 85% of smartphones (Android is
built on top of the Linux kernel).
The reason that Linux is such a flexible operating system is that almost all of its
features can be accessed using a text terminal, without a graphical desktop
environment. This gives us faster access to a computer or server’s resources.
In the next few exercises, we’ll talk about Linux’s history and open-source ideas,
the components of the Linux operating system, and the different “flavors” of
Linux. Towards the end, we will tour a Linux desktop.
Let’s get started!
Unix history
To understand how Linux came to be, we must look back to the early days in
computing, when Ken Thompson and Dennis Ritchie of Bell Laboratories began
working on UNIX, the first ever portable operating system. The year was 1969.
UNIX could run on a range of devices and was widely used as proprietary
software. Then, Richard Stallman started the GNU Project in 1983 with goals to
create a free operating system. At the time, the free software movement was
advocating for the freedom for users to modify and share copies of software. The
project created the GNU General Public License (GPL), a widely used free software
license, which set the background for the Linux operating system.
In 1991 there was not yet a free operating system, so a Finnish computer science
student named Linus Torvalds began developing an operating system as a hobby.
He released the code under GPL and slowly, the community around Linux grew as
more and more developers contributed to the base code.
Today, Linux refers to the many versions of operating systems built on top of the
base code. This means anyone can create their own version of a Linux operating
system!
Learn
How Computers Work
Introduction
Computers make up the world around us - from robots to phones to our coffee
machines, modern appliances are often powered by computers. We rely on this
technology on a daily basis; therefore, we should ask ourselves the following
question:
How does a computer work?
Using a computer is an interactive experience. When we press a button on our
keyboard to type something, our computers know what characters to display.
When we move our mouse, computers generate a cursor that mimics the
mouse’s movements. How does a computer know what to produce based on the
interactions we have with it?
In this lesson, we’ll go over the four main functions of a computer that make
these interactions possible:
Input
Processing
Memory
Output
Let’s get started!
Input
From clicking our mouse to turning up the volume of the speakers during our
favorite song, we are constantly giving our computers input. We can think of
input as how we as people physically interact with computers. We give our
computer commands by interacting with various physical sensors (like buttons)
which then get turned into data for our computer to process.
So how does a simple act such as clicking a mouse become the catalyst for a
computer to carry out an action? First, we need to establish a connection from
our input device to our computer through a physical port, which is usually
attached to the computer’s motherboard.
The input device’s job is to detect and report any type of event; for example, a
mouse can sense the action of being clicked. Once an event is received by the
input device, it reacts by sending information to the CPU. In order to properly
“speak” with the CPU, information needs to be communicated using binary code
which are instructions composed of 0s and 1s.
Once the input is converted into binary, it is sent to the CPU to be processed.
Processing
Once we have some data, we need to process it so that our computer can figure
out what we’re asking it to do and how to execute those requests. The job of
processing information is given to the central processing unit, or CPU.
The CPU controls all the different components between hardware and software.
We can think of it as the “brain” of the computer! The CPU also holds the
responsibility of establishing communication between hardware and software. For
example, if we turn the dial on our speakers up, data about that interaction is
sent to the CPU. The CPU then deciphers the information and sends instructions
to the speaker about how to handle this task. If we want to run software on our
computer, it is also up to the CPU to perform all the necessary operations.
That’s a lot of responsibility for one piece of hardware. With all the different
software and processes available to us, how can the CPU take in information and
execute the associated instructions so quickly? This is where computer memory
comes in handy!
Memory
Our computers have a lot of information to process - where does all this data get
stored? Computer memory refers to the system or device used to store computer-
based data temporarily or permanently. The type of hardware we use to store
data depends a lot on how long we need to hold on to that information.
Primary Memory
Not all memory needs to last forever. Sometimes we just need information
temporarily. For example, if we want to order food, we only need to remember
the restaurant’s phone number long enough for us to dial the number - then we
can forget that information until the next time we order food.
This same idea applies to running software on our computers. When a command
to run a program is sent to the CPU, the CPU retrieves data from Random Access
Memory, or RAM, in order to access what instructions it needs to execute.
Accessing data from RAM is significantly faster than accessing data from other
memory systems.
This type of data is also only stored temporarily; once we exit a program or turn
off the computer, the data is lost. For example, if we exit a word-processing
application before saving, anything we wrote in the document is gone.
Secondary Memory
If we upload 150 photos to our computer, the computer needs a space to
permanently store the data associated with the images so that we could access
the pictures anytime. This type of data would most likely be saved onto our
computer’s hard drive.
Output
Once the CPU processes data and sends out instructions on how to handle it,
output is produced! We can think of output as the computer fulfilling the
command we gave it through an output device.
Examples of output devices include the following:
Monitors
Speakers
Printers
For example, if we clicked a mouse to open a file, the output would be the
monitor displaying the file’s content. If we turned the volume on our speakers up,
the output would be the sound becoming louder.
Output is the final step in the process of our computer interaction.
Review
Great job reaching the end of this lesson. Let’s go over what we learned about
how a computer works:
Input is data we give to our computers
Processing is comprised of the translation of input and the instructions
given for output
Memory is used to store either temporary or permanent information
Output is the information that gets returned by the computer
Now that we have a basic overview of how a computer works, we’re ready to take
a deeper dive into learning about the processes behind making a computer
functional.
Basics of Operating Systems
Learn about what an operating system is and what they are responsible
for.
The four main functions of a computer are input, processing, memory, and
output; but where do operating systems fit into this? In this article, we’ll go over
the various responsibilities of an operating system at a high level.
Introduction to Operating Systems
Take a moment to recall the process of using a computer. It may look something
like this: We press a button and a humming noise signifies that our computer has
powered on. After a moment, our computer monitor displays a desktop
background and what happens next is up to us! Here are a few examples:
Use our mouse to open up our favorite music application and turn up our
speakers to enjoy our favorite song.
Start up a word processing software to write something for work and then
save it to our computer in a folder we use specifically for our job.
Open up an internet browser to write an email while playing our favorite
online multiplayer game.
The possibilities are truly endless. The process of interacting with our computers
to do these types of activities often seems easy from our perspective. The truth
is, these tasks are quite complicated from the perspective of our computers. Let’s
revisit this task:
Use our mouse to open up our favorite music application and turn up our
speakers to enjoy our favorite song.
For our computer to accomplish this task, it needs to handle the input of mouse
movement and mouse clicks, fetch the data necessary to run the software
responsible for the music application, run that software, retrieve the data
necessary to play a specific song, communicate with the speaker to output this
song, handle the input of the speaker dial being turned, and communicate with
the speaker to output the music at a louder volume.
That’s a lot of work being done in just a few seconds! Lucky for us that, as users,
we don’t have to think about any of this. The responsibility of handling tasks like
this falls on the operating system.
What is an operating system?
An Operating System, or OS, is system software that’s responsible for handling
the basic functionalities of a computer. Some examples of popular OSs are:
Windows
Linux
Mac
Android
iOS
Every computer contains at least one operating system which starts working the
moment a computer is turned on. The OS has control over both the software and
hardware resources of a computer. At the core of an operating system is
the kernel which manages all the interactions between the hardware and
software components of a computer.
Functions of an OS
Take a look at some of the vital functions of an OS:
Process Management
Memory Management
File Management
IO Management
Multitasking
Networking
Security
Providing a user interface
We’ll focus on the following: process management, memory management, file
management, and IO management.
Process Management
Our computers run a lot of software. Word processing documents, internet
browser, a spreadsheet document, video games - all of these are examples of
software. But how does the software know what to do? Being on Codecademy, we
might already be familiar with this answer - computer programs! Computer
programs contain specific instructions that dictate how a program should work
when they’re run.
When we run a program, the instance of that execution is represented by a
process. Operating systems handle the responsibility of managing active
processes.
Memory Management
We utilize a significant amount of memory in order to store data in our
computers; however, not all data is treated the same! Some data, like pictures,
need to be stored permanently. Other data, like the information we need to run a
process, only needs to be stored temporarily while the application is in use. This
temporary memory is known as primary, or main, memory. While hardware like
hard disks are used to store permanent data, the operating system is responsible
for the management of primary memory stored in RAM.
File System Management
If we store source code, such as a C program, in a folder on our computer, we are
utilizing our computer’s file system. The operating system manages information
about individual files as well as the directories they belong in. The OS is also
responsible for maintaining file systems by being able to perform tasks such as
creating, deleting, renaming, and copying files and/or directories.
IO Management
Keyboards and speakers and mice, oh my! IO stands for Input/Output and
represents the devices used for interaction. A mouse is considered an input
device, because we use them to send data to our computer. A monitor is
regarded as an output device since it is used to communicate data (like an
image) to us, the user. The operating system plays a large role in managing IO by
ensuring communication between IO hardware and IO software.
Wrapping Up
Nice job reaching the end of this article. Let’s go over what we learned:
The operating system (OS) is system software that manages the basic
functionalities of a computer.
Every computer has at least one operating system. The operating system
starts running as soon as a computer is turned on.
Some of the tasks that an OS is responsible for are process management,
memory management, file system management, and IO management.
Setting Up A Linux Environment
Learn how to set up Linux to run it yourself!
In this coming section, you will learn how to set up a Linux Ubuntu operating
system on your device.
We will go through two options:
Accessing the Linux Ubuntu OS through a virtual machine. This option
allows you to try out Linux Ubuntu without having to boot it to your actual
computer. We’ll be installing an application called VirtualBox and running
an instance of Ubuntu off that.
Dual-booting your current machine with the existing OS and Linux Ubuntu.
This means you can make your computer run Linux natively from startup,
getting the full experience! This one includes a bit more intention, so
definitely check out our tutorial.
Let’s get started!
Installing Linux Using a Virtual Machine
In this article, you will learn how to install Ubuntu, a Linux distribution,
onto a virtual machine using VirtualBox.
What we’ll be learning
If we want to experiment with Linux without affecting your main operating
system (OS) at all, we can use a virtual machine (VM). We can run Linux
directly atop our primary OS, whether it’s Mac OS X/macOS or Windows.
In this tutorial, we will specifically talk about installing a Linux distribution
called Ubuntu inside your VM software. However, the instructions are pretty
similar for running other Linux distributions. We’ll walk through
installing VirtualBox, creating a VM within it, and installing the latest Ubuntu
distribution to the VM.
About VirtualBox
VirtualBox is an open-source hypervisor that is developed by Oracle. It is similar
to an emulator that creates and runs VMs where we can install different OSs
without having to tinker with our disk partitions or worrying about impacting our
primary OS. Instead, we run a different OS like Ubuntu as if it were another
program running on our computer.
Installing VirtualBox
To install VirtualBox, first, go to the download page on the VirtualBox website.
Select and download the correct package for your primary OS (the host OS, in
virtualization terminology).
Once the package is installed, install VirtualBox as you would typically install a
program. Feel free to use the default installation options.
Create a VM
Provisioning a machine
Once VirtualBox is installed on your machine, start the program and you should
see the VirtualBox Manager window open.
In this screen you will see options to create and add VMs to VirtualBox, as well as
any VMs you have previously created.
Select the “New” button to create a new VM. The prompt will ask for a name for
the VM, a file path for where to save the VM files. There are options for the “type”
of OS you would like to install on your VM, such as Windows, macOS, or Linux. It
will also ask for the “version” of the OS you will install, such as Ubuntu or Debian.
For this tutorial please select Linux for the “Type”, Ubuntu (64-bit) for the
“Version”, and select “Next”.
The following screen will ask to select the memory size to allocate for your
machine. This will set aside a certain amount of RAM on your host machine to be
used for your VM when it is running.
Please allocate 1024 MB and select “Next”.
The next step is to create a virtual hard disk for your VM which is where files and
programs will be saved when operating your VM. Please select “Create a virtual
hard disk now” and then click the “Create” button.
You will then be prompted to select the type of hard disk file. Select “VDI
(VirtualBox Disk Image)” and click on “Next”.
Select whether the new virtual disk should be of a “fixed size” or dynamically
allocate space as it fills up. Select “Dynamically allocated” and click “Next”.
Then set the maximum size for the disk to store file data, and then click “Create”
to finish provisioning the VM.
VirtualBox will bring you back to the main screen where you can see your newly
created VM.
Ubuntu
Download Ubuntu
In order to install an OS to a VM you will need to install the OS just like you would
on a regular computer. You’ll need to download a copy of the installation.
The latest version LTS version of Ubuntu (as of early 2022) can be downloaded for
free here.
Installing the OS
Now you should have everything ready to install Ubuntu. From the VirtualBox
Manager screen, double click the VM you created on the left and a prompt will
appear asking to select the start-up disk. Use the dropdown menu to select the
Ubuntu image that you downloaded in the previous step and click “Start” to boot
the VM.
VirtualBox will open a new window where you can see the display for your VM!
From this point on, all these instructions take place in the VirtualBox window
loading Ubuntu.
The VM will boot to a welcome screen where you can select “Install Ubuntu” to
start the installation process. Follow the prompt to select your Keyboard
Language. A normal installation will include a number of apps and software
whereas a minimal installation will only include basic utilities and you can install
your own as you go. We’ll use the normal installation for this tutorial. You can
check “Download updates” to update software packages as part of the
installation process.
In the next screen, select “Erase disk and install Ubuntu”. Don’t worry! This takes
place inside your VM and won’t affect your primary disk. Click “Install now” to
continue. Ubuntu will prompt you to select your location and create a username
and password. Afterwards, the installation will begin.
The installation can take a bit of time depending on your installation type and
your internet speed:
After restarting the VM you can log into your account and use your Ubuntu
machine! Since our Ubuntu installation is completely contained within a VM, it’s
practically impossible to screw up your host computer.
Conclusion
Now you can feel free to play around, try out the programs, new commands,
install random software, and explore without fear of breaking anything. The only
thing you can accidentally impact is the VM but it can simply be deleted and
reinstalled again!
How to Dual Boot Linux
In this article you will learn how to install Ubuntu as a second operating
system you can boot on your current computer.
What We’ll Be Learning
If you want to experiment with Linux running as a desktop while keeping your
existing operating system, you can set up a dual boot installation of Linux. This
allows you to select which operating system is booted when the computer is
started.
In this lesson we’ll walk through how to partition your hard drive to create space
for a second operating system, creating a bootable USB drive with the Ubuntu
installation software, and using it to boot Linux on the computer.
To follow along this tutorial, have an empty USB drive (with at least 2GB capacity)
on hand. It’s best to free up any extra storage in your computer too.
Note that this tutorial includes specific directions for Windows, but most of this
tutorial applies to a Mac dual boot as well.
Prepare Installation Media
In this tutorial, we’ll be loading Ubuntu onto a USB drive so we can boot from the
USB. We are using Balena Etcher to create a bootable USB. Etcher is a program
that works on Windows, Mac OS, and Linux. It provides an easy to use interface
for burning disk images. You can download and install the program from
the Balena Etcher download page.
After installing Etcher, you’ll need to download a copy of the Ubuntu installation.
You can download the latest version of Ubuntu from their website for free. In this
article, we will use the latest LTS version as of early 2022.
After downloading the Ubuntu installation file, open the Balena Etcher program
and insert the empty USB drive to your computer. Select the Ubuntu image we
just downloaded as the image we would like to burn in Etcher. Then, carefully
select the empty USB as the target. Flashing the image will erase all the contents
on the target drive, so be sure you have the correct target selected. Next, flash
the image to the USB drive.
Afterwards, you’ll have a live USB. You’ll be able to boot using the USB drive from
almost any computer into a working copy of Ubuntu. However, changes you make
to any files will not persist until you have installed Ubuntu to the hard drive.
A new dialog window will open with a field where you can enter the amount of
disk space, in megabytes, you would like to free up for the Ubuntu installation. A
minimal Ubuntu installation requires 8.6 GB, and the Normal installation requires
25 GB of free space. Any additional software and programs you install in Linux
will use this space, so be sure to account for disk usage depending on how you
plan on using Linux!
After selecting the “shrink” option, the hard disk partition will be resized, and
create a new partition with unallocated disk space, which will be used for the
Ubuntu installation.
Install Ubuntu to partition
Now that you have the Ubuntu installation media ready, and freed space on your
hard drive, you are ready to install Ubuntu as a dual boot option.
In this section, we’ll be asking you to follow instructions while you restart your
computer, so try to access this page/these instructions on another device.
Plug in the bootable USB to the computer you are installing Linux on
Restart the computer.
To boot to the USB drive you may have to change the boot order in your
BIOS to boot from the USB drive first. Alternatively, you may be able to
select the USB drive to boot into from the BIOS screen. These options will
change depending on your motherboard or manufacturer.
For Mac: As your computer is restarting, hold onto the alt key to load the boot
menu - you should find the dual boot option you named earlier.
When you boot into the Live USB, you’ll encounter an Ubuntu welcome screen.
The screen will provide you the option to “Try Ubuntu” or “Install Ubuntu”. The
first option is suited for testing if your computer’s Wi-Fi drivers or other hardware
will work with Ubuntu. You will choose the second option for the installation.
Follow the prompt to select your Keyboard Language. If you don’t know your
keyboard layout, then Ubuntu can help you find your layout.
The next screen, Updates and other software, will let you pick which type of
software you would like to be installed during the installation process. A Normal
installation will include a number of apps and software whereas a Minimal
installation will only include basic utilities and you can install your own as you go.
We’ll use the Normal installation for this tutorial. You can check “Download
updates” to update software packages as part of the installation process.
On the “Installation type” screen, you will have options on where to install the
Ubuntu on your drive.
The “Install Ubuntu alongside Windows” option will automatically create
partitions for the hard drive using the unallocated disk space we freed up
earlier.
The “Erase disk and install Ubuntu” option will delete everything on your
hard drive and install Ubuntu, This means everything from your Windows
operating system will be erased.
“Something else” option will open an advanced menu for you to manually
create the partitions for the Ubuntu installation.
In this tutorial we’ll be selecting the option to install Ubuntu alongside Windows
in order to dual boot Linux. Be sure to pick the first option to avoid accidentally
deleting any files or if you would like to take a closer look at how storage will be
allocated, select the “Something else” option.
After clicking Install Now, Ubuntu will ask for your location.
Finally, you need to create your user account on the system. Fill in your name
and verify if the username that is suggested is fine for you. You can also change
the name of the computer afterwards. Clicking “continue” will begin the
installation. The installation can take a bit of time depending on your installation
type and your internet speed, so take a break and come back.
After the installation is finished, you can restart the computer and remove the
USB stick.
On Windows, When the computer restarts you will see the GRUB menu
which is installed by Ubuntu. The GRUB boot screen will show you the
installed systems such as Ubuntu and Windows.
On Mac, you can hold down alt as your computer restarts to get the Boot
Menu to select between MacOS or Ubuntu. To avoid having to hold
down alt every time, you can download a boot manager like rEFInd.
Now, every time you start your computer, you can select which operating system
you want to use. Enjoy your new dual-booting system!
Features of the Linux Desktop Environment
Learn about features of the Linux environment!
In this upcoming content, you will learn about how to explore a Linux
environment, in particular the Ubuntu environment.
You will learn about what comes preinstalled in the Linux Ubuntu desktop, what
the Linux file system looks like, how to install applications, and some basic
features of how servers are started in a Linux environment.
Learn
Desktop Applications in Linux Ubuntu
Introduction
Ubuntu is a popular
Preview: Docs Linux is a family of Unix-like operating systems that are all based
on the Linux kernel.
Linux distribution due to its ease of installation and user-friendliness. This Debian-
based operating system is comprised of lots of free and
Preview: Docs Loading link description
open-source software
. This lesson will focus on the desktop version of Linux Ubuntu. Specifically, we’ll
discuss:
Some open-source applications in Linux and their commercial equivalents
Pre-Installed applications on the Ubuntu desktop
Terminal-based applications
The Linux Ubuntu operating system has many similarities to popular commercial-
based operating systems like Windows or MacOS. Linux Ubuntu is comprised of a
multi-user desktop environment complete with user login, wallpapers, clickable
icons, and menus to access applications. Just like in other desktops, we can
customize a unique look and feel and manage system inputs and outputs.
We can change screensavers, change our Bluetooth connections, and more!
Follow along as we explore this desktop environment, in particular its
applications.
Pre-Installed Applications
Along with a browser like Firefox and a word editor like Libre Office, Ubuntu also
comes pre-installed with a file manager, a calendar application, and many other
useful utilities.
FUN FACT: Did you know that the development budget for Firefox only equals
about one hour of Google revenue?
If we need additional software, it can easily be discovered and installed. Ubuntu
offers an “App Store”-like application called Software Center. This allows you to
search for and install thousands of applications with a click of a button.
Additionally, an experienced user could also manually use the Linux shell via
command-line to quickly find and install the same software.
Review
Congratulations, we’ve reached the end of this lesson! We can see that the Linux
Ubuntu desktop is really not that much different from the Windows or macOS
desktop that may be more familiar to most. Ubuntu provides similar tools and
applications but prioritizes open-source software over closed-source.
To review, we’ve discussed:
Open-source software in Linux and proprietary software equivalents
Pre-Installed Ubuntu applications
Non-graphical or Terminal-based applications
Ubuntu Linux comes pre-installed with a variety of common applications that will
get you up and running in no time, As we become more familiar with the Linux
environment, we may look for more speed and functionality in non-graphical
applications in the command line where we can directly communicate with the
Linux shell.
We encourage you to explore these applications in your own Linux desktop
environment!
The Linux Filesystem
In this article, we will be exploring the Linux filesystem hierarchy. We
will describe the directory structure and how it differs from other
operating systems.
Linux Filesystem
Linux OS’s have a secure, multi-user filesystem. Its directory structure is
organized to maintain a good balance between security and functionality.
Directories accessible to the user are separated from directories needed by the
administrator.
Linux generally follows the Filesystem Hierarchy Standard (FHS). This standard
reference (developed in 1994) describes the common layout conventions used by
most UNIX and UNIX variant systems. It consists of a single primary (or root)
directory with multiple branching sub-directories.
Root Directory ( / )
The root directory / is the starting point for the entire Linux filesystem
hierarchical tree. It is the top-most directory from which all other file systems are
mounted at system boot up. All files and folders will branch from the root
directory even if the data is stored in different places physically.
The root directory is owned by the root user (admin) and its permissions are
tightly controlled to allow only administrators to add, remove, or modify files and
folders in this directory.
Sub-Directories
By convention, Linux has several important sub-directories, each with its own
specific purpose and permissions. Some of these sub-directories are accessible to
anyone (i.e. /tmp) while others are only accessible to the administrator
(i.e. /etc).
This table provides some details on the purpose of each of the common Linux
sub-directories.
SUB-DIRECTORY PURPOSE