Tag: Linux command line

  • Linux Tutorial Series – 132 – Installing a package

    Here is the video version, if you prefer it:

    There are two ways to install a package. (Shotts, 2019)⁠ One of them is from a repository:

    apt-get install packageName

    The other is from a file:

    dpgk -i packageFileName

    Hope you learned something useful!

    References

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

  • Linux Tutorial Series – 131 – Finding a package

    Here is the video version, if you prefer it:

    To preface this: I personally always use Google to find the packages I need. Either I look for the package name on the distribution website or I am looking for specific packages I need to install for some purpose. I never used the commands that follow so far, but they are useful to know about.

    To find a package you want to install, you can use the following command: (Shotts, 2019)⁠

    apt-cache search query

    An example:

    mislav@mislavovo-racunalo:~/Linux_folder$ apt-cache search zip

    advancecomp - collection of recompression utilities

    node-almond - minimal AMD API implementation for use in optimized browser builds

    amanda-client - Advanced Maryland Automatic Network Disk Archiver (Client)

    amanda-server - Advanced Maryland Automatic Network Disk Archiver (Server)

    You get a list of packages related to your search query.

    You can also use

    apt search query

    for the same purpose.

    Hope you learned something useful!

    References

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

  • Linux Tutorial Series – 130 – Updating your package list

    Here is the video version, if you prefer it:

    Before we go into how to install packages and related operations, let’s first establish a rule, if you will: Always run sudo apt-get update before doing any of the operations we will cover (besides removing a package).

    Why is it so? Your operating system has a list of packages. Before installing any packages, it is a good idea to tell the operating system: “OK, operating system. Please check if there are more recent versions of packages available or if there are any new packages available.” (“What does ‘sudo apt-get update’ do?,” n.d.)⁠ You do so with sudo apt-get update. You need superuser permissions to run this command, hence the sudo.

    Again, remember to run this command before any other package manipulation related actions besides removing a package.

    Hope you learned something useful!

    References

    What does “sudo apt-get update” do? (n.d.). Retrieved February 11, 2020, from https://askubuntu.com/questions/222348/what-does-sudo-apt-get-update-do

  • Linux Tutorial Series – 129 – Package management

    Here is the video version, if you prefer it:

    Let’s talk about package management today. What is package management and why do we need it?

    Let’s start with why do we need it. We need it because packages are a convenient way to deliver software – we deliver software like a package. Package management is a term for installing, modifying and removing packages. The alternative to installing software from a package is to install the software from source, but that is for another article.

    Different Linux distributions use different packaging systems. (Shotts, 2019) A package consists of files that contain the software we are installing. Packages are available in repositories. Each distribution has its own repository with packages. If a software depends on something to run (such as an external piece of code to calculate something), then we say that that external piece of code is a dependency. Package managers (programs that manage packages) take care of dependencies when installing packages.

    There are high-level package management tools (such as apt and apt-get in Debian-like distributions) and low-level package management tools (such as dpkg in Debian-like distributions). We will use those to manage our packages.

    Hope you learned something new!

    A caveat: In the following articles I will cover package management operations (installing, removing, …) using package manager that is used in Debian and Debian-like Linux distributions. I won’t cover other distributions. In case you have another distribution, I suggest using Google to find the equivalent commands.

    References

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

  • Linux Tutorial Series – 128 – Other compression and archiving commands

    Here is the video version, if you prefer it:

    There are other compression commands (such as bzip2) and archiving commands (such as zip). (Shotts, 2019)⁠

    zip may be useful; its syntax is:

    zip zipFile fileToArchive

    where zipFile is the newly created zip file and fileToArchive is the file you want to compress.

    If your fileToArchive is a directory, use:

    zip -r zipFile fileToArchive

    To unzip use:

    unzip zipFile

    I never used bzip2 so far, but just know that it exists.

    Hope you learned something useful!

    References

    Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 261-262; 268-270

  • Linux Tutorial Series – 127 – The tar command

    Here is the video version, if you prefer it:

    The tar command is used to create an archive of files or to extract files from an already existing archive of files. (Ward, 2014) To create an archive of files, use the following syntax:

    tar cvf archiveName.tar file1 file2 …

    cvf mean the following – c enters the create mode (telling tar to create a new archive), v is the flag for verbose output (so you know what is happening) and f means that the next argument will be the name of the to-be-constructed archive.

    ⁠To extract files from an already existing archive, use the following syntax:

    tar xvf archiveName.tar

    v and f mean the same things as I explained above, but x is the extract mode, telling tar to extract the archive provided as the argument.

    Memorize these two commands by heart. That’s what I did.

    When extracting files, it is always a good idea to extract them in a newly created folder. That way, if the extracted files make a mess, you can always move that folder to the location you want to (or delete it). There are options in tar to check the archives contents, but I haven’t used them – I used the method of extracting the archive in a new folder.

    Hope you learned something useful!

    References

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

  • Linux Tutorial Series – 126 – The gzip command

    Here is the video version, if you prefer it:

    The gzip command is used to compress one or more files. (Shotts, 2019)⁠ Here is its syntax:

    gzip fileName

    Interesting options include:

    -v – verbose mode (informative output is displayed)

    -t – test the integrity of the compressed file

    -d – decompress

    For decompression you can use gunzip command as follows:

    gunzip fileName

    That way you can decompress a file compressed with gzip.

    Thank you for reading!

    References

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

  • Linux Tutorial Series – 125 – Compression – Why is it used?

    Here is the video version, if you prefer it:

    Before we talk about compressing files in Linux, let’s first talk about what compression is and more importantly, why is it used.

    Compression is used to encode information in a way to take up less space (space being measured in computer memory in this case). Decompression is the reverse process – reading the information that was compressed and reconstructing the original.

    Let’s say I have 10 letters A in a row:

    AAAAAAAAAA

    and let’s say I need 1 memory unit to represent the letter A. I also need 1 memory unit to represent any other letter or a digit. Then I have 10 memory units in total.

    However, I could think: “OK, how can I transfer the same information, but using less memory units?”. One way is to send the information over like this:

    A10

    and that there’s an agreement between me (the sender) and the receiver that A10 means “A repeated 10 times”. That way (assuming, as I stated above, that every letter and digit takes up 1 memory unit) I have represented the occurrence of A 10 times in a row with only 3 memory units. 10/3 would be the compression ratio, the ratio between uncompressed and compressed information.

    Data compression can be lossless or lossy – lossless means that no information is lost (like in our example) and lossy compression means that we lose some information in the compression procedure, but we can gain a close approximation when decompressing it. (Shotts, 2019)⁠

    Those are the very basics of compression and why it is used. There is an entire field called Information Theory that deals with compression. There is also the Hutter prize, which aims to reward the person who can advance state-of-the-art in compression: (“Hutter Prize,” n.d.)⁠ The compression algorithms used today are more elaborate than the basic one I explained above, of course, but you get the idea.

    Hope you learned something interesting!

    References

    Hutter Prize. (n.d.). Retrieved February 10, 2020, from http://prize.hutter1.net/

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

  • Linux Tutorial Series – 124 – Checkpoint

    Here is the video version, if you prefer it:

    Going on, we will talk about file compression and commands related to package management. Both are used relatively frequently. If you are a “regular” desktop user, then using a graphical user interface (GUI) to compress and decompress archives is going to be enough most (if not all) of the time. Still do read through it, because sometimes you may have to use the command line and it pays to know what the tutorials you found on Google are telling you. In relation to package management, that is something you will use very frequently both as a regular desktop user and as a software engineer (or some other career choice) using Linux, so do pay close attention.

  • Linux Tutorial Series – 123 – Review

    Here is the video version, if you prefer it:

    We talked about file modes and permissions. Let’s review that on an example:

    -rw-r--r--

    First character (looking from left to right) tells us if we are talking about a file or a directory or something else, the next three characters tell us user permissions, the next three tell us group permissions and the next three tell us world permissions.

    Then we talked about the following:

    • chmod is used to change file permissions
    • chown is used to change file owner
    • umask defines the default permissions (keep in mind the octal to binary conversion we talked about and how it relates to permissions)
    • passwd is used to change users password
    • adduser is used to add users
    • userdel command is used to delete users
    • /etc/passwd keeps users and their IDs, while /etc/sudoers keeps the list of users who can execute the sudo command

    Hope you refreshed your memory!