| Terminology |
Definition |
| Open-Source |
A licensing model that grants end users the permission to install, use, modify, or distribute a software product or source code |
| Copy Left |
A type of license that allows end users to distribute works of free and open source softwareas long as it is released again under the same license terms |
| Python |
A High-Level Programing language that is widely used for automation |
| Artificial Intelligence (AI) |
The science of creating machines with the ability to develop problem-solving and analysis strategies without significant human intervention |
While there is a shared concept that Linux is meant to be free and open source to anyone who would like to do it, there seems to be a lot of disagreement on how to exactly manage software packages.
Package Managers in Linux are tools that make it easier to install and remove software.
- Low Level Package Managers work directly with package files, either with a .rpm or .deb file extension.
- .rpm is the Red Hat-based package manager
- Some of the common rpm options are:
- -i Installs Packages
- -U Updates the package - -e Removes the package
- -qa Lists all installed packages
- -qi Displays detailed information about a package
- DPKG is the low level Devian-Based manager
- Some of the common dpkg commands are
- -i Installs the Package
- -r removes the package but keeps its configuration files
- --purge Removes the package along with its configuration files
- -l Lists all installed packages
- -s Displays detailed information about a package
High-Level Package managers provide more functionality than low-level package managers. Allowing for repository management and dependency resolution
- GNOME software is commonly used in GNOME Desktops
- Synaptic is the graphical front end for apt
- snap - Universal package for containerized applications
- Flatpak - Package Manager for sandboxed applications
- AppImage - Portable application format that does not require installation
¶ Software Installation and Updates
- Dependencies are additional software packages or libraries required for a program to function correctly
- The RPM and dpkg package managers do not resolve dependencies automatically, while other tools like YUM and APT do.
- update-alternatives is a command-line tool used in Debian to manage multiple versions of a program.
- It does this by maintaining symbolic links that point to the default version of a program, and are stored in/etc/alternatives
- Alternatives are assigned a priority number. and will automatically select the one with the highest priority
- View available alternatives with sudo update-alternatives --display programName
- Manually configure alternative with sudo update-alternatives --config programName
- Add New Alternative with sudo update-alternatives --installs /usr/bin/program programName path/to/version priorityNumber
- Remove an Alternative with sudo update-alternatives --removes programName /path/to/version
Software configuration involves modifying settings and parameters to customize the behavior of applications and services
- Configuration files can either be global or user-specific
- Global Configuration files are usually stored in /etc and affect the whole system
- User-Specific configuration files are stored in the user's home directory and are often hidden files starting with a.
- Configuration files are formatted in a variety of different ways, such as
- Key-Value Pairs - /etc/environment
- INI Format - /etc/samba/smb.conf
- XML/JSON/YAML - Used by many applications
- You can use the rpm command to remove packages, but it does not handle dependencies - You would use the -e option to remove the package
- You can also use the yum command, which handles dependencies - You would use the remove option to remove software with yum
- dnf is the modern replacement for yum. dnf also handles dependencies - similarly to yum, you would use the remove option to remove software
- You can use dpkg to remove software on debian based systems, but it does not handle dependencies
- The -r removes the software
- --purge also removes the software configuration files
- Apt can also be used to handle the removal of software on debian based systems
- You can use the remove option to remove the software
- If you use the autoremove option, it will help with dependencies
- The. The purge option will also clear the configuration files
- apt-get is the newer version of apt and will have the same options as apt
Many programming languages have their own package management tools to install, update, and remove libraries or software
Python comes with its own package manager of sorts called pip, and it is used to install different Python packages and resolve the dependencies for those Python packages
-
You can install pip on Red Hat with sudo dnf install python3-pip
-
You can install pip on Debian-based systems with sudo apt install python3-pip
-
Pip handles Python packages similarly to the package managers that we have already covered
- To install a package, you use pip install
- To install a specific version of a package, you use pip install
- To list installed packages, use pip list
- To update a package, pip install --upgrade
- To uninstall a package, use pip uninstall
-
The pip Package manager resolves dependencies using virtual envirnments, it is a good idea to isolate your project with virtual environments to avoid dependency conflicts
- Create a virtual environment with python3 -m venv myenv
- Activate the virtual environment with source myenv/bin/activate
- deactivate your virtual environment with deactivate
Rust is a modern high-preformance programing language designed for safety and speed. It is commonly used to build operating systems, game engines, web servers, and other mission-critical applications
- Cargo is the package manager for Rust - Create a new project - cargo new
- Build and run a project - cargo build
- Install a crate - cargo install
- List the installed crates - cargo install --list
- update a crate - cargo update
- remove a crate - cargo uninstall
- Node Package Manager is the default package manager for Node.js. Some of the options are:
- Install a package - npm install
- update a package - npm update
- list installed packages - npm list
- uninstall a package - npm uninstall
- sudo rpm -ivh packageName. This will show some missing dependencies- You can use rpm -qR to show all of a software packages dependienceies
- sudo dpkg -i packageName to deploy missing dependencies
¶ Acquire and Use Software
¶ wget and curl
wget and curl allow you to access webpages from the command line; this is most notably useful for downloading software from a download link.
- The syntax for wget is wget options URL, curl uses the same syntax
- Some of the common options for wget are
- -P Downloads to a different directory - -b Downloads in the background
- Some common options for curl are
- --progress-bar Displays a progress bar during the download
-- verbose Displays additional download information
-
Repositories, or Repos, are software storage locations that package managers can check when installing or updating software. There are three kinds of software repositories
- Local Repositories - These are stored on each system's local drive
- Centralized internal repositories - These are stored on one or more systems within the internal LAN
- Vendor Repositories - These repositories are managed on the internet, usually by the software vendor
-
Many repositories exist, and not all are trusted. In a lot of cases, there could even be malware present; it is often better to create and maintain your own repos; some of the reasons are
- Software version control
- Application installation control
- Bandwidth control
- Administrators can designate a specific directory as a YUM repository by using the createrepo command. This command updates the XML files that are used to reference the repository's location.
- After running the createrepo command, the administrator must also create a .repo configuration file to provide additional information about the repository. This file must include
- {repo-name} - The Repositorys name
- name=Repository Name - The Friendly Repository Name
- baseurl= The path to the repo
- enabled=1 Enables the repo
- gpgcheck=0 Disabled gpg checking
- Just like in Red Hat-Based distrobutions Administrators can designate specific repositories to use for software
- Repositories can be configured in /etc/apt/sources.list and in the /etc/apt/sources.list.d directory
- If you make updates to the sources. list ensure to use apt update
- You can use the apt.conf is used to manage the configuration of the apt suite of tools. Depending on the distrobution the configuration file may be found in /etc/apt.conf or /etc/apt/apt.conf
- System administrators can disable repositories to ensure system stability, security, and compliance.
- On Red Hat, you can exclude a repo by using dnf with the syntax sudo dnf update --disablerepo=repositoryName or sudo yum update --disablerepo=repositoryName, or by editing the repository configuration file
- On a Debian-based system, you can disable a repository by commenting it out in the /etc/apt/sources.list file, and updating apt with apt update
- Some common issues with repositories are
- Missing or incorrect repositroy URL's
- Expiring GPG keys
- Disabled Repositories
- Conflicting repositories - Corrupted Metadata
- Package queries are a way to gather information about the software installed on your system.
- RPM-Based Package managers track software in a database; that being said, that database can be queried to find important information about the installed software.
- The syntax to write all installed software to the softwarelist.txt file is rpm -qa > softwarelist.txt. The rpm command has two useful query options
- -qa The output from this option is likely to be very large, and it is best to output to a file
- -qi Displays the information about one software package only.
- The dpgk command provides detailed information about installed packages
- List all installed packages dpkg -l > softwarelist.txt
- Display information about a specific package - dpkg -s packageName
¶ Sandboxed Software
- Sandboxing applications in Linux enhances security, isolates dependencies, and prevents interference with the host system.
- A VM is a fully isolated environment that emulates a complete host operating system
- Containers are a lightweight isolated environment that shares the host system's kernel but runs applications with their own dependencies. They are generally much more effecient then VM's
¶ Sandboxing with Snaps
- A snap package allows applications to be run in isolated environments and was developed by Canonical.
- You can install snap with sudo dnf install snapd # or sudo apt install snapd#
- From there, you would want to enable the service with sudo systemctl enable --now snapd.socket
- You can review all of the snap packages with sudo snap list
- You can install a snap package with sudo snap install packageName
- You can run the application with snap run PackageName
- Flatpak is a universal package format that allows applications to run in isolated environments. It is designed to work across all Linux Distros
- You can install Flatpak with dnf/apt install flatpack#
- Then you would want to add the flathub repository with flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- Install a flatpak image with flatpak install flathub packageName
- Run a flatpak package with flatpak run packageName
- App images are portable applications that bundle all dependencies into a single executable and do not require installation or root privileges; all you need to do is make the file executable.