An Rpm Package Can Be Converted To A Cpio Archive Using What Command?

Luckily, it’s possible to convert any.rpm file into a cpio archive using the “ar” command. office, home, workspace @ Pixabay To do so, type in the following command: ar -pvx.rpm >.cpio The cpio archive will be created in the same directory as the.rpm file. NOTE: you should only use this format for installer packages.
Using the rpm2cpio command, the rpm package will convert (to the rd package will output (to stdout) a cpio archive from the RPM package. The first method we’re going to use to extract the files we need is the output of rpm2cpio; then the second method is cpio. Using cpio, files are copied from and to archives.

What command can be used to display the contents of a file that was compressed with a compression utility?

Z extension. uncompress – Uncompresses a compressed. Z file. zcat – Displays the contents of a compressed file.

What command looks for a Makefile?

The makefile is read by the make command, which determines the target file or files that are to be made and then compares the dates and times of the source files to decide which rules need to be invoked to construct the target. Often, other intermediate targets have to be created before the final target can be made.

What option can be added to the dpkg command to remove a specific package from the system including any configuration files used by the package?

We already discussed how to remove a package using the dpkg command. You can also purge a package, a process which removes everything, including conffiles. This can be done using the -P command line option.

Which option when used with the gzip command causes the compression ratio for files that have been compressed to be listed?

When using the gzip utility, the -l option is also known as best compression and results in a higher compression ratio.

Which option to the rpm command can be used to remove a package from the system?

RPM Options

option Meaning
-e remove a package
–nodeps install, upgrade or remove a package without checking for dependencies
-h Print 50 hash marks as the package archive is unpacked – hash marks get printed out to assure the installer that the RPM is working, and if it is, how far along it is.

What command utilizes the Lempel Ziv?

The LZW algorithm is a very common compression technique. This algorithm is typically used in GIF and optionally in PDF and TIFF. Unix’s ‘compress’ command, among other uses.

What is the make command?

make is typically used to build executable programs and libraries from source code. Generally speaking, make is applicable to any process that involves executing arbitrary commands to transform a source file to a target result.

How does the make command work?

The make command uses information from a description file, which you create, to build a file containing the completed program, which is then called a target file. The internal rules for the make command are located in a file that looks like a description file.

What is make command in Ubuntu?

Ubuntu Make is a command line tool which allows you to download the latest version of popular developer tools on your installation, installing it alongside all of the required dependencies (which will only ask for root access if you don’t have all the required dependencies installed already), enable multi-arch on your

What is RPM command?

RPM command is used for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Linux system. RPM stands for Red Hat Package Manager. With root privilege, you can use the rpm command with appropriate options to manage the RPM software packages.

What is RPM package manager in Linux?

RPM stands for Red Hat Package Manager. It was developed by Red Hat and is primarily used on Red Hat-based Linux operating systems (Fedora, CentOS, RHEL, etc.). An RPM package uses the. rpm extension and is a bundle (a collection) of different files.

What options for the dpkg command can be used to list files that include a package?

dpkg command cheat sheet for Debian and Ubuntu Linux

Syntax Description
dpkg -l List all installed packages, along with package version and short description
dpkg -l {package} List individual installed packages, along with package version and short description

What level of compression is specified the gzip command would compress the file the most?

gzip allows you to specify a range of compression levels, from 1 to 9. -1 or –fast means fastest compression speed with minimal compression ratio, -9 or –best indicates the slowest compression speed with maximum compression ratio. The default compression level is -6.

What option can be added to the Userdel command to remove the home directory of the target user?

Example of using ‘userdel’ command

If you forgot to add the ‘-r’ option to the userdel command and want to delete the target user’s file later, delete the target user’s home directory with rm command. If you want to completely delete the file created by that user, it will completely disappear if you do the following.

Which of the following file extensions are used by the Debian package manager?

deb (file format)

The GNOME icon for deb files. (Showing the Debian logo on a package)
Filename extension .deb,.udeb
Type of format Package management system
Container for Software package
Extended from ar archive, tarball

How to extract cpio archive from rpm file?

However, there is a small nifty utility available called rpm2cpio. It extracts cpio archive from RPM Package Manager (RPM) package. With the following hack, you will be able to extract an RPM file. First you use the rpm2cpio to convert the.rpm file into a cpio archive on standard out.

What does rpm2cpio write to?

It writes the cpioarchive contained in the package file to standard output, which, if you’ve not redirected it somehow, is your screen. Here’s a more reasonable example: # rpm2cpio logrotate-1.0-1.i386.rpm > blah.cpio# file blah.cpioblah.cpio: ASCII cpio archive (SVR4 with CRC)#

How to extract an RPM file from RPM Package Manager?

It extracts cpio archive from RPM Package Manager (RPM) package. With the following hack, you will be able to extract an RPM file. First you use the rpm2cpio to convert the.rpm file into a cpio archive on standard out. If a – argument is given, an rpm stream is read from standard in.

How do I open an RPM file in CentOS?

CentOS user. Extracting rpm file using combination of rpm2cpio and cpio command. To be frank, there is no direct option available for the rpm command to extract an RPM file. However, there is a small nifty utility available called rpm2cpio. It extracts cpio archive from RPM Package Manager (RPM) package.

An RPM package can be converted to a CPIo archive using what command?

Many Linux users are familiar with the RPM package format, which stands for Red Hat Enterprise Linux.Not all Linux setups will have access to a machine capable of installing a rpm package, which is the source of the difficulty here.When you wish to publish your program as an installer, this might provide a challenge.Fortunately, the ″ar″ command can be used to convert any.rpm file into a cpio archive, which is quite useful.To do so, enter the following command into your computer: ar -pvx.rpm >.cpio ar -pvx.rpm >.cpio The cpio archive will be produced in the same directory as the.rpm file and will contain the identical contents.

  1. Please keep in mind that this format should only be used for installation packages.
  2. Instead of utilizing an installer, we propose that you use tar or zip instead!
  3. RPM package format is well-known to many Linux users, and they are aware that installing an RPM package might be challenging if they do not have access to a machine that is capable of handling rpm files.

In order to distribute your software, some people prefer to convert any given rpm filename-rpm >filename-cpioum by first typing ar -pvx filename-rpm >filename-cpioum before placing it in their distribution folder, from which its contents can then be extracted by running the following command: tar xf filename-cpioum.

Using rpm2cpio

  • At some point, you may find yourself in the position of needing to extract one or more files from a package file. One method of accomplishing this would be to: Installing the package is simple.
  • Make a copy of the file(s) you’ll be working with
  • Delete the contents of the package.

Using rpm2cpio might be a more convenient option.

rpm2cpio — What does it do?

The rpm2cpio command accepts an RPM package file and transforms it to a cpio archive, as the name indicates.Because it is intended to be used largely as a filter, there isn’t much that has to be mentioned in the code.Rpm2cpio accepts just a single parameter, and even that is entirely optional!This is an optional parameter, and it contains the name of the package file that is to be transformed.The default behavior of rpm2cpio is to read from standard input and convert it to a cpio archive when no filename is supplied on the command line.

  1. Let’s take a go at it: rpm2cpio logrotate-1.0-1.i386.rpm (rpm2cpio logrotate-1.0-1.i386.rpm) ″28 November 1995″ ″Red Hat Software″ ″Red Hat Linux″ 0000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 NAME OF THE SHOPPER (We’ve just showed the first few of lines of output thus far.) What on earth is all of this nonsense?
  2. It’s important to remember that rpm2cpio is written as a filter.
  3. When it is finished, it sends the contents of the cpio archive contained in the package file to standard output, which is, if you haven’t done so before, the screen on your computer.

To illustrate, consider the following example: the command rpm2cpio logrotate-1.0-1.i386, which produces the blah.cpio file blah.cpio blah.cpio: Cpio archive in ASCII format (SVR4 with CRC) We’ve instructed rpm2cpio to convert the logrotate package file in this section.In addition, we’ve redirected the output of rpm2cpio to a file named blah.cpio.Following that, we can verify that the generated file is, in fact, a genuine cpio archive file by running the file command.Rpm2cpio’s ability to read the package file from its standard input may be demonstrated with the following command, which is completely equal to the one before.rpm2cpio > blah.cpio |

  1. cat logrotate-1.0-1.i386.rpm |
  2. rpm2cpio > blah.cpio

A more real-world example — Listing the files in a package file

While there’s nothing wrong with using rpm2cpio to actually build a cpio archive file, it does need a few extra steps and consumes a little more disk space than is really necessary in this situation.Alternatively, you could pipe the output of rpm2cpio straight into cpio: rpm2cpio logrotate-1.0-1.i386, cpio -t usr/man/man8/logrotate.8, cpio -t cpio -t usr/man/man8/logrotate.8 usr/sbin/logrotate 14 blocks For the sake of this demonstration, we used the -t option to instruct cpio to build a ″table of contents″ for the archive created by rpm2cpio.When you wish to extract a file, you may use this to make it much easier to find the correct filename and location.

Extracting one or more files from a package file

  • Continuing with the previous example, let’s extract the logrotate package’s man page from its source code. The entire path to logrotate.8 is shown in the table of contents, which is usr/man/man8/logrotate.8. All that is required is that we utilize the filename and path provided below: rpm2cpio logrotate-1.0-1.i386.rpm |cpio -ivd logrotate-1.0-1.i386.rpm 14 blocks usr/man/man8/logrotate.8 usr/man/man8/logrotate.8 usr/man/man8/logrotate.8 usr/man/man8/logrotate.8 usr/man/man8/logrotate.8 usr/man/man8/logrotate.8 The cpio parameters -i, -v, and -d instruct cpio to do the following actions: Extract one or more files from an archive.
  • In 512-byte blocks, display the names of any files that have been processed, as well as the total size of the archive file
  • Cpio will create any directories that are required to be created before the filename supplied in the command.
  1. Consider the following example: we want to extract the logrotate package’s manual page.
  2. As we can see in the table of contents, the entire path to logrotate.8 is usr/man/man8.
  3. Nothing more than the filename and path specified below will be required.
  4. The command rpm2cpio logrotate-1.0-1.i386.rpm followed by the command cpio -vd was used to rotation the files.
  5. logrotate.8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 utf-8 These are the cpio options to use in this case: extract one or more files from an archive; extract one or more files from a directory; and command cpio to perform the following actions:
    In 512-byte blocks, show the names of any files that have been processed, as well as the total size of the archive file
    Cpio will create any directories that are required before the filename supplied in the command.

Linux Final Exam – Subjecto.com

SIGQUIT Which kill signal terminates a process by takingthe process information in memory and saving it to a file called core on thehard disk in the current working directory?
127 What number indicates the lowest kernel priority(PRI) of a process possible?
pstree What command below is used to display the lineageof a process by tracing its PPIDs until the init daemon?
The process is currently running on the processor. In the process state column, what does an″R″ indicate?
-l In order to display a list of at job IDs, whatoption can be specified to the at command?
-e What option, when added to the crontab command,opens the vi editor with a user’s cron table?
+ When there are multiple background processesexecuting in the shell, the jobs command indicates the most recent one withwhich symbol?
-e What option can be used with the ps command todisplay an entire list of processes across all terminals and includingdaemons?
64 How many different kill signals can be sent by thekill command to a given process?
process state In the output of the ps -l command, what column isthe most valuable to systems administrators because it indicates what theprocess is currently doing?
device calls Which of the following is not one of the three maintypes of Linux commands?
fg After a background process has been started, whatcommand below can be used to move it to the foreground?
sixth In a cron table entry, what field specifies theabsolute pathname to a command that is to be executed?
/var/spool/at On a Fedora based system, where are the shellenvironment and scheduled commands for at stored?
The process is high priority. When viewing the output of the ps ax command, whatdoes a < symbol in the STAT column indicate for a process?
parent process ID What can be used on a Linux system to trace thelineage of each child process?
SIGHUP What kill signal stops a process, then restarts itwith the same PID?
What character, when appended to a command, causesthe command to be run in the background?
0 Processes are started with what nice value bydefault?
% When killing a background job with the killcommand, the background job ID must be prefixed by what character below?
newgrp To change the primary group temporarily to anothergroup that is listed in the output of the groups and id commands, you can usewhich command below?
-L A user account can be locked with the usermodcommand using what option?
-r What option can be added to the userdel command toremove the home directory of the target user?
lp In order to send a print job to a printer usingCUPS, what command must be used?
login.defs What configuration file contains parameters thatset the default location for e-mail, password expiration information, minimumpassword length, and the range of UIDs and GIDs available for use?
lpadmin Which command should be used to restrict access toprinters?
SystemMaxUse What option can be used in the journaldconfiguration file to specify a file size limit to the event log?
-p Select the option that can be used with the lpstatcommand to display a list of printers that are enabled:
0 On Linux, the root user always has a UID of whatnumber?
631 The CUPS Web administration tool can be accessedvia web browser by accessing what TCP port below?
lpstat Adding the -t option to what command below willprovide a list of all printers on the system and their status?
useradd In order to create user accounts on a Linux system,what command should be utilized?
alert What System Log Daemon priority indicates an errorthat should be rectified immediately, such as a corrupt system database?
panic What priority used by the System Log Daemonindicates a very serious system condition that would normally be broadcast toall users?
-d What option should be used in conjunction with thelp command in order to specify the destination printer name?
secure What log file contains information and errormessages regarding network access generated by daemons such as ssd andxinetd?
50 What is the default print job priority for allprint jobs created by the lp command?
514 The System Log Daemon uses what TCP and UDP port toaccept incoming requests from another System Log Daemon on a remote system?
pwconv A system that uses an /etc/passwd file only can beconverted to use /etc/shadow for security by using what command?
/etc/skel Where is the skeleton directory located on mostLinux systems?
-l Select the option that, when used with the gzipcommand, causes the compression ratio for files that have been compressed tobe listed:
rpm2cpio An RPM package can be converted to a cpio archiveusing what command?
-P What option can be added to the dpkg command toremove a specified package from the system, including any configuration filesused by the package?
dpkg-query What command can be used to search for DPM packageinformation?
60%-70% What is the average compression ratio for the gziputility using the LZ77 compression algorithm?
RPM Most Linux distributions make use of what packagemanager?
.Z When using the compress utility, each filespecified for compression is renamed with what extension?
40-50 The Adaptive Lempel-Ziv compression algorithm usedby the compress utility is capable of an average compression ratio of whatpercent?
6 If no level of compression is specified, the gzipcommand assumes what compression level?
yum grouplist What yum command below can display a list ofpackage group names?
zcat What command can be used to display the contents ofa file that was compressed with the compress utility?
-c When used with the uncompress command, what optiondisplays the contents of the compress file to Standard Output?
nine The dump/restore utility is limited to a maximum ofhow many different incremental backups?
/dev/nht0 What device file below indicates the first ATAPIIDE tape device (nonrewinding)?
apt-get In order to download DPM packages, what commandshould be used below?
make What command looks for a Makefile and uses theinformation within to compile the source code into binary programs using theappropriate compiler program for the local hardware architecture?
package dependency RPM packages that require other RPM packages to beinstalled on a system prior to being installed creates a relationship knownas?
-f When used with the compress command, what optionbelow can be used to compress symbolic links?
-q What option can be added to the rpm command inorder to query packages?
-F What option can be added to the rpm command toupgrade a specified package only if an older version exists on the system?
traceroute What command can be used to troubleshoot routing bydisplaying all routers between the current computer and a remote computer?
: IPv6 IP addresses are delimited by what characterbelow?
/var/log/samba Where are the log files for the Samba daemonlocated?
-X What option can be used with ssh to enabletunneling of X Windows information?
ifconfig What command can be used to assign a TCP/IPconfiguration to a NIC as well as view the current configuration of allnetwork interfaces?
net.ipv4.ip_forward In order to enable IP routing on Linux at boot,what setting must be configured in /etc/sysctl.conf?
ping Select the command that can be used to send a smallTCP/IP packet to another IP address and await a response:
Secure Shell (SSH) What tool below was designed as a secure remoteaccess utility that encrypts information that passes across the network?
0-1023 What range of ports is considered to be″well-known″?
-i What option can be added to the netstat command inorder to display network statistics?
hexadecimal An IPv6 IP address consists of 16-bit numbers inwhat numbering scheme?
255.255.0.0 What is the subnet mask for a Class B IP address?
/etc/ssh/sshd_config The sshd daemon is configured by editing whatconfiguration file?
256-bit What is the Advanced Encryption Standard (AES)encryption algorithm’s largest key length size?
25 What well-known TCP port is utilized by the SMTPservice?
three How many DNS servers can be configured in the/etc/resolv.conf file?
TCP/IP What is the most commonly used LAN protocol?
255.255.255.0 What is the subnet mask for a Class C IP address?
/etc/named.conf Select below the configuration file that is used toconfigure the BIND / DNS server:
8-bit Each octet in an IP address represents a binarynumber consisting of how many bits / bytes?
hwclock What command can be used to view and modify thedate and time within the BIOS?
@server How can you specify the intended DNS server toquery with the dig command?
/var/named/named.local What zone configuration file contains a PTR recordused to identify the loopback adapter?
0 In NTP, what stratum consists of atomic devices orGPS clocks?
! What FTP command runs a shell on the localcomputer?
tzselect In order to change the time zone of a system afterinstallation, what command must be used?
mput filename What ftp command uploads the filename from thecurrent directory on the local computer to the current directory on theremote computer, and allows the use of wildcard metacharacters to specify thefilename.
TCP 80 The Apache daemon listens for HTTP requests on whatport by default?
DirectoryIndex index.html What directive below in Apache’sfilespecifies that the index.html file in the document root directory will besent to clients who request an HTML document?
/var/www/html Where is the default document root directory forthe Apache web server?
curl Which command below can be used at a BASH commandprompt to obtain a web page?
pg_dump What PostgreSQL command-line utility backs upPostgreSQL database settings?
15 What is the maximum number of characters that canbe used in a NetBIOS name?
DROP DATABASE Select the SQL statement below that can be used todelete a database:
UDP 123 What port is used by the Network Time Protocol(NTP) for communication?
ntp_query What command can be used to see what actual timeservers are being used for synchronization?
HELO When working with Sendmail, what command can beused to test SMTP support?
DNS What kind of servers resolve fully qualified domainnames to IP addresses for a certain namespace on the Internet?
MX What DNS resource record type is used to providethe IP address for the e-mail server for a zone?
newaliases After modifying the /etc/aliases file, what commandmust be run in order to rebuild the aliases database?
Universal Access Assistive technologies are configured using whatutility on Fedora 20 in GNOME?
-P What option for the iptables command can be used tospecify the default policy for a certain chain type?
-q Which sar command option is used to displaystatistics for the processor queue?
jabbering Older hardware that is malfunctioning may begin tosend large amounts of information to the CPU when not in use. What is thisprocess called?
nohup Running background processes using what commandallows you to exit your command-line shell without ending any backgroundprocesses?
ssh_host_dsa_key. pub What file contains the DSA public key in the/etc/ssh directory?
SIGHUP If applications run into difficulties gainingresources during execution and stop functioning, restarting the process usinga specific kill signal may resolve the issue. Select the proper kill signalbelow:
ulimit What command can be used to change the maximumnumber of file handles that can be used by a program?
TCP wrapper If network services that are started by inetd orxinetd are in use, what can be used to provide extra security?
1024 By default, the shell on a Linux system limits thenumber of filehandles a program can have open to what value?
Run the ldconfig command. After downloading an installing any sharedlibraries, what should be done to ensure the list of shared librarydirectories and the list of shared libraries are updated?
iostat What utility in the sysstat package measures theflow of information to and from disk devices?
every ten minutes How often are sar commands scheduled to run on bothFedora 20 and Ubuntu Server 14.04?
-B Select the option that, when used with the sarcommand, displays swap statistics:
nmap Which command can be used to see what networkservices are running on your network?
Hard DIsk What is the most common hardware component to failon a Linux system?
-V What option can be specified with the rpm commandto identify any missing files in a package or package dependency?
ldd What command can be used to view what sharedlibraries are required by a certain program?
-d Select the iptables option that specifies thedestination address of packets for a rule:
xwininfo If X Windows fails to start, what command can beused to troubleshoot the issue?
See also:  How To Track A Package Transferred From Ups To Usps?

TL;DR

  1. This page describes how to list files in an RPM package, display package metadata, and extract the contents of an RPM package, among other things.
  2. On the next pages, you will find examples of commands for extracting RPM package files and displaying information about packages that are both installed and uninstalled on a system.
  3. Continue reading this page for additional information on how to list and extract RPMs from their packages.
  4. Examining and extracting the contents of the Debian package

What is an RPM package?

  1. A CPIO archive is essentially a header structure on top of which an RPM package is built.
  2. Generally speaking, an RPM package is divided into four sections: the header, which contains an identifier (magic number) to distinguish it from other files and identify it as an RPM package; the signature, which verifies that the package is intact; the header or tagged data, which contains package information, version numbers, and copyright messaging; and the archive, which contains the actual program files.

List files in an RPM package file using the rpm command

  1. The RPM package manager rpm includes a number of utilities that allow you to interact with packages.
  2. The following command will provide a list of all of the files contained within an RPM package: $ rpm -qlp./path/to/test.rpm rpm -qlp./path/to/test.rpm As an illustration: $ rpm -qlpv./packagecloud-test-1.1-1.x86 64.rpm -rwxr-xr-x1rootroot8286 -rwxr-xr-x1rootroot8286 -rwxr-xr-x1rootroot8286 /usr/local/bin/packagecloud hello (July 16th, 2014) In this example, the rpm command is invoked with the parameter -q to designate it as a query command, the flag -l to list the files included within the package, and the flag -p to inform it that it should query the uninstalled package file.
  3. For the sake of this example, the -v flag (verbose) just gives more information (permissions, owner, etc.) about the process.
  4. As we can see, the package creates a binary executable named packagecloud hello in the /usr/local/bin/ directory of the user’s home directory.
See also:  What To Do When Fedex Loses Your Package?

List files in an installed RPM package

  1. To list the files from an RPM package that has been installed, use the rpm command with the -q and -l flags: cloud-test is installed with the help of rpm.
  2. It is important to note that the preceding command used the name of a package rather than the path to a specific RPM package.
  3. It is necessary to first extract a cpio archive from an RPM package before you can begin extracting files from the package.
  4. RedHat has a utility called rpm2cpio that accomplishes exactly what you’re looking for: $ rpm2cpio./packagecloud-test-1.1-1.x86 64.rpm rpm2cpio./packagecloud-test-1.1-1.x86 64.rpm The rpm2cpio command will create a cpio archive from the RPM package and output it to standard output (stdout).
  5. We’ll use the output from rpm2cpio to extract the package files, and then we’ll use the cpio command to extract and generate the files we’ll need to complete the task.
  • As an illustration: $ rpm2cpio./packagecloud-test-1.1-1.x86 64.rpm |
  • rpm2cpio./packagecloud-test-1.1-1.x86 64.rpm PackageCloudHello is created by running cpio with the -idmv option.
  • 17 stumbling obstacles The cpio command is used to copy files into and out of archives.
  • In the above example, we use the cpio command with the -i flag to extract the files from the archive, the -d command to construct the leading directories when necessary, and the -m command to preserve the file modification times when extracting new files from the archive.
  • For the sake of this example, the -v option (verbose) is used to display a list of the files that were processed.

The consequence of our previous example is the formation of a./usr/ subdirectory in our working directory, which contains the files from the RPM package that we downloaded earlier on.packagecloud-test-1.1-1.×86 64.rpm.packagecloud hello.sh in usr/local/bin/packagecloud usr/local/bin/packagecloud hello: A 64-bit LSB executable in ELF format, for the x86-64 architecture, version 1 (SYSV), dynamically linked (uses shared libraries), for GNU/Linux 2.6.24, BuildID=0x77fe4f2fa02ee973bf4d74867729e950fcde7107 (not stripped), not stripped NOTE that just extracting package files to the root directory does not result in a package being correctly installed.To successfully install RPM packages, make use of the yum or rpm tools.

Show RPM package preinstall and postinstall scripts

  1. When querying a package with the rpm command, use the -scripts parameter to display the scripts that will be executed when the package is installed or removed from a system.
  2. Testing the following command will display the scripts for the uninstalled package test-1.1-1.el6.x86 64.rpm: test-1.1-1.el6.x86 64.rpm packagecloud-test-1.x86 64-qp -scripts./packagecloud-test-1.x86 64-qp.rpm This will produce something along the lines of: preinstall scriptlet (which makes use of /bin/sh): Do anything using the postinstall scriptlet (using the /bin/sh command line): if; then Another thing to do before running the preuninstall scriptlet (using /bin/sh) is to do the following: if; then Do anything else using the postuninstall scriptlet (using the /bin/sh command line interface): Things may be done here as well.
  3. When using rpm, you may use the following syntax to display the scriptlets of a package that has previously been installed.
  4. $ rpm -q -scripts rpm -q -scripts

View contents of RPM packages on remote repositories using repoquery

  1. Repoquery is offered by the yum-utils package; ensure that it is installed by following these instructions: It is possible to query information from Yum repositories that have been installed on the system using the repoquery command.
  2. By default, the repoquery command will download the Yum repo information and refresh the cache, but you may change this behavior.
  3. Using the -C or -cache switch will allow you to run repoquery exclusively from the Yum cache.
  4. When you run the repoquery command, you may list the contents of a package by passing the -list option to the command: repoquery -list is a query that returns a list of possible results.
  5. As an illustration: $ repoquery -list packagecloud-test /usr/local/bin/packagecloud hello $ repoquery -list packagecloud-test When seeing the contents of packages that have not been downloaded or installed on your system, this feature may be quite beneficial.
  • repoquery will only provide information on packages that are available in the Yum repositories that have been specified.

Conclusion

  1. The ability to understand how packages interact with the systems on which they are installed may be extremely useful in day-to-day operations.
  2. Assuming we understand that an RPM package is made up of two parts: an archive and header data, we can extract the information we need from the archive using previously existing tools (rpm2cpio and cpio), and then utilize the RPM toolchain to query, examine, and view the contents of an RPM package.

Compressing a File in Linux

The compress command is one of the file compression commands available in Linux, and it is included as part of the ncompress package. It reduces the file size by employing the Lempel-Ziv optimization technique. The compressed file’s output is saved as a file with the extension.Z.

Example 1

To compress a text file named myfile.txt, use the following command on your computer: myfile.txt should be compressed The compressed output file may be seen by using the following command: ls -l ls -l ls -l Myfile.txt will be the name of the compressed text file. Z.

Example 2

In order to recursively compress all of the files and sub-directories in a directory, run the following command on the command line: compress -r mydir (compress -r mydir)

Example 3

  1. If an output file, such as myfile.txt.Z, already exists, the compress command will question you to confirm that you wish to overwrite the old file with the newly created one.
  2. In order to force the compression, you must be certain that you wish to replace any existing output file.
  3. To do so, use the following command: compress -f myfile.txt is a command-line option.
  4. Additionally, if you wish to utilize the compress command as part of a batch or shell script, this option will be valuable to you.

Example 4

To produce a compressed output file and save it to a separate location, run the following command: compress -c myfile.txt > otherfile.Z is a command-line option.

Example 5

  1. More information, such as the compression %, may be obtained by using the following command: compress -v myfile.txt is a command-line option.
  2. myfile.txt: – this file has been replaced by myfile.txtZ 10.00 percent compression is used.
  3. Take note of the fact that the command output contains a real-time display of the compression rate in the background.
  4. This option can be used in conjunction with other choices in order to track the progress.

The ″make″ Command and ″Makefiles″. – Ram Naraian

  1. The make command and the Makefiles are as follows:- You will notice that the create command has a lot of built-in information, but it cannot figure out how to build your program on its own, as you will see.
  2. Making your application requires you to give a file that instructs make on how to develop it.
  3. The makefile is the name of this file.
  4. The makefile is most typically found in the same directory as the other source files for a project and is called the makefile.
  5. At any given time, you can have a large number of distinct makefiles running on your workstation.
  • When dealing with big projects, it is possible to manage them by creating distinct makefiles for each section of the project that has to be managed separately.
  • Using the make command in conjunction with a makefile, you may create a highly effective project management tool.
  • The command line interface is frequently used not only to manage the compilation of source code, but also to produce instructional pages and install the program into a target directory.
  • The following is the syntax of Makefiles:- A makefile is a collection of dependencies and rules that must be followed.
  • A dependence consists of a target (a file that has to be generated) and a collection of source files on which it is dependant, as shown in the diagram.

In the rules, it is explained how to construct the target from the dependent files.Typically, the target is a single executable file that has been downloaded.The make command reads the makefile, which defines the target file or files that are to be created and then compares the dates and times of the source files to determine which rules need to be called in order to construct the target file or files.It is common for several intermediate milestones to be established before the final aim may be achieved successfully.The make command makes use of the makefile to establish the order in which the targets must be created as well as the right sequence of rules to be invoked throughout the build process.Make the following choices and adjust the following parameters: – There are various settings available inside the make software itself.

The three most generally used options are 1) -k, which instructs make to continue running even if an error is discovered rather than halting as soon as the first problem is identified; and 2) -f, which tells make to display a warning rather than stopping immediately when an error is detected.This may be used, for example, to quickly identify which source files are causing problems during compilation.2) -n, which instructs create to print out the result of what it would have done if it had really performed the action.3) -f, which allows you to specify which file should be used as the makefile by build.

If you do not specify this option, the ordinary version of make searches for a file named makefile in the current directory before proceeding.Alternatively, if that file does not exist, it looks for a file named Makefile.For example, if you wish to call a file XYZ, you may do it by using the -f options.For example, make -f XYZ.

  • Dependencies and the intended audience:- According to the dependencies, each file in the final program is related to the source files in some way.
  • The target is often an executable file that is produced as a result of the make command being executed.
  • As an illustration, Assume that a program has the source files listed below.
  • main.c,2.c,3.c,a.h,b.h, and c.h are all C files.
  • These rules should be written in a make file by first writing the target, followed by a colon and a space or a tab, and then a tab or space separated list of files that are necessary in order to generate the target file.
  1. / The following is a list of the programs that are dependent on the previous program.
  2. main.o 2.o 3.o myapp: main.o 2.o: 2.c a.h b.h 3.o: 3.c a.h b.h c.h main.o: main.c a.h b.h 2.o: 2.c a.h b.h 3.o: 3.c a.h b.h c.h This indicates that the target myapp is dependent on the main.o,2.o, and 3.o files (dependencies for myapp target).
  3. target main.o is reliant on main.c and a.h to function properly (dependencies for main.o target) 2.c, a.h, and b.h are all dependent on target 2.o (dependencies for 2.o target) 3.c, a.h, b.h, and c.h are all dependent on target 3.o (dependencies for 3.o target) This collection of dependencies provides a hierarchical representation of how the source files are related to one another.
  4. You can see right away that if b.h changes, you will need to rewrite both 2.o and 3.o, and because 2.o and 3.o will have changed, you will also need to rebuild myapp as a result of the change.
  1. Rules:- Making a target is described in the second section of the makefile, which contains the rules to follow.
  2. The following command should be used once the make command has decided that version 2.o has to be rebuilt in the example from the previous section: It’s possible that simply running gcc -c 2.c will suffice in this case.
  3. The distinction between a space and a tab in the makefile’s syntax.
  4. All rules must be on separate lines that begin with a tab; a space will not suffice.
  5. Because multiple spaces and a tab appear to be almost identical, and because there is no differentiation between spaces and tabs practically anywhere else in Linux programming, this can lead to confusion and issues.

Additionally, a space at the end of a line in the makefile may result in a make command failing to execute.A straightforward makefile (named Makefile1) is as follows: -o myapp: main.o 2.o 3.o gcc -o myapp: main.o 2.o 3.o gcc The following three main.c files are included: 1.c a,h,g,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Because your makefile does not include either of the typical default names of makefile or Makefile, you must use the -f option to call the make command using the -f option.If you run this code in a directory that does not include any source code, you will see the following message: $make -f Makefile1 make: $make -f Makefile *** There is no rule to create the target’main.c’, which is required by’main.o’.

Stop.$ In this case, the make command has presumed that myapp, the first target in the makefile, is the file that you wish to produce.This is incorrect.Afterwards, it examined the other dependencies and decided that a file named main.c is required in order for the program to function properly.Because you haven’t generated this file yet, and because the makefile doesn’t specify how it should be produced, make has sent an error to the command line interface.

  1. So, now that the source files have been created, try again.
  2. Because you aren’t concerned with the outcome, these files might be really straightforward.
  3. Because the header files are actually empty, you may create them using the following command: touch $touch a.h $touch b.h $touch c.h $touch Main is contained in the files c.h main.c, which calls the functions function two and function three.
  4. Function two and function three are defined in the remaining two files.
See also:  Which Post Office Delivers To Me?

Because the source files have include lines for the proper headers, it appears that they are dependent on the contents of the headers that are included.Although it is a simple program, the following are the listings: • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • /* 2.c */ include ″a.h″ include ″b.h″ void function two() /* 3.c */ include ″a.h″ include ″b.h″ include ″b.h″ include ″c.h″ void function three() void function three() void function three() void function three() void function three() void function three() Now, try making this again: $make -f Makefile1 gcc -c main.c gcc -c 2.c gcc -c 3.c gcc -o myapp main.o 2.o 3.o $make -f Makefile1 gcc -c main.c gcc -c 2.c gcc -c 3.c $make -f Makefile1 gcc -c main.c gcc -c This is a well-executed design.What It Is and How It Works: – In this case, the make command has examined the dependents portion of the makefile and decided which files must be generated and in what sequence they must be created.Despite the fact that you mentioned how to construct myapp first, make has established the right sequence in which the files should be created.

  1. It has then executed the instructions you specified in the rules section in order to create the files you asked it to create.
  2. The make command displays the commands as they are being executed by the computer.
  3. You can now test your makefile to verify whether it appropriately handles changes to the file b.h by running the following command: $adjust b.h.
  4. $make -f Makefile1 gcc -c 2.c gcc -c 3.c gcc -o myapp main.o 2.o 3.o $make -f Makefile1 gcc -c 2.c gcc -c 3.c gcc -o myapp main.o 2.o 3.o $make -f Makefile1 gcc -c 2.c gcc -c 3.c $make After reading your makefile and determining the minimal number of instructions necessary to rebuild myapp, the make command went ahead and carried out those commands in the right sequence.
  5. See what happens when you remove an object file from your computer: $rm 2.o $make -f Makefile1 gcc -c 2.c gcc -o myapp main.o 2.o $make -f Makefile1 gcc -c 2.c gcc -o myapp main.o 2.o $make -f Makefile1 gcc -c 2.c gcc -o myapp main.o 2.o $make -f Makefile1 gcc -c Once again, make accurately identifies the steps that must be taken.
  6. Comments in a Makefile include the following: – A remark in a makefile begins with and continues to the end of the line, unless otherwise specified.

Makefile macros include the following: In fact, even if this was the extent of what make and makefiles could do, they would still be extremely useful tools for managing many source file projects.They would, on the other hand, tend to be huge and rigid when dealing with projects that have a significant number of individual files.Therefore, makefiles allow you to use macros in order to write your programs in a more generalized manner than otherwise possible.In a makefile, you define a macro by writing MACRONAME=value, and then you access the value of MACRONAME by writing either $(MACRONAME) or $, depending on your preference.

$MACRONAME may also be accepted by some versions of the make command.To make a macro’s value blank (which means that it expands to nothing), you can leave the rest of the line after the = blank.Another issue with Makefile1 is that it makes the assumption that the compiler is named gcc.Another UNIX system that you could be working on might be utilizing cc or a89.To get your makefile to work on a new version of UNIX, or even if you wanted to use a different compiler on your present system, you would have to alter multiple lines in your makefile in order for it to be functional.Macros are a convenient means of storing all of these system-dependent components and making it simple to update them.

In most cases, macros are created within the makefile itself, but they may also be specified by using make with the macro definition sent as an argument.Make CC=c89, as an example, and you’ll see what I’m talking about.Definitions in the makefile are overridden by command-line definitions such as this.When macro definitions are used outside of makefiles, they must be supplied as a single parameter, thus either avoid using spaces or use quotation marks like this: ″CC = c89″ should be written.

  • /A makefile that includes the macro: / Using some macros, here’s a rewritten version of the makefile, designated as Makefile2.
  • all: myapp Which compiler (CC = gcc) do you use?
  • What is the location of include files?
  • INCLUDE =.
  • Alternatives for future development Options for release CFLAGS = -g -Wall –ansi CFLAGS = -O -Wall –ansi CFLAGS = -O -Wall –ansi $(CC) -c myapp main.o 2.o 3.o $(CC) -c myapp main.o 2.o 3.o main.o: main.c a.h $(CC) -I$(INCLUDE) $(CFLAGS) -c main.c 2.o: 2.c a.h b.h $(CC) -I$(INCLUDE) $(CFLAGS) -c main.c 2.o 3.o: 3.c b If you destroy your existing installation and build a new one using this new makefile, you will receive the result $rm *.o myapp.
  • $make -f (Make a Finished Object) Makefile2 GCC -I.
  • -g -Wall -ansi -c main.c GCC-I.
  • -g -Wall -ansi -c 2.c GCC -I.
  • -g Wall -ansi -c 3.c GCC -o myapp main.o 2.o 3.o $ MacroDefinition $?

GCC-I.-g -Wall -ansi -c main.c GCC-I.The list of prerequisites (files on which the target relies) has been updated more recently than the current target version.the target’s name at the time of writing $

Linux dpkg Command Tutorial for Beginners (8 Examples)

  1. If you are using a Debian or Debian-based system (such as Ubuntu), there is a good probability that you have run into this problem before.
  2. dpkg packages are used.
  3. These are Debian packages, and Linux command line has built-in commands/tools to deal with these sort of packages.
  4. One such tool is dpkg, which we shall cover in further detail later on in this lesson.
  5. It’s important to note that all of the examples in this tutorial have been tested on an Ubuntu 16.04LTS computer before proceeding.

Linux dpkg command

  1. The dpkg utility is a package manager for Debian/Debian-based computers, and it may be used to install and remove packages.
  2. The following is the syntax for it: dpkg ACTIONS OR dpkgfilename are both valid options.
  3. And here’s what the guy page has to say about it: dpkg is a Debian package management tool that allows you to install, create, uninstall, and manage Debian packages.
  4. dpkg’s aptitude package manager is the primary and more user-friendly front-end for the package manager (1).
  5. The behavior of dpkg itself is fully controlled by command line arguments, which are composed of exactly one action and zero or more options, respectively.
  • The action- parameter instructs dpkg on what to perform, while the options parameter controls the behavior of the action in some way or another.
  • dpkg may also be used as a front-end to dpkg-deb(1) and dpkg-query(1), which are also command-line utilities (1).
  • In the Activities section, you can find a list of all of the actions that are supported by the system.
  • If such an operation is found, dpkg simply executes dpkg-deb or dpkg-query with the parameters provided; however, no particular options are presently offered to them; hence, in order to utilize any such options, the back-ends must be invoked directly by the user.
  • The examples that follow are in the form of a Q&A format, and they should provide you with a solid general understanding of how dpkg works.

Q1. How to install a package using dpkg?

  1. This may be accomplished through the use of the -i command line option.
  2. dpkg -i dpkg -i dpkg -i As an illustration: dpkg -i google-chrome-stable current amd64.deb Google Chrome Stable Current AMD64 The following are the stages that must be completed throughout the installation process: 1.
  3. Unzip the new package’s control files to a convenient location.
  4. 2.
  5. If a previous version of the same package was installed prior to the new installation, run the prerm script for the previous package to remove it before continuing.
  • 3.
  • Execute the preinst script, if one is given by the installation package.
  • When you are through unpacking the new files, make a backup of the old data as well so that if something goes wrong, the old files may be recovered.
  • (5) If a previous version of the same package was installed prior to the current installation, run the postrm script from the previous package.
  • (6) It is important to note that this script is performed after the preinst script of the new package, because new files are written at the same time as old files are deleted in this script.

6.Configure the package’s settings.Please refer to the -configure command for further information on how to do this task.

Q2. How to remove an already installed package using dpkg?

  1. This may be accomplished through the use of the -r command line option.
  2. use dpkg -r instead of dpkg As an illustration: dpkg -r googler 3.3.0-1 all.deb dpkg -r googler 3.3.0-1 all.deb The following is what the man page has to say about this option: The following are the steps involved in removing a package: 1.
  3. Run the prerm script.
  4. 2.
  5. Delete the files that were previously installed.
  • 3.
  • Execute the postrm script

Q3. How to list all installed packages in the system?

The -l command line option can be used to do this. use dpkg -l instead of dpkg For example, the following is the result produced by this command line option on my system:

Q4. How to make dpkg list contents of a package?

The -contents option can be used to do this. dpkg -contents is a command that displays the contents of a package. As an illustration:

Q5. How to just unpack a package using dpkg?

  1. It’s possible that you’ll only want to unpack the package and not configure it at some point.
  2. As a matter of fact, dpkg has a setting for this as well: dpkg -unpack is a command that unpacks packages.
  3. In the event that you want to configure an already unpacked package later on, you may do so by specifying the -configure command line argument.
  4. dpkg -configure is a configuration command.
  5. The following is an excerpt from the man page describing this option: The following are the stages involved in configuring a system: To begin, unpack the conffiles while also making a backup of the previous conffiles in case something goes wrong.
  • 2.
  • Execute the postinst script, if one is given by the installation package.

Q6. How to check if a package is installed or not?

This is accomplished through the use of the -s command line option. dpkg -s dpkg -s dpkg -s As an illustration:

Q7. How to print architecture of packages dpkg installs?

Access to this information may be gained through the use of the -print-architecture command line option. dpkg -print-architecture is a command that prints the architecture of a package. For example, the following is the output that the above command produced on my system: amd64

Q8. How to purge a package using dpkg?

  1. How to delete a package from your system by using the dpkg command has already been addressed.
  2. You may also purge a package, which is a procedure that eliminates everything from the package, including the configuration files.
  3. This may be accomplished through the use of the -P command line option.
  4. dpkg -P (deployment package) Listed below is what the man page has to say about this particular option: The fact that some configuration files are written and processed independently through the configuration scripts may lead dpkg to be unaware of their existence and behavior.
  5. It is necessary for the package’s postrm script (which is called by dpkg) to take care of their removal during the purge process in this scenario, since they will not be removed by dpkg on their own.
  • Of course, this only applies to files in system directories; configuration files saved to individual users’ home directories are exempt from this restriction.
  • The purging of a package is comprised of the following procedures: 1.
  • If it hasn’t previously been done so, uninstall the package.
  • This is explained in further detail in the -remove command line argument.
  • 2.

Execute the postrm script.

Conclusion

The dpkg command has a variety of options to choose from. This section contains information on the choices that will assist you in getting started with the tool. The man page for the command may be found on its webpage when you have finished experimenting with them. × Subscribers are the only ones who have access to this feature. Subscriptions can be obtained here.

Leave a Reply

Your email address will not be published.