{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Linux - the basics\n", "\n", "::::{grid} 2\n", ":outline:\n", "\n", ":::{grid-item}\n", ":columns: 9\n", "\n", "**Learning goals:** \n", "- To understand the main difference between Linux and Windows/OSX\n", "- To understand the main advantages and disadvantages of Linux\n", "- To understand the difference between normal and superuser (root)\n", "- To learn some basic terminology\n", "\n", "**Keywords:** Linux CLI commands, finding help on commands, wildcards\n", "\n", "**Associated material:** Cheat sheet of the most common Linux commands.\n", "\n", ":::\n", "\n", ":::{grid-item}\n", ":columns: 3\n", "\n", "```{image} img/Tux.svg\n", ":width: 150px\n", ":name: Tux\n", ":align: right\n", "```\n", "\n", ":::\n", "::::" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", "\n", "\n", "Now it is time to discuss some of the Linux basics. This description does not aim to be complete, but rather practical in terms of pointing out the difference between Linux, Windows and OSX. The differences appear to - based on experience - a lot of confusion so we start from there. Unlike Windows and MacOS, Linux is open-source software, thousands are volunteer programmers participate in the development. As already discussed above, it is the dominant operating system in all HPC. \n", " \n", "Before discussing Linux further, let's list some of the advantages and disadvantages.\n", "\n", "If you are considering of installing Linux or don't know much about it, here is a short video discussing the basics:\n", "\n", "\n", "```{dropdown} **Movie: Linux for beginners**\n", "\n", "\n", "
\n", " MS Thesis (University of Helsinki, Finland): \"Linux: A Portable Operating System\"\n", " Probably the most influential MSc thesis in any field ever.\n", "\n", "\n", "* Here is a [link to his thesis](http://content.time.com/time/specials/packages/article/0,28804,1970858_1970909_1971691,00.html)\n", "* Torvalds is also the creator of [Git](https://en.wikipedia.org/wiki/Git)\n", "* Was awarded the [Millenium Technology Prize in 2012](https://taf.fi/millennium-technology-prize/winners-2012/). The [Millenium Technology Prize](https://taf.fi/millennium-technology-prize/) is worth 1 million Euros. Previous recipients in the field of computers include [Sir Tim Berners-Lee](https://www.w3.org/People/Berners-Lee/), the inventor of the [World Wide Web](https://en.wikipedia.org/wiki/World_Wide_Web).\n", "* Torvalds has been named as one of the world's most influential people by the Time Magazine several times ([here is the article from 2004](http://content.time.com/time/specials/packages/article/0,28804,1970858_1970909_1971691,00.html))\n", "\n", "\n", "```{dropdown} **Movie: The mind behind Linux, Linus Torvalds. TED talk.**\n", "\n", "
/
and the directories under it are referred, for example, as /home
where the *slash* at the beginning refers to the root directory: thus, /home
says that the directory home
is located at the first level under the root directory. If we have a user sam
, then her home directory would be located in /home/sam
, that is, it is at the second level below the root directory.\n",
"\n",
"Note that if you are running Linux using WSL or WSL2, this is how your Linux part is organized. The organization is also very similar in OSX. The most notable difference is that the user directories on a Mac are located under /User
\n",
"instead of /home
.\n",
"\n",
"**Important:** If you are running pure Linux, Linux through a virtual machine or Mac OSX, you have two ways of accessing your files and the file system: \n",
"\n",
"1. Using the terminal (=console) window and\n",
"2. using the file manager provide by your GUI. This is, of course, similar to Mac or Windows.\n",
"\n",
"However, if you installed Linux using WSL, your Windows systems does not have access (or \"it doesn't see\") your Linux partition. This means that the only way to access your files is using a console (well... there are other options but that they would require more work). \n",
"\n",
"\n",
"\n",
"```{figure} img/linux-file-system-diagram.svg\n",
":width: 700px\n",
":name: linux-file\n",
":align: left\n",
"\n",
"Sketch of a typical Linux file system. Orange: this is the location of user directories. For example, if your username issam
, this is where your personal files and directories are. The path to this directory would then be /home/sam
. Green: The directory /opt
is a good place to put your own software (that you compile). \n",
"```\n",
"\n",
"### More about directories\n",
"\n",
"Here are brief explanations of some of the directories shown in the Figure. Note that typically all of the directories in the figure contain subdirectories that are named according to their purpose.\n",
"\n",
"/bin
/usr/bin
.\n",
"\n",
"/home
/home
. For example, if there are two users /sam
and /jane
in the system, their personal home directories would be located at /home/sam
and /home/jane
, respectively; for example, their personal download, music, video etc. directories would be then located (and typically created automatically when a user is created) at /home/sam/Downloads
, /home/sam/Music
, /home/jane/Downloads
, and so on.\n",
"\n",
"/usr
and /usr/bin
/home
. Historically, /usr
was the location for the users' home directories. In all modern installations it contains various system files and directories. The directory /usr/bin
is a bit special since software (non-operating system related) is put here. For example, web browsers such as Firefox or graphics software are usually installed here (=not in /bin
which contains mostly OS-related executables.\n",
"\n",
"\n",
"/boot
/etc
/etc
contains configuration files for the system and some applications. For example, the password-containing (encrypted) passwd
file is located in there. \n",
"\n",
"/sbin
/sbin
instead of /bin
.\n",
"\n",
"/media
/mnt
/media
as described above. This directory can be used to mount devices manually.\n",
"\n",
"/tmp
/dev
, sys
and /proc
/lib
/opt
/var
/var/spool
and, very importantly, different log files in /var/log
. The files include syslog
, auth.log
and they include information about functioning of the different devices such as Wifi and bluetooth, users logging in and out and failed attempts to login, and so on. When something goes wrong, these files usually contain the information that can help to fix problems. \n",
"\n",
"\n",
"### Hidden or the so-called dot-files:\n",
"\n",
"All operating systems contain hidden files and directories. They contain are files and directories that contain information about the system configuration. \n",
"\n",
"In both Linux and OSX, these hidden files are the so-called *dot-files*. \n",
"\n",
"**How to see the hidden files:**\n",
"\n",
"We will discuss them more later, but you can make them visible (try it out but there is no reason to keep them visible all the time) from your GUI file manager's options in both Linux and Windows.\n",
"\n",
"On Mac, there is no direct access to them through the file manager, but you can make them visible in Finder by clicking command-shift-dot.\n",
"\n",
"**Additional info:**\n",
"\n",
"1. As always, keep backups of your own personal directories and data.\n",
"\n",
"\n",
"\n",
"### More information\n",
"\n",
"- [Linux vs. Windows: What's the difference in 2020?\n",
"](https://www.linuxjournal.com/content/linux-vs-windows)\n",
"- [The Linux Directory Structure, Explained](https://www.howtogeek.com/117435/htg-explains-the-linux-directory-structure-explained/)\n",
"- [Linux Directory Structure Explained for Beginners](https://linuxhandbook.com/linux-directory-structure/)\n",
"- [Filesystem Hierarchy Standard](https://www.linuxjournal.com/content/filesystem-hierarchy-standard)\n",
"- For the afficionados: There are *a lot* of different file systems, see: [Wikipedia: Comparison of file systems](https://en.wikipedia.org/wiki/Comparison_of_file_systems)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Two user types: superuser and normal\n",
"\n",
">“There are only two industries that refer to their customers as ‘users’.”