Ubuntu and I

Ubuntu and I go way back, starting in 2006. I had built my own PC a couple years before that was running Windows. I decided to finally start using Linux on the desktop full time. I had dabbled with it in college labs but nothing serious. A few years before I had even unsuccessfully attempted to install some Red Hat version from CDs provided in the back of books I got from the library. This time I was wiser and more determined.

The biggest obstacle I remember is getting my PCI WiFi card to work. Using some tutorials and NDISwrapper I got it working flawlessly. Thus began my journey with Ubuntu. If you read older posts on this blog you’ll see how I brought my love for Ubuntu to my workplace. There were a bunch of old unused servers lying in storage. Just about then the network file share device died and I got to add a few hard drives to one of the old servers for the purposes of a network file share. I tried Ubuntu and it installed easily. Just to experiment a bit more I also tried installing Debian and Fedora (even CentOS) but the experience wasn’t as smooth as Ubuntu.

Around the same time I was tasked with building a web-based project. I got the latest Ubuntu release installed in a VM and started developing. I deployed the application on the same version of Ubuntu on another repurposed server. I was on top of the world because Ubuntu was giving me opportunities to get work done.

When my MacBook started showing its age I tried to inject some life into it by installing Linux. Ubuntu was the only distro that worked best with the hardware out of the box. Some things like camera needed some extra work but I didn’t bother because I didn’t need it to work.

We needed a system at work to drive the monitoring screen in our NOC. I found an abandoned desktop with a bad hard drive. Debian wouldn’t install, Fedora balked and Ubuntu installed fine. To my knowledge that desktop with the bad hard drive is still performing 4+ years later.

More recently I have been using Fedora and openSUSE for getting my work done. These distros have improved a lot and even outpace Ubuntu in some areas. But one thing is for sure: I keep recommending Ubuntu to new users to Linux because it’s well-rounded. I also keep coming back to Ubuntu every now and then because it is built for power users, too.

Linux Mint: “Warning: No support for locale: en_US.UTF-8″ in update-initramfs

After installing Linux Mint 17 in a VM I started the Update Manager to get the latest updates, including kernel. In the details window I saw this error:

update-initramfs: Generating /boot/initrd.img-3.13.0-24-generic
Warning: No support for locale: en_US.UTF-8

Thanks to Tip: fix for update-initramfs “No support for local …” I found the cause and the solution.

Cause (quoting from the source post): “The problem is that /usr/share/initramfs-tools/hooks/root_locale is expecting to see individual locale directories in /usr/lib/locale, but locale-gen is configured to generate an archive file by default.”

Solution: Run locale-gen again (but use directories not archive file) and then update-initramfs.

sudo locale-gen --purge --no-archive

sudo update-initramfs -u -t

Fix for “undefined reference to clock_gettime”

While running the build.sh script for SIPp I ran into this error:

src/sipp-time.o: In function getmicroseconds()': /chroot/root/sipp/src/time.cpp:57: undefined reference to clock_gettime'

The fix is to add LDFLAGS=”-ltr” like so:

LDFLAGS=" -lrt " ./configure --with-openssl --with-pcap --with-sctp --with-rtpstream

LDFLAGS=" -lrt " make

More information about this error: Ubuntu Linux C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’; Untitled; [xymon] Can not compile 4.2.3 on CentOS 5.2

SaltStack Quickstart Guide on Mac OS X

As always, refer to the official SaltStack documentation first.

To get up and running with SaltStack on Mac OS X can be a daunting task. I have found it much easier to use MacPorts to accomplish any such tasks.

Step 1: Install MacPorts on your Mac OS X. I find this to be an essential step for any developer using Mac OS X. Of course, there’s Homebrew as an alternative. I haven’t used it but you may check it out as well.

Once you have setup MacPorts successfully you are ready to begin. Of course, since MacPorts provides a variety of GCC versions I prefer it over the default gcc provided on my Mac. Install a newer GCC and link your system to it.

[user@host ~] $ sudo port install gcc48

[user@host ~] $ sudo mv /usr/bin/gcc /usr/bin/gcc.orig

[user@host ~] $ sudo ln -s /opt/local/bin/gcc-mp-4.8 /usr/bin/gcc

Install Python 2.7.

[user@host ~] $ sudo port install python27

Install Virtualenv.

[user@host ~] $ sudo port install py27-virtualenv

M2Crypto is a requirement for SaltStack and you need to install SWIG. Otherwise you may get errors[1].

[user@host ~] $ sudo port install swig

[user@host ~] $ sudo port install swig-python

Create your virtualenv.

[user@host ~] $ /opt/local/bin/virtualenv-2.7 ~/dev/virt-env/salt-virt

Activate the virtualenv.

[user@host ~] $ source ~/dev/virt-env/salt-virt/bin/activate

Install SaltStack pre-requisites.

(salt-virt)[user@host ~] $ pip install pyzmq PyYAML pycrypto msgpack-python jinja2 psutil

Install SaltStack.

(salt-virt)[user@host ~] $ pip install salt

Make sure things are working well.

(salt-virt)[user@host ~] $ python

Python 2.7.8 (default, Jul 13 2014, 17:11:32) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import salt
>>> ^D

To deactivate the virtualenv,

deactivate

Note: this post was created using Mac OS X 10.9 (Mavericks) with SaltStack 2014.1.7.


[1] Possible SWIG error

unable to execute 'swig': No such file or directory

error: command 'swig' failed with exit status 1

gevent Quickstart Guide

This is a simple list of steps on how to get started with installing gevent on openSUSE (tested on openSUSE 13.1 with gevent 1.0.1). We’ll use virtualenv instead of a system-wide install.

You need to have a compiler (gcc) and Python development library.

[user@host ~] $ sudo zypper install gcc python-devel

Install Python 2.7 virtualenv, since gevent 1.0.1 doesn’t appear to support Python 3.

[user@host ~] $ sudo zypper install python-virtualenv

Create virtual environment in your home directory (or anywhere else you want).

[user@host ~] $ virtualenv ~/virt

Activate the virtualenv.

[user@host ~] $ source virt/bin/activate

Install gevent.

(virt) [user@host ~] $ pip install gevent

Check it all works.

(virt) [user@host ~] $ python

Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gevent import sleep
>>> sleep(2)
>>> 

When you’re done deactivate the virtualenv.

(virt) [user@host ~] $ deactivate

SSH Cookbook: Temporarily Disable Security Message on Connection to a Remote Server

First off, DO NOT do this all the time. ONLY do this when you have evaluated the risks and decided to risk a security breach anyways. I usually do this in my testing environment where I get to work with a lot of new or changing VMs.

When you connect for the first time to a server you are prompted to verify its fingerprint. It is then added to your ~/.ssh/known_hosts file so when you connect the next time and the fingerprint matches you are not prompted again. For example:

The authenticity of host '192.168.1.22 (192.168.1.22)' can't be established.
RSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
Are you sure you want to continue connecting (yes/no)?

This can be annoying when you connect to a lot of “new” SSH servers. It also doesn’t work in test environments where scripts need to continously connect to machines they have not connected to before and may not ever connect again. This can be even more annoying when the same IP is recycled between various test machines and your client machine does not connect because a known host’s fingerprint changed.

You can temporarily disable fingerprint matching at the time you are connecting:

ssh myuser@192.168.1.22 -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

You can also put this config in your ~/.ssh/config file so that you don’t need to provide these extra flags all the time:

Host myhost
    HostName 192.168.1.22
    Port 22
    User myuser
    AddressFamily inet
    CheckHostIP no
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Now when you connect to the server you will see a message similar to this one:

Warning: Permanently added '192.168.1.22' (RSA) to the list of known hosts.

It hasn’t actually added it to the known hosts file and that’s the beauty of it.

One last thing: DO NOT do this when connecting to machines you absolutely must trust. It’s alright to use this technique when connecting within a test lab environment, for example.

zypper Cookbook: Autoremove Packages and Remove Orphaned Packages

As I learned how to autoremove unnecessary packages as you remove a package and also how to identify orphaned packages, I marveled at the beauty of zypper and the excellent work of all its contributors. Not only does zypper have the functionality to do just about anything related to repos and packages, it has sensible online help right at your fingertips.

Before I show how to perform these two tasks this post is primarily about, let me show you two easy ways to figure out whether zypper can do what you want to do.

The first thing is global help on what is available with zypper.

zypper help

  Usage:
	zypper [--global-options]  [--command-options] [arguments]

  Global Options:
	--help, -h		Help.
	--version, -V		Output the version number.
	--promptids		Output a list of zypper's user prompts.
	--config, -c 	Use specified config file instead of the default.
	--userdata 	User defined transaction id used in history and plugins.
	--quiet, -q		Suppress normal output, print only error
				messages.
	--verbose, -v		Increase verbosity.
	--no-abbrev, -A		Do not abbreviate text in tables.
	--table-style, -s	Table style (integer).
	--rug-compatible, -r	Turn on rug compatibility.
	--non-interactive, -n	Do not ask anything, use default answers
				automatically.
	--non-interactive-include-reboot-patches
				Do not treat patches as interactive, which have
				the rebootSuggested-flag set.
	--xmlout, -x		Switch to XML output.
	--ignore-unknown, -i	Ignore unknown packages.

	--reposd-dir, -D 	Use alternative repository definition file
				directory.
	--cache-dir, -C 	Use alternative directory for all caches.
	--raw-cache-dir 	Use alternative raw meta-data cache directory.
	--solv-cache-dir 	Use alternative solv file cache directory.
	--pkg-cache-dir 	Use alternative package cache directory.

     Repository Options:
	--no-gpg-checks		Ignore GPG check failures and continue.
	--gpg-auto-import-keys	Automatically trust and import new repository
				signing keys.
	--plus-repo, -p 	Use an additional repository.
	--disable-repositories	Do not read meta-data from repositories.
	--no-refresh		Do not refresh the repositories.
	--no-cd			Ignore CD/DVD repositories.
	--no-remote		Ignore remote repositories.

     Target Options:
	--root, -R 	Operate on a different root directory.
	--disable-system-resolvables
				Do not read installed packages.

  Commands:
	help, ?			Print help.
	shell, sh		Accept multiple commands at once.

     Repository Management:
	repos, lr		List all defined repositories.
	addrepo, ar		Add a new repository.
	removerepo, rr		Remove specified repository.
	renamerepo, nr		Rename specified repository.
	modifyrepo, mr		Modify specified repository.
	refresh, ref		Refresh all repositories.
	clean			Clean local caches.

     Service Management:
	services, ls		List all defined services.
	addservice, as		Add a new service.
	modifyservice, ms	Modify specified service.
	removeservice, rs	Remove specified service.
	refresh-services, refs	Refresh all services.

     Software Management:
	install, in		Install packages.
	remove, rm		Remove packages.
	verify, ve		Verify integrity of package dependencies.
	source-install, si	Install source packages and their build
				dependencies.
	install-new-recommends, inr
				Install newly added packages recommended
				by installed packages.

     Update Management:
	update, up		Update installed packages with newer versions.
	list-updates, lu	List available updates.
	patch			Install needed patches.
	list-patches, lp	List needed patches.
	dist-upgrade, dup	Perform a distribution upgrade.
	patch-check, pchk	Check for patches.

     Querying:
	search, se		Search for packages matching a pattern.
	info, if		Show full information for specified packages.
	patch-info		Show full information for specified patches.
	pattern-info		Show full information for specified patterns.
	product-info		Show full information for specified products.
	patches, pch		List all available patches.
	packages, pa		List all available packages.
	patterns, pt		List all available patterns.
	products, pd		List all available products.
	what-provides, wp	List packages providing specified capability.

     Package Locks:
	addlock, al		Add a package lock.
	removelock, rl		Remove a package lock.
	locks, ll		List current package locks.
	cleanlocks, cl		Remove unused locks.

     Other Commands:
	versioncmp, vcmp	Compare two version strings.
	targetos, tos		Print the target operating system ID string.
	licenses		Print report about licenses and EULAs of
				installed packages.
	download		Download rpms specified on the commandline to a local directory.
	source-download		Download source rpms for all installed packages
				to a local directory.

Type 'zypper help ' to get command-specific help.

The second thing is the last line in the output of zypper help: how to get help on the commands available with zypper. For example, let’s lookup help for packages command.

zypper help packages

packages (pa) [options] [repository] ...

List all packages available in specified repositories.

  Command options:

-r, --repo   Just another means to specify repository.
-i, --installed-only      Show only installed packages.
-u, --uninstalled-only    Show only packages which are not installed.
    --orphaned            Show packages which are orphaned (without repository).
    --suggested           Show packages which are suggested.
    --recommended         Show packages which are recommended.
    --unneeded            Show packages which are unneeded.
-N, --sort-by-name        Sort the list by package name.
-R, --sort-by-repo        Sort the list by repository.

Lookie here now, we found a way to identify orphaned packages.

zypper packages --orphaned

Loading repository data...
Reading installed packages...
S | Repository | Name                          | Version   | Arch  
--+------------+-------------------------------+-----------+-------
i | @System    | openSUSE-release-livecd-gnome | 13.1-1.10 | x86_64

Go right ahead and remove the orphaned packages that offend you so.

We can go one step further and make sure any packages that only depend on the package you’re removing are also removed.

zypper help remove

remove (rm) [options]  ...

Remove packages with specified capabilities.
A capability is NAME[.ARCH][OP], where OP is one
of <, =, >.

  Command options:
-r, --repo     Load only the specified repository.
-t, --type            Type of package (package, patch, pattern, product).
                            Default: package.
-n, --name                  Select packages by plain name, not by capability.
-C, --capability            Select packages by capability.
    --debug-solver          Create solver test case for debugging.
-R, --no-force-resolution   Do not force the solver to find solution,
                            let it ask.
    --force-resolution      Force the solver to find a solution (even
                            an aggressive one).
-u, --clean-deps            Automatically remove unneeded dependencies.
-U, --no-clean-deps         No automatic removal of unneeded dependencies.
-D, --dry-run               Test the removal, do not actually remove.

We can remove, for example nodejs, and all its dependencies (that are not dependencies for any other package) this way:

sudo zypper remove --clean-deps nodejs

I hope by now you are as convinced as I am that zypper is not only functional but (gasp!) beautiful as well.

Follow

Get every new post delivered to your Inbox.

Join 31 other followers