Tag: Linux Tutorial

  • Linux Tutorial Series – 180 – Shebang

    Here is the video version, if you prefer it:

    The first part of a shell script is called a shebang. A shebang tells the kernel what interpreter to use to execute the script that follows. (Shotts, 2019) By interpreter, I mean the shell. (“Does the shebang determine the shell which runs the script?,” n.d.)⁠ You will recognize the shebang because it is the line that starts with #!.

    A sidenote: shell scripts are interpreted, not compiled.⁠

    Let’s now write a shebang in our script. Let’s name our script tutorialScript.sh. In it, write the following as the first line:

    #!/bin/bash

    That tells the kernel to interpret our script using the bash interpreter. You have different-looking shebangs for different interpreters.

    Hope you learned something useful!

    References

    Does the shebang determine the shell which runs the script? (n.d.). Retrieved February 21, 2020, from https://unix.stackexchange.com/questions/87560/does-the-shebang-determine-the-shell-which-runs-the-script

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

  • Linux Tutorial Series – 179 – Shell scripts – when and when not to use them

    Here is the video version, if you prefer it:

    Shell scripts ought to be used for automating tasks and file management. That was an assertion made by (Ward, 2014) and I agree with that.

    If you ever need to do something more than manipulate files or automate tasks, shell scripts probably aren’t the ideal choice for it. I used shell scripts for the following tasks:

    • seeing a difference between multiple files in two folders
    • automating a task of starting a program

    If I were to use shell scripts for some kind of text manipulation or some calculations, I would use a different programming language. It’s not that shell scripts can’t do calculations or manipulate text, it is that it is easier to do so in other programming languages. So keep in mind: If it is not file management or automation, use another programming language. Pick the right tool for the right task.

    Hope you learned something useful!

    References

    Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 250

  • Linux Tutorial Series – 178 – What are shell scripts?

    Here is the video version, if you prefer it:

    Shell scripts are commands written in a file. (Ward, 2014)⁠ If you were to look at a shell script file, it would be composed of commands. Not everything would be a command though, but you would recognize commands.

    So in a sense, we aren’t learning nothing new, but we will learn some things which appear in shell scripts and don’t appear outside them.

    Talk soon!

    References

    Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 249

  • Linux Tutorial Series – 177 – Checkpoint

    Here is the video version, if you prefer it:

    We are about to delve into shell scripting. Shell scripts are used to automate certain things related to files.

    It is good to be acquainted with shell scripts if you are a software developer, but if you are a regular user, read this only if you are interested. The aim of this section will be to get you familiar enough with shell scripting to read and write shell scripts, albeit you will need to Google certain details of the things you are trying to achieve (if you are writing your own shell scripts). We will do this by making a very simple shell script which demonstrates the usage of each of the constructs we will learn to use.

    Talk soon!

  • Linux Tutorial Series – 176 – Review

    Here is the video version, if you prefer it:

    Let’s recap the main points:

    • Use cron to schedule things periodically; use at to schedule things only once
    • Every single computer in a computer network has an IP address through which it can be addressed
    • ip command is used to see information about your network interfaces
    • Use ping someWebsite to check your Internet connection (you should have no packet loss)
    • Use ssh to login to a remote host
    • Use scp for copying files to/from a remote host
    • X Window System is related to the Linux desktop
    • Build systems exist to ease the process of creating an executable from source code
    • To build something from source code do the following: 1. Download the folder with the source code; 2. Run ./configure; 3. Run make; 4. Run make install

    Hope you refreshed your memory!

  • Linux Tutorial Series – 175 – Building a program from source

    Here is the video version, if you prefer it:

    You may sometimes need to build a program from source. If its package is not available (or if the package doesn’t contain the most recent version of the program), then you need to build the program from source.

    Generally, the steps are:

    1. Download the source code
    2. In your Terminal (positioned in the source code folder), execute ./configure
    3. In your Terminal (positioned in the source code folder), execute make
    4. In your Terminal (positioned in the source code folder), execute make install

    Here, you are basically instructing your build system to take the source code and make the executable files out of it. That’s all you need to know.

    I found a great more in-depth tutorial here: (“How to Install Software from Source Code… and Remove it Afterwards,” n.d.)⁠

    Hope you learned something useful!

    References

    How to Install Software from Source Code… and Remove it Afterwards. (n.d.). Retrieved February 15, 2020, from https://itsfoss.com/install-software-from-source-code/

  • Linux Tutorial Series – 174 – Compiling when programs get large – build systems

    Here is the video version, if you prefer it:

    Today I want to introduce you to the concept of a build system. To understand what a build system does, let’s first discuss some other things and then we will gleam an intuition behind build systems.

    Let’s say you were compiling a program that used a lot of libraries. To remind ourselves, libraries have to be linked to our program to produce the final executable file. Those libraries can also be called dependencies – we depend on them (or, more precisely, on the functionality within them) to be able to use our program.

    Now, imagine if our program depended on a lot of libraries. Let’s say thousands of them. I think you get a feeling that it would be pretty hard to manage all of that manually. We would have to tell the linker to look for all of the thousands of libraries and that is tedious. And one thing programmers don’t like is tedious.

    Build systems take care of this problem (among other things). Build systems make managing dependencies very easy. One of the most popular build systems is make, which is used when building programs from source code – that is, when compiling programs from source code.

    Hope you learned something useful!

  • Linux Tutorial Series – 173 – Plot twist – not all programs are compiled

    Here is the video version, if you prefer it:

    As the title says, not all programs are compiled. Your reaction might be: Gasp “That means that the last post was a lie?” “No”, I would respond. Read on.

    There are two kinds of programming languages – ones that are compiled and ones that are interpreted. (Shotts, 2019)⁠ The compiled programming languages undergo the process described in the previous post. Interpreted do not. Interpreted programming languages are executed line-by-line. So instead of taking the whole program and translating it into zeroes and ones, then linking it and forming an executable file, a program called interpreter goes line-by-line over the interpreted language’s source code and executes it as it encounters each line of the source code.

    Interpreted languages are generally slower than compiled languages.

    Hope you learned something new!

    References

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

  • Linux Tutorial Series – 172 – Compiling a program – what does that even mean?

    Here is the video version, if you prefer it:

    In this article, I will mention a couple of key terms related to the Linux desktop. (Ward, 2014)⁠

    The first one is the X Window System. It is just a framework – think of it as “bare bones” of a GUI (Graphical User Interface) environment. It is up to other programs to build upon this “bare bones” and construct the graphical user interface. (“X Window System,” n.d.)⁠

    Desktop environment is a package that allows for cooperation of different applications in a graphical sense. For example, application A tells application B that it is 50% done with a certain task and the application B displays that on its status bar. GNOME and Unity are examples of a desktop environment.

    Some other terms and their explanations: Window managers arrange windows on the screen and provide interactive decorations like title bars that allow the user to move and minimize windows. Common elements on desktop applications (such as buttons and toolbars) are called widgets. Toolkits are used to provide widgets because that speeds up development.

    That’s it for this post. I never dug really deep into Linux desktop, but if you ever encounter any one of these terms, I hope you have some more clarity as to what they mean.

    Hope you learned something useful!

    References

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

    X Window System. (n.d.). Retrieved February 15, 2020, from https://en.wikipedia.org/wiki/X_Window_System

  • Linux Tutorial Series – 171 – Linux desktop – a couple of key terms

    Here is the video version, if you prefer it:

    In this article, I will mention a couple of key terms related to the Linux desktop. (Ward, 2014)⁠

    The first one is the X Window System. It is just a framework – think of it as “bare bones” of a GUI (Graphical User Interface) environment. It is up to other programs to build upon this “bare bones” and construct the graphical user interface. (“X Window System,” n.d.)⁠

    Desktop environment is a package that allows for cooperation of different applications in a graphical sense. For example, application A tells application B that it is 50% done with a certain task and the application B displays that on its status bar. GNOME and Unity are examples of a desktop environment.

    Some other terms and their explanations: Window managers arrange windows on the screen and provide interactive decorations like title bars that allow the user to move and minimize windows. Common elements on desktop applications (such as buttons and toolbars) are called widgets. Toolkits are used to provide widgets because that speeds up development.

    That’s it for this post. I never dug really deep into Linux desktop, but if you ever encounter any one of these terms, I hope you have some more clarity as to what they mean.

    Hope you learned something useful!

    References

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

    X Window System. (n.d.). Retrieved February 15, 2020, from https://en.wikipedia.org/wiki/X_Window_System