|
RPM Commands This document contains an overview of the principal RPM commands for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Red Hat Linux system. # rpm -ivh foo-2.0-4.i386.rpm # rpm -i ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm # rpm -i http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm Used to install a RPM package. Note that RPM packages have file naming conventions like foo-2.0-4.i386.rpm, which include the package name (foo), version (2.0), release (4), and architecture (i386). Also notice that RPM understands FTP and HTTP protocols for installing and querying remote RPM files. # rpm -e foo To uninstall a RPM package. Note that we used the package name foo, not the name of the original package file foo-2.0-4.i386.rpm above. # rpm -Uvh foo-1.0-2.i386.rpm # rpm -Uvh ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm # rpm -Uvh http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm To upgrade a RPM package. Using this command, RPM automatically uninstall the old version of the foo package and install the new package. It is safe to always use rpm -Uvh to install and upgrade packages, since it works fine even when there are no previous versions of the package installed! Also notice that RPM understands FTP and HTTP protocols for upgrading from remote RPM files. # rpm -qa To query all installed packages. This command will print the names of all installed packages installed on your Linux system. # rpm -q foo To query a RPM package. This command will print the package name, version, and release number of the package foo only if it is installed. Use this command to verify that a package is or is not installed on your Linux system. # rpm -qi foo To display package information. This command display package information including the package name, version, and description of the installed program. Use this command to get detailed information about the installed package. # rpm -ql foo To list files in installed package. This command will list all of files in an installed RPM package. It works only when the package is already installed on your Linux system. # rpm -qf /usr/bin/mysql mysql-3.23.52-3 Which package owns a file? This command checks to determine which installed package a particular file belongs to. # rpm -qpl kernel-2.4.20-18.10.1.i686.rpm # rpm -qpl ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm # rpm -qpl http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm List files in RPM file. This command allows you to query a (possibly) uninstalled RPM file with the use of the the "-p" option. You can use the "-p" option to operate on an RPM file without actually installing anything. This command lists all files in an RPM file you have in the current directory. Also note that RPM can query remote files through the FTP and HTTP protocols. # rpm --verify mysql To verify an installed package. This command will list all files that do NOT pass the verify tests (done on size, MD5 signature, etc). Where a file does NOT pass, the output is listed using the following codes that signify what failed: S File size M Mode (includes permissions and file type) 5 MD5 sum L Symlink D Device U User G Group T Mtime Take for example the following: # rpm --verify mysql S.5....T c /etc/my.cnf This example indicates that file /etc/my.cnf failed on: File size MD5 Sum Modified Time However, the "c" tells us this is a configuration file so that explains the changes. It should still be looked at to determine what the changes were. # rpm --checksig foo To check a RPM signature package. This command checks the PGP signature of specified package to ensure its integrity and origin. Always use this command first before installing a new RPM package on your system. Also, GnuPG or Pgp software must be already installed on your system before you can use this command.
Post / Read Comments All About ls Command Lists the contents of a directory. Syntax ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames] -a Shows you all files, even files that are hidden (these files begin with a dot.) -A List all files including the hidden files. However, does not display the working directory (.) or the parent directory (..). -b Force printing of non-printable characters to be in octal \ddd notation. -c Use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n). -C Multi-column output with entries sorted down the columns. Generally this is the default option. -d If an argument is a directory it only lists its name not its contents. -f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory. -F Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals sign (=). -g Same as -l except the owner is not printed. -i For each file, print the i-node number in the first column of the report. -l Shows you huge amounts of information (permissions, owners, size, and when last modified.) -L If an argument is a symbolic link, list the file or directory the link references rather than the link itself. -m Stream output format; files are listed across the page, separated by commas. -n The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the associated character strings. -o The same as -l, except that the group is not printed. -p Displays a slash ( / ) in front of all directories. -q Force printing of non-printable characters in file names as the character question mark (?). -r Reverses the order of how the files are displayed. -R Includes the contents of subdirectories. -s Give size in blocks, including indirect blocks, for each entry. -t Shows you the files in modification time. -u Use time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option). -x Displays files in columns. -1 Print one entry per line of output. pathnames File or directory to list. Examples ls -l In the above example this command would list each of the files in the current directory and the files permissions, the size of the file, date of the last modification, and the file name or directory. Below is additional information about each of the fields this command lists. Permissions Directories Group Size Date Directory or file drwx------ 2 users 4096 Nov 2 19:51 mail/ drwxr-s--- 35 www 32768 Jan 20 22:39 public_html/ -rw------- 1 users 3 Nov 25 02:58 test.txt Below is a brief description of each of the above categories shown when using the ls -l command. Permissions - The permissions of the directory or file. Directories - The amount of links or directories within the directory. The default amount of directories is going to always be 2 because of the . and .. directories. Group - The group assigned to the file or directory Size - Size of the file or directory. Date - Date of last modification. Directory of file - The name of the file or file. ls ~ List the contents of your home directory by adding a tilde after the ls command. ls / List the contents of your root directory. ls ../ List the contents of the parent directory. ls */ List the contents of all sub directories. ls -d */ Only list the directories in the current directory.
Post / Read Comments How to Make Packages of Files on UNIX 1 Introduction One often needs to put a group of files into one single package file. This is typically for the purpose of copying the files from one machine to another. 2 Tar Files On UNIX systems, the most commonly used pack/unpack program is tar. One uses the c (“create”) command to pack, and the x (“extract”) command to unpack. For example, suppose I have files A, B and C, of which I wish to put copies into a file g.tar. I could type tar cf g.tar A B C The c option means I am creating a tar-file, while the f says that the next item on my command line will be the tar-file name. So, I am creating a tar-file named g.tar from the files A, B and C. Important note: Make sure to include the command-line argument which specifies your tar-file name, in this example g.tar. In the example above, if we were to mistakenly type tar cf A B C then tar would think we wish A to be the tar-file. That would destroy the contents of the original A! I can now copy the single file g.tar to another machine. At that machine, I can type tar xf g.tar to extract all the files from g.tar. By the way, if say, B had been a subdirectory, then the g.tar file would also include all the files within B, and the B subdirectory and its files would then be created by the unpacking at Machine 2. When you unpack a tar-file, in some cases you should use the p option, e.g. as tar xpf g.tar This preserves the original file permissions. 3 File Compression In many cases, a tar-file will also be compressed, both to reduce network transfer time and to save space on the disk. On UNIX machines, this compression is usually done with gzip or bzip2. (The latter is newer and generally more efficient at compression.) For instance, if in the example above I type gzip g.tar Similarly, if I use gzip, the original file g.tar will be replaced by compressed file with a .gz suffix added to its name. I can uncompress by using the -d option. In other words gzip -d g.tar.gz would replace g.tar.gz by the original uncompressed file g.tar. An acceptable suffix is .tgz, which means a file that has first been created as .tar and then compressed by gzip. So, to unpack the file y.tgz one could type gzip -d y.tgz tar xf y.tar The syntax of using the bzip2 program is like that of gzip. 4 Unpacking Windows Packages Programs for Windows are generally bundled and compressed using the zip program (not gzip). You can spot them by their .zip prefix. Most UNIX machines include a program unzip which can unpack .zip files. You may wish to use this program with the -a option, which changes Windows text files to UNIX format
Post / Read Comments |