Mastering Linux System Administration. Richard Blum

Чтение книги онлайн.

Читать онлайн книгу Mastering Linux System Administration - Richard Blum страница 27

Mastering Linux System Administration - Richard Blum

Скачать книгу

see the following output: Name Version Rev Tracking Publisher Notes core18 20200929 1932 latest/stable canonical* base lxd 4.0.4 18150 4.0/stable/… canonical* - snapd 2.47.1 9721 latest/stable canonical* snapd stress-ng V0.11.24 5273 latest/stable cking-kernel-tools - $

      When you install a snap package, the snapd program mounts it as a drive. You can see the new snap mount by using the mount command.

      $ mount … /var/lib/snapd/snaps/stress-ng_5273.snap on /snap/stress-ng/5273 type squashfs (ro,nodev,relatime,x-gdu.hide) $

      If you need to remove a snap, just use the snap remove command.

      $ sudo snap remove stress-ng stress-ng removed $

      As the snap is removed, you'll see some messages about the progress of the removal. Instead of removing a snap, if you prefer, you can just disable it without removing it. Just use the snap disable command. To reenable the snap, use the snap enable command.

      Before package management systems and application containers, open source application developers had to distribute their software as source code and allow users to compile the applications on their own systems. Source code packages were commonly released as a tarball. Tarball packages bundle files into an archive file using the tar command‐line command. Once the files are bundled into a tarball, it's common to use a compression utility to compress the file to easily distribute it.

      1 Unpack the files in the tarball using the tar command. The ‐xvf options expand the tarball specified on the command line. Optionally, if the tarball has been compressed, you'll need to include an option to uncompress the file. Use ‐J for .xz compressed files, or use ‐z for .gz compressed files.

      2 Create the script for compiling the software on your system using the configure script included with the package. This detects what tools are installed on the system and what CPU features and capabilities are available. This creates a Makefile script to build the software.

      3 Run the Makefile script to compile the source code using the make command.

      4 Install the software using the make install command.

      The software package developer determines the installation location and whether you need to have root privileges to run the application.

      image Real World Scenario

      INSTALLING SOFTWARE FROM SOURCE CODE

      If you develop or work with open source software source code much, there's a good chance you will still find software packed up as a tarball. This section walks you through the process of unpacking and installing a tarball software package.

      For this example, the GNU software package hello will be used. The hello package is a simple program that produces a “Hello World!” output but demonstrates how GNU packages source code files for distribution.

      1 Download the hello tarball package to your Ubuntu server. Go to the GNU software download website ftp.gnu.org/gnu/hello/. Click the link to download the current version of the package. The current filename is hello‐2.10.tar.gz.

      2 Unpack the software tarball using the command tar ‐zxvf hello‐2.10‐tar.gz. This command will create a directory named hello‐2.10 and unpack all of the files into that directory.

      3 Change to that directory by typing cd hello‐2.10. In this directory, you should see a README and an INSTALL file. It's important to read these files. In these files will be instructions you will need to finish the software's installation.

      4 Run the configuration script by typing the command ./configure. You will see output messages as the script scans your system to check for the appropriate tools for building the software. If anything goes wrong, the configure step will display an error message explaining what's missing from your system.

      5 Compile the application by typing make. You should see a lot of messages scroll by as the script compiles the individual pieces of the application, but you shouldn't see any error messages. When the make command is finished, you'll have the actual hello software program available in the directory! However, it's somewhat inconvenient to have to run it from that directory. Instead, you'll want to install it in a common location on your Linux system.

      6 Install the application by typing sudo make install. Now the hello application is installed on your Linux system.

      Unfortunately, uninstalling an application installed by source code may or may not be easy. It's up to the developers whether to include an uninstall make script. Try running the sudo make uninstall command from the software directory to see whether that works.

      THE CORE LINUX PROGRAMMING LANGUAGES

      Most Linux utility programs are written using the C or C++ programming language. To compile them on your system, you will need the gcc package installed, as well as the make package. Most Linux desktop distributions don't install these by default. If the configure program shows an error that these parts are missing, consult your specific Linux distribution docs on what packages you need to install.

       Explore different Linux software package management systems. Developers bundle the files required for an application into a package to make it easier to install. A package management system allows you to easily track, install, and remove application packages on your Linux system. There are two popular Linux package management systems: dpkg for Debian‐based systems, and rpm for Red Hat–based systems.Master It The Debian Linux distribution maintains an official website that tracks all software packages as they're developed for the Debian environment. Go to the packages.debian.org website and determine what version of the systat application is available as a stable Debian package.

       Use Debian software packages to install software. The Debian‐based Linux distributions use the dpkg utility to interface with the package management system from the command line, and they use the apt‐cache and apt‐get utilities to interface with a common repository to easily download and install new software. A front end to these utilities is apt. It provides simple command‐line options for working with software packages in the dpkg format.Master It The C shell provides an alternative to the Bash Shell, handy for writing advanced shell scripts. For Ubuntu, the C shell is bundled as part of the csh package. What commands should you use to install the csh package from the standard Ubuntu software repository?

        Install applications using Debian snap containers. Application containers are a relatively new player in software package management. An application container bundles all the files necessary for an application to run in one installable package. This means the application doesn't rely on any external dependencies such as library files, and the container bundle can be installed in any Linux distribution and run. Currently, the two most popular container packages are snap, common in the Ubuntu Linux distribution, and flatpak, used in Red Hat Linux environments.Master It The PowerShell package provides a powerful scripting language similar to that found on Microsoft Windows

Скачать книгу