====== Beginner / Session 4 ======
----
===== فایلها و دایرکتوریها =====
cat -n -s
cat -s file.txt | tr -s ' ' | tr -s '\n' | tr 'a' 'Z'
tac / rev
split
split -b 1G file.tar.xz "file.tar.xz.part."
cat file.tar.xz.* | tar xJf -
chmod 644 755 +x -x
chown -R / chgrp -R
md5sum
md5sum test.txt
cat test.txt | md5sum
echo "testing" | md5sum
echo -n "testing" | md5sum
cp -rv / mv / rm -rf
sync
rsync -av --progress --dry-run -e 'ssh -p22022' --delete
find / updatedb / locate
grep / egrep / fgrep / rgrep
tar / gzip / gunzip / zcat / zless / zgrep / bzip2 ...
head -n / tail -f
hexdump -C / string / strace / ldd
dos2unix
ln -sfn
ls -ctrlh
touch
mkdir -p / cd / rmdir / tree
rm -rf
sort / uniq -c / wc -l
diff -ruN
----
===== کامپایل و نصب squid =====
cd /usr/src
wget "http://www.squid-cache.org/Versions/v6/squid-6.3.tar.gz"
tar xf squid-6.3.tar.gz
cd squid-6.3
./configure --help | less
./configure
make
make install
# Compile & Install
# Config: /usr/local/squid/etc/squid.conf
# Permission
# Start & Check : /usr/local/squid/sbin/squid --help
# Automatic start
# Log rotation
/usr/local/squid/sbin/squid -N
chown -R nobody:nogroup /usr/local/squid/var/logs/
#!/bin/bash
#
# /etc/rc.d/rc.squid
#
PIDFILE="/usr/local/squid/var/run/squid.pid"
TIMEOUT=60
start()
{
echo -n 'Starting TPROXY Squid . . . '
PROCESS=$(ps -A | egrep ' squid$')
if [ "$PROCESS" == "" ]; then
if [ -f ${PIDFILE} ] ; then
rm ${PIDFILE}
fi
fi
ulimit -HSn 16384
ulimit -HSd unlimited
/usr/local/squid/sbin/squid
echo "Ok"
}
stop()
{
echo 'Stoping TPROXY Squid'
/usr/local/squid/sbin/squid -k shutdown
TIME=0
while [ "$TIME" != "$TIMEOUT" ] ; do
TIME=$(( $TIME + 1 ))
echo -n $TIME
if [ "$(pgrep '^squid$')" == "" ]; then
if [ -f ${PIDFILE} ] ; then
rm ${PIDFILE}
fi
break
else
echo -n "."
fi
sleep 1
done
killall squid &> /dev/null
killall squid &> /dev/null
killall squid &> /dev/null
echo ".Ok"
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'rotate')
echo -n 'Rotating TPROXY Squid log files . . . '
/usr/local/squid/sbin/squid -k rotate
echo "Ok"
;;
*)
echo "usage $0 start|stop|restart|rotate"
;;
esac
# /etc/logrotate.d/squid
/usr/local/squid/var/logs/access.log {
daily
rotate 186
start 1
copytruncate
compress
compresscmd /usr/bin/bzip2
compressext .bz2
compressoptions -sq9
dateext
notifempty
missingok
}
/usr/local/squid/var/logs/cache.log /usr/local/squid/var/logs/store.log {
daily
rotate 31
start 1
copytruncate
compress
compresscmd /usr/bin/bzip2
compressext .bz2
compressoptions -sq9
dateext
notifempty
missingok
sharedscripts
postrotate
/usr/local/squid/sbin/squid -k rotate
endscript
}