Simple howtos

This collection of mini howtos is a dynamic copy of the Unix Toolbox. This page extracts the XML content directly from the original XHTML DOM and displays only the requested node. Source code here (use "save as").
Unix Toolbox revision 14.4
Copyright (c) 2007-2012 Colin Barschel. Some rights reserved under Creative Commons [Attribution - Share Alike]
System
Processes
File System
Network
SSH SCP
VPN with SSH
RSYNC
SUDO
Encrypt Files
Encrypt Partitions
SSL Certificates
CVS
SVN
Useful Commands
Install Software
Convert Media
Printing
Databases
Disk Quota
Shells
Scripting
Programming
Online Help

Install Software

Usually the package manager uses the proxy variable for http/ftp requests. In .bashrc:
export http_proxy=http://proxy_server:3128
export ftp_proxy=http://proxy_server:3128

List installed packages

# rpm -qa                            # List installed packages (RH, SuSE, RPM based)
# dpkg -l                            # Debian, Ubuntu
# pkg_info                           # FreeBSD list all installed packages
# pkg_info -W smbd                   # FreeBSD show which package smbd belongs to
# pkginfo                            # Solaris

Add/remove software

Front ends: yast2/yast for SuSE, redhat-config-packages for Red Hat.
# rpm -i pkgname.rpm                 # install the package (RH, SuSE, RPM based)
# rpm -e pkgname                     # Remove package

SuSE zypper (see doc and cheet sheet)http://en.opensuse.org/SDB:Zypper_usage

# zypper refresh                     # Refresh repositorie
# zypper install vim                 # Install the package vim
# zypper remove vim                  # Remove the package vim
# zypper search vim                  # Search packages with vim
# zypper update vim                  # Search packages with vim

Debian

# apt-get update                     # First update the package lists
# apt-get install emacs              # Install the package emacs
# dpkg --remove emacs                # Remove the package emacs
# dpkg -S file                       # find what package a file belongs to

Gentoo

Gentoo uses emerge as the heart of its "Portage" package management system.
# emerge --sync                      # First sync the local portage tree
# emerge -u packagename              # Install or upgrade a package
# emerge -C packagename              # Remove the package
# revdep-rebuild                     # Repair dependencies

Solaris

The <cdrom> path is usually /cdrom/cdrom0.
# pkgadd -d <cdrom>/Solaris_9/Product SUNWgtar
# pkgadd -d SUNWgtar                 # Add downloaded package (bunzip2 first)
# pkgrm SUNWgtar                     # Remove the package

FreeBSD

# pkg_add -r rsync                   # Fetch and install rsync.
# pkg_delete /var/db/pkg/rsync-xx    # Delete the rsync package
Set where the packages are fetched from with the PACKAGESITE variable. For example:
# export PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages/Latest/ 
# or ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/

FreeBSD portshttp://www.freebsd.org/handbook/ports.html

The port tree /usr/ports/ is a collection of software ready to compile and install (see man ports). The ports are updated with the program portsnap.
# portsnap fetch extract             # Create the tree when running the first time
# portsnap fetch update              # Update the port tree
# cd /usr/ports/net/rsync/           # Select the package to install
# make install distclean             # Install and cleanup (also see man ports)
# make package                       # Make a binary package of this port
# pkgdb -F                           # Fix the package registry database
# portsclean -C -DD                  # Clean workdir and distdir (part of portupgrade)

OS X MacPortshttp://guide.macports.org/ (use sudo for all commands)

# port selfupdate                    # Update the port tree (safe)
# port installed                     # List installed ports
# port deps apache2                  # List dependencies for this port
# port search pgrep                  # Search for string
# port install proctools             # Install this package
# port variants ghostscript          # List variants of this port
# port -v install ghostscript +no_x11# -no_x11 for negative value
# port clean --all ghostscript       # Clean workdir of port
# port upgrade ghostscript           # Upgrade this port
# port uninstall ghostscript         # Uninstall this port
# port -f uninstall installed        # Uninstall everything

Library path

Due to complex dependencies and runtime linking, programs are difficult to copy to an other system or distribution. However for small programs with little dependencies, the missing libraries can be copied over. The runtime libraries (and the missing one) are checked with ldd and managed with ldconfig.
# ldd /usr/bin/rsync                 # List all needed runtime libraries
# otool -L /usr/bin/rsync            # OS X equivalent to ldd
# ldconfig -n /path/to/libs/         # Add a path to the shared libraries directories
# ldconfig -m /path/to/libs/         # FreeBSD
# LD_LIBRARY_PATH                    # The variable set the link library path