Skip to main content

Commands

Useful DB Queries for Drupal Applications

Submitted by system on
Show grouped node counts based on OG group ids for nodes created after a particular time stamp select gid, count(*) from og_membership inner join node on og_membership.etid = node.nid and node.created >= 1678127400 group by gid;
Show node type specific node count list select type,count(*) from node group by type;
Show group membership wise node counts select gid,count(*) from og_membership group by gid;
Start the node next Increment number from a specific nid ALTER TABLE node AUTO_INCREMENT = 20000000;

Optimizing Images using command line

Submitted by system on
The images uploaded by users may not be of ideal size and may require compression to manage server space. There are some tools available for compressing JPG and PNG files. Please note that the owner changes to the current username for the file after compression. Please remember to change ownership if required of the file or per folder post compression. jpegoptim : Optimize a jpg image with the same name jpegoptim image.jpg
Optimize all jpg images in a folder jpegoptim *.jpg

Keyboard Key bindings in Ubuntu

Submitted by system on
My laptop keyboard faced a particular problem with both Ctrl keys not working. It was a hardware issue and only keyboard replacement would resolve. I searched for alternatives where I could replace any key not being used to Ctrl key. xmodmap is a utility for modifying keymaps and pointer button mappings in Xorg. To do the same, I replaced the Menu Key in keyboard(keycode = 135) which acts like a right click and mapped it as right control key. To do so, one would need to create the file ~/.Xmodmap and update with the following data. !clear the control keys
clear control

MySQL handly commands

Submitted by amitsedai on
To prevent duplicate entry issue - replace INSERT into with REPLACE INTO . DEF: REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted. REPLACE into table (id, name, age) values(1, "A", 19)
Run Optimize of All tables of a database: mysqlcheck -o db_to_optimize -udb_user -p
All databases mysqlcheck -o --all-databases -udb_user -p

Drupal Features Update and Revert

Submitted by amitsedai on
Features Update: Update a feature module on your site. This updates the feature module in the site if the components are overriden drush fu
Features Revert: Revert a feature module on your site. Reverts the basic configuration in the module onto the site removing any custom configurations made at the database end. drush fr

Sendmail

Submitted by amitsedai on
You can use the mailq command sendmail -bp command to display a summary of the mail messages queued for future delivery. mailq
OR sendmail -bp
Remove all queued mails from: /var/spool/mqueue cd /var/spool/mqueue/
ls
rm *

-- Source http://www.cyberciti.biz/faq/linux-unix-bsd-clear-sendmail-queue/

Handy Linux Commands

Submitted by amitsedai on
Split: Split a text file in half (or any percentage) on Ubuntu Linux The following command splits access.log files into multiple files with 6000 lines each split -l 6000 access.log
Split files into size of 5M each split --bytes 5M --numeric-suffixes --suffix-length=3 foo.mysql last_part.mysql
Diff : Get Difference between files and folders Following command provides recursive difference diff -r dir1/ dir2/

Using Drush Alias

Submitted by amitsedai on
drush aliases allow you to run a drush commands on your local server but actually execute the command on a remote server. One can create aliases in a folder that drush recognizes, mostly inside the .drush folder for Linux Based Systems. For a mysite example, we can create a file called as mysite.aliases.drushrc.php inside the .drush folder (Or any folder which Drush goes through before executing). All aliases in a site can also be combined in a single file called as aliases.drushrc.php Example data that can be added to mysite.aliases.drushrc.php <?php