BackReturn Home


An Introduction To Using Linux

These notes are loosely based on this video series by Eli the Computer Guy. It may contain certain "Eli-isms", as well as some of my own interpretations. Extra resources are interspersed throughout.

Contents

General Background Information
Easy Installation
Using Basic Commands...
...For Closing The Shell
...For Learning More
...For Navigating Through "Directories" or "Folders"
...For Handling "Files" or "Folders"
...For Installing / Updating / Uninstalling Software
...For Handling Permissions
Conclusion


General Background Information

An "Operating System" (or "OS" for short) is the main piece of software on a computer. It gets all of the other software to work with the hardware of the computer. The core part of the Operating System is the "Kernel". The Kernel is a program that always stays in Memory. Two popular Operating Systems are Microsoft Windows and macOS.

The GNU Operating System + The Linux Kernel = GNU+Linux [This is what most people are referring to when they just say the word "Linux".]

If you are just curious about GNU+Linux and don't know where to begin, then skip to the next section Easy Installation.



Types of GNU+Linux:

• "Forks"
Each may use a different set of commands, different package managers, and/or have a different file structure. [Example: Debian vs. Redhat]

• "Distributions" (or "Distros" for short)
Each may come bundled with a different GUI, different default settings, and/or different applications. [Example: Ubuntu vs. Fedora]

• "Versions"
Each may change through a periodic update (e.g.: security patches). This is usually designated by a version number. Note that legacy software may only run on a specific version.

As you go down the above list, it becomes more specialized, more specific.

All of this might sound complicated. It doesn't have to be! Pick a Distro that will suit your needs. Some questions to ask yourself:

• Does it need to run on a specific piece of hardware?
• Am I willing to pay to get extra tech support?
• Is everyone who is going to use it familiar with it? If not, are they willing to learn?



"Free Software" can mean either:

• You can see and modify the code of a program ("Free, as in speech")
• No purchase is necessary in order to use a program ("Free, as in beer")

Some people also use the term "Open Source", or the acronym "FOSS" (short for "Free and Open Source Software"). There can be many nuances behind the usage of these terms.

Whatever the case, there may be a specific "Terms of Service" (i.e.: rules for how we can use it). Also, look carefully at the License. These are very important considerations when using any software, not just GNU+Linux. We need to make sure that we can do with it what we think we can do with it. Software with a particular License may require that anything built off of it must also use the same License. Further, the main piece of software may follow one License, while add-ons might follow another.



• "Command Line Interface" (or CLI) - This is a text-based way of interacting with a computer (i.e.: you type in "commands" to get it to do things). The CLI is often just referred to as the "Shell" (because it is the software that 'surrounds' or interacts with the Kernel). The default Shell is usually a program called Bash, but there are others available too (e.g.: Tcsh/Csh, Ksh, Zsh, Fish).

• "Graphical User Interface" (or GUI) - This gives a visual way of interacting with a computer (e.g.: a background, a taskbar, menus, icons, and other things that can be selected with the mouse cursor). The core component of the GUI is a "Window Manager". The Window Manager allows the computer to display the processes going on inside of it visually, as boxes or "windows".

• "Desktop Environment" - This gets the different parts of the GUI to work together (e.g.: it allows different windows to interact so we can do things like drag-and-drop). Some common ones are Xfce and KDE. It may come with specific applications built-in.


Easy Installation

Here we will give a simple step-by-step procedure for running LinuxMint (a very easy to use Distro derived from Ubuntu). This will let us try it out, and if we want, permanently install it over Microsoft Windows or some other OS. If you are worried about accidentally deleting all of your files, then do all of this on a computer that you are NOT worried about wiping out. [Eli shows how to run a copy of Ubuntu inside of macOS using VirtualBox. This is another option for testing it out if you are hesitant to go through the process described below.]

Step 1: Download the ISO of LinuxMint that looks interesting to you, whether it be "Cinnamon", "MATE", or "Xfce". [This determines the Desktop Environment.] If you are trying to install it on an older computer, use the Xfce edition. If this is not an issue, then it doesn't really matter which one you pick so long as it is compatible with your processor. If you are unsure if your processor is 32-bit or 64-bit, search for your computer model on The Internet to find out, or look at your system settings.

Step 2: Verify the ISO to make sure that it is a legitimate (unhacked!) copy and will install properly. This is an important step. DO NOT skip it. If it checks out, then go to the next step. If it doesn't, re-download it and check it again.

Step 3: Grab an empty USB drive. It will have to be at least ~2+ GBs in size. The ISO has to fit on it.

Step 4: Download and install Universal USB Installer by Pen Drive Linux. This program will format the USB drive and put the ISO onto it. Follow the instructions in the window that appears when you open up the program. Be very careful when picking the drive letter for the USB! Make sure that it is the right one or you might accidentally delete what is on your hard drive.

Step 5: While the test computer is off, plug in the USB drive that you just set up into one of its USB ports.

Step 6: When you turn it on, be prepared to press the key that will open up the "boot menu". It is usually the "escape" (ESC) key or one of the "function" (F) keys at the top of the keyboard. If you do not press the key in time, then restart the computer and try it again until you have reached the boot menu.

Step 7: From within the boot menu, pick the drive letter that matches where the USB is plugged in and hit ENTER. LinuxMint should now start up normally. When it starts up, the taskbar on the bottom of the screen works much like an older version of Microsoft Windows. Clicking the little "LM" in the bottom left-hand corner will open up a menu that shows the different types of applications that LinuxMint comes packaged with. Explore it a little to see if you like it.

Step 8: If LinuxMint is something that you would be interested in using regularly, then double-click the icon on the desktop that says "Install Linux Mint". This will guide you step-by-step in overwritting the OS on the hard drive with LinuxMint. Again, be sure that there are no files on the hard drive that you want to save because they will be permanently deleted. Also, be warned, GNU+Linux does not always have the best hardware support (particularly when it comes to things like graphics cards and external hard drives). Make sure that all of your hardware works before installing!

Step 9: After it is installed, a welcome message should appear. Follow what it says. Afterwards, you may still need to do a little bit of housekeeping (e.g.: install other updates / drivers / codecs, set up the firewall, etc.). Not all of these things may be applicable to you.

Congratulations! You are now a Linux user.


Using Basic Commands...

Because LinuxMint has a GUI, we can get by without ever really using the Shell. However, knowing how to use it can be very useful. Sometimes people copy-and-paste commands from various websites into the Shell without understanding what those commands actually do. This is not always a good idea. Instead, let's try to learn why we might use a particular command before we type it in. Please keep in mind that all commands are case-sensitive (i.e.: there is a difference between typing something in uppercase or lowercase, and we must use spaces properly). Some commands are also Distro specific. Here, we are focused on commands appropriate to LinuxMint. [If you are interested, there is also a little interactive course at LinuxCommand.org for learning more.]

...For Closing The Shell

To open the Shell, click the black icon on the taskbar labeled "Xfce Terminal", or press CTRL + ALT + T. The window that pops up is the Shell. This is where we can type in commands.

To close the Shell, type in exit and press ENTER.

...For Learning More

If we input a letter and press TAB, then we will get a list of all of the commands that start with that letter.

Type in whatis followed by a space, then a command, and press ENTER. This will tell us very briefly what that command does.

If we need more information, type in man followed by a space, then a command, and press ENTER. This will bring up a page within the manual that covers that command. Yes, the manual for the Operating System is built into the Operating System itself! ☺

There is a text reader called less integrated into the Shell. The page that pops up whenever we use the man command is actually a text file. Use the ↑ UP ARROW and ↓ DOWN ARROW to navigate through this text file, or press ENTER to advance through it line-by-line. Press H for a descrption of how to navigate through text files in general with less. Press Q to quit using less.

There is one other way to find out more information about a command. Type in the command followed by a space, then --help, and press ENTER. The information that comes up is very similar to the page in the manual, but it is not a separate text file. It appears inside the Shell itself.

Notice that, outside of a text file, the ↑ UP ARROW and ↓ DOWN ARROW will just cycle through our previously typed commands. This can sometimes make the information that the --help command brings up impossible to scroll through. In order to open up this information in less, type a vertical bar | immediately after --help, followed by the word less, and then press ENTER. This will open up the same information in a text file that we can scroll through with the arrow keys. Again, press Q to quit using less.

More often than not, we will probably use man instead of --help|less, but try both and see what works best for you.

If there is ever too much stuff on the Shell screen at once, type in clear and press ENTER. This will remove all of the previously entered commands and extra text.

...For Navigating Through "Directories" or "Folders"

Whenever we are using a GUI, we usually refer to a specific location on a drive as a "folder". Whenever we are using a CLI, we usually refer to a specific location on a drive as a "directory". Directories and folders are equivalent.

People often use the terms "file" and "folder" interchangeably. However, it can sometimes be helpful to differentiate between the two. A "file" is something with a particular extension. Files can be:

documents (with extensions like .txt or .pdf)
images (with extensions like .jpg or .png)
audio (with extensions like .mp3 or .ogg)
videos (with extensions like .mp4 or .avi)
...and so on.

Folders can contain files or other folders. Please do not get these terms confused! Again, folders are locations, while files are things within those locations. Since files and folders "branch out" of other folders, they create a pattern called the "File Tree".

Microsoft Windows uses letters like "C:\" to specify different drives. GNU+Linux does not do this. Instead, all drives are treated as if they are part of a single directory.

Whenever we open the Shell, we will see something that looks like this...

username@machinename: ~$ ■

The tilde ~ means that we are in our "home directory" (i.e.: where all of the user folders are located). It is called "home" because that is where we keep our personal files.

To find out the directory that we are in at any given moment, type in pwd and press ENTER. This will give us the "address" of our current location within the File Tree, a list of folders separated by forward slashes /. The letters pwd mean "print working directory", and the "working directory" is our current location.

To get a list of everything within this directory, type ls and press ENTER. The letters ls mean "list", and a list of folders and/or files should pop up. Any text in blue is the name of another directory.

To change directories (i.e.: to open up a folder), type cd followed by space, and then the name of that directory. Press ENTER. We will see the text in front of the cash sign $ change to show that we are now within a different directory. The letters cd mean "change directory".

We can jump to any directory that we want if we know its address within the File Tree. Therefore, we have to distinguish between where we were previously (i.e.: our "relative path"), and the actual address of our current location (i.e.: our "absolute path"). To go back to the directory that we were just in (i.e.: along our relative path), type in cd followed by a space, and then a hyphen -. Press ENTER. To go up a folder (i.e.: along our absolute path), type in cd followed by a space, and then two periods. Press ENTER. To reiterate:

cd - takes us to the directory that we were in previously
cd .. takes us up a folder within the same address

If we ever want to get back to the home directory, type in cd followed by a space, and then a tilde ~. Press ENTER.

The farthest that we can go down along the absolute path is called "root". It is called "root" because it is the lowest point of the File Tree, the core from which other files and folders extend. The home directory is contained inside of the root directory.

We can get to the root directory by typing in cd followed by a space, then a forward slash /, and pressing ENTER.

If we list the contents of root, we will see a bunch of folders related to the functioning of the Operating System. While not all Distros use the same scheme, the folders here usually follow a particular pattern called the "Filesystem Hierarchy Standard" (or FHS for short). To give a general summary of the folders that you will probably see here and what they contain:

Folder Name Contents
/bin
binaries A "binary" is essentially a program. This is how the system keeps track of applications.
/sbin
system binaries This contains programs related to the system itself.
/boot
bootloaders This contains everything needed for the OS to boot up.
/dev
devices This contains "pseudofiles" related to the hardware of the computer. For example, "sda" is a disk, and a number after it is a partition on that disk.
/etc
et cetera This contains system-wide applications and settings.
/lib
libraries This contains files that are used by the programs within /bin and /sbin.
/mnt
or
/media
mount This contains all external drives (USB, SD, etc.).
/opt
optional This usually contains software that is manually installed, or applications that are self-created.
/proc
processes This contains "pseudofiles" that are generated to describe system processes and the use of system resources. This information is handy for developing programs.
/root
This is the root user's home folder.
/run
This is a "temporary filesystem" (or "tempfs") that runs inside of RAM. It shows the runtime information for boot processes. Everything within this folder disappears with a shutdown or reboot.
/snap
This contains "snap packages", self-contained applications that run differently from normal.
/srv
service This contains service data (such as information related to a webserver or FTP).
/sys
system This is similar to /run. It shows what is going on within the Kernel.
/tmp
temporary This holds file data that is in use. For example, it can contain information for a text document that hasn't been saved yet. If a program crashes, check here before you reboot to try to recover the files.
/usr
user This contains applications installed by specific users. It is different from /bin.
/var
variable This contains files that are expected to change dynamically in size. For example, it can include "log files" (which keep track of what is going on inside of a program) or the "spool" (which shows what is in the printer queue).
/home
This contains all of the user's personal files. It is similar to "My Documents" in Microsoft Windows.

It is okay if none of this makes any sense yet. We just want to give a general idea of what is in here.

To reiterate:

~$ means that one is in the "home directory", where your user files are
/$ means that one is in the "root directory", where the system files are

It is called "home" because that is where you keep your stuff (i.e.: personal files), and it is called "root" because that is the lowest point in the File Tree.

...For Handling "Files" or "Folders"

To make a new directory (i.e.: a new folder), type in mkdir followed by a space, and then the name that you want to give the folder. Press ENTER. The letters mkdir are short for "make directory".

We can move a file by typing in mv followed by a space, the name of the file, another space, and then the address of the location that we want to place it in. Press ENTER.

We can copy a file in the same way, but by using cp instead of mv. Rather than shifting the file from one location to another, it will make an extra copy within the location we specify.

To remove a file (i.e.: delete it), type in rm followed by a space, and then the file name. Press ENTER. Please note that this deletes the file directly; it does NOT put it into the "Trash" folder!

To recap:

move is mv
copy is cp
remove is rm

Any text in red is a file that is "zipped" or compressed. To "unzip" or decompress it, use the command unzip, followed by a space, and then the file name. Press ENTER. All of the files that it contains will then appear within the same directory.

...For Installing / Updating / Uninstalling Software

Linux Mint has a program called "Software Manager" (under "System" in the main menu). This program allows one to install / uninstall various apps with just a click of a button (through an interface that is similar to something like Google Play). However, one will eventually need to learn some commands if they want to install stuff that Software Manager doesn't have.

In order to change system files, which includes installing and uninstalling software, one has to be in "superuser". [This is equivalent to what Windows would call "administrator".] Superuser privileges are often expressed through a command, sudo. This is short for "superuser do". Whatever command comes after it will be run under "superuser," but we will probably be prompted to enter a system password first.

The program through which other programs are installed / updated / unistalled is called a "package manager". The one on LinuxMint is known as "Advanced Packaging Tool". It gets the files that it needs from The Internet. The command for it is apt.

Type in sudo apt install followed by a space, and then the name of a program. It will install this program once we hit ENTER.

Similarly, we can replace the word install with update, remove, and purge to do these actions on that same program after it is installed. Sometimes different aspects of a program will be separated into distinct "packages". Therefore, the difference between remove and purge is that the latter also gets rid of all associated files.

Another way to uninstall software is through a program called "Synaptic Package Manager" (under "System" in the main menu). A "Quick Introduction" dialog box should appear upon opening this program. It will briefly describe how to use it. Similar to the remove and purge commands, packages can be marked for "removal" or "complete removal" by right-clicking their name within the list.

...For Handling Permissions

Sometimes we have to change the permissions on an individual file or folder before we can do anything with it. By "permission", we mean that we have to specify who can do what to which file or folder.

When it comes to "Who?", there are only four possibilities:

Account Meaning
user
This is the owner of the file or folder.
group
This is when multiple users share in the ownership of a file or folder.
other
This is every user outside of the above two categories.
all
This refers to the above three categories simultaneously.

When it comes to "What?", there are only three actions that can be done:

Action Meaning
read
To "read" a file or folder is to be able to view its contents.
write
To "write" to a file or folder is to be able to modify it (i.e.: to add or delete from its contents).
execute
To "execute" a file is to be able to run it; this assumes it is a program. To "execute" a folder means that we can enter into it with the cd command.

For example:

We might find a program that we want to install (e.g.: an "AppImage", a "Shell Script", etc.). But when we try to open it, nothing happens or it returns a "Permission Denied" error.

Let's look at what the permissions of the file are. Type in ls -l followed by a space, and then the name of the file. Press ENTER. [Note that there is a space between the ls and the -l.]

As we have already seen, ls means to "list". In this case, the -l means to put it into "long form" (i.e.: show the details behind the files and folders that are listed). A line of text that is split into columns should pop up. Generally, the layout from left-to-right is...

A string of ten letters and/or hyphens
The number of files that make up that folder
The name of the user of that file or folder
The name of the group of that file or folder
The size of that file or folder (in "bytes")
The date and time of when that file or folder was last modified
The name of that file or folder

The permissions are described by that string of ten letters and/or hypens. This may look complicated, but it is actually pretty straightforward...

• The first character tells us whether it is a file (marked with a -) or a directory (marked with a d).

• The next three characters tell us what actions the user can do with that file or folder. If there is an r, then they can read that file or folder. If there is a w, then they can write to that file or folder. If there is an x, then they can execute that file or folder. The letters r, w, and x always come in this order. If there is a hyphen instead of one of those letters, then it means that the user cannot do that action.

• The next three characters tell us what actions the group can do with that file or folder. It works exactly the same as the above.

• The final three characters tell us the actions that others can do with that file or folder. Again, it works exactly the same as the above.

If we want to change any of these permissions, then we can use the chmod command. This is short for "change mode".

Type in chmod followed by a space. The next character that we type will determine who this command applies to:

Use u for user.
Use g for group.
Use o for other.
Use a for all of the above.

The character after that will determine whether we are adding permissions (with a +), removing permissions (with a -), or setting a particular permission and removing all others (with a =).

The character (or set of charaters) after that will determine what those permissions are:

Use r for read.
Use w for write.
Use x for execute.

This will be followed by a space, and finally, the name of the file or folder that we are changing the permissions of. By hitting ENTER, it will change those permissions.

For example:

If we type in chmod u+x, and then the name of the file or folder, it will allow the user to execute that file or folder once we hit ENTER. In other words, the +x means that we are giving the permission to execute that file or folder to u, the user.

If we type in chmod u-x, and then the name of that same file or folder, it will remove the permissions that we just gave once we hit ENTER. Again, -x means that we are removing the permission to execute that file or folder to u, the user.

To give another example:

If we type in chmod g=r, and then the name of a file or folder, it will allow the group to read that file or folder and nothing else once we hit ENTER. The g=r means allow the group to read that file or folder and remove every other permission from it (i.e.: make it "read only").

In summary...

Step 1: Type in chmod followed by a space.
Step 2: Type in u, g, o, or a to determine who it applies to.
Step 3: Type in +, -, or = to give, remove, or change permissions.
Step 4: Type in r, w, and/or x to determine what actions are allowed.
Step 5: Press ENTER.

There is an alternate way of approaching this same task. Instead of using symbols and letters, we could use a number to represent some equivalent combination:

Base-10 Number Meaning
0
no permissions
1
execute
2
write
3
write and execute
4
read
5
read and execute
6
read and write
7
read, write, and execute

Why are these numbers associated with these combinations? It has to do with their representation in Base-2 (or "binary") and how it relates to that string of ten letters / hypens...

Base-10
0
1
2
3
4
5
6
7
Base-2
000
001
010
011
100
101
110
111
Equivalent Pattern
---
--x
-w-
-wx
r--
r-x
rw-
rwx

We can then use a combination of three numbers to set the permissions for the user, the group, and others at the same time. For example:

Type in chmod followed by a space, 777, and then the name of a file or folder. Once we hit ENTER, it will allow the user, group, and all others the ability to read, write, and execute that file or folder. In other words, anyone can now do anything they want with that file or folder. The first seven allows the user read, write, and execute permissions. The second seven does the same thing for the group. The last seven does the same thing for everyone else.

Be very careful when setting the persmissions to different files and folders, especially ones that are related to the system! Even if we alone are using that computer, we do not need to be able to modify or run every file or folder. In other words, we have to know what a file does in order to know how to handle it properly without messing up the Operating System or leaving sensitive information vulnerable.


Conclusion

We hope that this has been helpful in exploring GNU+Linux and gaining a basic understanding of how to use it. This can serve as a basis for more "advanced" uses of the Operating System, like writing "Shell Scripts", a kind of programming done within the CLI itself.

Thank you for reading! ❤️