parsed.org

Tips by tag: configuration

Add a Newline to the End of a File by cygnus on Dec 31, 2005 04:09 PM

Use sed to add a newline to the end of a file (this will perform an in-place replacement and create a backup file, MYFILE.bak):

$ sed -i.bak '$G' MYFILE

Some programs, such as Emacs, will omit the trailing newline from a file unless configured to add one. Emacs can be configured to add a newline automatically.

backupcommandsconfigurationeditorsemacsin-placeline-endingsnewlinesedshell
Adding Services by xinu on Apr 21, 2005 08:57 AM

To add a service to boot automatically on startup, do the following:

# chkconfig --level 345 <service_name> on
bootchkconfigcommandsconfigurationservicestartup
Adjust maximum segment size on interface. by AlexB on Jan 23, 2006 10:31 PM

Sometimes MTU issues arise, particularly with PPPoE on Cisco DSL CPE. These can be addressed by changing the TCP Maximum Segment Size (MSS) on the pertinent interface:

interface Dialer1
  ! ...
  ip tcp adjust-mss <size in bytes>
  ! ...
ciscoconfigurationdslmssmtupppoetcp
Alias File by xinu on Sep 10, 2005 12:17 AM

Instead of poluting your otherwise pristine aliases file, include larger files using this syntax:

all_users: ":include:/filename"

This will allow you to email all_users@localhost and get all the users in the referenced file.

aliasesconfigurationmailmtasendmailserversyntax
Attaching Messages by xinu on Jan 12, 2005 11:06 AM

While looking at the summary of your message press A to attach a message in one of your spools. You'll be prompted for the mailbox. Then, tag (t) the messages you want attached and quit (q).

attachmentsconfigurationkeystrokesmailboxmessagesmuamutt
Autocompletion in VIM using TAB by oozy on Apr 25, 2007 03:54 AM

Put this into ~/.vimrc:

fun! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
       return "\<tab>"
    else
       return "\<c-p>"
    endif
endfun

fun! ShiftInsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
       return "\<s-tab>"
    else
       return "\<c-n>"
    endif
endfun

inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-r>=ShiftInsertTabWrapper()<cr>

:set dictionary+=dict.file
:set dictionary+=%
:set iskeyword+=:
:set complete+=k
autocompletionconfigurationeditorssettingsvivimvimrc

Use these screenrc commands to bind specific key sequences to commands outside of the escape sequence (normally C-a). You can bind key combos to commands this way so you don't always have to prefix commands with your escape key sequence:

# Bind Control-PageDown to 'next', Control-PageUp to 'prev'
# to navigate between windows
bindkey ^[[5;5~ prev
bindkey ^[[6;5~ next

# Bind arrow keys Control-Down to 'next', Control-Up to 'prev'
# to navigate between windows
bindkey ^[[1;5A prev
bindkey ^[[1;5B next

(The keycodes for these keys can be obtained by running cat > /dev/null and pressing the desired key combination.)

bindingbindkeycommandsconfigurationescapekeystrokesscreenscreenrc
Bitchx Timestamps by cygnus on Jan 12, 2005 10:38 AM

%@ is the specifier for timestamps in output formatting:

/fset send_public %@%P<%n$2%P>%n $3-
/fset send_action %@%K* %W$1 %n$3-
bitchxcommandsconfigurationirctimestamps
Change Oracle's HTTP/FTP Ports by xinu on Sep 17, 2007 02:03 PM

If you've got another service (e.g., tomcat) fighting for port 8080, you can change the port Oracle uses with the following calls:

-- change HTTP port from 8080 to 8083
call dbms_xdb.cfg_update(updateXML(dbms_xdb.cfg_get(), '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()', 8083));

-- change FTP port from 2100 to 2111
call dbms_xdb.cfg_update(updateXML( dbms_xdb.cfg_get(), '/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()' , 2111));

-- refresh settings
exec dbms_xdb.cfg_refresh;

Tip borrowed from an article by red-database-security.com.

configurationconflictftphttporacleportssqltomcat
Changing Face Colors by cygnus on Mar 06, 2005 07:48 PM

To change the color of a particular face (e.g. font-lock-comment-face), use this elisp (editing where necessary):

(custom-set-faces
 '(font-lock-comment-face
   ((t (:foreground "lightblue" (background light))))
   )
)

lightblue and other color names are defined in rgb.txt, included with your emacs and X installations.

colorsconfigurationeditorselispemacsx11
Changing Process Priority by xinu on Mar 10, 2005 01:52 PM

Ever been on a machine that was ailing and just wouldn't respond? As soon as you're root, lower the priority of the offending process ID(s) (in this example, 1103) by using the 'renice' command:

# renice -19 1103
commandsconfigurationcontroldebuggingmonitoringpriorityprocessrecoveryrenicerescuesecurityshell
Cleaner Output by xinu on Jan 15, 2005 06:03 PM

Tired of those wide tables that wrap? You can end your query with a \G to get output like this:

mysql> select * from users\G
*************************** 1. row ***************************
     id: 1
   name: xinu
created: 20050115210745
*************************** 2. row ***************************
     id: 2
   name: cygnus
created: 20050115210803
2 rows in set (0.00 sec)
configurationconvertmysqloutputsql
Common RC Settings by xinu on Jan 13, 2005 10:56 AM

Some recommended settings for your ~/.vimrc because we all hate tabs (right?):

set sw=4
set ts=4
set sts=4
set expandtab
syntax on
configurationeditorsindentationvimvimrc
Customization of global shortcut keys by cygnus on Jan 12, 2005 10:30 AM

To set your own global keybinding to a function, use global-set-key in your ~/.emacs as follows:

(global-set-key "C-cl" 'enlarge-window-horizontally)
configurationdot-emacseditorselispemacskeystrokes

If you like working with a dark background and enjoy syntax highlighting but hate the navy blue on black, try putting the following line in your ~/.vimrc:

set background=dark
backgroundconfigurationeditorshighlightingsyntaxvimvimrc
Display NULL by xinu on Jan 20, 2005 08:10 PM

If instead of a blank space you'd prefer something that tells you a particular column in a row is NULL, you can set it:

\pset null '(null)'
commandsconfigurationpostgresqlpsql
Ditch All Output Of Query by xinu on Jan 12, 2005 10:25 AM

If you want to run a query or a function and ditch the output, you can do something like this:

xinu=# select my_void_function() \g /dev/null
commandsconfigurationpostgresqlpsql
Dragging Windows Between Desktops by cygnus on Oct 03, 2005 10:59 AM

You can send windows to other desktops in Openbox by right-clicking on the title bar and clicking the appropriate desktop name from the Send to desktop submenu. An easier way to do this is to click and hold on a window title bar and use your desktop switching keys (usually C-A-PgDown and C-A-PgUp by default). As you change desktops, the window you're holding onto will move to each desktop you visit. Just release the mouse button when you've reached the desired desktop.

These keybindings also facilitate the same behavior if you press the keys while focused on the window you want to move:

<keybind key="S-A-Left">
  <action name="SendToDesktopLeft"><wrap>no</wrap></action>
</keybind>
<keybind key="S-A-Right">
  <action name="SendToDesktopRight"><wrap>no</wrap></action>
</keybind>
<keybind key="S-A-Up">
  <action name="SendToDesktopUp"><wrap>no</wrap></action>
</keybind>
<keybind key="S-A-Down">
  <action name="SendToDesktopDown"><wrap>no</wrap></action>
</keybind>

This has been tested with Openbox 3.2.

configurationkeybindingskeystrokesopenboxwmx11xml
Echo Hidden by xinu on Jan 15, 2005 02:47 PM

If you want to see how a query like \du is being built:

\set ECHO_HIDDEN
analysiscommandsconfigurationpostgresqlpsqlsql
Editing Startup Items by cygnus on Jan 13, 2005 09:54 AM

To edit the programs that run on startup of a Windows 9X / XP installation (this doesn't work on Windows 2000), go to Start -> Run and run msconfig. Click on the Startup tab and check or uncheck items to add or remove them from your startup sequence.

bootconfigurationstartupwin2kwin9xwindowswinxp
Executing Multiple Commands by cygnus on Oct 03, 2005 10:52 AM

If you want Openbox to invoke multiple commands for a keybinding, you can just add extra action elements inside the keybind element. Sometimes XMMS freezes up on my machine, so I use this in my rc.xml file:

<keybind key="C-A-k">
  <action name="Execute"><execute>killall -9 xmms</execute></action>
  <action name="Execute"><execute>xmms</execute></action>
</keybind>

This has been tested with Openbox 3.2.

configurationinvocationkeybindingskeystrokesopenboxrc.xmlwmx11xmlxmms
Fill Column by xinu on Jan 12, 2005 10:52 AM

If you want to change the fill column, do the following:

C-u 60 C-x f

(where '60' is the fill column setting you want to use.)

configurationeditorsemacskeystrokes
Firefox Popups by xinu on Aug 02, 2005 12:19 PM

Like you, I love Firefox for many reasons, including its popup blocking support. It turns out that some clever people figured out that you could launch popups from Flash, getting around the Firefox default settings.

Fortunately, you can get around it:

1. Type about:config into the Firefox location bar.
2. Right-click on the page and select New and then Integer.
3. Name it privacy.popups.disable_from_plugins
4. Set the value to 2.

The possible values are:

0: Allow all popups from plugins.
1: Allow popups, but limit them to dom.popup_maximum.
2: Block popups from plugins.
3: Block popups from plugins, even on whitelisted sites.

Note: Borrowed from http://www.petebevin.com. Read the original article.

browserconfigurationfirefoxpopupspamui
Flush Inbox by xinu on Jan 17, 2005 09:57 AM

If you want to flush your inbox and move the messages you've read into the =read box without leaving mutt, just revisit your INBOX again by pressing c!.

configurationinboxkeystrokesmailboxmessagesmuamutt
Flush Queue by xinu on Mar 16, 2005 12:02 PM

To force it to run through the queue (again), you can run:

# ${PATH_TO_POSTFIX}/postfix flush
commandsconfigurationmailmtapostfixqueueserver
Goto-line by cygnus on Jan 12, 2005 10:31 AM

Use this in your ~/.emacs to bind a key to goto-line:

(global-set-key "C-cl" 'goto-line)
configurationdot-emacseditorselispemacskeystrokes
IMAP Header Caching by cygnus on Mar 20, 2006 12:33 PM

Starting with Mutt 1.5.7, you can have Mutt cache IMAP headers to improve IMAP performance considerably. Set the header_cache option in your ~/.muttrc:

set header_cache=/home/bob/.cache_dir
cacheconfigurationheadersimapmessagesmuamutt
Keeping a Screen Open by cygnus on Jan 23, 2005 02:21 PM

You can use this in your shell dotfile (e.g. ~/.bash_profile, ~/.zshrc) to create a screen session when you log in or reattach to an existing screen:

if [[ $TERM != 'screen' ]] ; then
    if [[ `screen -list | grep -v "No" | awk '$2 { print }' | wc -l` == 0 ]] ; then
        screen
    else
        screen -dr
    fi
fi

This works in bash and zsh.

attachbash_profilebootconfigurationscreenscreenrcsessionshellstartup
Linux Shared Memory by cygnus on Jan 12, 2005 10:39 AM

Update /etc/sysctl.conf and add (or alter):

kernel.shmmax = <max bytes>

and run sysctl -p to update the system settings.

commandsconfigurationshared-memorysysctlsysctl.confsystem
Macros by xinu on Jan 12, 2005 10:50 AM

To create a macro:

C-x (

Once in macro recording mode, enter a series of commands. When finished:

C-x )

To name the most recently recorded macro:

M-x name-last-kbd-macro

Enter a name for the macro. The name will now be accessible as M-x <name>.

To generate macro elisp suitable for reload, run M-x insert-kbd-macro and enter the name of a defined macro. Paste the resulting code into ~/.emacs.

configurationdot-emacseditorsemacskeystrokesmacros
Make Emacs Use Spaces Instead of Tabs by cygnus on Dec 21, 2005 11:01 AM

To get emacs to stop inserting tab characters and insert spaces instead, use this in your ~/.emacs file:

(setq-default indent-tabs-mode nil)
configurationdot-emacseditorsemacsindentationspacestabs
Mouse avoidance mode by cygnus on May 03, 2006 02:59 PM

Emacs features a minor mode, mouse-avoidance-mode, which causes the mouse to move away from the Emacs point when the point gets too close. This can be really helpful if you're used to moving your mouse away from the cursor to avoid typing "underneath" the mouse. In your custom-set-variables section in ~/.emacs, add the appropriate elisp:

(custom-set-variables
 .
 .
 '(mouse-avoidance-mode (quote animate) nil (avoid))
 .
 .

The animation parameters of mouse-avoidance-mode can be customized with M-x customize.

configurationeditorselispemacsmouseneat
Multiple Start Pages by xinu on Jul 27, 2005 09:39 AM

If you want to start up multiple pages in Firefox, put a string like this in your start URL under Tools -> Options:

http://www.google.com/|http://www.slashdot.org/
browserconfigurationfirefoxstartup
Mutt Templates by xinu on Jan 12, 2005 12:11 PM

If you know you want to use a previous email as a template, find the message and press M-e. It will dump you in an editor with the same headers and content.

configurationeditorheaderskeystrokesmuamutttemplate
MySQL-style output border by cygnus on Jan 12, 2005 10:25 AM

In your ~/.psqlrc, add this to emulate MySQL-style borders in query results:

\pset border 2
commandsconfigurationmysqloutputpostgresqlpsqlpsqlrc
Nickserv Ghosts by xinu on Aug 01, 2005 09:29 AM

If you've logged on and there's a stale connection still up holding your nick, you can notify the server that it's a ghost and get it back with the following:

/m nickserv ghost <nick> <password>
configurationfreenodeircnickserv
Omit Hosts From Logs by xinu on Dec 31, 2005 03:51 PM

If you want to omit traffic from certain hosts (the dev machines, etc) you can add these directives to your configuration block:

SetEnvIf Remote_Addr 192.168.1.99$ do_not_log
CustomLog logs/access_log combined env=!do_not_log

*Note: You need to have mod_env installed for this to work.

apacheconfigurationloggingmod_env
Operating on tagged messages by pattern by xinu on Jan 13, 2005 09:03 AM

Press T and enter a pattern like:

~s foo

or:

~c bogus@example.com

After you've tagged the messages you want to operate on, press ; followed by an action (e.g. s some_folder).

configurationkeystrokesmessagesmuamutttagging
Optimize Firefox for Broadband by xinu on Jan 12, 2005 01:37 PM

Open about:config in a new tab and make the following changes:

network.http.pipelining -> True
network.http.pipelining.maxrequests -> 10

Anywhere on the screen, right-click and add a new integer:

nglayout.initialpaint.delay -> 0

If you're using a proxy, also change the proxy versions:

network.http.pipelining.proxy.pipelining -> True

WARNING: Be conservative when setting your pipelining settings. To the untrained eye this feature looks like a DOS attempt on the server side and might get you blocked.

browserconfigurationfirefoxgotchanetworkperformance
Pasting With the Mouse by cygnus on Feb 09, 2006 04:12 PM

If you use middle-clicking to paste into Emacs windows but don't like how the paste occurs at the click location and would rather paste at point, use this in your ~/.emacs:

(setq mouse-yank-at-point t)

Thanks to Kevin Turner for pointing this out.

configurationdot-emacseditorselispemacsmousepointyank
Purge Uninstalled Packages by cygnus on Jan 12, 2005 11:04 AM

Use this command to purge old configs and files from your system that are in uninstalled packages:

$ dpkg --get-selections | awk '/deinstall/ {print $1}' | xargs dpkg --purge
awkcommandsconfigurationdebiandpkgpackagespurgexargs
Query Timing by xinu on Jan 19, 2005 09:43 AM

If you want to see how long a query is taking to run, you can either run explain analyze or enable timing for the client by typing \timing.

analysisconfigurationdebuggingdurationoutputperformancepostgresqlpsqlruntimesqltiming
Quick Access To Folders by xinu on Jan 12, 2005 10:13 AM

Some of your commonly accessed mutt folders have shortcut names. Press c to change folders and then use the following:

! - inbox
< - sent messages
> - read messages
aliasesconfigurationfolderskeystrokesmuamutt
Rails Scripts by xinu on Sep 02, 2005 11:52 AM

If you need your script to have access to ActiveRecord, ActiveMail, et al. you can place these directives at the top of your script:

#!/usr/bin/env ruby

require 'rubygems'
require_gem 'activesupport'
activerecordconfigurationlanguagesmodulesprogrammingrailsrorruby
Redhat/Fedora Services by xinu on Jan 18, 2005 01:02 PM

If you have a services script in /etc/rc.d, you can add the service to the various run levels to create the appropriate start/kill symlinks:

# chkconfig --level 345 imap on
# service xinetd restart
bootchkconfigcommandsconfigurationfedoraredhatservicesstartupsymlinks
Redirect All Pages To Root by cygnus on Feb 27, 2007 12:16 PM

To redirect all pages to / with Apache, use mod_rewrite:

RewriteEngine On
RewriteRule \/.+ / [L,R]
apacheconfigurationmod_rewriteredirectrewriterules

If your BGP neighbour is a Cisco unit (and possibly others), it is possible to reprocess all learned routes and new announcements without clearing and retransmitting the full contents of the BGP table. This is known as a "soft reconfiguration," and is supported as of IOS 12.0. This avoids fast route cache invalidation, network service disruption, and other results associated with wiping the BGP table that would normally be undesirable, although it is more memory-intensive:

Router# clear ip bgp <neighbor IP, AS number, or *> in

To trigger a release of updates toward a neighbor in a similar fashion:

Router# clear ip bgp <neighbor IP, AS number, or *> out
bgpciscocommandsconfigurationiospeerrefilterrouterouter
Removing the Help Line by cygnus on Jul 07, 2006 08:30 PM

You can remove the "help line" at the top of your Mutt screen (the one that says "q:Quit d:Del ...") by unsetting the 'help' config item in ~/.muttrc:

unset help
configurationdisplayhelpmuamuttmuttrcunset
Resetting the Root Password by xinu on Sep 10, 2005 12:14 AM

Reset the root password:

1. Insert the Solaris install CD.
2. Issue STOP-A (Ctrl-Break).
3. Type: boot cdrom -s
4. fsck /dev/rdsk/c0t0d0s0
5. mnt /dev/dsk/c0t0d0s0 /a
6. cd /a/etc
7. TERM="vt100"; export TERM
8. vi shadow
9. on root line, delete everything in the second ":" delimited field.
10. exit out of file (ESC :wq! -or ESC ZZ)
bootcommandsconfigurationhackpasswordresetrootsolarisstartup
Session ID Format by cygnus on Aug 12, 2005 03:19 PM

Beware that on some versions of PHP, the PHP session ID value is a hexadecimal hash but on some newer systems the configuration is used to adjust the contents of the session ID string:

; Define how many bits are stored in each character when converting
; the binary hash data to something readable.
;
; 4 bits: 0-9, a-f
; 5 bits: 0-9, a-v
; 6 bits: 0-9, a-z, A-Z, "-", ","
session.hash_bits_per_character = 5
configurationgotchahexadecimallanguagesphpphp.iniprogrammingsession
Setting Modes by xinu on Jan 15, 2005 02:52 PM

If you wish for a particular file to be handled with a mode that isn't already associated with its extension, you may put a header like this anywhere in the file:

-*- mode: outline; mode: auto-fill -*-

Alternatively, you can update your ~/.emacs to use modes based on file extension or filename. For example, to use html-mode for files ending in .tpl:

(setq auto-mode-alist
  (cons '("\\.tpl$" . html-mode) auto-mode-alist))

You can also configure Emacs to use a specific major and minor mode together for a given file extension. This example defines my-mode to load outline-mode (a major mode) and auto-fill-mode (a minor mode) for files ending in .foo:

(defun my-mode ()
  (outline-mode)
  (auto-fill-mode))

(setq auto-mode-alist
  (append '(("\\.foo$" . my-mode))
    auto-mode-alist))
configurationdot-emacseditorselispemacs
Setting the Prompt in 'psql' by cygnus on Jan 14, 2005 12:34 PM

Set the PROMPT1 variable using psql prompt escape sequences:

\set PROMPT1 '[%n@%M:%/]=%# '
  • %n - User
  • %M - Host ([local] or the domain or IP address of the server)
  • %/ - Database
  • %# - # if superuser, $ if regular user.
commandsconfigurationescapepostgresqlpsqlvariables
SSH Config by xinu on Dec 05, 2007 10:48 AM

If you find yourself having to log into various systems with long strange names and usernames that aren't your own, check into ~/.ssh/config. Adding a Host block for each system you need to log into will give you a short name to use as well as let you set the user (and various other things - check out man ssh_config):

Host cs
  HostName cs.really.long.name.example.com
  User mrxinu

At this point you can type ssh cs and log right in.

commandsconfigurationsshssh_config
Stop On Errors by xinu on Jan 12, 2005 11:07 AM

Set this variable in your ~/.psqlrc to stop on error when psql is used to run non-interactive scripts (e.g. cat file | psql ...):

\set ON_ERROR_STOP 1

Or use it from the command line:

$ psql ... -v ON_ERROR_STOP=1 ...
commandsconfigurationdebugginginteractivepipepostgresqlpsqlpsqlrc
Time-Based Redirection by xinu on Feb 10, 2005 02:20 PM

If you want to take your site down for maintenance, but leave your webmail portal active on Sundays, you could put this in either your <VirtualHost> block or in an .htaccess file for your site:

RewriteEngine on
RewriteCond %{TIME_WDAY}         0
RewriteRule !^/mail.*            https://path/to/your/maint/page.html
apacheconfigurationhtaccessmod_rewriterewritevirtualhost
Unmounting a Frozen NFS Mount by cygnus on Feb 08, 2006 02:24 PM

If an NFS mount is frozen because the endpoint is unavailable, you can try a "lazy umount" on the mount to let the kernel take care of cleaning it up, rather than letting user-space processes wait on it:

# umount -l /path/to/mount

Additionally, you can use the NFS "soft" option when mounting the share to prevent hard locking of this kind; see nfs(5). Thanks to Kevin Turner for this tip.

brokenconfigurationfilesystemfrozengotchalazymountnfssoft
Using 'strings' for Paths in a Binary by xinu on Sep 13, 2005 02:34 PM

If you need to discover on which paths a binary depends, you can sometimes run strings on it and grep for everything starting with a slash:

# strings /usr/sbin/named | grep ^/
/lib/ld-linux.so.2
/etc/named.conf
/etc/rndc.key
/etc/lwresd.conf
/etc/resolv.conf
/var/run/named/named.pid
/var/run/named/lwresd.pid
/dev/null
binaryconfigurationgrepprocessshellstrings
Virtual Mapping by xinu on Jan 13, 2005 08:23 AM

Some virtual mapping goodness:

<VirtualHost *>
  ServerName cprogrammer.org
  ServerAlias cprogrammer.org *.cprogrammer.org

  # See the docs for the %-specs; %1 maps to the first part of the
  # domain (a.b.c.d.e -> a, a.b.c -> a)
  VirtualDocumentRoot /users/%1/public_html
  VirtualScriptAlias /users/%1/public_html/cgi-bin/
</VirtualHost>
apacheconfigurationmappingneatvirtualhost
Windowlist Caption Alternative by cygnus on Jan 12, 2005 10:06 AM

This caption config line will add a "caption" to the bottom of the screen which will highlight the currently selected screen and show you a list of all the rest. Add it to your ~/.screenrc:

caption always " | %-w%{= BW}%50>%n %t%{-}%+w |%<"
captionconfigurationscreenscreenrc
Windows equivalent of '/etc/hosts' by xinu on Jan 12, 2005 10:53 AM

This file is essentially the same as the UNIX hosts file:

C:\Windows\System32\Drivers\etc\hosts

configurationdnshostswindows
X TTF Font Woes by cygnus on Jan 12, 2005 10:38 AM

Put your .ttf font file into ~/.fonts/ and re-run fc-cache and ttmkfdir in ~/.fonts/.

configurationfontttfx11
RSS