Archive for the ‘linux’ Category

Ever want to immediatly serve content from a specific directory over HTTP, but didn’t want to bother messing with
httpd.conf or other webserver configiurations?

If you’ve got Python installed, this is a snap. Execute python with the SimpleHTTPServer module, using port 8080 so
there isn’t a need to elevate privs to root.

 python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 …

or python3 -m http.server 8080

Sure enough, pointing a browser to the IP address :8080 of the box hits my home directory listing. Super easy, super
fast, super simple!

I use this to serve content to my PS3. The PS3 doesn’t support NFS or CIFS, so to download content to the hard drive,
the best method is by pulling it over HTTP with the embedded web brower. On my MacBook, I change into the directory
containing whatever media I want to transfer, fire up HTTP, and suck it down to the hard drive on the PS3. Nice!

source: http://prefetch.net/blog/index.php/2009/10/31/serve-out-content-over-http-from-your-cwd-immediatly/

C:\Program Files\PS3 Media Server\win32>mencoder d:\77\DSC_0215.AVI -ovc x264 -x
264encopts bitrate=3200 -oac mp3lame -o d:\77\plc.mkv

You may check first what is the path of sendmail:
whereis sendmail or php -i | grep sendmail
move /usr/sbin/sendmail to something like /usr/sbin/sendmail.or
vi /usr/sbin/sendmail
put the code below:

#!/usr/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/formmail.log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n";
}
else {
print INFO "$date - $PWD - @info\n";
}
my $mailprog = '/usr/sbin/sendmail.or';
foreach (@ARGV) {
$arg="$arg" . " $_";
}
open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);


chmod a+x /usr/sbin/sendmail
touch /var/log/formmail.log
and chmod 777 /var/log/formmail.log

that should be all.

Full list of available commands    Ctrl-a Ctrl-?
Open a new screen in existing session    Ctrl-a Ctrl-c
Switch to last accessed screen    Ctrl-a Ctrl-a
Switch to next screen    Ctrl-a Ctrl-n
Switch to previous screens    Ctrl-a Ctrl-p
Disconnect, leaving the session running in background    Ctrl-a Ctrl-d
Split screen vertically    Ctrl-a Ctrl-S
Unsplit screen    Ctrl-a Ctrl-Q
Move focus between splits    Ctrl-a Ctrl-Tab
List currently opened screens    Ctrl-a Ctrl-S
Rename current screen    Ctrl-a Ctrl-A
Monitor a screen for silence    Ctrl-a Ctrl-_
To disconnect (but leave the session running)
Hit Ctrl + A and then Ctrl + D in immediate succession. You will see the message [detached]
To reconnect to an already running session
screen -r
To reconnect to an existing session, or create a new one if none exists
screen -D -r
To create a new window inside of a running screen session
Hit Ctrl + A and then C in immediate succession. You will see a new prompt.
To switch from one screen window to another
Hit Ctrl + A and then Ctrl + A in immediate succession.
To list open screen windows
Hit Ctrl + A and then W in immediate succession

cat /etc/passwd | awk -F: '{print $1}' | while read line; do echo $line; crontab -l -u $line; done

http://www.linuxscrew.com/2009/12/21/best-of-linux-cheat-sheets/

Atomic Archives

* [atomic] – stable rpm channel for packages created by ART.
* [atomic-testing] – near production quality packages created by ART.
* [atomic-bleeding]- untested, non-production packages with frequently zero testing, and known unresolvable compatibility issues created by ART. You shouldn’t be here unless you are me.
* [plesk] – 3rd Party channel for SW-Soft’s Plesk Server Administrator

GPG Key
All ART packages are signed with GPG. This is to ensure that the packages have not been tampered with. ART packages that fail the gpg check should be reported immediately.

Install the ART GPG key:
wget http://www.atomicrocketturtle.com/RPM-GPG-KEY.art.txt
rpm --import RPM-GPG-KEY.art.txt

Yum Atomic Archives
CentOS 3 – 5 / RHEL 3 – 5 / Fedora 4 – 10
The Atomic archives are available through the yum package manager for Fedora, RHEL and CentOS.These archives require access to both the vendors base and update channels, RHEL3 and RHEL 4 users are therefore recommended to access the atomic archives through up2date.

Automatic configuration
Using Lynx (yum -y install lynx):
lynx -source http://www.atomicorp.com/installers/atomic.sh | sh

Using Wget:
wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh

ls | while read line; do x=$(echo $line |egrep -o .*mp3); mv $line $x ;done

#!/bin/sh
SERVICE='named'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
cat /dev/null
else
echo "$SERVICE is not running... starting"
/etc/init.d/$SERVICE restart | mail -s "$SERVICE restarted" email@domain.tld
fi

p.s. do not name the script as the service 🙂

/usr/bin/mysql_secure_installation