Tag: Linux Tutorial

  • Linux Tutorial Series – 24 – Checkpoint

    Here is the video version, if you prefer it:

    In the following posts, we are going to cover a lot of commands. Those commands are the bread-and-butter of the Linux command line. You will use them almost daily and almost every tutorial on how-to do something on Linux uses these commands and so it is very important to understand what they do, since most tutorials assume you know what they do.

    I will not lie – this will be a little bit dry. However, treat it as learning to add and subtract. It is not fun at the time you are learning it, but you power through it. I am asking you to power through it a little bit. It will pay off.

    See you on the other side!

  • Linux Tutorial Series – 23 – Recap

    Here is the video version, if you prefer it:

    Today let’s quickly review the things we learned:

    • Shell is a program that runs commands
    • Commands are programs you can run with options and arguments
    • date and cal are used to display the time and the calendar (this is not so important)
    • Use Up/Down arrows to search command history
    • Use Left/Right arrows to navigate to individual characters of the current command
    • Use the clear command to clear your Terminal window
    • Exit a terminal command session with exit or press CTRL + D
    • Directories are a way to organize files
    • Files are resources that contain information
    • We talked about what to expect in the directories of a typical Linux directory hierarchy
    • Parent directory is one directory “above” your current directory
    • Absolute path names start with the root folder and proceed onward
    • Relative path names start from the folder you are currently in

    Hope you refreshed your memory!

  • Linux Tutorial Series – 22 – Absolute and relative pathnames

    Here is the video version, if you prefer it:

    When talking about paths, you can often hear “absolute path” or “relative path”. What do these mean?

    Absolute path is a path which starts from the root directory of your Linux system. (Barrett, 2016)⁠ So an absolute path would be something like:

    /home/mislav

    Relative paths are relative to the directory you are currently in (the so called working directory). So, if I wanted to use the cd command (which allows me to change directories (“cd(1) – Linux man page,” n.d.)⁠):

    mislav@mislavovo-racunalo:~$ cd SomeFolder

    I would go from ~ (which is a shorthand for /home/mislav) to SomeFolder, not from the root directory (denoted by /) to SomeFolder.

    Hope this was useful!

    References

    Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Page 18

    cd(1) – Linux man page. (n.d.). Retrieved January 5, 2020, from https://linux.die.net/man/1/cd

  • Linux Tutorial Series – 21 – Parent and current (working) directory – what do these terms mean?

    Here is the video version, if you prefer it:

    Maybe you heard the terms “parent directory” and “current directory”, “working directory” or “current working directory”. “What do these terms mean?” you might ask yourself. Well, fear not, because I have come to alleviate you from your ignorance! (imagine epic music playing in the background)

    Working directory (or its synonyms), in the context of using the Linux command line, refers to the directory you are currently located in. (Barrett, 2016)⁠Let me elaborate:

    I just started a new Terminal session and this is what I get as output:

    mislav@mislavovo-racunalo:~$

    See the ~ between the : and $? Well, that is my working directory. ~ actually stands for my home directory, so instead of ~, if we wanted to be fully correct, there should be /home/mislav. If you start a Terminal session, your working directory should also be ~ as well. From within the Terminal, you can change directories (using the cd command), but that is not the topic of this post.

    Now, more importantly, why is it important to know in which directory you are in? A good question. It’s like I asked it myself. Let’s look at the following example:

    mislav@mislavovo-racunalo:~$ ls

    anaconda3 grep-hadoop-example Python-3.7.4

    'Calibre Library' hadoop-example stanfordnlp_resources

    ...

    ( here means output continues)

    The ls command lists directory contents. (“LS(1),” n.d.)⁠ But contents of what directory, exactly? Well, if you don’t explicitly say what directory, it is assumed that you want the ls to list the contents of the working directory.

    So that’s why it is useful! Imagine if you were inside the directory you desire to operate upon and every time you wanted to call a command you needed to write out the full “trajectory” (also called a path) to the directory you wanted to operate on (as in ls /home/mislav while already being in /home/mislav). That’s tedious and programmers don’t like tedious. Thus, when calling a command (in our case, ls), it assumes you want to operate on the current directory.

    Lastly, parent directory is the directory directly above the current directory. (Shotts, 2019)⁠ For example, if I was in the folder

    /home/mislav

    the parent directory of the mislav directory is the home directory. (3 uses of the word directory in one sentence, whew!)

    Hope you learned something useful!

    References

    Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Pages 17-19

    LS(1). (n.d.). Retrieved December 29, 2019, from http://man7.org/linux/man-pages/man1/ls.1.html

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 31-32

  • Linux Tutorial Series – 20 – Linux directory hierarchy

    Here is the video version, if you prefer it:

    In this article, let’s talk about the Linux directory hierarchy. Here is how it looks like:


    Figure 1 – Linux directory hierarchy (modeled after Figure in (Ward, 2014)⁠, page 40)

    Here is a description of each of the directories: (Ward, 2014)⁠ (Barrett, 2016)

    • bin/ – programs (executables) you run in the shell are located here
    • boot/ – files for booting the system
    • dev/ – device files (your hardware devices represented as files)
    • etc/ – configuration files for your system
    • home/ – personal directories of all of the users
    • lib/ – files needed to successfully run some programs (those files are also known as libraries)
    • lost+found/ – damaged files that were recovered by a disk recovery tool⁠
    • media/ – files that enable access to disks
    • mnt/ – files that enable access to disks
    • opt/ – packages you might have paid extra money for (“What does ‘opt’ mean (as in the ‘opt’ directory)? Is it an abbreviation?,” n.d.)⁠
    • proc/ – operating system statistics
    • run/ – cross-distribution location for the storage of files that do not require preserving across reboots (system restarts); this is very complicated to read – I would read that as “files that can evaporate after every reboot” (“RunDirectory,” n.d.)⁠
    • sbin/ – place for system executables (only the superuser can run these)
    • srv/ – “This main purpose of specifying this is so that users may find the location of the data files for particular service, and so that services which require a single tree for readonly data, writable data and scripts (such as cgi scripts) can be reasonably placed.” (“1.19. /srv,” n.d.)⁠
    • sys/ – provides device and system interface
    • tmp/ – temporary files
    • usr/ – system files
    • var/ – program runtime information

    That’s pretty much it. Within those directories you may have subdirectories, which have their own meanings, but this article should give you the “one layer deep” explanation of what is going on. If you need additional explanation of a particular directory, use Google. I have found it useful to remember the general layout of what is where as I have described above, but if I ever find myself in need of the specifics of some particular directory or subdirectory I Google it.

    Hope this helped!

    References

    1.19. /srv. (n.d.). Retrieved December 22, 2019, from https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/srv.html

    Barrett, D. J. (2016). Linux pocket guide (3rd ed.). O’Reilly Media. Pages 21-23

    RunDirectory. (n.d.). Retrieved December 22, 2019, from https://wiki.debian.org/ReleaseGoals/RunDirectory#A.2Frun

    Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 40-42

    What does “opt” mean (as in the “opt” directory)? Is it an abbreviation? (n.d.). Retrieved December 22, 2019, from https://stackoverflow.com/questions/12649355/what-does-opt-mean-as-in-the-opt-directory-is-it-an-abbreviation

  • Linux Tutorial Series – 19 – Directories and files

    Here is the video version, if you prefer it:

    In Linux, you will find both directories and files. Think of directories like folders in Windows or like drawers or folders in everyday life – they are used to store files within them and give structure to your files. (“Directory (computing),” n.d.)⁠ Files are resources for storing information. (“Computer file,” n.d.)⁠

    Directories also have a hierarchy. So we can have directory1/directory2. That means that directory2 is a child directory of directory1. Imagine this as a folder within a folder. When we list the “hierarchical trajectory” from some directory to some other directory, we are talking about a path. (“Path (computing),” n.d.)⁠

    Hope you learned something useful!

    References

    Computer file. (n.d.). Retrieved February 23, 2020, from https://en.wikipedia.org/wiki/Computer_file

    Directory (computing). (n.d.). Retrieved February 23, 2020, from https://en.wikipedia.org/wiki/Directory_(computing)

    Path (computing). (n.d.). Retrieved December 29, 2019, from https://en.wikipedia.org/wiki/Path_(computing)

  • Linux Tutorial Series – 18 – Exiting a terminal session

    Here is the video version, if you prefer it:

    How do you exit a shell session in Linux? You type exit or press CTRL + D. (Shotts, 2019)⁠

    mislav@mislavovo-racunalo:~$ exit

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 29

  • Linux Tutorial Series – 17 – The clear command

    Here is the video version, if you prefer it:

    If your Terminal window ever gets clogged up with old commands and old command output, type in clear to clear your Terminal window, as so:

    mislav@mislavovo-racunalo:~$ clear

    Keep this in mind if things get messy.

    Hope you learned something useful!

  • Linux Tutorial Series – 16 – Command history and cursor movement

    Here is the video version, if you prefer it:

    Did you know you can use the Up/Down arrows on your keyboard to see previous commands you executed in the Linux shell? Did you know that you can use Left/Right arrows to move your cursor? (Shotts, 2019)⁠

    If you did not, now you do. If you did, great for you!

    Hope this helped.

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 27

  • Linux Tutorial Series – 15 – Talking about time – date and cal

    Here is the video version, if you prefer it:

    Today, let’s talk about two time-related commands in the shell. They are called date and cal. (Shotts, 2019)⁠

    date gives you the current time:

    mislav@mislavovo-racunalo:~$ date

    Sun 22 Dec 2019 12:11:15 PM CET

    cal gives you the calendar:

    mislav@mislavovo-racunalo:~$ cal

    December 2019

    Su Mo Tu We Th Fr Sa

    1 2 3 4 5 6 7

    8 9 10 11 12 13 14

    15 16 17 18 19 20 21

    22 23 24 25 26 27 28

    29 30 31

    Obviously, applications of this are vast. Let’s say you freeze yourself and wake up 70 years in the future. Of course you’re not going to ask some human what year is it! That would be ludicrous! Instead, you will find the first computer with Linux and run the commands you learned from this article. I just saved your life 70 years in the future. You are welcome.

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 28