Package concepts: DEBs and apt

Using Debian packages

You’ll use dpkg to install Debian packages:

dpkg [options] [action] [package-files] [package-name]

-i install
-r remove
-P purge, removes a package and its configs
-p display info about an installed package
-L list files associated to a package
-c   –audit search for partially installed packages
–force-things override defaults that would cause dpkg to abort
–ignore-depends=[package]
–no-act check for dependencies, conflicts and other problems without installing
-G do not install if a newer version is already installed
-E skip version, do not install if the same version is already installed

Continue reading “Package concepts: DEBs and apt”

Package concepts: RPMs and yum

Basic concepts:

  • Packages are usually distributed as single files
  • Dependencies are the requirements of packages for one another
  • Checksums verify the validity of the installed software
  • You can create binary packages from source

Using rpm

RPM was developed by Red Hat for its own distro; RPM supports any CPU architecture. The convention for naming .rpm is as follows:

package-a.b.c-x.arch.rpm

package name
a.b.c version of the program, assigned by the author
x build number, assigned by the maintainer
arch x86, x86_64

Continue reading “Package concepts: RPMs and yum”

Using regular expressions

Two programs that make heavy use of regular expressions are grep and sed.

There are two forms of regular expressions: basic and extended.

  • alphabetic string
  • bracket expressions: char enclosed in [ ] match any one character enclosed
  • range expressions: start and end points are separated by a dash
  • any single character: the dot . represents any single character except a new line
  • start/end of line: ^ start of line, $ end of line
  • repetition operators: * zero or more occurrences, + one or more occurrences, ? zero or one match
  • multiple possible strings: | separates two possible matches
  • parenthesis: ( ) surround sub-expressions
  • escaping: if you want to match one of the special characters (ie. . dot), you must escape it with a backlash \

Continue reading “Using regular expressions”

Processing text using filters

File-combining commands

cat: concatenate; combine an arbitrary number of files and send it to a file. It’s also commonly used to display the content of short files.

Options for cat:

-E –show-ends see where line ends
-n –number add numbers to the beginning of every line
-b –number-nonblank numbers only lines that contain text
-s –squeeze-blank compress groups of blank lines down to a single one
-t –show-tabs display tabs as ^I

tac: it reverses the order of lines in the output.

join: combines two files matching the content of specified fields. Fields are usually separated by a space. -t [char] option lets you specify another character to be used as separator.

paste: merges file line by line, separating the lines from each file with tabs.

Continue reading “Processing text using filters”