Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
29 total  XML / RSS feed 

postfix - flush queues / logs

Using the program: postsuper

There are three queues (active, deferred, incoming) and four log directories (bounce, defer, trace, flush).

To remove all mails in the deferred queue:

postsuper -d ALL deferred


Note that all of the queues and log dirs are located in:
/var/spool/postfix

shutdown linux server

how to shutdown a linux box with -f skip fsck file system check, -r reboot.

You must always specify a time or the word: now. Give time in minutes by using: +m

shutdown -rf +1 "Scheduled test of system reboot"


Will reboot the server in one minute, skipping fsck on startup.

stop Apple Tiger dashboard advisory daemon

Useless daemon tries to contact Apple to make sure widgets installed in Dashboard are the right version (the fuck?)

udo mv /System/Library/LaunchDaemons/com.apple.dashboard.advisory.fetch.plist /System/Library/

bash terminal profile

// description of your code here

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export DISPLAY=:0.0
export EDITOR=/usr/bin/vim
case $TERM in
xterm* | aterm | rxvt | screen )
XTITLE="\[\e]0;\u (\w)\a\]" ;;
* )
XTITLE="" ;;
esac
PS1="$XTITLE""[\u:\w]\n\\$ "
. /etc/aliases_bash

prevent .DS_Store files being created everywhere by OS X

// description of your code here

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

add mysql symbolic link to OS X MacPorts installed mysql

instead of having to type out mysql5 each time I want to run mysql, make a symbolic link to mysql5

ln -s ../lib/mysql5/bin/mysql /opt/local/bin/mysql

mysql on OS X

mysql installed via ports by default resides in

/opt/local/share/mysql5/mysql


from this location you can start/stop mysql with the following

./mysql.server stop
./mysql.server start


to have a my.cnf file to edit

sudo cp my-small.cnf my.cnf

Customizing OS X keyboard

In order to change the mapping of the keyboard in OS X you must use Ukelele or a similar program to create a keylayout XML file in ~/Library/Keyboard Layouts. Once this file is created, it is available for use via System Preferences -> International -> Input Menu -> check the keyboards you want available for use.

Within Ukelele goto File -> New -> Copy of other keyboard layout -> (Within Finder) Macintosh HD/[Ukelele install dir]/System Keyboards/Roman/French.keylayout

Now you should see a basic layout of the keyboard. Pressing control keys such as alt and ctrl should show a different set of characters on the same keyboard. Note that the Windows key is the Apple key.

Open up the Character map (also found within Internation/Input Menu and activated via the same drop down as the keyboards in the top bar) and click and drag characters where you want them active on the keyboard. When finished with the layout, save the file, something with extension keylayout and put it within ~/Library/Keyboard Layouts. Logout and log back in and use the Input Menu to search for the keyboard you just named and highlight its checkbox. The keyboard should now be available from the top bar drop down menu. In some cases you may have to rename the layout file and logout/login for the changes to take effect.

send email with attachment from command line

useful for sending db backups

echo command is for the body
-s specifies the subject
-a gives the attachment
finally the recipient
email will be sent as root@serveraxis
echo "database backup for 070614" | mutt -s "backup: myerasmus_db_070614" -a erasmus_db_070614.sql.bz2.gpg [email address]

encrypt files using gpg

encrypt for recipient [Bob] [file]

gpg -e -r Bob file


decrypt, passphrase will be asked for
gpg --output <filename> -d [file] 

godaddy wildcard dns entry

To add a wildcard dns entry, make it an A record with proper IP address destination

@ <IP address of web server>
* <IP address of web server>

linux ubuntu ssh login

To replace the normal text password login with ssh public/private key pair....

Generate a pair at home (creates RSA based key pair)
ssh-keygen -t rsa

Enter in a passphrase when it asks.

upload the .pub key to the server
sftp root@<server address>
lcd /home/<your login>/.ssh
put id_rsa.pub


Login to the server normally as root.
Goto the .ssh directory
Append the public key to the authorized_keys
ssh root@<server address>
cd .ssh
cat id_rsa.pub >> authorized_keys


Then check that /etc/ssh/sshd_config has...
RSAAuthentication yes
PubkeyAuthentication yes

... in it

Restart the ssh server
/etc/init.d/ssh reload


Logout.
Try logging in again as root and you should be prompted for passphrase to your ssh key.

Use
ssh -v root@<server address>

to diagnose problems

linux server runlevel adminstration

To change system services from booting, or to set them to start at boot time use

First step is to create a symbolic link within /etc/init.d to the proggie that you want to service-ize

Here's an example with Apache 2.2
sudo ln -s /usr/local/sbin/apachectl /etc/init.d/apache2
sudo chmod +x /etc/init.d/apache2


Now we have to set which runlevels will use this program

sysv-rc-conf


This is a GUI interface into the various runlevels, what's currently running and not. Use space bar to
toggle whether a service is on or not.

NB: most servers run at runlevel:2

check which runlevel is default for the server by looking at:
/etc/inittab

postfix reload

To restart postfix and read main.cf and master.cf files from /etc/postfix

postfix reload

launch firefox ubuntu

first to find the big hex number
then to add it. Note the format of the command

xauth list
xauth add ubuntu/unix:0 . 8443108aff2df3cff0d91fa307ad3885

ubuntu linux headers install

for various reasons (like installing vmware tools)

apt-cache search linux-headers-$(uname -r)
apt-get install linux-headers-$(uname -r)

install rubygems on ubuntu

When compiling and installing rubygems it required the zlib module that wasn't installed in Ruby by default. To add in that functionality, go to the source Ruby directory, the ext directory, the zlib directory, then create the make file, then install it.

Make sure you have the proper library files before doing this (i.e. on Ubuntu its zlib1g-dev, installed via apt-get)

apt-get zlib1g-dev
cd /usr/local/src/ruby-1.8.6/ext/zlib
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
make install


The 'make' command should have all output lines NOT '...no'
If it does, then zlib1g-dev is NOT installed. Get it via the packages and redo this to create the makefile

After this return to the rubygems source directory and run:
ruby setup.rb

ubuntu search apt-get packages

look up package names and contents via shell

apt-cache search <search string>

Apache - IfModule dir_module directive within httpd-vhosts.conf

Change directory listing / default files served when hitting a directory.

This can be placed directly within the VirtualHost directives.

<IfModule dir_module>
  DirectoryIndex index.html index.php
IfModule> 

vi - change and save settings to the editor

within home directory, edit the .exrc file with set commands

the following sets numbered lines and auto indent.
Full listing of set commands available within by using :set all in vi
set nu
set ai
« Newer Snippets
Older Snippets »
29 total  XML / RSS feed