[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 regular file) or open it with Software Installer. (I’m talking about KDE, don’t know about Gnome Nautilus). Moreover, if you choose to open it with ark, it doesn’t recognise the format. Of course, the easiest way would be to launch Midnight Commander, “enter” this file as if it was a regular folder and copy whatever you need, but we are looking for a non-interactive and more straightforward method here.

Incantation:

rpm2cpio file.rpm | cpio -t
rpm2cpio file.rpm | cpio -i

Notes:
*) rpm2cpio converts the .rpm file specified as a single argument to a cpio archive on standard out;
*) The -t switch of cpio prints a table of contents of the input, and the -i does the extraction;
*) I tested this on Fedora;
*) The command rpm2cpio is a part of the rpm package on Fedora. You should see how to obtain it for your distro;
*) The command cpio is a separate package on Fedora. You should see how to obtain it for your distro;

Advertisements
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 = '%';
FLUSH PRIVILEGES;

To enable MySQL service to accept connections from all hosts change the following line in file mysql.conf:
bind-address=127.0.0.1
to
bind-address=0.0.0.0
or better just comment out:
#bind-address=127.0.0.1
and restart the MySQL service.

Notes:
*) The percent symbol ("%") in the notation root@"%" means “any host”, but it doesn’t imply localhost. You need to repeat the commands above with root@localhost in order to grant/revoke permissions for localhost.

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 the password.

Notes:
1) It’s OK to use domain users in both cases ("domainusername"). You need to use quotes to escape the backslash.

2) You can give the password in the commandline options list like this:
-o username="domainusername",password=topsecret
Note that this syntax saves the password. Also, it will be visible in the processes list.

3) The -t smbfs option can usually be omitted. The mount command should detect the type automatically.

See: http://cri.ch/linux/docs/sk0001.html

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 you supply a log message with the -m flag, CVS starts an editor and prompts for a message;
*) The string vendor is a vendor tag, and start is a release tag. They may fill no purpose in this context, but since CVS requires them they must be present;
*) working does not need to be under your local CVS directory structure at all. It can be anywhere on your hard disk. The only thing that matters is the CVSROOT- related path you specify to be used by the import command (tools/mysources, in this case);
*) cvs import does not change the directory in which you invoke it. In particular, it does not set up that directory as a cvs working directory. If you want to work with the sources, import them first and then check them out into a different directory;
*) The synopsis of the command is: import [-options] repository vendortag releasetag... This command imports everything under the current working directory. I didn’t find a way to specify particluar items to import;
*) If the mysources directory in the CVSROOT does not exist, it will be created and everything under /tmp/working/* will be added there. If mysources exists, everything under /tmp/working/* will be added there, preserving the original content that was there before;

See: this reference from ximbiot.com for more info on the topic.

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 to use:

Incantation:

sed -i -e "/^tw.*$/d" testfile

Result:
now testfile has this content:

one
three

Notes:
*) -i stands for “in-place”, i.e. perform the command directly in the file (GNU sed only);
*) The caret (^) matches the beginning of the line;
*) A period (.) matches any single character;
*) The asterisk (*) matches zero or more occurrences of the previous character;
*) The dollar sign ($) matches the end of the line;
*) d is the delete command;

Posted in console | Tagged | Leave a comment