Author: Josh
-
MySQL /tmp Usage with Optimize Table Command
I’m currently trying to prune a MyISAM table with 200 million rows down to 100 million rows. As part of this process, I am simply removing any orphaned records. This is a simple tracking table where every record must have an associated record in the users table. The total size on disk is 11G of…
-
Command line replace with perl
I often run into issues on the command line where I’d like to perform a non-greedy search and replace. This is not possible with sed, grep, or egrep, AFAIK, so I must resort to perl. Here is how it’s done: perl -pe ‘s|”http://(.*?)/.*$|$1|g’ The above example will take a list of requested URIs or search…
-
Apache – Getting rid of (internal dummy connection) in the logs.
On busy sites the (internal dummy connection) message in apache logs can be a major annoyance as it fills the logs. A simple way to filter this out is to use the following log declarations (assuming IPV6 capable host): SetEnvIf Remote_Addr “::1” dontlog CustomLog /var/log/httpd/access_log combined env=!dontlog RE: http://wiki.apache.org/httpd/InternalDummyConnection
-
Decode base64 text using perl from the command line
I recently ran into an issue where I needed to decode some base64 text from the command line and used perl to manage the task: perl -MMIME::Base64 -ne ‘print decode_base64($_)’ < /tmp/input.txt RE: http://perldoc.perl.org/MIME/Base64.html
-
Removing memberUid from OpenLDAP group
The following syntax can be used to remove a user from an OpenLDAP group: $ ldapmodify -x -D “cn=manager,dc=example,dc=com” -W <<EOF > dn: cn=sshusers,ou=groups,dc=example,dc=com > changetype: modify > delete: memberUid > memberUid: previousMember > EOF
-
VIM Control Characters – search and replace
Control characters require an escape sequence prior to using in a search and replace operation in VIM. In Linux, the escape character is Ctl-v. Windows requires a Ctl-q. Remove all ^M characters from a file on Linux: %s/^V^M//g Remove all ESCAPES (\27, ^[) from a file on Windows: %s/^q^[//g
-
Bash Tip! Renaming files using Bash string operations
To rename all html files in a particular directory to shtml files, use the following loop: for file in *.html do mv ${file} ${file%%.html}.shtml done This uses the ${variable%%match} format which strips the longest match from the end of the variable.
-
Samba 3.4 Changes idmap backend!
I recently upgraded some hosts to Fedora 11 which has Samba 3.4 included. I configure most of the hosts I control to be integrated with Active Directory for authentication and this upgrade broke that authentication. The problem was that the winbind daemon was not able to query the LDAP server which was used as the…
-
error while loading shared libraries: : cannot open shared object file: No such file or directory
A fairly typical scenario when installing software that does not come fro the distribution package manager is to install an application and find that it cannot find a library necessary to run, although the library is definitely installed. I recently ran into this issue when compiling spine on an old Debian Sarge system. $ ./spine…
-
History with time stamps!
When reviewing the history file in bash, it’s terrible not knowing when a command was executed. Using the HISTTIMEFORMAT variable in a .bashrc file, the timestamp can be added to all commands. # ~/.bashrc HISTTIMEFORMAT=”%m/%d/%y %I:%M:%S %p ” Sample output: 525 05/21/09 07:56:46 PM tail -f /var/log/messages /var/log/secure As you can see, the command is…