Challenging Concepts Flashcards
4 main rights of the GNU GPL License
- The right to download and run the software freely.
- The right to make changes to the software as desired.
- The right to redistribute copies of the software.
- The right to modify and distribute copies of new versions of the software.
4 main characteristics of the GNU GPL License
- Copyleft: The GPL is a copyleft license, which means that any derivative works or modifications made to the original software must also be licensed under the GPL. This ensures that the software and its derivatives remain free and open source.
- Source Code Availability: The GPL requires that the source code of the software be made available to users. This allows users to study, modify, and distribute the software.
- Distribution of License: When distributing software under the GPL, the license terms must be included along with the software. This ensures that recipients are aware of their rights and obligations under the GPL.
- Compatibility with Other GPL-Licensed Software: The GPL is designed to be compatible with other GPL-licensed software. This means that if you combine or link GPL-licensed software with other GPL-licensed software, the resulting work must also be licensed under the GPL.
2 main license types
- Copyleft Licenses (e.g., GNU GPL): Copyleft licenses are designed to ensure that software and its derivatives remain free and open source.
- Permissive Licenses (e.g., Apache, BSD, MIT): Permissive licenses, on the other hand, have fewer restrictions compared to copyleft licenses.
Ways open source software may not be free:
- Licensing Restrictions: While open source software grants certain freedoms, it is still subject to licensing terms. Users must comply with the specific requirements outlined in the chosen open source license, such as attribution or copyleft provisions.
- Support and Maintenance Costs: Although the software itself may be freely available, users may incur costs for support, maintenance, or additional services related to the open source software. These costs can vary depending on the specific software and the level of support required.
- Compatibility and Integration Challenges: Integrating open source software into existing systems or ensuring compatibility with other proprietary software may require additional effort and resources. This can result in costs associated with customization or development work.
What is Creative Commons about?
Creative Commons is an organization that offers licenses allowing creators to share their work while retaining certain rights. These licenses provide flexibility and allow creators to choose the permissions they want to grant. By using Creative Commons licenses, creators can easily communicate how their work can be used, shared, and adapted. This promotes collaboration, creativity, and the sharing of knowledge and culture. However, it’s important to note that Creative Commons licenses work within existing copyright law and do not replace it.
Linux Software for Image Editing
- GIMP (GNU Image Manipulation Program) is a powerful open-source image editing software.- It offers a wide range of features for photo retouching, image composition, and image authoring.- GIMP supports various file formats and provides tools for advanced editing, such as layers, filters, and customizable brushes.- It has an active community and a large number of plugins and scripts available for extending its functionality.
- Others: Krita, Inkscape, Darktable, Shotwell, RawTherapee
Popular Vector Graphics (Linux):
- Inkscape is a popular open-source vector graphics editor.- It provides a comprehensive set of tools for creating and editing vector-based artwork.- Inkscape supports SVG (Scalable Vector Graphics) as its native file format and can import/export other vector and raster formats.- It offers features like shape manipulation, text support, gradients, and advanced path editing.- Inkscape is known for its user-friendly interface and its ability to handle complex vector graphics projects.
Linux software for 3D Animation
- Blender is a versatile open-source 3D animation suite.- It offers a wide range of features for modeling, animation, rendering, and post-production.- Blender supports various 3D file formats and provides tools for creating realistic animations, visual effects, and simulations.- It has a powerful node-based material and compositing system, making it suitable for advanced 3D projects.- Blender has an active community and is widely used in the animation and visual effects industry.
- Other: Krita, Synfig Studio, Natron, Pencil2D
Linux Webserver Software
- Apache HTTP Server is a widely used open-source web server software.- It is known for its stability, security, and flexibility, supporting various modules and configurations.- Apache is highly customizable and can handle a large number of concurrent connections.- NGINX is another popular open-source web server known for its high performance and scalability.
- NGINX is often used as a reverse proxy or load balancer, efficiently handling high traffic volumes.- Both Apache and NGINX have extensive documentation and active communities for support.
- Reverse proxy manages client requests on behalf of backend servers, providing additional functionality such as load balancing, SSL termination, and security. On the other hand, a load balancer specifically focuses on distributing incoming traffic across multiple servers to optimize performance
Linux applications for: image editing, vector graphics, 3d animation , and Linux Webservers
GIMP, Inkscape, Blender, Apache NGINX
Linux applications used as a cloud computing client in the web browser
- OwnCloud: OwnCloud is a self-hosted cloud storage platform that allows users to access and manage their files, calendars, contacts, and more through a web interface. It provides features similar to popular cloud storage services like Dropbox or Google Drive.
- Nextcloud: Nextcloud is another self-hosted cloud platform that offers file synchronization, sharing, and collaboration features. It also provides additional functionalities such as calendar and contact management, document editing, and video conferencing.
- Seafile: Seafile is a cloud storage and file synchronization platform that can be self-hosted or used with their cloud service. It offers features like file sharing, collaboration, and version control.
- Pydio: Pydio (formerly known as AjaXplorer) is an open-source file sharing and synchronization platform. It allows users to access, share, and collaborate on files through a web interface.
Where the OS is stored on a Raspberry PI
The microSD card serves as the primary storage medium for the Raspberry Pi’s operating system, system files, and user data.
Creative Commons is about
Putting the control back into the hands of the author
Creative Commons is a licensing framework that allows creators to specify the permissions for others to use their work. It offers a range of licenses, from more permissive to restrictive, governing how content can be shared, modified, and used, while still retaining some rights.
What the ‘.’ and ‘..’ files represent
. (Dot): This entry refers to the current directory. When you see . in a directory listing, it indicates the directory itself.
.. (Double Dot): This entry refers to the parent directory. If you’re navigating through a file system, .. takes you up one level in the directory hierarchy.
if you’re in the directory /home/user/documents, then . refers to /home/user/documents, and .. refers to /home/user.
4 reasons why the space character is significant to the shell
- Command Parsing: The shell uses spaces to parse commands into distinct elements. Each element typically corresponds to a command, an option, or an argument.
-
Word Separation: Commands and their arguments are separated by spaces. For example, in the command
ls -l
,ls
is the command, and-l
is an option passed to that command. The space helps the shell recognize these as separate words. - Path Separation: When specifying file paths or directory names as arguments, spaces are used to separate different parts of the path. Quotation marks can be used to include spaces within a single argument, ensuring that the entire path is treated as a single entity.
-
Redirection and Pipes: Spaces are used to separate different parts of a command when redirecting input/output or chaining commands together using pipes. For example,
command1 > output.txt
orcommand1 | command2
.
Why Windows file extensions are meaningless to the shell
In a command shell or terminal environment, file extensions are generally considered part of the file name and don’t inherently convey the type or purpose of the file in the same way they might in graphical file managers.
How to ‘wrap’ a long command in the terminal
To “wrap” or break a long command into multiple lines in the terminal, you can use the backslash \ character at the end of each line.
It’s important to note that there should be no space after the backslash; it should be the last character on the line.
The linked pages for the info command are called nodes
Linked Pages: The documentation presented by the info command is not a single, linear document. Instead, it consists of interconnected pages or nodes, where each node covers a particular aspect or topic. These nodes are linked together to facilitate navigation.
Info Command: The info command is a text-based documentation viewer in Unix-like operating systems. It allows users to access and navigate through detailed information about various commands, programs, and concepts.
Nodes: In the context of the info command, a “node” is a unit of information that corresponds to a specific topic or section within the documentation. Nodes are interconnected, allowing users to move from one node to another to explore related information.
The difference between an absolute and relative path
Absolute Path:
Specifies the complete path from the root directory to the target file or directory.
Always starts from the root directory (designated by a forward slash, / in Unix-like systems) and includes all the directories in the path.
Provides a full and unambiguous description of the file or directory location.
Examples:
Unix/Linux: /home/user/documents/file.txt
Windows: C:\Users\User\Documents\file.txt
Relative Path:
Specifies the path to the target file or directory relative to the current working directory.
Does not start from the root directory; instead, it’s based on the current location in the file system.
May be shorter and more convenient but depends on the context of the current working directory.
Examples:
If the current directory is /home/user/:
documents/file.txt (Unix/Linux)
Documents\file.txt (Windows)
Explain the key aspects of File Hierarchy Standard (FHS) and how that relates to a user’s /home folder
The File Hierarchy Standard (FHS) is a set of guidelines and conventions that dictate the structure of the file system on Unix-like operating systems. The FHS helps ensure consistency and interoperability across different Unix and Linux distributions. It defines the organization and placement of files and directories in the filesystem hierarchy.
Key aspects of the FHS include:
-
/
: Root Directory:- The top-level directory in the file system hierarchy.
- All other directories and files are organized beneath the root directory.
-
/bin
: Essential User Binaries:- Contains essential binaries (executable files) required for system recovery and maintenance.
-
/etc
: Configuration Files:- Contains system-wide configuration files and shell scripts used by system administrators.
-
/home
: User Home Directories:- Contains home directories for users.
- Each user typically has a subdirectory under
/home
with their username (e.g.,/home/user1
,/home/user2
).
-
/usr
: User Binaries and Read-Only Data:- Contains user-related programs, libraries, documentation, etc.
- Often includes subdirectories like
/usr/bin
,/usr/lib
, and/usr/share
.
-
/var
: Variable Files:- Contains variable data files, such as log files and temporary files.
Now, regarding a user’s /home
folder:
- The
/home
directory is specifically designated for user home directories. - Each user typically has a subdirectory within
/home
named after their username (e.g.,/home/user1
). - The user’s home directory is where personal files, documents, and user-specific configurations are stored.
The /home
directory, as outlined by the FHS, provides a standardized location for user home directories, making it easier for system administrators and users to locate and manage their personal files. The FHS contributes to the consistency and compatibility of file system organization across different Unix and Linux distributions.
Where do you find documentation on installed software packages
- Man Pages (Manual Pages):
The primary source of documentation for command-line programs.
Accessible by using the man command followed by the name of the program.
Example: man ls to view the manual page for the ls command.
Info Pages: - Info Pages:
Some software packages provide documentation in the info format.
Accessible using the info command followed by the name of the program.
Example: info gcc to view the documentation for the GCC compiler.
Documentation Directories: - Documentation Directories:
Many packages include documentation files installed in standard directories like /usr/share/doc or /usr/share/man.
Check these directories for README files, manuals, and other documentation related to installed software.
Configuration Files: - Configuration Files:
Some software packages store documentation in their configuration directories.
Check the installation directory or configuration directory for files like README, INSTALL, or other documentation files.
Online Resources: - Online Resources:
Visit the official website or documentation repository for the software.
Online documentation is often available on project websites or community forums.
Package Manager Commands: - Package Manager Commands:
Use package manager commands to show information about installed packages.
Example: dpkg -L <package-name> or rpm -ql <package-name> to list installed files, which may include documentation.
Help Option:</package-name></package-name> - Help Option:
Some programs support a –help option that provides a summary of command-line options.
Example: <command></command> –help to display a brief help message.
What is the default level of compression for the zip command by option (hint: man zip)
The default compression level for the zip command is typically set to “normal” compression. In the zip command’s manual (man zip), you can find information about the available compression levels.
You can, however, specify a compression level using the -X option, followed by a numeric value from 0 to 9, where 0 is no compression and 9 is maximum compression.
zip -X9 archive.zip file1 file2 directory/
tar
tar: The tar command in Unix-like operating systems is used for archiving and compressing files and directories.
tar, -c and -x options, -j, -J, and -z options, the -f option
Options:
- -c
: Create a new archive.
- -x
: Extract files from an archive.
- -z
: Compress the archive using gzip.
- -j
: Compress the archive using bzip2.
- -J
: Compress the archive using xz.
- -f
: Specifies the filename of the archive.Options:
Breakdown:
~~~
tar -cvf archive.tar file1 file2 directory/
```
Create an Archive (-c
):
tar -cvf archive.tar file1 file2 directory/
-
-c
: Create a new archive.-
-v
: Verbose mode (optional, shows the files being archived).-
-f archive.tar
: Specifies the filename of the archive.-
file1 file2 directory/
: List of files and directories to be included in the archive.Breakdown:
tar -xvf archive.tar
Extract from an Archive (-x
):
tar -xvf archive.tar
-
-x
: Extract files from an archive.-
-v
: Verbose mode (optional, shows the files being extracted).-
-f archive.tar
: Specifies the filename of the archive.Breakdown:
tar -czvf archive.tar.gz file1 file2 directory/
Create a Compressed Archive (-cz
for gzip, -cj
for bzip2, -cJ
for xz):
tar -czvf archive.tar.gz file1 file2 directory/
-
-c
: Create a new archive.-
-z
: Compress the archive using gzip.-
-v
: Verbose mode (optional, shows the files being archived).-
-f archive.tar.gz
: Specifies the filename of the compressed archive.-
file1 file2 directory/
: List of files and directories to be included in the archive.Breakdown:
tar -xzvf archive.tar.gz
Extract from a Compressed Archive (-xz
for gzip, -xj
for bzip2, -xJ
for xz):
tar -xzvf archive.tar.gz
-
-x
: Extract files from an archive.-
-z
: Decompress the archive using gzip.-
-v
: Verbose mode (optional, shows the files being extracted).-
-f archive.tar.gz
: Specifies the filename of the compressed archive.The exact order of files that follow
tar: The tar
command in Unix-like operating systems is used for archiving and compressing files and directories.
Order of Options and Files:
-
Create an Archive (
-c
):tar -cvf archive.tar file1 file2 directory/
-
-c
: Create a new archive. -
-v
: Verbose mode (optional, shows the files being archived). -
-f archive.tar
: Specifies the filename of the archive. -
file1 file2 directory/
: List of files and directories to be included in the archive.
-
-
Extract from an Archive (
-x
):tar -xvf archive.tar
-
-x
: Extract files from an archive. -
-v
: Verbose mode (optional, shows the files being extracted). -
-f archive.tar
: Specifies the filename of the archive.
-
-
Create a Compressed Archive (
-cz
for gzip,-cj
for bzip2,-cJ
for xz):tar -czvf archive.tar.gz file1 file2 directory/
-
-c
: Create a new archive. -
-z
: Compress the archive using gzip. -
-v
: Verbose mode (optional, shows the files being archived). -
-f archive.tar.gz
: Specifies the filename of the compressed archive. -
file1 file2 directory/
: List of files and directories to be included in the archive.
-
-
Extract from a Compressed Archive (
-xz
for gzip,-xj
for bzip2,-xJ
for xz):tar -xzvf archive.tar.gz
-
-x
: Extract files from an archive. -
-z
: Decompress the archive using gzip. -
-v
: Verbose mode (optional, shows the files being extracted). -
-f archive.tar.gz
: Specifies the filename of the compressed archive.
-
The order of options and the filename (-f
option) should come immediately after the tar
command. The list of files and directories to be archived or extracted follows the options and the filename.
STDIN (Standard Input):
- File Descriptor Number:
- Purpose: STDIN is the
STDIN (Standard Input):
- File Descriptor Number: 0
- Purpose: STDIN is the standard input stream. It is the source of input for commands or processes. When you type from the keyboard or redirect input from a file, the data flows through STDIN.
STDOUT (Standard Output):
- File Descriptor Number:
- Purpose: STDOUT is the
STDOUT (Standard Output):
- File Descriptor Number: 1
- Purpose: STDOUT is the standard output stream. It is the default destination for the normal output of commands. When a command executes successfully, its output is directed to STDOUT. By default, STDOUT is displayed on the terminal.
STDERR (Standard Error):
- File Descriptor Number:
- Purpose: STDERR is the
STDERR (Standard Error):
- File Descriptor Number: 2
- Purpose: STDERR is the standard error stream. It is used for error messages and diagnostics. When a command encounters an error, the error message is sent to STDERR. Like STDOUT, STDERR is also, by default, displayed on the terminal.
Redirecting and Managing Streams:
- Redirecting STDOUT: You can redirect the output of a command to a file using
Redirecting and Managing Streams:
- Redirecting STDOUT: You can redirect the output of a command to a file using >
or append to a file using >>
. For example:
bash command > output.txt
-
Redirecting STDERR: To redirect STDERR, you can use
2>
or2>>
. For example:bash command 2> error.txt
-
Redirecting Both STDOUT and STDERR: To redirect both STDOUT and STDERR to the same file, you can use
&>
or&>>
. For example:bash command &> output_and_error.txt
Difference between STDIN, STDOUT, and STDERR (and their corresponding file descriptors numbers)
In Unix-like operating systems, including Linux, STDIN, STDOUT, and STDERR are streams that handle input, output, and error messages for processes. They are associated with file descriptors, which are small non-negative integers used to identify open files or streams.
Here’s an overview of each:
-
STDIN (Standard Input):
- File Descriptor Number: 0
- Purpose: STDIN is the standard input stream. It is the source of input for commands or processes. When you type from the keyboard or redirect input from a file, the data flows through STDIN.
-
STDOUT (Standard Output):
- File Descriptor Number: 1
- Purpose: STDOUT is the standard output stream. It is the default destination for the normal output of commands. When a command executes successfully, its output is directed to STDOUT. By default, STDOUT is displayed on the terminal.
-
STDERR (Standard Error):
- File Descriptor Number: 2
- Purpose: STDERR is the standard error stream. It is used for error messages and diagnostics. When a command encounters an error, the error message is sent to STDERR. Like STDOUT, STDERR is also, by default, displayed on the terminal.
Redirecting and Managing Streams:
- Redirecting STDOUT: You can redirect the output of a command to a file using >
or append to a file using >>
. For example:
bash command > output.txt
-
Redirecting STDERR: To redirect STDERR, you can use
2>
or2>>
. For example:bash command 2> error.txt
-
Redirecting Both STDOUT and STDERR: To redirect both STDOUT and STDERR to the same file, you can use
&>
or&>>
. For example:bash command &> output_and_error.txt
These streams and file descriptors provide a flexible way to handle input, output, and error messages in the command-line environment. Understanding how to manipulate and redirect these streams is valuable for managing command output and error handling in scripts and day-to-day use.
In Unix-like operating systems, redirecting and appending refer to how the output of a command is handled when it is sent to a file. The key difference lies in
Redirecting output (overwrite or create)
In Unix-like operating systems, redirecting and appending refer to how the output of a command is handled when it is sent to a file. The key difference lies in whether the output overwrites the existing content of the file or is appended to the end of the file.
-
Redirecting Output (
>
):- The
>
symbol is used for redirecting output to a file. - If the file already exists, the contents are overwritten with the new output.
- If the file does not exist, a new file is created.
- Example:
bash command > output.txt
- This will create or overwrite
output.txt
with the output of thecommand
.
- This will create or overwrite
- The
-
Appending Output (
>>
):- The
>>
symbol is used for appending output to a file. - If the file already exists, the new output is added to the end of the existing content without overwriting.
- If the file does not exist, a new file is created.
- Example:
command >> output.txt
- This will append the output of the
command
to the existing content or create a new file ifoutput.txt
doesn’t exist.
- This will append the output of the
- The
Examples:
~~~
b
echo “First line” > file.txt
Appending output (add to existing or create)
echo “Second line”»_space; file.txt
~~~
In these examples, the >
symbol overwrites the content of file.txt
with “First line,” and the >>
symbol appends “Second line” to the end of the file. The result in file.txt
would be:
First line Second line
Understanding the difference between redirecting and appending is crucial when managing files in the command line, especially when dealing with command output or log files.
A (Address) Record:
Resolves a domain name to an IPv4 address.
AAAA Record:
- Resolves a domain name to an IPv6 address.
CNAME (Canonical Name) Record:
- Creates an alias or nickname for a domain. It points to the canonical (true) domain name.
MX Record:
- Specifies mail servers responsible for receiving email on behalf of the domain.
What are the DNS record types?
DNS Record Types:
-
A (Address) Record:
- Resolves a domain name to an IPv4 address.
-
AAAA (IPv6 Address) Record:
- Resolves a domain name to an IPv6 address.
-
CNAME (Canonical Name) Record:
- Creates an alias or nickname for a domain. It points to the canonical (true) domain name.
-
MX (Mail Exchange) Record:
- Specifies mail servers responsible for receiving email on behalf of the domain.
-
PTR (Pointer) Record:
- Used for reverse DNS lookups, mapping an IP address to a domain name.
-
NS (Name Server) Record:
- Specifies authoritative DNS servers for the domain.
-
SOA (Start of Authority) Record:
- Contains administrative information about the domain, including the primary DNS server and other settings.
-
TXT (Text) Record:
- Allows arbitrary text to be associated with a domain. Commonly used for verification or information.
What are DNS query commands?
DNS Query Commands:
-
nslookup
:- Used for querying DNS servers and obtaining information about domain names, IP addresses, or other DNS records.
- Example:
nslookup example.com
-
dig
(Domain Information Groper):- A versatile tool for DNS queries, providing detailed information about DNS responses.
- Example:
dig example.com A
-
host
:- A simple utility for performing DNS lookups.
- Example:
host example.com
Where is DNS configured in a Linux machine?
DNS Configuration on Linux:
-
/etc/resolv.conf
:- This file contains information about name servers and search domains.
- Example:
nameserver 8.8.8.8 nameserver 8.8.4.4
-
/etc/nsswitch.conf
:- Configures the name service switch, specifying the order of service lookups (e.g., DNS, files, NIS).
- Example:
hosts: files dns
-
/etc/hosts
:- Allows manual mapping of IP addresses to hostnames.
- Example:
127.0.0.1 localhost 192.168.1.1 example.com
-
systemd-resolved
:- In systems using systemd, the
systemd-resolved
service may handle DNS resolution. - Configuration:
/etc/systemd/resolved.conf
- In systems using systemd, the
These configurations help define how a Linux machine resolves domain names, interacts with DNS servers, and handles local host mappings. The specific configuration files may vary between Linux distributions.
When to use find, locate, or grep
The find
, locate
, and grep
commands in Linux are used for different purposes, and the choice of which one to use depends on the specific task you want to accomplish. Here’s a brief overview of each command and when to use them:
-
find
:-
Purpose:
find
is a powerful command-line tool for searching and locating files and directories in a file system hierarchy. -
When to Use:
- Searching for files based on criteria such as name, size, modification time, etc.
- Performing complex file operations, such as executing commands on found files.
- Recursive searching through directories.
-
Example:
# Find all text files in the /home/user directory find /home/user -name "*.txt"
-
Purpose:
-
locate
:-
Purpose:
locate
is a faster alternative for finding files by name. It uses a pre-built index of files on the system. -
When to Use:
- Quickly searching for files by name.
- When you want to find files without specifying complex search criteria.
- Suitable for situations where the index is up-to-date.
-
Example:
# Locate all files with the name "example.txt" locate example.txt
-
Note: The
locate
command relies on a pre-built index, and the index may not be up-to-date if the system configuration or files have changed recently. You can update the index using theupdatedb
command.
-
Purpose:
-
grep
:-
Purpose:
grep
is a powerful command-line tool for searching text patterns within files. -
When to Use:
- Searching for specific text patterns or strings within files.
- Examining log files, configuration files, or any text-based files.
- Combining with other commands through pipes for more complex searches.
-
Example:
# Search for the string "error" in all .log files in the /var/log directory grep "error" /var/log/*.log
-
Purpose:
In summary:
- Use find
when you need to search for files based on various criteria and perform complex operations.
- Use locate
for quick file name-based searches when the index is up-to-date.
- Use grep
when you want to search for specific text patterns within files.
These commands can also be combined in more complex commands or scripts to achieve specific search and manipulation tasks.
find
:
find
:
- Purpose: find
is a powerful command-line tool for searching and locating files and directories in a file system hierarchy.
- When to Use:
- Searching for files based on criteria such as name, size, modification time, etc.
- Performing complex file operations, such as executing commands on found files.
- Recursive searching through directories.
-
Example:
# Find all text files in the /home/user directory find /home/user -name "*.txt"
locate
:
locate
:
- Purpose: locate
is a faster alternative for finding files by name. It uses a pre-built index of files on the system.
- When to Use:
- Quickly searching for files by name.
- When you want to find files without specifying complex search criteria.
- Suitable for situations where the index is up-to-date.
-
Example:
# Locate all files with the name "example.txt" locate example.txt
-
Note: The
locate
command relies on a pre-built index, and the index may not be up-to-date if the system configuration or files have changed recently. You can update the index using theupdatedb
command.
grep
:
grep
:
- Purpose: grep
is a powerful command-line tool for searching text patterns within files.
- When to Use:
- Searching for specific text patterns or strings within files.
- Examining log files, configuration files, or any text-based files.
- Combining with other commands through pipes for more complex searches.
-
Example:
# Search for the string "error" in all .log files in the /var/log directory grep "error" /var/log/*.log
What to do to force an update of the locate index
To force an update of the locate index on a Linux system, you can use the updatedb command. The updatedb command is responsible for updating the file name database that locate relies on.
tar does not compress by default but that zip does!
The tar
and zip
commands serve different purposes and have different default behaviors when it comes to compression.
tar
Command:
-
Default Behavior: The
tar
command is primarily used for creating archives or collections of files and directories. By default,tar
does not perform compression; it simply bundles files together into a single archive file. -
Compression Options: While
tar
itself doesn’t compress, it often works in conjunction with compression tools like gzip or bzip2. Users can use additional options to compress the archive during the creation process. For example:-
tar -cvzf archive.tar.gz files
: Creates a gzip-compressed archive (-z
option).
-
zip
Command:
-
Default Behavior: The
zip
command, on the other hand, is designed to both archive and compress files by default. When you usezip
without specific compression options, it automatically compresses the files added to the archive. -
Compression Options: Users can still control the compression level when using
zip
through options like-0
(no compression) to-9
(maximum compression). For example:-
zip archive.zip files
: Creates a compressed archive using the default compression level.
-
Summary:
In summary, the key difference lies in the default behavior:
-
tar
archives files without compression by default but can be combined with compression tools. -
zip
archives and compresses files by default, and users can adjust the compression level.
If compression is desired with tar
, users need to explicitly specify a compression tool during the archive creation process. Each tool has its strengths, and the choice between tar
and zip
depends on the specific requirements of the task at hand.
Relationship between speed and compression for the zip command the options used
The zip
command provides options to control the compression level, allowing users to balance compression efficiency with processing speed. The key options for controlling compression in the zip
command are typically -0
through -9
, where 0
indicates no compression, and 9
indicates maximum compression.
Here’s a general overview of the relationship between speed and compression for the zip
command:
-
Low Compression Levels (
-0
to-5
):- Speed: Faster compression.
- Compression Ratio: Lower compression ratio (larger file size).
- Usage: Suitable for scenarios where speed is a priority, and achieving the maximum compression ratio is not critical.
bash zip -0 archive.zip files # No compression zip -5 archive.zip files # Low compression
-
Medium Compression Levels (
-6
to-8
):- Speed: Moderate compression speed.
- Compression Ratio: Balanced compression ratio.
- Usage: A good compromise between speed and compression ratio, suitable for general use.
bash zip -6 archive.zip files # Medium compression zip -7 archive.zip files # Medium compression zip -8 archive.zip files # Medium compression
-
High Compression Level (
-9
):- Speed: Slower compression.
- Compression Ratio: Higher compression ratio (smaller file size).
- Usage: Ideal for scenarios where achieving the maximum compression ratio is crucial, even if it comes at the cost of slower processing.
bash zip -9 archive.zip files # High compression
Example:
```bash
# Create a zip archive with medium compression level
zip -6 archive.zip files
~~~
The choice of compression level depends on the specific requirements of the task. If fast compression is essential and file size is less critical, a lower compression level may be suitable. Conversely, if achieving the smallest possible file size is a priority and speed is less important, a higher compression level may be preferred.
The typical bus types used with hard drives
The typical bus types used with hard drives refer to the interfaces that connect hard drives to the motherboard or storage controller. Over the years, various interfaces have been developed to accommodate the increasing speed and performance of hard drives. Here are some of the common bus types used with hard drives:
-
Parallel ATA (PATA):
- Description: Also known as IDE (Integrated Drive Electronics), PATA was once a standard interface for connecting hard drives to motherboards. It uses a parallel data transfer method.
- Data Transfer Rate: Older PATA interfaces support lower data transfer rates compared to modern standards.
-
Serial ATA (SATA):
- Description: SATA is the successor to PATA and uses a serial data transfer method. It has become the standard interface for connecting internal hard drives to motherboards.
- Data Transfer Rate: SATA interfaces support higher data transfer rates than PATA, and there are multiple generations (SATA I, SATA II, SATA III) with increasing speeds.
-
Small Computer System Interface (SCSI):
- Description: SCSI is a set of standards for connecting and transferring data between computers and peripheral devices, including hard drives. SCSI interfaces were commonly used in enterprise environments.
- Variants: There are different variants of SCSI, including Ultra SCSI, Ultra2 SCSI, Ultra160 SCSI, and Ultra320 SCSI, each offering higher data transfer rates.
-
Serial Attached SCSI (SAS):
- Description: SAS is a serial interface designed for connecting high-performance devices, including hard drives, in enterprise environments. It is backward compatible with SATA.
- Data Transfer Rate: SAS interfaces support high data transfer rates and are commonly used in servers and storage systems.
-
Non-Volatile Memory Express (NVMe):
- Description: NVMe is an interface protocol developed for modern, high-performance SSDs. It is designed to take advantage of the high-speed characteristics of NAND flash memory.
- Data Transfer Rate: NVMe interfaces offer significantly higher data transfer rates compared to SATA, making them suitable for high-performance storage.
These interfaces have evolved over time, with newer standards providing faster data transfer rates and improved features. The choice of interface depends on factors such as the type of hard drive (HDD or SSD), the intended use (consumer or enterprise), and the performance requirements of the system. In modern systems, SATA and NVMe are the most common interfaces for connecting hard drives.
The 3 components that make up any Linux distribution
A Linux distribution consists of three key components:
- Linux Kernel: The core of the operating system that directly interacts with hardware, managing system resources and providing essential services.
- System Libraries: Sets of code and data that offer standardized functions to higher-level programs, abstracting interactions between the kernel and software.
- System Utilities and Tools: User-level programs and commands for tasks such as file management, process control, and system configuration, enabling user interaction with the operating system.
These components, along with a package management system, work together to create a complete and functional Linux distribution. Popular distributions include Ubuntu, Fedora, Debian, CentOS, and Arch Linux, each tailored to specific user needs and preferences.
The 2 major families of distros, and how to recognize
The two major families of Linux distributions are:
-
Debian-based:
-
Recognition: Package management tools like
apt
ordpkg
are used for installing and managing software packages. Common Debian-based distributions include Ubuntu and its variants, Debian itself, and Linux Mint.
-
Recognition: Package management tools like
-
Red Hat-based:
-
Recognition: Package management tools such as
yum
ordnf
are used for software installation and management. Prominent Red Hat-based distributions include Red Hat Enterprise Linux (RHEL), CentOS, Fedora, and Oracle Linux.
-
Recognition: Package management tools such as
In summary, Debian-based distributions use apt
or dpkg
for package management, while Red Hat-based distributions use yum
or dnf
. Recognizing the package management tools is a quick way to identify which family a Linux distribution belongs to.
For Debian, main characteristics for:
Debian and Ubuntu Server, Ubuntu/Mint, and KALI
(+updownstream relationship)
Debian and Ubuntu Server (stable), Ubuntu/Mint (desktop/consumer), KALI (ethical hacking/pentesting)
Debian is a versatile Linux distribution with different flavors tailored for various purposes:
-
Debian and Ubuntu Server (stable):
- Debian serves as the foundation for stable server environments, and Ubuntu Server, based on Debian, inherits this stability for server deployments.
-
Ubuntu/Mint (desktop/consumer):
- Ubuntu, a Debian derivative, and Linux Mint, based on Ubuntu, are user-friendly desktop distributions designed for consumer use.
-
KALI (ethical hacking/pentesting):
- Kali Linux, another Debian derivative, specializes in ethical hacking and penetration testing, providing a comprehensive toolkit for security professionals.
For Red Hat, main characteristics of: Fedora > RHEL > CentOS, Oracle Linux, Scientific Linux.
(+updownstream relationship)
Fedora (upstream distro) > RHEL > CentOS, Oracle Linux, Scientific Linux (all downstream distros)
In the Red Hat ecosystem:
-
Fedora (upstream distro):
- Cutting-edge, community-driven distribution serving as the upstream for Red Hat projects. Features the latest software and technologies.
-
RHEL (Red Hat Enterprise Linux):
- Enterprise-focused, stable, and secure Linux distribution with long-term support. Used in mission-critical environments.
-
CentOS:
- A downstream, community-supported version of RHEL. Provides RHEL’s stability and compatibility without the official Red Hat support.
-
Oracle Linux:
- Oracle’s distribution built on RHEL. Optimized for Oracle software and often used in Oracle Database environments.
-
Scientific Linux:
- A community-supported distribution based on RHEL. Initially aimed at scientific computing, but development has ceased, and users are encouraged to migrate to CentOS.
Distribution release cycles and LTS releases:
It is a structured timeline that defines when new versions or updates of a software product will be released to the public.
Long-Term Support releases, such as Ubuntu LTS or Debian LTS, receive extended maintenance and support, typically for a period of several years.
Ubuntu: Releases published
twice yearly in April and October (e.g., Ubuntu 22.04, Ubuntu 22.10)
Ubuntu LTS or ‘Long Term Support’ releases are published
every 2 years (e.g., even years only; 22.04 is an LTS release
Ubuntu LTS releases are supported for
5 years
Other distro LTS releases may be as short as
3 years (e.g., OpenSuSE Leap, SLES)
Some distros use a ‘rolling’ release model which means the distro is
continually updated after installation (KALI Linux, OpenSuse, Tumbleweed)
Debian package management tools
Low-level is dpkg; High-level are apt, apt-get, aptitude (gui)
Red Hat package management tools
Low-level is rpm; High-level are yum, dnf
SuSE is a _____-based distro but shares some elements of _____ (e.g., _____ package format for interoperability via the _____ pacakge manager)
SuSE is a distribution based on Slackware, but it incorporates certain elements from Red Hat, such as the rpm package format, enabling seamless interoperability through the zypper package manager.
Purpose of the /proc psuedo-virtual filesystems
The /proc filesystem provides a way to access information about processes and system resources. It offers a structured interface where you can access details such as process IDs, CPU information, memory usage, and much more.
Purpose of the /sys psuedo-virtual filesystems
The /sys filesystem exposes information about various devices and device drivers in a hierarchical manner. It provides a standardized interface to access and configure device-specific settings and attributes. This filesystem is particularly useful when managing hardware and troubleshooting device-related issues.
Purpose of the /dev psuedo-virtual filesystems
The /dev filesystem is used to access and interact with devices on your system. It represents devices as special files, allowing you to read from and write to them as if they were regular files. This enables applications and system processes to communicate with hardware devices, such as disk drives, printers, sound cards, and more.
UID of the root user and the first standard user
Assigning the root user a UID of 0 helps ensure that it has the highest level of privileges and can carry out critical system operations. Giving the first standard user a UID of 1000.
The IDs from 1-99 are also reserved for use by other system accounts.
The importance of the /etc/passwd and /etc/shadow files
The/etc/passwdfile includes details such as the username, user ID (UID), group ID (GID), home directory path, default shell, and more. This file acts as a user database, storing the basic user information required for system processes and user authentication.
the/etc/shadowfile works in conjunction with the/etc/passwdfile to enhance security. It stores the encrypted password hashes for each user on the system.
Why a standard user can execute the passwd command, how is it possible when the binary is owned by root?
The setuid (set user ID) is a special permission that can be assigned to an executable file, allowing it to be executed with the permissions of the file’s owner instead of the user executing it. In the case of the passwd binary, the setuid bit is set, and the owner is the root user.
Difference between ‘#’, ‘/’, ‘/root’, and the ‘root’ user
represents the root user’s command prompt, / is the root directory in the file system hierarchy, /root is the home directory for the root user, and the ‘root’ user is the superuser account with unlimited privileges.
What is umask is used for?
The umask command is used to set the default file permissions for newly created files and directories.
What are the permissions on the /tmp directory
The /tmp directory typically has the following default permissions:
drwxrwxrwt (or 1777 in octal notation)
Owner: The owner of the /tmp directory is usually the root user (or another privileged user).
Group: The group ownership can vary, but it is commonly set to a group like root or wheel.
The first character d indicates that it is a directory.
How to change the user and group of a file
To change the ownership of a file or directory, you will need to specify the desired user and group. The format for the chown command is as follows:
chown [user]:[group] [file/directory]
For example, if you have a file called “example.txt” and you want to change its ownership to the user “john” and the group “staff”, you would run:
chown john:staff example.txt
Domain 1 commands
File and Directory Operations: Commands for navigating, creating, deleting, and modifying files and directories.
- figlet
figlet is a command-line tool used to generate ASCII art banners and large letters from ordinary text.
- apt-cache search figlet
The apt-cache search figlet command searches for packages related to “figlet” in the package cache on a Debian-based system. Use sudo apt-get install figlet to install the “figlet” package.
- sudo apt-get install figlet
This command will prompt you to enter your password (since sudo grants elevated privileges) and then proceed to download and install the “figlet” package along with any necessary dependencies.
- figlet I Love C851!
```bash
figlet “I Love C851!”
~~~
This command generates ASCII art for the text “I Love C851!” using figlet.
- sudo apt-get remove figlet
This command removes the “figlet” package from a Debian-based system.
- yum search speaking cow
yum: The package manager used for managing software packages on Red Hat-based systems like Fedora and CentOS.
search: A yum subcommand that searches for packages based on keywords.
speaking cow: In this case, “speaking cow” is treated as a search term, but it’s not a recognized package name or keyword in the standard package repositories.
- sudo yum install cowsay
This command installs the “cowsay” package on a Red Hat-based Linux system using the yum package manager. After the installation, you can use the cowsay command to display text with an ASCII art cow and speech bubble in the terminal.
- cowsay “Brought to you by C851!”
This command uses the cowsay program to display the message “Brought to you by C851!” with an ASCII art representation of a cow and a speech bubble in the terminal.
- sudo yum remove cowsay
This command removes the “cowsay” package from a Red Hat-based Linux system using the yum package manager.
- ls /usr/share/common-licenses/
This command lists the contents of the directory “/usr/share/common-licenses/” on a Unix-like system. The directory typically contains common software licenses used by various packages on the system.
Domain 2 Commands
User and Group Management: Commands for handling user accounts, permissions, and groups.
- command, [options]… [arguments]… (e.g., ls -la /home /tmp has multiple options and arguments)
Command: Refers to the executable or command to be executed in the terminal.
[options]…: Denotes optional flags or switches that modify the behavior of the command. Options are typically preceded by a hyphen (e.g., -l).
[arguments]…: Denotes input values or additional information that the command may require to execute properly. Arguments are usually non-flag parameters (e.g., directory or file names).
Example: The example provided, ls -la /home /tmp, illustrates the usage of the ls command with the options -la and the arguments /home and /tmp. This command would list detailed information about the contents of the “/home” and “/tmp” directories.
- how to wrap a command in the shell (e.g., using the \ character at the end of the line)
To wrap a command in the shell, you can use the backslash \ character at the end of the line. This is known as line continuation, and it allows you to break a command into multiple lines for better readability.
- -h, –help, man, info, ls /usr/share/doc/
These are various ways to access help and documentation for commands in a Unix-like operating system:
-
-h or –help:
-
Usage:
command -h
orcommand --help
- Purpose: Displays a brief help message or usage information for a command.
-
Usage:
-
man (manual):
-
Usage:
man command
- Purpose: Opens the manual page for a command, providing detailed documentation, usage, and options.
-
Usage:
-
info:
-
Usage:
info command
- Purpose: Opens the info page for a command, offering more extensive documentation with hyperlinks.
-
Usage:
-
ls /usr/share/doc/:
-
Usage:
ls /usr/share/doc/
-
Purpose: Lists the contents of the
/usr/share/doc/
directory, which often contains additional documentation for installed packages.
-
Usage:
These methods allow you to access various levels of documentation, from quick help messages to detailed manuals and additional documentation files. Choose the method that best suits your needs based on the level of detail you require.
- less/more (and how to exit)
less
and more
are terminal pager programs that allow you to view the contents of files or command output one screen at a time. Here’s how to use them and how to exit:
less
:
-
Usage:
bash less filename
orbash command | less
-
Navigation:
- Move forward one screen:
Spacebar
- Move backward one screen:
b
- Scroll up/down line by line:
Arrow keys
orj
andk
- Search:
/
followed by the search term, then pressEnter
- Quit:
q
- Move forward one screen:
more
:
-
Usage:
bash more filename
orbash command | more
-
Navigation:
- Move forward one screen:
Spacebar
- Move backward one screen:
b
- Quit:
q
- Move forward one screen:
Exiting:
-
Exiting
less
:- Press
q
to quit.
- Press
-
Exiting
more
:- Press
q
to quit.
- Press
Both less
and more
allow you to navigate through the content and quit easily. less
provides more advanced features, such as searching and scrolling, while more
is a simpler pager. Choose the one that fits your needs.
- type echo
This command displays information about the type of the echo command, indicating whether it’s a shell built-in command or an external executable. The output will typically indicate that echo is a shell built-in command.
- type man
This command will likely indicate that man is an external executable and not a shell built-in. The man command is used to display the manual pages for other commands or programs installed on a Unix-like operating system.
- pwd
The pwd command stands for “print working directory.” When you run pwd in the terminal, it outputs the absolute pathname of the current working directory – that is, the directory you are currently in within the file system.
Domain 3 Commands
Process Management: Commands for managing running processes, background tasks, and job control.
Domain 5 Commands
Networking: Commands for network-related tasks, such as configuring network settings, checking connectivity, and troubleshooting.
Linux Command Domain 1
File and Directory Operations: Commands for navigating, creating, deleting, and modifying files and directories.
Linux Command Domain 2
User and Group Management: Commands for handling user accounts, permissions, and groups.
Linux Command Domain 3
Process Management: Commands for managing running processes, background tasks, and job control.
Linux Command Domain 4
System Information and Monitoring: Commands to gather information about the system, hardware, and monitor system performance.
Linux Command Domain 5
Networking: Commands for network-related tasks, such as configuring network settings, checking connectivity, and troubleshooting.
/usr/
(MULTI-)USER UTILITIES AND APPLICATIONS SECONDARY HIERARCHY REQUIRED DIRECTORIES: BIN, INCLUDE, LIB, LOCAL, SBIN, SHARE
/opt/
ADD-ON APPLICATION SOFTWARE PACKAGES
/srv/
DATA FOR SERVICES PROVIDED BY THIS SYSTEM
/dev/
DEVICE FILES
/lib/
ESSENTIAL SHARED LIBRARIES AND KERNEL MODULES
/bin/
ESSENTIAL USER COMMAND BINARIES
/root/
HOME DIRECTORY FOR THE ROOT USER
/mnt/
MOUNT POINT FOR A TEMPORARILY MOUNTED FILESYSTEMS
/media/
MOUNT POINT FOR REMOVABLE MEDIA
/etc/
SPECIFIC SYSTEM CONFIGURATION REQUIRED DIRECTORIES: OPT, XII, SQML, XML
/boot/
STATIC FILES OF THE B00T LOADER
/sbin/
SYSTEM BINARIES