* You are viewing the archive for the ‘Linux’ Category

10 ways to generate random password from command line

Here’s 10 ways to generate random password:

For any of these random password commands, you can either modify them to output a different password length, or you can just use the first n characters of the generated password if you don’t want such a long password.

This method uses SHA to hash the date, runs through base64, and then outputs the top 32 characters.
date +%s | sha256sum | base64 | head -c 32 ; echo
This method used built-in /dev/urandom feature, and filter out only characters that you would normally use in a password. Then it outputs the top 32 characters.
< /dev/urandom tr … Continue Reading

Auto Optimize Your MySQL Tables Script

To make MySQL driven websites running fast, I’ve pieced together a script and cron job that will save you some support calls.

Step 1: Create a PHP script:
<?php
// Change vars as needed here
$server = “localhost”;
$user = “mysql_user”;
$pwd = “mysql_password”;
$dbName = “mysql_dbName”;

$link = mysql_connect($server, $user, $pwd);

if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}

$db_selected = mysql_select_db($dbName, $link);

if (!$db_selected) {
die (‘Can\’t use $dbName : ‘ . mysql_error());
}

// Find all tables in the selected DB
$alltables = mysql_query(“SHOW TABLES”);

// Process all tables.
while ($table = mysql_fetch_assoc($alltables))
{
foreach ($table as $db => $tablename)
{
Continue Reading

Stop Cron Job From Emailing

At the end of the cmd of the cronjob you can add: >/dev/null 2>&1
a line would look like this: etc/web/htdocs/cron.php >/dev/null 2>&1

Some useful ffmpeg commands

Extracting images from a video file using ffmpeg:

Extract single frame at 10th second (ffmpeg uses HH:MM:SS:sss format) of the video:
$ ffmpeg -i input.avi -r 1 -ss 00:00:10.000 -f image2 output_%05d.png
Extract a frame every 2 seconds of the video:
$ ffmepg -i input.avi -r 0.5 -f image2 output_%05d.png
Extract all frames from the input video:
$ ffmpeg -i input.avi -f image2 output_%05d.png
To combine images into a video file (avi container with HuffYUV encoding with 30 fps for this example).
One thing to not here is ffmpeg assumes the input frame rate is 25 by default and does not put all the frames inside the output … Continue Reading

Schedule tasks on Linux using crontab

If your website loads heavy on your web server, you might want to run some processes in the background such as sending emails to bulk users or thumbnail creation. Linux has a very good program for this called “cron”. It allows tasks to be automatically run in the background at regular intervals. You could also use it to automatically create backups, synchronize files, schedule updates, and much more.

Crontab
The crontab (cron derives from chronos, Greek for time; tab stands for table) command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically.
To see what crontabs … Continue Reading

nohup Execute command after closing shell script

Most of the time user login to remote server via ssh. If user start a shell command/script and exit (abort remote connection), process / command will get killed.
Even sometime job/command took longer time to execute. In such case user needs to run command/script in background even if remote connection aborts.

To accomplish such task user “nohup” command.
Use nohup utility which allows to run command/process or shell script that can continue running in the background after you log out from a shell:

nohup syntax:
           nohup command-name &
Where
        command-name: is name of shell script or command name. … Continue Reading

Basic SVN Commands

Basic SVN Commands:

I found good article for SVN basic commands.
Please visit the following link to check this out:
http://wiki.greenstone.org/wiki/index.php/Useful_SVN_Commands