rpm -Querying/Verifying, -
-q selection-options -l
rpm -q --whatprovides /usr/bin/gcc ; rpm -ql gcc
-U (--upgrade) -F (--freshen : only upgrade the installed packages)
rpm --showrc
shows the values rpm will use for all of the options are currently set in rpmrc and macros configuration file(s).
rpm -ivh {rpm-file} Install the package
Examples:
rpm -ivh mozilla-mail-1.7.5-17.i586.rpm
rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm
rpm -Uvh {rpm-file} Upgrade package
Examples:
rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm
rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm
rpm -ev {package} Erase/remove/ an installed package
Examples:
rpm -ev mozilla-mail
rpm -ev --nodeps {package} Erase/remove/ an installed package without checking for dependencies
rpm -ev --nodeps mozilla-mail
rpm -qa Display list all installed packages
rpm -qa
rpm -qa | less
rpm -qi {package} Display installed information along with package version and short description
rpm -qi mozilla-mail
rpm -qf {/path/to/file} Find out what package a file belongs to i.e. find what package owns the file
rpm -qf /etc/passwd
rpm -qf /bin/bash
rpm -qc {pacakge-name} Display list of configuration file(s) for a package
rpm -qc httpd
rpm -qcf {/path/to/file} Display list of configuration files for a command
rpm -qcf /usr/X11R6/bin/xeyes
rpm -qa --last Display list of all recently installed RPMs
rpm -qa --last
rpm -qa --last | less
rpm -qpR {.rpm-file}
rpm -qR {package} Find out what dependencies a rpm file has
rpm -qpR mediawiki-1.4rc1-4.i586.rpm
rpm -qR bash
Compile Open Source Code:
Static Libraries
also known as archives, have their names end with .a . /usr/lib/libss.a
.a is created and maintained by ar utility.
To create static library:
ar crv lib1.a prog1.o prog2.o
[root@localhost lib]# ar -t libss.a
ss_err.o
std_rqs.o
invocation.o
help.o
execute_cmd.o
listen.o
parse.o
error.o
prompt.o
request_tbl.o
list_rqs.o
pager.o
requests.o
data.o
get_readline.o
[root@localhost lib]# cd
[root@localhost ~]# vi prog1.c
[root@localhost ~]# vi prog2.c
[root@localhost ~]# vi prog1.c
[root@localhost ~]# gcc -c prog1.c prog2.c
[root@localhost ~]# ls *.o
prog1.o prog2.o
[root@localhost ~]# vi lib.h
[root@localhost ~]# vi prog2.c
[root@localhost ~]# gcc -c prog1.c prog2.c
[root@localhost ~]# vi program.c
[root@localhost ~]# gcc -c program.c
[root@localhost ~]# gcc -o program program.o prog1.o
[root@localhost ~]# ./program
Shan: you won 134513872
[root@localhost ~]# ar crv libshan.a prog1.o prog2.o
a - prog1.o
a - prog2.o
[root@localhost ~]# ar -t libshan.a
prog1.o
prog2.o
extra member from archive
[root@localhost tmp]# ar x libshan.a
[root@localhost tmp]# ls
libshan.a prog1.o prog2.o
Use nm to see which functions are included in an object file, library or executable program(if compiled with symbols).
[root@localhost tmp]# nm program.o
U exit
00000000 T main
U prog1
[root@localhost tmp]# cat ../program.c
#include "lib.h"
int main ()
{
prog1("1000000");
exit (0);
}
[root@localhost ~]# ldd program
libc.so.6 => /lib/tls/libc.so.6 (0x0018a000)
/lib/ld-linux.so.2 (0x00171000)
Probem with Static libraries: when many running processes need to use the same function (provided by static lib),
the system ends up with many copies of the same code/functions in memory.
Shared Library solves this problem. When a program uses a shred lib, it doesn't contain the function code but
it references to shared code that will be available at run time. When the resulting program is loaded into
memory to be executed, the function references are resolved and calls are made to the shared library, which will
be loaded into the memory if needed.
In this way, the system can just have a single copy of a shared library to be used by many applications at once.
An additional benefit is that the shared library can be updated independently of the programs that rely on it
because symbolic links from the file /lib/libc.so.6 to the actual library revision libc-2.3.4.so is used.
rwxrwxrwx 1 root root 13 Oct 30 12:04 /lib/tls/libc.so.6 -> libc-2.3.4.so
RMP cheat page.