How can you install software on a Linux system and what are the common package managers used in Linux?
What are software packages and package managers?
A software package is a collection of files and metadata that contains the information and instructions needed to install, run, and remove a software application or component. Software packages can have different formats, such as .deb, .rpm, .tar.gz, .snap, or .appimage, depending on the distribution and the packaging system used. A package manager is a tool that simplifies the process of installing, updating, and removing software packages by resolving dependencies, checking compatibility, and verifying integrity. Some of the most popular package managers in Linux are apt, yum, dnf, pacman, snap, and flatpak.
How to use apt to install and remove .deb packages?
Apt is the package manager utilized by Debian-based distributions, such as Ubuntu, Mint, or Kali. It is used to manage .deb packages, which are compressed archives that contain the binary files and the control files of the software. To use apt, you must open a terminal and execute the following commands:
sudo apt update
, which updates the list of available packages from the repositories;
sudo apt install package_name
, which installs a package by name;
sudo apt remove package_name
, which removes a package by name;
sudo apt install /path/to/file.deb
, which installs a package from a local .deb file; and
sudo apt purge package_name
, which removes a package and its configuration files.
How to use yum or dnf to install and remove .rpm packages?
Yum and dnf are the package managers used by Red Hat-based distributions, such as Fedora, CentOS, or RHEL. These managers work with .rpm packages, which are compressed archives that contain the binary files and the metadata of the software. To use yum or dnf, you need to open a terminal and use certain commands. For example, if you want to update the list of available packages from the repositories, then you should use
sudo yum update
or
sudo dnf update
. If you want to install a package by name, then type in
sudo yum install package_name
or
sudo dnf install package_name
. To remove a package by name, you can use
sudo yum remove package_name
or
sudo dnf remove package_name
. If you want to install a package from a local .rpm file, type in
sudo yum localinstall /path/to/file.rpm
or
sudo dnf localinstall /path/to/file.rpm
. Lastly, if you want to remove a package and its dependencies, use
sudo yum autoremove package_name
or
sudo dnf autoremove package_name
Explain the Linux file system / structure
The Linux file system structure is hierarchical and follows a standard layout defined by the Filesystem Hierarchy Standard (FHS). Here’s a brief explanation of key directories within the Linux file system:
ls, cp, mv, and rm.fsck, reboot, ifconfig, and iptables./etc/passwd for user account information and /etc/fstab for file system mount points./dev/sda (a hard disk), /dev/tty (terminals), and /dev/null (a null device)./proc/cpuinfo for CPU information and /proc/meminfo for memory information./var/log for log files, /var/spool for printer and mail spools, and /var/tmp for temporary files that need to persist between reboots./usr/bin for non-essential user command binaries and /usr/lib for non-essential libraries./home named after their username, such as /home/user1./bin and /sbin. These libraries are essential for the system to boot and run the commands in those directories./mnt is often used for manual mounts, while /media is typically used by the system to automatically mount removable media./tmp are typically cleared upon system reboot./home to provide security and organizational benefits.Understanding this structure is crucial for system administration, troubleshooting, and effective use of a Linux system. Each directory serves a specific purpose, ensuring a well-organized and efficient file system layout.
Why the Drive C?
Since early computers only had floppy drives, they were called a and b and they were removable, the first hard drive letter turned out to be C.
What is Mac’s ancestor?
Unix
What can you find in /bin and /sbin folder?
It is short for binaries and these are the most basic binaries, which is another word for programs or applications. ls, cat etc kind of functions are stored here.
In the sbin folder there are system binaries that a system admin would use and a standard user wouldnt have access without permission. When you install a program on Linux, it’s typically not placed in these folders.
What is /boot folder in Linux?
It contains everything your OS needs to boot. Bootloaders live here.
What is /dev folder in Linux?
This is where your devices live. Here you will find your hardware. Everything in Linux is a file, so you can find your disk and your partition in this folder. Everything else also lives here, your webcam, keyboard etc. This is an area where applications and drivers should access.
What is /etc folder in Linux?
etc has system wide application configuration.
What are /lib folders doing?
These are where the libraries stored
What are /mnt and /media folders for?
Floppy disk, external disk, second hard drive, these are here. A B D drive are here. /media OS managed, mnt for us to mount.
What is /opt?
Optional. For all the applications that we install can go here.
What is /proc folder for?
This is where all kind of information about system processes reside. Every process has an ID and all the information about a process can be found here. You can also find information about the cpu here.
What is /root for?
It is the root users home folder. You need root permissions to access here.
What is /srv folder?
If this is a server like an ftpserver, it would have the files here.
What is /sys folder?
It is a way to interact with the kernel. This folder is created everytime the system boots up and it is not physically written to the disk, so you wouldnt put files here.
What is /usr?
Here resides non essential applications for Linex and these are basically user installed applications.
What is /home folder?
Each user has its own folder inside of home. Personal files and docs. Application variables
Tell me about FHS?
File Hierarchy Standard. In the early days of Linux, the file system structure was pure chaos so the Linux community rallied around this standard for a consistent directory structure on every distribution.
Tell me about key directories in Linux file system
When a binary exists in /bin /usr/local/bin or /usr/bin you can specify the default by reordering the directory precedence in the path variable.
What is Linux and what makes it different from other operating systems?
Linux is a free, open-source operating system based on Unix. It was released by Linus Torvalds in 1991.
What makes it different:
- Open Source Nature
- Flexibility and Customization: Linux offers extensive flexibility and customization options. It can be installed on a wide range of computer hardware devices, from mobile phones, tablets, and routers, to game consoles, desktops, mainframes, and supercomputers.
- Security: Linux is generally considered to be more secure than many other operating systems. Its permission and user role features require that user and administrator accounts have separate permissions.
- Stability and Reliability: Linux is known for its stability and reliability. It is often used in server environments because Linux-based servers don’t need to be rebooted periodically to maintain performance levels.
- Community Support: Being open-source, Linux has a large community support system with numerous forums, communities, and distributions to help users.
- Cost: Linux can be a more cost-effective option for both personal and enterprise users as it is mostly free to use. Unlike other major operating systems, which can require costly licenses, most Linux distributions are available to download, use, and distribute at no cost.
- Package Management: Linux distributions come with their own package management systems. These tools allow users to easily install, update, and remove software.
- Performance: Linux systems generally run faster and with greater performance consistency than many other operating systems. They are highly effective in handling numerous processes at once, and generally manage system resources very efficiently.
- Privacy: Linux tends to collect much less data about user activities compared to some other operating systems.
- Variety of Distros: Linux offers a variety of distributions tailored for different types of users and systems. From lightweight distros like Lubuntu and Arch Linux for older hardware to those designed for specific professional use cases like CentOS for servers, there is a Linux for almost every purpose.
What’s the command for changing the permission of a file? Give an example
chmod
This command allows you to set the read, write, and execute permissions for the owner, group, and others who interact with a file or directory.
Permissions in Linux are defined for three types of users:
Owner
Group
Others
Permissions are represented numerically or symbolically:
Read (r) = 4
Write (w) = 2
Execute (x) = 1
Example 1: Using Numeric (Octal) Notation
If you want to set the owner permissions to read and write, group permissions to read, and no permissions for others, you would calculate the permissions as:
Owner: Read + Write = 4 + 2 = 6
Group: Read = 4
Others: No permissions = 0
chmod 640 [filename]
Example 2: Using Symbolic Notation
To add execute permission to a file for the owner, you can use symbolic notation like this:
chmod u+x [filename]