Linux Flashcards
(37 cards)
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.
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
- /bin: The home for executable binaries, such as mount ls cd. bin contains core OS programs that must be accessible before /usr gets mounted at boot.
- /usr: is a primary home for binaries that are not directly used by OS itself. Most user programs like git or wget live here. It stands for Unix System Resources not user!
- /usr/local/bin : holds executables installed by the admin, usually after buiilding them from source.
- sbin: sbin house sysadmin utilities that require root access like iptables and sshd.
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.
- /lib : contains shared library files essential for /bin and /sbin binaries to function properly. These libraries need to be accessible early in the boot process before mounting /usr. C library routines and compiler runtimes…
- /usr/lib: User libraries that are not critical early in the boot process.
- /etc: Home of Linux configuration files. Text based config files control everything from networking to authentication services. ssh_config for example or fstab.
- /home: stores documents, media and projets.
- /root: Exclusive to administrators.
- /var: Fast changing data like logs and caches live under /var
- /var/log: We care about this folder to inspect about hardware events, security issues or performance problems.
- /run: Contains volatile run-time info like systemd details, user sessions and logging daemons. System services use run for ongoing communication via sockets and lock files. For example, mysql.sock might be crucial for db access.
- /proc: OS state via cpuinfo, view filesystem mounts, and dive deeper with tools like lsof, strace and pmap.
- /sys: exposes lower-level kernel and hardware objects, allowing granular monitoring, configuration of components live devices, modules, network stack via virtual files. (Socket layer, TCP stack, netfilter, traffic control, network interface) Sys and proc combined they provide complete system observability spanning high level metrics to low level component interactions. These inspection points are useful for performance tuning and forensic triage.
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]