Author Archives:

[HOWTO] Create a large file that occupies no space

dd if=/dev/zero of=largefile count=0 obs=1 seek=200G

[TIP] Find newest (last modified) files

find . -type f -printf “%TY-%Tm-%Td %TT %p\n” | sort | tail -5 or find . -type f -printf “%TY-%Tm-%Td %TT %p\n” | sort -r | head -5

[TIP] Avoid SSH security question

ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null user@host

[TIP] Force variable substitution within single quotes in BASH

Sometimes in a BASH script you need to have single quotes but the value inside them is actually a variable. Here is how to have both the single quotes and the actual value of the variable expanded. % foo=bar % echo $foo bar % echo “$foo” bar % echo ‘$foo’ $foo % echo “‘$foo’” ‘bar’ [...]

[TIP] Count non-empty lines in a text file

grep -c -v ‘^$’ filename If you want to, as well, exclude lines which contain only spaces: grep -c -v ‘^ *$’ filename Notes (from the grep man page): -c, –count Suppress normal output; instead print a count of matching lines for each input file. With the -v, –invert-match option (see below), count non-matching lines. [...]

[HOWTO] Install and Configure FreeBSD 7.1 on VMware Workstation 6.5 From the Ground Up

This HOWTO shows a step-by-step installation and configuration of FreeBSD 7.1 from scratch. The reader should have a basic Linux and/or Unix knowledge and should feel comfortably with the console. Throughout this document, by “VMware” I’m actually referring to “VMware Workstation”. Note: This is a work in progress, I add content and, from time to [...]

[HOWTO] Mount ISO Image File on AIX

The usual mount -o ro,loop image.iso /mnt/iso/, which you’re used to on Linux, can’t be used on AIX. On AIX you dd the ISO file into a raw Logical Volume, then mount the LV as a filesystem. Here are the steps for copying the ISO named image.iso into the folder /mnt/iso/ (a JFS filesystem): 1. [...]

[TIP] View or Extract RPM Packages Content

Case: You have an RPM package file, for example file.rpm. You want to view what files it contains, and then extract them just as if it was a .tar.gz archive. By the way, it’s a pity Konqueror doesn’t provide a reasonable context menu when you rightclick on it, but only offers to compress (like any [...]

[HOWTO] Grant and Revoke Remote root Access to MySQL

To grant root access from all hosts (except for localhost): GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY ‘topsecret’; To revoke root access from all hosts (except for localhost): DELETE FROM mysql.user WHERE User = ‘root’ AND Host = ‘%’; FLUSH PRIVILEGES; To enable MySQL service to accept connections from all hosts change the [...]

[TIP] Mount a Windows share on Linux

To test if your Linux machine sees the shares on the Windows box: smbclient -L windowsbox -U username and it prompts you for the password. Mount the share: mount -t smbfs -o username=john //winbox/share /mnt and it prompts you for the password. Notes: 1) It’s OK to use domain users in both cases (“domainusername”). You [...]

[TIP] Mount ISO Image File on Linux

Once you’ve downloaded an ISO image file, you can mount it as a loopback device. This will give you access to the files in the ISO without having to burn it to a CDROM first. mount -o ro,loop image.iso /mnt/iso/

[HOWTO] Import a Directory Tree in CVS

Case: Let the directory tree you want to put under CVS control resides in /tmp/working, and you want it to appear in the repository as ${CVSROOT}/tools/mysources. Incantation: cd /tmp/working cvs import -m “Imported sources” tools/mysources vendor start Notes: *) Unless you supply a log message with the -m flag, CVS starts an editor and prompts [...]

[TIP] delete a line in-place with GNU sed

Case: Suppose you have a file named testfile with the following content: one two three Say, you want to delete those lines that start with the string tw (that is two in our example). Here is the GNU sed command to use: Incantation: sed -i -e “/^tw.*$/d” testfile Result: now testfile has this content: one [...]

Follow

Get every new post delivered to your Inbox.