Linux Flashcards
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:
-
/ (Root Directory):
- The top-level directory of the Linux file system. All other directories and files branch from here.
-
/bin (Binary):
- Contains essential command binaries (executables) that are needed for system booting, repairing, and general system use. Examples include
ls
,cp
,mv
, andrm
.
- Contains essential command binaries (executables) that are needed for system booting, repairing, and general system use. Examples include
-
/sbin (System Binaries):
- Contains essential system binaries, typically used for system administration tasks. Examples include
fsck
,reboot
,ifconfig
, andiptables
.
- Contains essential system binaries, typically used for system administration tasks. Examples include
-
/etc (Et Cetera):
- Contains all the system-wide configuration files and shell scripts that are used to boot and initialize system settings. Examples include
/etc/passwd
for user account information and/etc/fstab
for file system mount points.
- Contains all the system-wide configuration files and shell scripts that are used to boot and initialize system settings. Examples include
-
/dev (Device Files):
- Contains device files that represent hardware devices. Examples include
/dev/sda
(a hard disk),/dev/tty
(terminals), and/dev/null
(a null device).
- Contains device files that represent hardware devices. Examples include
-
/proc (Process Information):
- A virtual file system that contains information about running processes. It provides a mechanism to access kernel information through files. Examples include
/proc/cpuinfo
for CPU information and/proc/meminfo
for memory information.
- A virtual file system that contains information about running processes. It provides a mechanism to access kernel information through files. Examples include
-
/var (Variable):
- Contains variable data files. This includes log files, spool files, and temporary files. Examples include
/var/log
for log files,/var/spool
for printer and mail spools, and/var/tmp
for temporary files that need to persist between reboots.
- Contains variable data files. This includes log files, spool files, and temporary files. Examples include
-
/usr (User):
- Contains user binaries, libraries, documentation, and source code for second-level programs. Subdirectories include
/usr/bin
for non-essential user command binaries and/usr/lib
for non-essential libraries.
- Contains user binaries, libraries, documentation, and source code for second-level programs. Subdirectories include
-
/home (Home Directories):
- Contains personal directories for users. Each user has a subdirectory within
/home
named after their username, such as/home/user1
.
- Contains personal directories for users. Each user has a subdirectory within
-
/lib (Libraries):
- Contains shared libraries needed by the binaries in
/bin
and/sbin
. These libraries are essential for the system to boot and run the commands in those directories.
- Contains shared libraries needed by the binaries in
-
/opt (Optional):
- Contains add-on application software packages. It is typically used for third-party software installations.
-
/mnt and /media (Mount Points):
- Used as mount points for temporarily mounting filesystems, such as USB drives, CD-ROMs, and network shares.
/mnt
is often used for manual mounts, while/media
is typically used by the system to automatically mount removable media.
- Used as mount points for temporarily mounting filesystems, such as USB drives, CD-ROMs, and network shares.
-
/tmp (Temporary):
- Used to hold temporary files created by system and user processes. Files in
/tmp
are typically cleared upon system reboot.
- Used to hold temporary files created by system and user processes. Files in
-
/boot (Boot Loader Files):
- Contains files needed for the system to boot, including the kernel and initial RAM disk. Examples include the boot loader configuration file and kernel images.
-
/root (Root Home Directory):
- The home directory for the root user. It is separate from
/home
to provide security and organizational benefits.
- The home directory for the root user. It is separate from
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.