In my recent articles about Linux, I gave an overview of the operating system. If you haven't read some of them, I would suggest that you go and check them out. Of course, if you know your way around, then you could skip but I still suggest that you take a quick look. Maybe you'll find something interesting; like... punch cards.
List of previous articles
The Linux operating system, part 1
Then I gave a few historical notes and why we talk about a terminal to enter commands
The Linux operating system - terminal, command line, shell
I touched the topic about how graphics are handled and mentioned some Linux distributions
The Linux operating system structure, graphics and distributions
Then I went on and explained how to start using Linux, together with the three options of a standalone installation, a dual-boot system, a virtual machine and the Linux subsystem for Windows.
The Linux operating system - native installations, virtual machines, live systems
I wrote a tutorial about setting up a virtual machine from scratch
The Linux operating system - virtualisation, a step-by-step guide for VirtualBox
Moving on
I think this is enough of an introduction at this stage, and maybe it's time to actually start using Linux!
Of course, if someone has any questions, just let me know and I'll write a new article about some other concept.
But so I'll skip the use of GUI programs, everybody knows how to use a file explorer, a browser, etc. Let's dive into the basics of the command line.
Feel yourself at home
In Linux every user has a home directory where all his/her files reside. A user can choose whether to permit others to read the files in his/her home. On a personal computer that doesn't matter. Nobody can steal your files if there is nobody else who has access to your computer. Note that this excludes any malicious activity since if someone else breaks in, e.g., by cracking your password. At least, it is highly recommended not to make your files writable by everybody.
When you open the terminal, you will find yourself in your home directory. It is usually marked by the tilde symbol, ~. However, you most likely don't see much if anything. In the beginning of the line you will probably see your username, the name of your computer, and maybe the directory where you are at:
username@MYCOMPUTER:~$
The dollar sign marks the end of the name of the directory you are situated at and any commands that you type will come after it. There are countless options to customise how your terminal looks like. There are (a limited number of) colours to choose from, you can hide your username or your computer name altogether, add a time stamp to each line... etc, etc. At some point I had hidden everything before the dollar sign. It looked more compact... but... over time you realise that it's actually handy. If you're going to connect to other computers and use several terminals, all similarly looking, then... better watch out! You may enter commands to the wrong computer! I once rebooted a server, thinking that it was my local computer... ouch.
You have the right to read, write and execute
You probably want to see what kind of files and directories (folders under Windows) exist in your home. You can use the ls
command which, surprise, surprise, lists the files. This command like many others can take parameters. If you type ls -l
, standing for "long", you will see details about each file and directory. For example:
-rw-rw-rw- 1 username username 15K Mar 11 2020 sympy-equations.ipynb
drwxr-xr-x 1 username username 512 Mar 11 2020 .ipynb_checkpoints/
Both lines start with some symbols d, r, w, x... They describe the permissions. Files start with a dash, while directories start with d. Next there are three sets of three letters. The letters stand for read, write and execute. The first triplet tells what permissions the owner of the file has. Now you may wonder why doesn't the user have all rights by default. Well, you don't want every single file to be executable. And often it makes no sense. Anything that's not a program or a script should not be executable since there are no instructions embedded into it. A picture can't perform any activity.
The next triplet of letter stands for the permission of the user group. On a computer with multiple users, there can be several user groups which can access common directories but a user of another group cannot. The last triplet stands for everybody. Having said that, there is also the almighty user who can see everything. It is called root and it can see any file on the system.
Going out
Now that you know how your home looks like, you might want to start exploring. You see in the line above that in my home I have a directory called .ipynb_checkpoints
. If you want to go in, you need to use the command cd
, standing for "change directory", and the name of the directory. In my case:
cd .ipynb_checkpoints
Having done that, I can see the content of this directory by using the ls
command again. So far so good. But how do I go back home?
Back home
There are several ways to navigate back. If you want to go back by one directory, you can type
cd ..
The two dots stand are a relative path, i.e., I want to see the directory where the current one resides in. If I want to go to my home straight, I can use the tilde as a shortcut
cd ~
Let's stop here for now, and next time I will give examples about copying, moving and deleting files.