Below you will find pages that utilize the taxonomy term “Unix”
Unix 101 : Shell wildcards expansion, to quote or not to quote
Or why you usually use ls -l *txt without quotes, but use quotes in find . -name “*txt”.
Unix 101 : Showing non-printing characters in text files (ex : DOS files)
A non-printing character is a character which won’t actually get directly printed (or displayed) but rather interpreted. Such non-printing characters are for example line-feed or tabulation. The interpretation of those characters can differ from one system to the next. For example the line-feed character is different on Unix or DOS.
If you need an easy way to confirm that a text file is DOS or UNIX formatted (they differ with respect to the end of line character(s) for example) or if you wish to display normally non-printing characters of a text file, you can use the -vET command line switches of the cat utility.
As explained in the man page :
- -v : will use the ^ and M- notation for control and multibytes characters
- -E : will make ends of lines visible
- -T : will make tabulations visible
For example :
Unix 101 : Filesystem basics & Special files
This post is meant to clarify a few key concepts about Unix filesystems such as directory permissions, hardlinks and symlinks.
AIX : Use sar to check cpu usage
If you’re looking for CPU usage statistics and system performance on IBM AIX, sar might just be the tool your looking for. It’ll display information for 5 minutes intervals from midnight to current time. The output looks like this :
Linux / Unix : Disk usage and identifying biggest files
When working as a systems administrator, you’ll always end up having to solve a file system full error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system.
OpenSolaris : Switching to the /dev development branch
In OpenSolaris, switching to the /dev development branch is a bit like switching to the testing branch for some linux distros. So you might want to think twice before doing so, as it might sometimes break things.
If you still want to do that, follow those instructions :
SSH : Multiplexing connections
There is a feature in OpenSSH since v3.9 which allows multiple SSH connections with the same caracteristics (host, port, remote login) to be made through a single TCP connection. This is useful because you’ll have to authenticate only once, and besides the new SSH connections will be much faster to establish.
Xen : OpenSolaris 2008.11 DomU running on a Linux Dom0
This post is a step by step explanation about how to get an OpenSolaris 2008.11 run as a Xen DomU on a Linux Dom0.
To follow this, you’ll need a Linux machine ready for Xen (I run Xen 3.3.0), with vncviewer installed.
This post doesn’t explain the basics of Xen, so you might want to start by learning Xen if you don’t already know a bit of it.
shell tip : identify broken symlinks
If you need to identify broken symlinks, you can do the following :
find -L . -type l
The -L options instructs find to follow symlinks when possible. Hence no “working symlink” will ever get returned as the targets won’t match -type l (meaning “file is a symlink”).
On the other hand, find will not be able to follow broken symlinks, so the information will be taken from the symlink itself and not from the non-existent or otherwise unreachable target. The -type l will then be a match and the broken symlink filename will be returned.
Gentoo : Managing software packages
In this post I’ll cover the basics one needs to know to install, upgrade and remove packages on a Gentoo linux system.
Gentoo : First thoughts after the switch
I’ve recently switched to the Gentoo Linux distribution (mostly to experiment with this Linux distro) and I don’t regret it so far. This post is about my first impressions about Gentoo.
NFS : see what’s exported from an NFS server
To know what directories are exported by a NFS server, you can use the showmount -e nfs_server from a NFS client.
[root@client:~]# showmount -e server<br /> Export list for server:<br /> /data/dir1 (everyone)<br /> /data/dir2 client1 client2 client3
(The /data/dir2 is exported only to specified clients)
Sun Solaris 10 : Creating snapshots with ZFS
ZFS is a great filesystem. Amongst its many features, it has snapshots. Let’s see how to use them.
Securing automated rsync over SSH
Quoting the RSYNC homepage : “rsync is an open source utility that provides fast incremental file transfer.”
To make rsync both secure and automated (i.e : non-interactive), you can use SSH as the transport and set up a key pair. This is what will be discussed in this post, along with a few improvements.
OpenSolaris 2008.05 released today
OpenSolaris 2008.05 is released today, you can grab it from the OpenSolaris website.
The distribution is a bootable CD which will let you try it before installing. It includes most of the big hits of Solaris 10 (zfs, dtrace, containers and so on).
If you never tried Solaris or OpenSolaris, this might be a good kick start !
SSH slow to connect to a Solaris 10 host
If you experience a slow SSH connection to a Solaris 10 host while after connection everything works fine, then read on !
OpenBSD : Release 4.3 is out
The twice-a-year release of OpenBSD is out today (More details on Undeadly). You can buy the CD set or get it by FTP (in this case consider donating to the project as CD sales are the main source of income to the project).
Enjoy.
CFEngine : Checking for processes
CFEngine can do wonders to keep a cluster in shape, but it can be very useful for a single server as well. Here is a configuration sample to monitor a few common services and restart them should they fail.
Unix : shell tips
I ran into this into the following article, “Learn 10 good UNIX usage habits“. This article is mainly common sense, but there are interesting points, such as :
- avoid piping when you can, in order to save performance (the classical construct grep | wc to count the lines is useless as most versions of grep can count with grep -c)
- use awk to “grep” on a specific field of a line with “… | awk ‘$1 == “XXX”‘ which is cool and I never use
- the find | xargs construct (I’d add “find -print0 | xargs -0”, useful if your find brings back filenames with a space inside …)
All in all it is worth a reading, if only to refresh your memory.
dsh : a distributed shell
A common problem when you deal with a pool of servers (clusters or server farms, you name it) is to execute the same command line on each server. It is usual to solve this with a “for” construct such as :
for i in server1 server2 ; do ssh $i "uname -a"; done
But this is basically re-inventing the wheel everytime. Here comes Distributed Shell (DSH).
Perl : Convert time from Epoch to local time

This little Perl one-liner can get handy when you need to translate “time in seconds since the Epoch” (for example in logs) to local time :
% perl -e 'print scalar(localtime(1202484725)), "\n";'<br /> Fri Feb 8 16:32:05 2008<br /> %
This was pretty useful today when browsing through Nagios event logs, where times are given in seconds from the Epoch.
By the way, the Epoch is defined as 00:00 UTC on January, 1st, 1970.
Perl : Optimizing pattern searches with Regexp::Assemble
When you perform a pattern matching with multiple “or” (|) clauses, such as /pattern1|pattern2|pattern3/, Perl regexp engine will try to match each of them one after the other in sequence, resulting in poor performance if you have a long list of “or” clauses.
In order to optimize such a pattern matching, you can use the Regexp::Assemble module.
Linux : Taking control of Virtual Terminals (VT) from command line
When you use Linux in text mode (as opposed to with an X server), you readily have access to multiple Virtual Terminals (aka VT for short) by hitting one of your
This lets you access one of the VTs which are initialized at boot time, but won’t let you create new ones even if your kernel configuration would allow more VTs. Furthermore, what if you want to deal with VTs from a script ?
This post covers the 3 commands which will let you control your VTs from the command line or from a script.
Unix : the “script” command
The script command is a must for any unix sysadmin.
Once invoked, it will faithfully write anything you typed as well as any output generated in your terminal into a file of your choice (defaults to “typescript”).
This is great when you want to document everything you did on a specific server, for example.
spaghetti:~$ script<br /> Script started, file is typescript<br /> spaghetti:~$<br />
When launched, you don’t see anything, but everything displayed goes to a file as well as the terminal.
sed : replacing a text in a file
To replace a text in a file, you can invoke sed as in the following example :
% cat file.txt | sed -e 's/text/replacement/g' > result.txt
This will change all the occurences of “text” to “replacement” in “file.txt” and output the result in “result.txt”
Note : As suggested by Matthias from adminlife in the comments, if you wanted to do “in place” text replacement (that is modify the file without a temporary file in between), you can do the following :
Solaris 10: On which CD is that XYZ package ?
If you want to know on which CD is a package, without :
- Mounting CD
- Searching
- Unmounting
- Swear and
- Go back to 1
Then you can :
- Mount CD #1 (mount -F hsfs /dev/dsk/
/mnt or, if you have automount cd /cdrom/cdrom0 or something like that) - Go in the Solaris_10/Product directory of the CD
- Do grep -l
.virtual_packagetoc_* which will output the .virtual_packagetoc_N where N is the number of the CD holding that package.
Exemple :
CFEngine – Installing on Debian GNU/Linux
In this post we’ll install CFEngine on a Debian system. Debian make is really simple to install any packages, so let’s follow the “standard” package installation procedure (I’ll assume that apt is correctly setup on your system ! If you have troubles with it, let me know, I’ll write a post on this topic).
CFEngine – What is it ?
CFEngine is a configuration management engine. I’m going to write a series of short posts as I’m going to use CFEngine in a current project. Let’s start with a short description of CFEngine purpose and main features.
Keeping track of changes with cfengine and SubVersioN
Cfengine is a tool which purpose is to describe what is a healthy system and how to bring it back to normal when something fails.
I won’t go into an explanation about how cfengine works, because the project webpage already has a neat tutorial and complete reference. Instead of that, I’ll explain how I used cfengine to build a fool proof Linux firewall.
OpenBSD : Give money !!
not to me !! 😀
The OpenBSD project needs money to hold its events (such as hackaton, where developpers gather to implement features, or usual running costs).
If you think you don’t use OpenBSD, think again ! The project OpenSSH, which implements a free, and secure SSH implementation, comes from OpenBSD. It is widely used in many OSes and appliances …
We need OpenBSD !! Don’t hesitate to make a donation !
The original post
The OpenBSD project
The OpenSSH sister project