Difference between revisions of "Quick Notes"

From Secure Computing Wiki
Jump to: navigation, search
m (Reverted edits by Esubiguxoc (talk) to last revision by Ecrist)
Line 1: Line 1:
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://oqagacyti.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
 
----
 
=[http://oqagacyti.co.cc CLICK HERE]=
 
----
 
</div>
 
 
This page is to list all of those quick, often one-line, commands or hints that help during the course of system administration.
 
This page is to list all of those quick, often one-line, commands or hints that help during the course of system administration.
  
Line 15: Line 7:
 
== Networking ==
 
== Networking ==
 
* [http://sd.wareonearth.com/~phil/net/overhead/ Network Overhead Guide]
 
* [http://sd.wareonearth.com/~phil/net/overhead/ Network Overhead Guide]
* To capture packets for wireshark/ethereal, run tcpdump as: '''tcpdump -i &lt;interface> -s 1500 -w &lt;some-file>'''
+
* To capture packets for wireshark/ethereal, run tcpdump as: '''tcpdump -i <interface> -s 1500 -w <some-file>'''
  
 
== MediaWiki Notes ==
 
== MediaWiki Notes ==
Line 25: Line 17:
 
==== Navigation/Side-Bar ====
 
==== Navigation/Side-Bar ====
 
You can edit the links under navigation, etc, on the left of the page by going to a special page in MediaWiki.
 
You can edit the links under navigation, etc, on the left of the page by going to a special page in MediaWiki.
'''&lt;host>/wiki/index.php/MediaWiki:Sidebar''' will take you there.  You can see the SCN side bar at [[MediaWiki:Sidebar]].
+
'''<host>/wiki/index.php/MediaWiki:Sidebar''' will take you there.  You can see the SCN side bar at [[MediaWiki:Sidebar]].
  
 
== [[VIM]] ==
 
== [[VIM]] ==
Line 38: Line 30:
 
* Interface statisctics without iftop from ports: ''systat -if''
 
* Interface statisctics without iftop from ports: ''systat -if''
  
with csh/tcsh, |&amp; pipes both stdout and stderr.  same effect as  2>&amp;1 |    in bourne-based shells (or /bin/sh)
+
with csh/tcsh, |&  pipes both stdout and stderr.  same effect as  2>&1 |    in bourne-based shells (or /bin/sh)
  
 
* [http://eriwen.com/productivity/find-is-a-beautiful-tool/ Find is a beautiful tool.]
 
* [http://eriwen.com/productivity/find-is-a-beautiful-tool/ Find is a beautiful tool.]
 
* [http://eriwen.com/tools/grep-is-a-beautiful-tool/ Grep is a beautiful tool.]
 
* [http://eriwen.com/tools/grep-is-a-beautiful-tool/ Grep is a beautiful tool.]
  
Make this command an alias to '''tree''' in your .&lt;shell>rc and get that ol' DOS-style tree:
+
Make this command an alias to '''tree''' in your .<shell>rc and get that ol' DOS-style tree:
&lt;pre>find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'&lt;/pre>
+
<pre>find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'</pre>
  
 
Here's a nice command to use in conjunction with GeekTool for current weather conditions on your desktop:
 
Here's a nice command to use in conjunction with GeekTool for current weather conditions on your desktop:
&lt;pre style="overflow: auto">curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCITYCODE&amp;u=c" | grep -E '(Current Conditions:|C&lt;BR)' | sed -e 's/Current Conditions://' -e 's/&lt;br \/>//' -e 's/&lt;b>//' -e 's/&lt;\/b>//' -e 's/&lt;BR \/>//' -e 's/&lt;description>//' -e 's/&lt;\/description>//'&lt;/pre>
+
<pre style="overflow: auto">curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCITYCODE&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'</pre>
 
''Note: change YOURCITYCODE with your zip code.''
 
''Note: change YOURCITYCODE with your zip code.''
  
Line 66: Line 58:
 
== vMail.Admin ==
 
== vMail.Admin ==
 
Link sudo to /usr/bin/sudo
 
Link sudo to /usr/bin/sudo
&lt;pre># ln -s /usr/local/bin/sudo /usr/bin/sudo&lt;/pre>
+
<pre># ln -s /usr/local/bin/sudo /usr/bin/sudo</pre>
  
 
== Firefox ==
 
== Firefox ==
Line 106: Line 98:
 
|-
 
|-
 
| action based on time interval
 
| action based on time interval
| SELECT FROM foo WHERE DATE(field) &lt; (YYYYMMDD - INTERVAL nnn unit)
+
| SELECT FROM foo WHERE DATE(field) < (YYYYMMDD - INTERVAL nnn unit)
 
| Where unit = DAY/YEAR/MONTH - one of those, will select based on records older than the interval.
 
| Where unit = DAY/YEAR/MONTH - one of those, will select based on records older than the interval.
 
|-
 
|-
Line 116: Line 108:
 
This command can be used to dump all databases on the current system to another system, piping the content through an SSH session:
 
This command can be used to dump all databases on the current system to another system, piping the content through an SSH session:
  
&lt;pre>mysqldump -u USERNAME -pPASSWORD --opt --compress --all-databases | ssh REMOTEHOST "cat - | mysql -u USERNAME -pPASSWORD"&lt;/pre>
+
<pre>mysqldump -u USERNAME -pPASSWORD --opt --compress --all-databases | ssh REMOTEHOST "cat - | mysql -u USERNAME -pPASSWORD"</pre>
 
=== Links ===
 
=== Links ===
 
* [http://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/ http://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/]
 
* [http://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/ http://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/]
Line 123: Line 115:
  
 
This is just a place-holder.
 
This is just a place-holder.
&lt;!--
+
<!--
 
Serial: xard-030-000-r-keg-bag-psn-mzo-tfd-uha-h
 
Serial: xard-030-000-r-keg-bag-psn-mzo-tfd-uha-h
 
Serial: xard-030-000-r-lys-pws-rhh-qjq-wbf-jax-i
 
Serial: xard-030-000-r-lys-pws-rhh-qjq-wbf-jax-i
Line 135: Line 127:
  
 
== GNU Screen ==
 
== GNU Screen ==
A nice .screenrc config file:&lt;br />
+
A nice .screenrc config file:<br />
 
''This config works well on both light and dark colored backgrounds.''
 
''This config works well on both light and dark colored backgrounds.''
&lt;pre>
+
<pre>
 
startup_message off
 
startup_message off
 
shelltitle ''
 
shelltitle ''
Line 144: Line 136:
 
hardstatus on
 
hardstatus on
 
hardstatus alwayslastline
 
hardstatus alwayslastline
hardstatus string '%{= bW}%-Lw%{= rW}%50>%n%f %t%{= bW}%+Lw%&lt; %-= %{..Y}%m/%d %c:%s%{-}'
+
hardstatus string '%{= bW}%-Lw%{= rW}%50>%n%f %t%{= bW}%+Lw%< %-= %{..Y}%m/%d %c:%s%{-}'
&lt;/pre>
+
</pre>
  
Here's another .screenrc config, from Jeremy O'Brien (piroko):&lt;br />
+
Here's another .screenrc config, from Jeremy O'Brien (piroko):<br />
 
''This config works well on dark colored backgrounds.''
 
''This config works well on dark colored backgrounds.''
&lt;pre>shelltitle ''
+
<pre>shelltitle ''
 
startup_message off
 
startup_message off
 
vbell off
 
vbell off
 
defmonitor on
 
defmonitor on
 
monitor on
 
monitor on
caption always "%{= kw}> %{y}%?%-Lw%?%{w}(%{R}%n*%t%?(%u)%?%{w})%{y}%?%+Lw%?%?%=%{w} [ %{.c}%M %d%{y}%0c:%s%{w} ]"&lt;/pre>
+
caption always "%{= kw}> %{y}%?%-Lw%?%{w}(%{R}%n*%t%?(%u)%?%{w})%{y}%?%+Lw%?%?%=%{w} [ %{.c}%M %d%{y}%0c:%s%{w} ]"</pre>
  
 
=== Screen after ''su'' ===
 
=== Screen after ''su'' ===
&lt;pre>sudo su - &lt;user>
+
<pre>sudo su - <user>
 
script /dev/null
 
script /dev/null
screen (or screen -r)&lt;/pre>
+
screen (or screen -r)</pre>
  
 
=== Links ===
 
=== Links ===
Line 181: Line 173:
  
 
Example for output files with support for multipart downloading:
 
Example for output files with support for multipart downloading:
&lt;pre>                                if (isset($_SERVER['HTTP_RANGE'])){
+
<pre>                                if (isset($_SERVER['HTTP_RANGE'])){
 
                                         list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
 
                                         list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
 
                                         list($range) = explode(',', $range, 2);
 
                                         list($range) = explode(',', $range, 2);
Line 203: Line 195:
 
                                         header('Content-Length: ' . $size);
 
                                         header('Content-Length: ' . $size);
 
                                 }
 
                                 }
&lt;/pre>
+
</pre>
  
 
== IRSSI ==
 
== IRSSI ==
Line 214: Line 206:
 
! What it does.
 
! What it does.
 
|-
 
|-
| &lt;nowiki>/^$|^\d{5}(-?\d{4})?$|^[ABCEGHJKLMNPRSTVWXYZ]\d[ABCEGHJKLMNPRSTVWXYZ](\s?)\d[ABCEGHJKLMNPRSTVWXYZ]\d/i&lt;/nowiki>
+
| <nowiki>/^$|^\d{5}(-?\d{4})?$|^[ABCEGHJKLMNPRSTVWXYZ]\d[ABCEGHJKLMNPRSTVWXYZ](\s?)\d[ABCEGHJKLMNPRSTVWXYZ]\d/i</nowiki>
 
| Validates for blank string, US zipcode (either 5 digit or 5+4, and Canadian postal codes (with or without a space).
 
| Validates for blank string, US zipcode (either 5 digit or 5+4, and Canadian postal codes (with or without a space).
  

Revision as of 17:42, 26 November 2010

This page is to list all of those quick, often one-line, commands or hints that help during the course of system administration.

VoIP

Links

bastard.net

Networking

  • Network Overhead Guide
  • To capture packets for wireshark/ethereal, run tcpdump as: tcpdump -i <interface> -s 1500 -w <some-file>

MediaWiki Notes

This section is for all the stuff you can do or need to do with Media Wiki that isn't found in an easy location.

Navigation/Side-Bar

You can edit the links under navigation, etc, on the left of the page by going to a special page in MediaWiki. <host>/wiki/index.php/MediaWiki:Sidebar will take you there. You can see the SCN side bar at MediaWiki:Sidebar.

VIM

Command Line Foo

  • Interface statisctics without iftop from ports: systat -if

with csh/tcsh, |& pipes both stdout and stderr. same effect as 2>&1 | in bourne-based shells (or /bin/sh)

Make this command an alias to tree in your .<shell>rc and get that ol' DOS-style tree:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Here's a nice command to use in conjunction with GeekTool for current weather conditions on your desktop:

curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOURCITYCODE&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'

Note: change YOURCITYCODE with your zip code.

iPhone Notes

Windows Notes

SpamAssassin

Postfix

http://www.freesoftwaremagazine.com/articles/secure_email_servers_from_scratch_with_freebsd_6_part_2

Postfix How-To

vMail.Admin

Link sudo to /usr/bin/sudo

# ln -s /usr/local/bin/sudo /usr/bin/sudo

Firefox

  • No Scroll Tabs: goto about:config, set browser.tabs.tabMinWidth=1
  • Close on Tab: goto about:config, set browser.tabs.closeButtons=1

PostgreSQL

  • Postgres does not authenticate users as MySQL, and doesn't offer a shell.
  • When connecting to Postgres dbs, you must specify the db, otherwise a db names as the role will be assumed.

Basic Commands

  • psql -l (dash el): list databases
  • pg_dumpall: dump all dbs to stdout
    • gzipped use: pg_dumpall | gzip -c > all.dbs.out.gz
    • restore: gzcat all.dbs.out.gz | psql -f - postgres

MySQL Stuff

Command/Query Examples

Description Command Notes
Forcibly change a user's password. SET PASSWORD FOR user=PASSWORD('password');
Add New Database User GRANT ALL PRIVILEGES ON db.table to 'user'@'host' IDENTIFIED BY 'password'; You can use a % to denote ANY host. The percent (%) purposely excludes localhost, however.
Copy rows from one table to another. INSERT INTO foo SELECT * FROM bar; copies records from table bar into table foo.
action based on time interval SELECT FROM foo WHERE DATE(field) < (YYYYMMDD - INTERVAL nnn unit) Where unit = DAY/YEAR/MONTH - one of those, will select based on records older than the interval.
Flush all queries from the cache. FLUSH QUERY CACHE

This command can be used to dump all databases on the current system to another system, piping the content through an SSH session:

mysqldump -u USERNAME -pPASSWORD --opt --compress --all-databases | ssh REMOTEHOST "cat - | mysql -u USERNAME -pPASSWORD"

Links

Apple Remote Desktop 3.1

This is just a place-holder.

GNU Screen

A nice .screenrc config file:
This config works well on both light and dark colored backgrounds.

startup_message off
shelltitle ''
defmonitor on
vbell off
hardstatus on
hardstatus alwayslastline
hardstatus string '%{= bW}%-Lw%{= rW}%50>%n%f %t%{= bW}%+Lw%< %-= %{..Y}%m/%d %c:%s%{-}'

Here's another .screenrc config, from Jeremy O'Brien (piroko):
This config works well on dark colored backgrounds.

shelltitle ''
startup_message off
vbell off
defmonitor on
monitor on
caption always "%{= kw}> %{y}%?%-Lw%?%{w}(%{R}%n*%t%?(%u)%?%{w})%{y}%?%+Lw%?%?%=%{w} [ %{.c}%M %d%{y}%0c:%s%{w} ]"

Screen after su

sudo su - <user>
script /dev/null
screen (or screen -r)

Links

PHP

Function Code Example Description
foreach foreach ($array as $key => $value) { code }

Example for output files with support for multipart downloading:

                                if (isset($_SERVER['HTTP_RANGE'])){
                                        list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
                                        list($range) = explode(',', $range, 2);
                                        list($range, $rangeEnd) = explode('-', $range);

                                        $range = intval($range);

                                        if (!$rangeEnd){
                                                $rangeEnd = $fileSize -1;
                                        } else {
                                                $rangeEnd = intval($rangeEnd);
                                        }
                                        $newLength = $rangeEnd - $range + 1;

                                        // Send Headers
                                        header("Content-Type: applicatoin/zip");
                                        header("Content-Length: $size");
                                        header("Content-Range: bytes " . $range - $rangeEnd / $size);
                                } else {
                                        $newLength = $size;
                                        header('Content-Length: ' . $size);
                                }

IRSSI

  • [1] - good how to for screen + irssi

RegEx (Regular Expressions)

REGEX What it does.
/^$|^\d{5}(-?\d{4})?$|^[ABCEGHJKLMNPRSTVWXYZ]\d[ABCEGHJKLMNPRSTVWXYZ](\s?)\d[ABCEGHJKLMNPRSTVWXYZ]\d/i Validates for blank string, US zipcode (either 5 digit or 5+4, and Canadian postal codes (with or without a space).

Samsung Vibrant/Galaxy S

  • LBS/GPS Test Mode: *#*#1472365#*#* SEND