mysql query logging
SET GLOBAL general_log=ON;
Samba Printing
This tutorial assumes the following:
You have a basic knowledge of unpacking tar files, command line usage and installing deb files using dpkg. Overall a basic knowledge of the linux commandline.
You have SAMBA 3.x installed
You have the latest CUPS installed
You are not looking for a restricted or AD based printing setup. Just a general printing share setup with Windows clients drivers. Restricted SAMBA/CUPS printing is outside of the scope of this document.
The following server setup was built using Ubuntu server 7.10 If you MUST use a GUI I recommend downloading and installing webmin to manage the samba component (again not covered in this document)
Below is the SMB.conf file used to make this configuration fully push windows drivers out to Windows clients.
[global]
load printers = yes
printing = cups
printcap name = cups
security = share ##Change to user ONLY when installing or updating drivers see step 5 for details##
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
public = yes
guest ok = yes
writable = no
printable = yes
[print$]
comment = Printer Drivers
path = /etc/samba/drivers
browseable = yes
guest ok = yes
read only = yes
write list = root
###Important!! if a print server is ALL you are running then this config will work and be secure enough. It is generally not recommended with most samba setups to have security = share. However for a standalone print server without restrictions this should work just fine.
1. Setup your CUPS printers (Plenty of CUPS howtos)
2. Download the CUPS windows drivers
You can use alien to convert the RPM to a deb OR use the tar.gz file
here is my experience
3. use the above smb.conf save it then restart samba
/etc/init.d/samba restart
(or if you have debian helper scripts installed)
service samba restart
4. add root to your samba setup.
smbpasswd root
(create your password at the prompt) Do not skip or you will get errors in the next step.
5. IMPORTANT!! Set smb.conf security = share to user or else the command WILL fail. Disconnect the system from the network othereise the next command will likley fail. It is searching for a domain controller.
type cupsaddsmb -H localhost -U root -a -v (enter password set in smbpasswd)
-your output should demonstrate that the files were copied.
If you are getting errors please post them in this thread.
After all this is done change the line on your smb.conf security = user back to share and then restart samba.
Assuming you have printers already setup your windows client should now be able to connect AND get the drivers. If you get a message stating you need to install a driver on the windows side, then something is still wrong. The cupsaddsmb did not work. However these are the configuration steps that worked for me after much research and reading. I hope they also prove useful to others as I am sure I am not the only one dealing with this.
source:
linux hp p1005
hp-setup -i
если соответствующий плагин не скачивается автоматически, то попробовать скачать вручную и указать путь
linux sensors
sensors-detect
/etc/init.d/module-init-tools start
sensors
hddtemp:
hddtemp /dev/sd?
Кракозябры в XP
"1250"="c_1251.nls"
"1251"="c_1251.nls"
"1252"="c_1251.nls"
gnome desktop restrict operations
#close mounted volumes to unprivileged users
chgrp admin -R /media
chmod 770 -R /media
#restrict gnome desktop changes
chown root:root -R /home/user/.gconf
chmod 774 -R /home/user/.gconf
/etc/ppp/peers/3g
/dev/ttyUSB0
115200
crtscts
noauth
usepeerdns
replacedefaultroute
defaultroute
user ""
password ""
/etc/ppp/3g
ECHO ON
ABORT '\nBUSY\r'
ABORT '\nERROR\r'
ABORT '\nNO ANSWER\r'
ABORT '\nNO CARRIER\r'
ABORT '\nNO DIALTONE\r'
ABORT '\nRINGING\r\n\r\nRINGING\r'
ABORT '\nUsername/Password Incorrect\r'
'' \rAT
OK 'AT+CGDCONT=1,"IP","internet"'
OK ATD*99#
CONNECT ""
port forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward # - Enables packet forwarding by kernel
iptables -P FORWARD ACCEPT
#for static purposes set something like that net.ipv4.conf.default.forwarding=1 (net.ipv4.ip_forward=1) in /etc/sysctl.conf# OR may ACCEPT only specified ports: iptables -A FORWARD -p tcp -i eth 0 -d 192.168.88.88 --dport 80 -j ACCEPT
service on port 80 at 192.168.69.88
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8888 -j DNAT --to 192.168.69.88:80
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
or iptables -t nat -A POSTROUTING -s 192.168.69.88 -p tcp --dport 80 -o eth0 -j MASQUERADE
shell
for (( i = 1; i < = 9; i++ )) ### Outer for loop ###
do
for (( j = 1 ; j < = 9; j++ )) ### Inner for loop ###
do
tot=`expr $i + $j`
tmp=`expr $tot % 2`
if [ $tmp -eq 0 ]; then
echo -e -n "\033[47m "
else
echo -e -n "\033[40m "
fi
done
echo -e -n "\033[40m" #### set back background colour to black
echo "" #### print the new line ###
done
for i in `seq 0 9`
do
echo $i
done
case $variable-name in
pattern1) command
...
..
command;;
pattern2) command
...
..
command;;
patternN) command
...
..
command;;
*) command
...
..
command;;
esac
case $rental in
"car") echo "For $rental Rs.20 per k/m";;
"van") echo "For $rental Rs.10 per k/m";;
"jeep") echo "For $rental Rs.5 per k/m";;
"bicycle") echo "For $rental 20 paisa per k/m";;
*) echo "Sorry, I can not gat a $rental for you";;
esac
http_proxy
1.
$ sudo nano -w /etc/bash.bashrc
then place the following at end of file:# export http_proxyort
if [ -z "$http_proxy" ]; then
export http_proxy=";
fi
2.$ sudo nano /etc/environment
then place the following at end of file:
http_proxy=";
3. place new file to /etc/profile.d/ with content export http_proxy=";
router
echo 1 > /proc/sys/net/ipv4/ip_forward # - Enables packet forwarding by kernel
iptables -P FORWARD ACCEPT
#for static purposes set something like that net.ipv4.conf.default.forwarding=1 (net.ipv4.ip_forward=1) in /etc/sysctl.conf#Допустим нам надо открыть доступ до интернета компьютеру с ip-адресом 192.168.1.22, тогда:
iptables -A POSTROUTING -t nat -s 192.168.1.22 -j MASQUERADE
#Or for network
iptables -A POSTROUTING -t nat -s 192.168.1.22/24 -j MASQUERADE
iptables-save > /etc/network/firewall.conf
#в /etc/network/interfaces в соответствующем интерфейсе добавить spre-up iptables-restore < /etc/network/firewall.conf
#либо закинуть скрипт с таким же содержимым в /etc/network/if-pre-up.d/
Apt-Cacher-ng
When an apt-get like client issues a request for a file, Apt-Cacher intercepts it and if the file is already cached it serves it to the client immediately,
otherwise it fetches the file from the Internet, saves it on the cache, and then serves it to the client.
This means that several Debian machines can be upgraded but each package need to be downloaded only once.
Apt-Cacher-NG does not require neither an interpreter, nor a web server and not even a huge runtime library.
It does never fork after server startup, it does not create flag files, flock() files or similar. Instead, it uses native system functions (mmap, sendfile) to operate with few overhead.
1. Install Apt-Cacher-NG on the server machine
# Download the latest version from the from the Debian pool, it will
# have fewer bugs and, usually, will work perfectly on Ubuntu:
curl -O
sudo dpkg -i apt-cacher-ng_0.4-1_i386.deb
2. Configure (apply to server and each client machine)
# search & replace 192.168.1.100 by the IP of the machine that will act as apt-cacher-ng server
2.1. Add a proxy entry to the apt system
# enable proxy usage by apt-get, aptitude, etc.
echo 'Acquire::http { Proxy ";; };' | sudo tee /etc/apt/apt.conf.d/01apt-cacher-ng-proxy
2.2. To also use Synaptic, configure its proxy settings:
# enable proxy usage by Synaptic:
sudo sed -i 's/httpProxy .*/httpProxy "192.168.1.100";/' /root/.synaptic/synaptic.conf
sudo sed -i 's/httpProxyPort .*/httpProxyPort "3142";/' /root/.synaptic/synaptic.conf
sudo sed -i 's/ftpProxy .*/ftpProxy "192.168.1.100";/' /root/.synaptic/synaptic.conf
sudo sed -i 's/ftpProxyPort .*/ftpProxyPort "3142";/' /root/.synaptic/synaptic.conf
sudo sed -i 's/useProxy .*/useProxy "1";/' /root/.synaptic/synaptic.conf
sudo grep Proxy /root/.synaptic/synaptic.conf
# ...or enable proxy using the Synaptic GUI:
a) In Synaptic go to "Settings- >Preferences- >Network"
b) click "Manual Proxy Configuration"
c) enter:
HTTP Proxy: 192.168.1.100 3142
FTP Proxy: 192.168.1.100 3142
Click OK
Click Reload
2.3. To stop using the proxy:
# disable proxy usage by apt-get, aptitude, etc.
sudo rm /etc/apt/apt.conf.d/01apt-cacher-ng-proxy
# disable proxy usage by Synaptic
sudo sed -i 's/useProxy.*/useProxy "0";/' /root/.synaptic/synaptic.conf
# stop the proxy server
sudo /etc/init.d/apt-cacher-ng stop
# update the default apt system
sudo aptitude update
click Reload in the Synaptic GUI
# to completly remove the proxy from your system
#sudo aptitude purge apt-cacher-ng
#sudo rm -fr /var/cache/apt-cacher-ng
3. Dashboard & manual
# see the apt-cacher-ng dashboard at: < >
# see apt-cacher-ng User Manual at: (right click at the link and open with your browser): < file:///usr/share/doc/apt-cacher-ng/html/index.html >
4. Import .deb files
4.1. from the local apt cache
test -x /var/cache/apt-cacher-ng/_import || sudo mkdir -p -m 2755 /var/cache/apt-cacher-ng/_import
sudo cp -alf /var/cache/apt/archives/* /var/cache/apt-cacher-ng/_import/
sudo chown -R apt-cacher-ng /var/cache/apt-cacher-ng/_import
# click "start import" at: < >
# cleanup and update apt cache index files
sudo rm -fr /var/cache/apt-cacher-ng/_import
sudo rm -fr /var/cache/apt/archives/*.deb
sudo rm /var/cache/apt/*cache.bin
sudo rm /var/lib/apt/lists/*Packages
sudo rm /var/lib/apt/lists/*Sources
sudo aptitude update
4.2. from an external backup
sudo /etc/init.d/apt-cacher-ng stop
sudo rsync -vau /path_to_the_backup/ /var/cache/apt-cacher-ng/
sudo /etc/init.d/apt-cacher-ng start
# continue from 4.1
## -- END --
vsftpd basic config
listen=YES
anonymous_enable=YES
anon_root=/media/ftp #don't give 777 to anon_root
#anon_world_readable_only=YES
no_anon_password=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
local_enable=YES
local_root=/media/ftp
local_umask=022 #umask 0 означает оставить все биты прав, umask 777 запрещает #выставление любых прав.
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
chown_username=aia
chown_upload_mode=0644
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to aia's FTP service.
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
служба с автозапуском на примере rtorrent c загрузкой конф.файлов
# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using ABSOLUTE paths (no, ~ is not absolute) in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" option.
# Attach to the screen session as your user with
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
##############
###< /Notes >###
##############
#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file
# (so that it is saved with upgrades, saved in your home directory,
# or whateve reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf
#Do not put a space on either side of the equal signs e.g.
# user = user
# will not work
# system user to run as
user="aia"
# the system group to run as, not implemented, see d_start for beginning implementation
# group=`id -ng "$user"`
# the full path to the filename where you store your rtorrent configuration
config="`su -c 'echo $HOME' $user`/.rtorrent.rc"
# set of options to run with
options=""
# default directory for screen, needs to be an absolute path
base="`su -c 'echo $HOME' $user`"
# name of screen session
srnname="rtorrent"
# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
###END CONFIGURATION###
#######################
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
DESC="rtorrent"
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME
checkcnfg() {
exists=0
for i in `echo "$PATH" | tr ':' '\n'` ; do
if [ -f $i/$NAME ] ; then
exists=1
break
fi
done
if [ $exists -eq 0 ] ; then
echo "cannot find rtorrent binary in PATH $PATH" | tee -a "$logfile" >&2
exit 3
fi
if ! [ -r "${config}" ] ; then
echo "cannot find readable config ${config}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
exit 3
fi
session=`getsession "$config"`
if ! [ -d "${session}" ] ; then
echo "cannot find readable session directory ${session} from config ${config}. check permissions" | tee -a "$logfile" >&2
exit 3
fi
}
d_start() {
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "screen -dm -S ${srnname} 2 >&1 1 >/dev/null" ${user} | tee -a "$logfile" >&2
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (e.g. running under an undesirable gid
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2 >&1 1 >/dev/null\"" ${user} | tee -a "$logfile" >&2
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2 >&1 1 >/dev/null" ${user} | tee -a "$logfile" >&2
}
d_stop() {
session=`getsession "$config"`
if ! [ -s ${session}/rtorrent.lock ] ; then
return
fi
pid=`cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
if ps -A | grep -sq ${pid}.*rtorrent ; then # make sure the pid doesn't belong to another process
kill -s INT ${pid}
fi
}
getsession() {
session=`cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" `
echo $session
}
checkcnfg
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
и далее
Меняем в строке user="user", "user" на Ваше имя пользователя.
Теперь собственно добавляем автозапуск, и стартуем rtorrent:
# chmod +x /etc/init.d/rtorrent
# update-rc.d rtorrent defaults
# /etc/init.d/rtorrent start
create deluge daemon
### BEGIN INIT INFO
# Provides: deluge-daemon
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemonized version of deluge and webui.
# Description: Starts the deluge daemon with the user specified in
# /etc/default/deluge-daemon.
### END INIT INFO
# Author: Adolfo R. Brandes
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Deluge Daemon"
NAME1="deluged"
NAME2="deluge"
DAEMON1=/usr/bin/deluged
DAEMON1_ARGS="-d"
DAEMON2=/usr/bin/deluge
DAEMON2_ARGS="-u web"
PIDFILE1=/var/run/$NAME1.pid
PIDFILE2=/var/run/$NAME2.pid
PKGNAME=deluge-daemon
SCRIPTNAME=/etc/init.d/$PKGNAME
# Exit if the package is not installed
[ -x "$DAEMON1" -a -x "$DAEMON2" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
# Define LSB log_* functions.
# Depend on lsb-base ( >= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
if [ -z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES" ]
then
log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
exit 0
fi
if [ -z "$DELUGED_USER" ]
then
log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME."
exit 0
fi
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --exec $DAEMON1 \
--chuid $DELUGED_USER --user $DELUGED_USER --test > /dev/null
RETVAL1="$?"
start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
--chuid $DELUGED_USER --user $DELUGED_USER --test > /dev/null
RETVAL2="$?"
[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 1
start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile --exec $DAEMON1 \
--chuid $DELUGED_USER --user $DELUGED_USER -- $DAEMON1_ARGS
RETVAL1="$?"
sleep 2
start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
--chuid $DELUGED_USER --user $DELUGED_USER -- $DAEMON2_ARGS
RETVAL2="$?"
[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2
RETVAL2="$?"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
RETVAL1="$?"
[ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2
rm -f $PIDFILE1 $PIDFILE2
[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] && return 0 || return 1
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME1"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
############### + /etc/default/deluge-daemon contents
# Configuration for /etc/init.d/deluge-daemon
# The init.d script will only run if this variable non-empty.
DELUGED_USER="< username >" # !!!CHANGE THIS!!!!
# Should we run at startup?
RUN_AT_STARTUP="YES"
##########################################
chmod +x /etc/init.d/deluge-daemon
update-rc.d deluge-daemon defaults
squid via ncsa
## be careful with squid port (default 3128)
http_port 8080
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
# Also find out your ACL section and append/modify
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users
### Create users
#apt-get install libpam-pwdfile // to use pwdfiles ??
htpasswd /etc/squid/passwd new_user
# Make sure squid can read passwd file:
chmod o+r /etc/squid/passwd