Tag Archive for unix

Preventing Apache memory leaks with ulimit

#!/bin/sh

HTTPD=/usr/local/apache2/bin/httpd
CONF=/bmi/httpd-php/conf/httpd.conf

exec 2>&1
echo starting...
ulimit -v 100000
exec $HTTPD -f $CONF -D NO_DETACH

source

Password Protect Folder / Directory with htaccess and htpasswd on Apache and Linux / Unix

Step 1 - Create .htaccess file in folder you want to protect, copy the code and paste the code below, and then set server path to the file

AuthUserFile /path/to/.htpasswd
AuthName "Restricted Area"
AuthType Basic
Require valid-user

Step 2 - Open Terminal, go to the directory you want to protect, and enter the following (changing the username to whatever you want). Enter the password upon prompting.

htpasswd -c .htpasswd username

source

fix permissions for files and directories

chmod -R u=rwX,go=rX .

source

Fill a disk with zeroes

dd if=/dev/zero of=/dev/hda/zero bs=512

source

Get the total disk space remaining

df -h

source

Get the disk space used by a directory

du -sh /path/to/dir

source

using find to list old files based on date

find /var/log -mtime -14 -type f -exec ls -al {} ;

source

Unmount All AFP Network Shares

mount | awk '/^afp_/ { system("umount -f " $3) }'

source

Compare Directories Using Diff

diff -qr dirA dirB | grep -v -e 'DS_Store' -e 'Thumbs' | sort

source

ffmpeg compilation with AMR/3GP (for flash video encoding)

./configure --enable-mp3lame --enable-amr_nb --enable-amr_nb-fixed --enable-amr_wb --enable-a52 --enable-gpl --extra-cflags=-I/usr/local/include/ --extra-ldflags=-L/usr/local/lib/

source