Author Archives: ptankov

[HOWTO] Create a large file that occupies no space

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

Posted in Uncategorized | Leave a comment

[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

Posted in console | Leave a comment

[TIP] Avoid SSH security question

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

Posted in console | Tagged | Leave a comment

[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 % … Continue reading

Posted in console | Tagged | 4 Comments

[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 … Continue reading

Posted in console | Tagged , , | Leave a comment

[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 … Continue reading

Posted in console | Tagged , | 6 Comments

[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 … Continue reading

Posted in console | Tagged | 2 Comments

[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 … Continue reading

Posted in console | Tagged | Leave a comment

[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 = … Continue reading

Posted in console | Tagged | 4 Comments

[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 … Continue reading

Posted in console | Tagged , , | Leave a comment

[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/

Posted in console | Tagged , , | 1 Comment

[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 … Continue reading

Posted in console | Tagged | Leave a comment

[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 … Continue reading

Posted in console | Tagged | Leave a comment