2019-01-09

tmux vs screen

I was a big fan of screen but against RHEL8 I have to move on tmux. Is is ok, by my finger memory have been adjusting to screen configuration, so there is a .tmux.conf with screen binding.
unbind C-b
### change default prefix to screen prefix C-a
set -g prefix C-a
set -g status-bg black
set -g status-fg white
set-window-option -g window-status-current-bg white
set-window-option -g window-status-current-fg black
set-window-option -g window-status-current-attr bold
set -g status-left '#[fg=colour80](#S) #(whoami) '
set -g status-justify centre
bind-key C-a last-window
bind-key C-c new-window
bind-key space next-window
bind-key bspace previous-window
bind a send-prefix
### set mouse on with prefix+m and off with prefix+M 
bind m \
    set -g mouse on \;\
    display 'Mouse: ON'
bind M \
    set -g mouse off \;\
    display 'Mouse: OFF'

2011-10-07

test1

info-kerberos

info-kerberos

1 def

  • The CLIENT and SERVER do not initially share an encryption key.
  • Whenever a CLIENT authenticates itself to a new VERIFIER it relies on the AUTHENTICATION SERVER to generate a new encryption key and distribute it securely to both parties (CLIENT and VERIFIER)
  • The Kerberos TICKET is a certificate issued by an AUTHENTICATION SERVER, encrypted using the SERVER KEY.
  • The TICKET is not sent directly to the VERIFIER, but is instead sent to the CLIENT who forwards it to the VERIFIER as part of the application request. Because the ticket is encrypted in the SERVER KEY, known only by the AUTHENTICATION SERVER and intended VERIFIER, it is not possible for the CLIENT to modify the ticket without detection.
  • There are two parts to the application request, a TICKET and an AUTHENTICATOR:
    1. The AUTHENTICATOR includes, among other fields (all encrypted with the SESSION KEY):
      • the current time
      • a checksum
      • an optional encryption key
    2. When a client wishes to create an association with a particular VERIFIER, the client uses the authentication request and response, messages, to obtain a TICKET and SESSION KEY from the AUTHENTICATION SERVER.

2 klist

  • klist -k [keytab_file] #sprawdzanie principali w pliku keytab
  • klist -k #sprawdzanie principali w defaultowym pliku, można sprawdzić path do pliku
  • klist #sprawdzanie principali z plików w /tmp/krb5cc_[nr]

3 kdestroy

4 create keytab (on AD)

  1. stworzenie nowego usera w AD trzymającego principal-e
    • opcja dla usera - password never expires
  2. dopisanie principala do powyższego usera za pomocą ktpass dostarczonego przez Windows Server 2003 Support Tools http://support.microsoft.com/kb/892777
    • ktpass -princ HTTP/[service_hostname]@[DOMAIN] -mapuser [above_ad_user] -pass [above_ad_user_pass] [/desonly] [-crypto des-cbc-crc] -out [output_file]
  3. sprawdzenie
    • AD => user => properties => Account => [User logon name: HTTP/[service_hostname]@[domain]

5 get kerberos ticket (on service server)

  • kinit [principal_name as above HTTP/[service_hostname]

6 files

  • /etc/krb5.conf - namiary na domenę i server AD
  • /etc/krb5.keytab - defaultowy keytab
  • /etc/krb5.realms
  • /tmp/krb5cc_500 - zapisane credentiale

2011-08-10

WINDOWS RUN

Run commands

COMMANDDESCRIBE
msconfigsystem config
compmgmt.msccomputer manager
lusrmgr.msclocal users and groups manager
devmgmt,mscdevices manager
diskmgmt.mscdisc manager
services.mscservices
fsmgmt.mscshare folders manager
eventvwr.mscshow logs
gpedit.mscgroup rules
certmgr.msccert manager
perfmon.mscper monitor
dnsmgmt.mscdns
dhcpmgmt.mscdhcp
appwiz.cpladd software
hdwwiz.cpladd devices
sysdm.cplsystem properties
ncpa.cplnetwork settings
inetcpl.cplnetwork properties
control admintoolsAdministrative Tools
control desktopDisplay Properties
control printersPrinters and Faxes
control schedtasksScheduled Task
control netconnectionsNetwork Connections

Translate error code

  1. convert error: dicimal => hex
  2. get last 4 digit
  3. convert last4digit: hex => decimal
  4. cmd: net helpmsg [last4digitdecimal]

2011-06-22

LINUX BASH

Set


set -xDisplay commands and their arguments as they are executed. +x turn off
set -vDisplay shell input lines as they are read. +v turn off





Params


$?error code
$#a number of params
$@list params
$*list params
$0script name
$1param nr 1
$$process ID





Keybindings


S-M-$complete variable
S-<first command in history
C-pprevious command in history
C-nnext command in history
S->last command in history
C-ejump to EOL
C-ajump to BOL
M-fjump forward a word
M-bjump back a world
C-udelete from BOL to cursor
C-kdelete from cursor to EOL
M-ddelete word forward from cursor
C-wdelete word backward from cursor




Variable manipulation


  • (command1; command2;…) #command inside brackeds are lauched in subshell with new process id(childs)
    subshell variables are recognized in subshell only
  • ${var}
  • ${#var} #a number of variable var characters


commandoutputdesc
export var=(el1 el2 el3); echo ${var[1]}val2the second element var variable, which is a list
export var=(el1 el2 el3); echo ${#var[1]}4a number of chars in the second element
export var=(el1 el2 el3); echo ${#var[@]}3list size
export var=12345; echo ${var:-text}if var was set the output is var value, if not the output is text, var is not change
export var=12345; echo ${var:=text}if var was set the output is var value, if not the output is text, var is changed to text
export var=12345; echo ${var:?text}if var was set the output is var value, if not the output is text to the error output
export var=12345; echo ${var:+text}if var was set the output is text, var is not change
export var=12345; echo ${var:1:3}234get second element (first is 0) and next 3
export var=12345; echo ${var#12}345remove elements based on schema 12 from the begining
export var=12345; echo ${var%45}123remove elements based on schema 45 from the end
export var=12345; echo ${var/34/ab}12ab5substitute elements by pattern 34 to ab anywhere
export var=12345; echo ${var/#12/ab}ab123substitute elements by pattern 12 to ab from the beggining
export var=12345; echo ${var/%45/ab}123absubstitute elements by pattern 45 to ab from the end





Array


  • Array=(el01 el02 el03)
  • element at the table is matched by [] symbol and by ${Array[0]}
  • iteration: for i in ${Array[@]};do echo $i; done




Buildin variables and commands


zmiennadesc
BASH_SUBSHELLsubshell nr
SECONDSamount of time running script
FUNCNAMEfuction name
DIRSTACKcurrent dir
LINENOcurrend row
:true
PWDcurrent dir
CDPATHcd command path
TMOUTlogout after [sec] of inactivity





Debug


bash -n [script]set -ncheck without run
bash -x [script]set -xdebug




Range variable


  • function inherits variables from script
  • script do not inherit variable from function
  • script inherit variable from for loop




Function


  • {} #anonymous function, variables from script
  • in {} there is the block of code which output might be redirect to file {} > output.file,
    block of code from {} is not placed in subshell like for ()




Test




[[


  • less suprises, safer to use, but it is not portable, not POSIX only bash,
    regexp matching, it is a keyword, not a program
  • string comparision:

    <, >, =, ==, !=
  • integer comparison:

    -lt, -le, -eq, -ge, -gt, -ne
  • conditional evaluation:
    &&, ||
  • expression grouping:

    (…)



[


  • right side must be quote ex. if [ -z "$variable ], is sysnonym for test but
    requires a final ], it is a program /usr/bin/[
  • string comparision:

    \<, \>, =, !=
  • integer comparison:

    -lt, -le, -eq, -ge, -gt, -ne




files


-f filetrue if file exists and is a regular file
-e filetrue if file exists
-d filetrue if file exists and is a directory





strings


-z stringtrue if the length of string is zero
-n stringtrue if the length of string is non-zero





using


  • [ c1 ] ||/&& [ c2 ]
  • both alternatives are different ex:
    c1c2
    andOKis run
    andFAILis not run
    orOKis not run
    orFAILis run






Getopts


variabledescription
OPTINDHolds the index to the next argument to be processed. This is how getopts "remembers" its own status between invocations. Also usefull to shift the positional parameters after processing with getopts. OPTIND is initially set to 1, and needs to be re-set to 1 if you want to parse anything again with getopts
OPTARGThis variable is set to an argument for an option found by getopts, but if the option is unknown it contains the option flag.
OPTERR(Values 0 or 1) Indicates if Bash should display error messages generated by the getopts builtin. The value is initialized to 1 on every shell startup - so be sure to always set it to 0 if you don't want to see annoying messages!


  • getopts OPTSTRING VARNAME [ARGS…]
    OPTSTRINGtells getopts which options to expect and where to expect arguments (see below)
    VARNAMEtells getopts which shell-variable to use for option reporting
    ARGStells getopts to parse these optional words instead of the positional parameters


  • commands without any args - nothing happened? Right. getopts didn't see any valid or invalid options (letters preceeded by a dash),
    so it wasn't triggered.
  • commands without any flags - nothing happened? The very same case: getopts didn't see any valid or invalid options
    (letters preceeded by a dash), so it wasn't triggered.
  • invalid options don't stop the processing: If you want to stop the script, you have to do it yourself (exit in the right place)
  • multiple identical options are possible: If you want to disallow these, you have to check manually (e.g. by setting a variable or so)




OPTSTRING


  • When you want getopts to expect an argument for an option, just place a : (colon) after the proper option flag.
  • If the very first character of the option-string is a : (colon), which normally would be nonsense
    because there's no option letter preceeding it, getopts switches to the mode "silent error reporting".
    In productive scripts, this is usually what you want (handle errors yourself and don't get disturbed by annoying messages).




ARGS


  • The getopts utility parses the positional parameters of the current shell or function by default (which means it parses "$@").
    You can give your own set of arguments to the utility to parse. Whenever additional arguments are given after the VARNAME parameter,
    getopts doesn't try to parse the positional parameters, but these given words.
    A call to getopts without these additional arguments is equivalent to explicitly calling it with "$@".




Calculate


  • echo $((2+3))



Return status


  • last command at function or script determe exit status, thisis bash return value
  • exit status might be at range 0-255




Commands


evalchange string from variable to command ex. i="ls"; eval $i
sourcefrom command line run script, from script working as #include (same as dot-command)
execdo not create fork but create new shell process, go out from script
true,falsereturn 0 as exit status of error
help [bash_command]help for bash commands ex. help eval





Output




ex 1: command > /dev/null 2>&1


  1. redirect standard output /dev/stdout to /dev/null
  2. redirect standard error /dev/stderr to device point at standard output /dev/stdout, so to /dev/null

Summarize: all output is redirect to /dev/null



ex 2: command 2>&1 > /dev/null


  1. redirect error output /dev/stderr to device point at standard output /dev/stdout
  2. redirect standard ouptut /dev/stdout to /dev/null but error output /dev/stderr
    is still redirected to /dev/stdout

Summarize: /dev/stdout to /dev/null and /dev/stderror to previous /dev/stdout



Printf


  • printf "%-30s%s" "hello" $VAR




Colors in directory


  • dircolors -p ~/.dircolors
  • eval `/usr/bin/dircolors -b ~/.dircolors`
  • alias dir="dir –color"
  • alias ls="ls –color"



color symbols


descatrybut
none00
bold01
underscore04
blink05
reverse07
concealed08
font kolorbackground color
black3040
red3141
green3242
yellow3343
blue3444
magenta3545
cyan3646
white3747


2011-06-14

ORACLE TRACE

Remember that trace files are in the user_dump_destination, but for jobs and for shared server configurations they are in background_dump_destination.
Oracle 9i

turn on trace in another session:

EXECUTE dbms_system.set_ev ([sid],[serial#],10046,[level],'');
turn off
EXECUTE dbms_system.set_ev ([sid],[serial#],10046,0,'');

Oracle 9i/10g

turn on trace for current session:

ALTER SESSION SET EVENTS '10046 trace name context forever, level [level#]'
  • level 0 #off
  • level 1 #default
  • level 4 #default + bind variable values
  • level 8 #default + wait event information
  • level 12 #level 4 + level 8
turn off
ALTER SESSION SET EVENTS '10046 trace name context off'

Oracle 9i/10g

turn on trace for os process:

ORADEBUG SETOSPID [os process from v$process];
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL [level#];
ORADEBUG TRACEFILE_NAME; --display current tracefile
turn off
ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;

Oracle 9i/10g

turn on trace for current session:

dbms_support package in $ORACLE_HOME/rdbms/admin/dbmssupp.sql
EXEC dbms_support.start_trace(waits=>TRUE, binds=>TRUE);
turn off
EXEC dbms_support.stop_trace;

turn on trace for the other session:

EXEC dbms_support.start_trace_in_session(sid=>[sid], serial=>[serial#], waits=>TRUE, binds=>TRUE);
turn off
EXEC dbms_support.stop_trace_in_session(sid=>[sid], serial=>[serial#]);

Oracle 10g

turn on trace for current session:

exec DBMS_MONITOR.SESSION_TRACE_ENABLE (session_id => [sid],serial_num => [serial#], waits => TRUE,binds => TRUE);
turn off
exec DBMS_MONITOR.SESSION_TRACE_DISABLE(session_id=> [sid],serial_num=> [serial#]);
check:
SELECT sql_trace,sql_trace_waits,sql_trace_binds FROM v$session;

turn on trace for client:

exec DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE(client_id => '[client_name]',waits => TRUE, binds => TRUE);
turn off
exec DBMS_MONITOR.CLIENT_ID_TRACE_DISABLE(client_id => '[client_name]');

turn on trace at database level:

exec DBMS_MONITOR.DATABASE_TRACE_ENABLE (waits => TRUE,binds => TRUE,instance_name > NULL);
turn off
exec DBMS_MONITOR.DATABASE_TRACE_DISABLE(instance_name > NULL);
check:
SELECT * FROM dba_enabled_traces;

Oracle 11g

turn on trace at component level

exec DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE(service_name => '[serv_name]', module_name => '[module]',action_name => '[action]',waits => TRUE,binds => FALSE, instance_name => NULL);
turn off
exec DBMS_MONITOR.SERV_MOD_TRACE_DISABLE(service_name => 'serv_name',module_name => 'module',action_name => '[action]',instance_name => NULL);
check: SELECT * FROM dba_enabled_traces;

2011-02-16

LINUX NETWORK

Turn off NetworkManager:

  • chkconfig NetworkManager off
  • systemclt disable NetworkManager.service

Setting gateway:

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=[hostname]
GATEWAY=[IP]

Bonding module:

/etc/modprobe.d/bond.conf

alias bond0 bonding
options bond0 miimon=100 mode=1

Setting ordinary interfaces:

/etc/sysconfig/network-scripts/ifcfg-[dev_name]

DEVICE=[dev_name]
BOOTPROTO=none
HWADDR=AA:AA:AA:AA:AA:AA
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

Setting bond interfaces

/etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=[IP]
NETMASK=[MASK]
IPV6INIT=no
NM_CONTROLLED=no

iwlist

  • iwlist [interface] frequency

WIFI - wpa_supplicant

wpa_passphrase

  • wpa_passphrase "[ssid]" "[passphrase]" #generating psk key which is used by wpa_supplicant.conf

wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

network={
  ssid="leny"
  #psk="[opentext_passphrase]"
  psk=[psk_from_wpa_passphrase]
  scan_ssid=1
  proto=WPA2 #WPA RSN
  priority=1
  scan_ssid=1 #if ssid is hidden
  #key_mgmt=WPA-EAP
  #key_mgmt=WPA-PSK
}

lanunch wifi steps:

  1. ip link set [dev_name] up
  2. iw [dev_name] scan
  3. wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -Dwext -i[dev_name] -B #run as daemon (-B flag)
  4. dhclient [dev_name]
  5. ip addr show [dev_name]
  6. route add default gw [IP]

2011-01-19

ORACLE AUDIT

1 Init params

initoptionvaluesdesc
AUDIT_TRAILNONE/DB/OS/DB,EXTENDED/XML/XML,EXTENDEDturn on audit and set type
AUDIT_FILE_DESTset directory for audit files when AUDIT_TRAIL=OS, default: $ORACLE_HOME/rdbms/audit
AUDIT_SYS_OPERATIONSTRUE/FALSEfor sys operations

1.1 AUDIT_TRAIL

  • in 11g audyt is set default on DB value
none or falseAuditing is disabled.
db or trueAuditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$).
db,extendedAs db, but the SQL_BIND and SQL_TEXT columns are also populated.
xmlAuditing is enabled, with all audit records stored as XML format OS files.
xml,extendedAs xml, but the SQL_BIND and SQL_TEXT columns are also populated.
osAuditing is enabled, with all audit records directed to the operating system's audit trail.

2 Turn on

  • set param audit_trail

Commands:

AUDITturn on audit
NOAUDIT ALLturn off all audit operations for current user
NOAUDIT ALL BY [username]
NOAUDIT SELECT TABLE BY [username]
AUDIT ALL BY [username] BY ACCESS/SESSIONACCESS - log everytime the event heppen, SESSION - log only at first time
NOAUDIT TABLE BY [username]
AUDIT select table, insert table, delete table, update table BY [username] BY ACCESS

Views:
STMT_AUDIT_OPTION_MAPContains information about auditing option type codes. Created by the SQL.BSQ script at CREATE DATABASE time.
AUDIT_ACTIONSContains descriptions for audit trail action type codes
ALL_DEF_AUDIT_OPTSContains default object-auditing options that will be applied when objects are created

3 VIEWS for SYS.AUD$

DBA_STMT_AUDIT_OPTSshow running audits for user
DBA_PRIV_AUDIT_OPTSDescribes current system privileges being audited across the system and by user
DBA_OBJ_AUDIT_OPTSDescribes auditing options on all objects. USER view describes auditing options on all objects owned by the current user.
DBA_AUDIT_TRAILLists all audit trail entries USER view shows audit trail entries relating to current user.
DBA_AUDIT_STATEMENTLists audit trail records concerning GRANT, REVOKE, AUDIT, NOAUDIT, and ALTER SYSTEM statements throughout the database, or for the USER view, issued by the user
DBA_AUDIT_EXISTSLists audit trail entries produced BY AUDIT NOT EXISTS
DBA_AUDIT_SESSIONLists all audit trail records concerning CONNECT and DISCONNECT. USER view lists all audit trail records concerning connections and disconnections for the current user.
DBA_AUDIT_OBJECTContains audit trail records for all objects in the database. USER view lists audit trail records for statements concerning objects that are accessible to the current user.

  • DDL (CREATE, ALTER & DROP of objects)
  • DML (INSERT UPDATE, DELETE, SELECT, EXECUTE).
  • SYSTEM EVENTS (LOGON, LOGOFF etc.)
  • SELECT * FROM dba_stmt_audit_opts ORDER BY 1,3;
col obj_name format a30
col owner format a15
col username format a15
SELECT owner,username,obj_name,action_name,to_char(timestamp,'YYYY-MM-DD HH24:MI:SS') FROM dba_audit_trail 
  WHERE timestamp >= trunc(sysdate-1) and username='CCI' order by timestamp;
prompt ###zajetosc_tabeli_audytu
SELECT sum(bytes)/1024/1024 as MB FROM dba_segments WHERE segment_name='AUD$';

4 Options

4.1 default audit options

  • rdbms/admin/secconf.sql
  • rdbms/admin/undoaud.sql #wylaczenie

4.2 ALL

ObjectSQL Statements and Operations Audited
ALTER SYSTEMALTER SYSTEM
CLUSTERCREATE, ALTER, DROP, TRUNCATE
CONTEXTCREATE, DROP
DATABASE LINKCREATE, ALTER, ALTER PUBLIC DATABASE LINK, DROP DATABASE LINK
DIMENSIONCREATE, ALTER, DROP
DIRECTORYCREATE, DROP
INDEXCREATE INDEX, ALTER, ANALYZE INDEX, DROP
MATERIALIZED VIEWCREATE, ALTER, DROP
NOT EXISTSAll SQL statements that fail because a specified object does not exist.
OUTLINECREATE, ALTER, DROP
PROCEDURECREATE FUNCTION, CREATE LIBRARY, CREATE PACKAGE, CREATE PACKAGE BODY
CREATE PROCEDURE, DROP FUNCTION, DROP LIBRARY, DROP PACKAGE, DROP PROCEDURE
PROFILECREATE, ALTER, DROP
PUBLIC DATABASE LINKCREATE, DROP
PUBLIC SYNONYMCREATE, DROP
ROLECREATE, ALTER, DROP, SET
ROLLBACK SEGMENTCREATE, ALTER, DROP
SEQUENCECREATE, DROP
SESSIONLogons
SYNONYMCREATE, DROP
SYSTEM AUDITAUDIT sql_statements, NOAUDIT sql_statements
SYSTEM GRANTGRANT system_privileges_and_roles, REVOKE system_privileges_and_roles
TABLECREATE, DROP,TRUNCATE TABLE
TABLESPACECREATE, TABLESPACE, ALTER, DROP
TRIGGERCREATE, ALTER with ENABLE and DISABLE clauses, DROP, ALTER TABLE with ENABLE ALL TRIGGERS clause and DISABLE ALL TRIGGERS clause
TYPECREATE, CREATE TYPE BODY,ALTER,DROP,DROP TYPE BODY
USERCREATE, ALTER, DROP
VIEWCREATE, DROP

Notes:
  • AUDIT USER #audits three SQL statements: CREATE, ALTER, DROP Use AUDIT ALTER USER to audit statements that require the ALTER USER system privilege. An AUDIT ALTER USER statement does not audit a user changing his or her own password, as this activity does not require the ALTER USER system privilege.

4.3 ADDITIONAL

ALTER SEQUENCEALTER SEQUENCE
ALTER TABLEALTER TABLE
COMMENT TABLECOMMENT ON TABLE table, view, materialized view,COMMENT ON COLUMN table.column, view.column, materialized view.column
DELETE TABLEDELETE FROM table, view
EXECUTE PROCEDURECALL
Execution of any procedure or function or access to any variable, library, or cursor inside a package.
GRANT DIRECTORYGRANT privilege ON directory,REVOKE privilege ON directory
GRANT PROCEDUREGRANT privilege ON procedure, function, package,REVOKE privilege ON procedure, function, package
GRANT SEQUENCEGRANT privilege ON sequence,REVOKE privilege ON sequence
GRANT TABLEGRANT privilege ON table, view, materialized view,REVOKE privilege ON table, view, materialized view
GRANT TYPEGRANT privilege ON TYPE,REVOKE privilege ON TYPE
INSERT TABLEINSERT INTO table, view
LOCK TABLELOCK TABLE table, view
SELECT SEQUENCEAny statement containing sequence.CURRVAL or sequence.NEXTVAL
SELECT TABLESELECT FROM table, view, materialized view
UPDATE TABLEUPDATE table, view

4.4 Objects available to audit

ObjectSQL Operations
TableALTER, AUDIT, COMMENT, DELETE, FLASHBACK, GRANT, INDEX, INSERT, LOCK, RENAME, SELECT, UPDATE
ViewAUDIT, COMMENT, DELETE, FLASHBACK, GRANT, INSERT, LOCK, RENAME, SELECT, UPDATE
SequenceALTER, AUDIT, GRANT, SELECT
Procedure, Function, PackageAUDIT, EXECUTE,GRANT
Materialized ViewALTER, AUDIT, COMMENT, DELETE, INDEX, INSERT, LOCK, SELECT, UPDATE
Mining ModelAUDIT, COMMENT, GRANT, RENAME, SELECT
DirectoryAUDIT, GRANT, READ
LibraryEXECUTE, GRANT
Object TypeALTER, AUDIT, GRANT

5 Truncate audit table

  • truncate table SYS.AUD$;

5.1 DBMS_AUDIT_MGMT

  • DBA_AUDIT_MGMT_CONFIG_PARAMS;

2010-12-21

LINUX INFO

Table of Contents

1 Commands

nnext the same level
pprevious
]next deeper
[previous
ttop
ddirectory
llast
rother way of last
Lhistory
mmenu
tabpositions in menu
freference
ssearch
iindex
ggo to node
nmove to the "next" node of this node
pmove to the "previous" node of this node
mpick menu item specified by name (or abbreviation), picking a menu item causes another node to be selected
dgo to the Info directory mode
<go to the top node of this file
>go to the final node in this file
[go backward one node, considering all nodes as forming one sequence
]go forward one node, considering all nodes as forming one sequence
tabmove cursor to next cross-reference or menu item
M-TABmove cursor to previous cross-reference or menu item
ffollow a cross reference. Reads name of reference
lmove back in history to the last node you were at/td>
rmove forward in history to the node you returned from after using l
Lgo to menu of visited nodes
Tgo to table of contents of the current Info file

2010-11-29

EMACS PYTHON MODE

C-c >indent right
C-c <indent left
M-/dynamic completion
C-M-icompletion
C-M-hmark class or function
C-c C-zpython interpreter
C-jgo to next indent line
C-c C-crun buffer
C-c C-rrun selected code
C-M-xrun current functionsy

2010-11-13

EMACS ORG MODE

MANIPULATION
[tab]expand
[Shift]-[tab]colapse
M-[left]/[right]nesting level
M-[up]/[down]change place on the same level
[Shift]-[left]/[right]task status | list type
[Shift]-[down]task priority
EDIT
C-c C-qadd/change tag
C-c C-x padd property
C-c C-x ddelete property
C-c C-eexport to another format
C-c C-cedit checkbox
C-c C-e tinstert default template
-----horizontal line
\\end of line (during export to html)
LINKS
C-c C-ledit link
C-c C-ofollow the link
[[link][description]]link
<<link>>target
[[target]]link to target
[[header]]link to header
DATE and TIME
C-c .add timestamp
[Shift]-[right]change timestamp
C-c C-dadd deadline time
C-c C-sadd schedule time
AGENDA
C-c aopen agenda
fforward week
bbackward week
.present day
C-c [add file to agenda
C-c ]remove from agenda
org-agenda-file variable
[space]press space in agenda window to go to event
ELEMENTS
[% | /]lists status
[ ]checkbox
[fn:1]footnote
TABLES
C-^sort table
| col1 | col2 | [tab]add table row
|-add horizontal line
M-[left] | [right] | [up] | [down] move column | row
[Shift]-M-[down]insert row above
[Shift]-M-[up]delete current row
[Shift]-M-[right]insert column
[Shift]-M-[left]delete column
insert vertical line at first row if want export to html
#+ATTR_HTML: border="1" rules="all" frame="all"border between cells during export to html
<nr>put in empty cell to set column width, you can set #+STARTUP: align parameter
calc
:=add forumla to the current field
:=vmean(@II..@III)vertical arythmetic mean from II to III horizontal line
:=vsum(@II..@III)vertical sum from II to III horizontal line
=add forumla to the whole column, if the field contains only ‘=’, the previously stored formula for this column is used
C-c ?find table current field coordinates
C-c }grid coordinates on/off
$1first column
@1first row
$-2third column from right to left
$+2third column from left to right
@Ifirst hline
@I..@IIrange from first hline to second hline
@1$21nd row, 2rd column
@-1$-3the field one row up, three columns to the left
@-I$2field just under hline above current row, column 2
@2$1..@4$36 fields between these two fields
@-1$-2..@-13 numbers from the column to the left, 2 up to current row
C-u C-c =install a new formula for the current field
C-c =edit the formula for the current field
C-c C-crecompute formula
C-u C-c *recompute all table
C-u C-c *recompute all table
#+TBLFM: @10$2=vsum(@II..@III)::@11$2=@2$2+@3$2compute multi formulas
#+TBLFM: $3=@-1+1::@2$3=1ordered nubmer list at 3rd col
EXPORT OPTION
     #+TITLE:       the title to be shown (default is the buffer name)
     #+AUTHOR:      the author (default taken from user-full-name)
     #+DATE:        a date, fixed, of a format string for format-time-string
     #+EMAIL:       his/her email address (default from user-mail-address)
     #+DESCRIPTION: the page description, e.g. for the XHTML meta tag
     #+KEYWORDS:    the page keywords, e.g. for the XHTML meta tag
     #+LANGUAGE:    language for HTML, e.g. ‘en’ (org-export-default-language)
     #+TEXT:        Some descriptive text to be inserted at the beginning.
     #+TEXT:        Several lines may be given.
     #+OPTIONS:     H:2 num:t toc:t \n:nil @:t ::t |:t ^:t f:t TeX:t ...
     #+LINK_UP:     the ``up'' link of an exported page
     #+LINK_HOME:   the ``home'' link of an exported page
     #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage{xyz}

you can put all above settings to one file and point at by:
#+SETUPFILE: ~/[filepath]
EXPORT TIPS
@<b>bold text@</b>use html tags
#+HTML: Literal HTML code for exportas above
#+BEGIN_HTML
All lines between these markers are exported literally
#+END_HTML
as above
! before export to pdf you must install rubber

EMACS DIRED MODE

M-x direddired mode
oopen file in split window horizontaly
enteropen file | enter dir
Ccopy file
Rrename file
Ddelete file
Zcompress file
Mchmod
Ochown
Gchgrp
mmark
uunmark
Uunmark all
grefresh
Asearch
^parent dir
tnew dir
qclose dir

EMACS

HELP:
C-h mcurent mode info
C-h kkey bind info
C-h asearch function
MAIN:
C-x C-cexit
C-/undo
[space] C-/redo
C-x C-bbuffer list
C-g | Esc Esc Esckeyboard quit
C-x bswitch between buffers
C-x C-wsave buffer as
C-x C-fopen file
C-u [nr] [arg]repeat argument [nr] times, default 4 times
SEARCH:
C-ssearch forward
C-rsearch backward
M-%find and repleace
BUFFERS:
C-x C-ssave all buffers
C-x ssave current buffer
C-x kkill buffer
C-x C-bshow buffer menu
BUFFER MENU:
dkill buffer
ssave buffer
xperform previously requested deletions and saves
uundo save and kill
%read only flag
*modify flag
qquit buffer menu
oopen buffer in another window
WINDOWS:
C-x 2horizontal window
C-x 3vertical window
C-x 0remove current window
C-x 1remove all other windows
C-x ochange window
C-x ^taller window
C-x }wider window
EDIT:
C-[space]select
C-[space] [space]unselect
M-wcopy the previously selected
C-wcut the previously selected
C-ypaste
C-a C-kdelete line
C-kdelete from cursor to the end of line
C-h bhelp key bindings
M-;comment/uncomment
M-g ggo to line
C-x r t [string]insert vertical column
C-x kkill region
Alt ;insert comment
C-x r tinsert character at every match line
C-x r kdelete first rectangle at match line(match upto next line field to delete)
INDENT:
C-u [num | -num] C-x [tab]indent previous selected region [num] of lines, minus means indent left
OTHER MODE:
M-x diredfile manager mode
M-x python-modepython mode

2010-10-22

ORACLE SQLNET

sqlnet.ora
trace_level_server=16 #turn on logging for server (4-USER,10-ADMIN,16-SUPPORT)
trace_level_client=16 #turn on logging for client
trace_directory_server=/tmp/oratrace #logfile dir
trace_directory_client=/tmp/oratrace
trace_file_client=cli #logfile name
trace_file_server=srv
trace_unique_client=true

2010-10-20

KERBEROS

2010-05-10

GIT

git config --list
git config --global user.name "dupa jas"
git config --global user.email fdsf@das.pl
git config --global core.editor vim
git config --global merge.tool diff
git help command
man git-command
git status
git init         #create git structure in .git directory

base commands:

git add . #add all files inside current directory to track git rm file #remove file git mv file1 file2 #move file git commit -a m "comment" #commit all without staged git commit -v #show changes to commit git commit --amend

branching:

git branch -a #list all branches, present with flag * git branch [branch_name] #create new branch git checkout [branch_name] #move to branch git checkout -b [branch_name] #create and move to new branch git checkout -- [file] git branch [branch_name] [hash|tag] #new branch branch_name from hash or tag git branch -d [branch_name] #remove branch git branch --merged git branch --no-merged

logging:

git log git log -1 #show last one commit git log -p -2 #show diff of two last commits git log --pretty=oneline|short|medium|full|fuller|email git log --pretty=format:"%h - %an, %ar : %s" git log --pretty=format:"%h %s" --graph git log --merged #only merged commits

diffs:

git diff #differences between tracking (working directory) and staged files git diff --staged #differences between staged and last commit git diff --cached #as above?

tagging:

git tag #show tags git tag -a v1 -m 'comment' #add new tag git show v1 git tag -a v1.1 hash #tag old commits

other:

git merge [branch_name] #ex inside master branch merging changes from branch branch_name git ls-files --stage #show files with hash in stage git hash-object [file] #make SHA1 hash for file git mergetool #choose merge tool .gitignore #file with list of ignoring files info/exclude #as above but for whole project

initialize git project on server without working directory:

mkdir project-01.git cd project-01.git git --bare init

initialize git project in local directory:

git init git add . git commit -m "initialize project"

initialize bare git project from current project;

- developer1: git clone --bare [current_project] [bare_project].git git remote add [alias] [path_to_bare_project] git remote set-head [alias] master - developer2: git clone [user]@[developer1_hostname]:[path_to_developer1_bare_project]

send to remote server

git remote add [alias] [user]@[server]:/[path on server to git project dir] #add remote alias git push origin master #push from master branch to origin alias git remote -v #check remote server git remote add [alias] user@server:path/project.git #add remote repo git remote show origin git remote rename file1 file2 git remote rm file git clone [url] #clonning repo, not checkout, with all history files etc. git clone git://url dir_name #clone with make local directory dir_name,track master on remote git clone http(s):// git clone user@server:/path #ssh clone with default alias origin creation etc. git clone --bare [project_path] [bare_project_path].git #create bare (without working dir) project from project with working dir git fetch [alias] #fetch data from remote server with alias to local branch (create pointer only), till last fetch or clone, git diff [alias] #compare differences git merge [alias] #merge differences git pull [alias] [local_branch] #as above 3 steps in 1 git remote -v #get remote alias git push [remote_alias] [branch_name] #send branch branch_name to remote repo git push [remote_alias] [branch_name]:[remote_branch_name] #as above with name change git push [remote_alias] :[branchname] #remove remote branch 

working dir-------staging area--------git dir

.git/objects #all content .git/refs #branches .git/HEAD #currently checked out .git/index #staging area (index)

2010-04-16

LINUX PASSWORD POLICY

1 Password strength:

  1. check pam module pam_cracklib.so in /lib/security
  2. edit /etc/pam.d/system-auth
    • password requisite pam_cracklib.so try_first_pass retry=3 minlen=8 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1
      retryattempts to pick new password
      minlenmin password length
      ucreditupper case -1 means at least 1
      lcreditlower case
      ocreditspecial character
      dcreditdigit


2 Password duration:

  • For new accounts default settings are in /etc/login.defs
  • Settings for current accounts are in /etc/shadow but we edit by command chage

2.1 chage

chage -l [user]check settings for user
chage -E "YYYY-MM-DD" [user]set date when account expire, -1 means never
chage -M [nr] [user]set maximum number of days between password change from last password change, -1 means never expire
chage -d "YYYY-MM-DD" [user]set last password change
chage -W [nr] [user]number of days of warning before password expires
chage -i [nr] [user]set password inactive, when account is blocked after password expire

3 Password repeat history:

  • edit /etc/pam.d/system-auth
    • password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=2
      remembernumber of password in history file /etc/security/opasswd


4 Login attempts:

  • check pam module pam_tally2.so in /lib/security
  • edit /etc/pam.d/system-auth
    • auth required pam_tally2.so deny=3 unlock_time=60 lock_time=5
      denynumber of attempts to log without deny
      unlock_timetime in sec when next login attempt perform
      lock_timetime in sec when delay every failed login attempt
    • all logs about login attempts are in /var/log/tallylog but we edit by command pam_tally2

4.1 pam_tally2

pam_tally2 -u [user]check failed login attempts
pam_tally2 -r -u [user]reset failed login attempts

2010-03-05

ORACLE AS

OPMNCTL (Oracle Process Management and Notification Server)
$ORACLE_AS_HOME/opmn/bin/opmnctl help
$ORACLE_AS_HOME/opmn/bin/opmnctl status help
$ORACLE_AS_HOME/opmn/bin/opmnctl status -l
$ORACLE_AS_HOME/opmn/bin/opmnctl stopall
$ORACLE_AS_HOME/opmn/bin/opmnctl startall

check AS version:
cat $ORACLE_AS_HOME/config/ias.properties | grep Version
$ORACLE_AS_HOME/OPatch/opatch lsinventory -detail

2010-02-12

ORACLE AWR

1 EM

  • Oracle Enterprise Manager => Advisor Central

2 DescAWR (Automatic Workload Repository)

  • Stats which are stored in tables WRH$ in SYSAUX tablespace

3 Prerequisities

  • STATISTICS_LEVEL = TYPICAL | ALL

4 Views

4.1 Memory:

  • DBA_HIST_SGA
  • DBA_HIST_PGASTAT
  • DBA_HIST_PGA_TARGET_DEVICE
  • DBA_HIST_SGASTAT
  • DBA_HIST_BUFFER_POOL_STAT
  • DBA_HIST_DB_CACHE_ADVICE
  • DBA_HIST_SHARED_POOL_ADVICE

4.2 Sql:

  • DBA_HIST_SQL_SUMMARY
  • DBA_HIST_SQLSTAT
  • DBA_HIST_SQL_PLAN

4.3 Other:

  • DBA_HIST_SYSSTAT
  • DBA_HIST_FILESTATXS
  • DBA_HIST_WR_CONTROL
  • DBA_HIST_SNAPSHOT
  • DBA_HIST_DATABASE_INSTANCE
  • DBA_HIST_ACTIVE_SESS_HISTORY

5 Snapshots

5.1 Check snapshots time collection

  • SELECT * FROM DBA_HIST_WR_CONTROL

5.2 Set snapshot retention

  • DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS ([retention - min],[interwal - min])

5.3 Run manual snapshot:

  • DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();

5.4 Drop snapshot:

  • DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE([low_id],[end_id]);

6 Reports

6.1 Generate AWR report:

  • $oracle_home/rdbms/admin/awrrpt.sql
  • $oracle_home/rdbms/admin/awrrpti.sql # with instance
  • ADDM reports (Automatic Database Diagnostic Monitor:
  • $oracle_home/rdbms/admin/addmrpt.sql

2009-12-17

ORACLE CREATE

create database manualy:


* create PFILE
main changes:
- db_name
- control_files
- audit_file_dest
- background_dump_dest
- user_dump_dest
- core_dump_dest

example init[dbname].ora
*.__db_cache_size=939524096
*.__java_pool_size=16777216
*.__large_pool_size=16777216
*.__shared_pool_size=587202560
*.__streams_pool_size=33554432
*.control_files='[path]/control1.ora','[path]/control2.ora','[path]/control3.ora'
*.audit_file_dest='[path]/admin/adump'
*.core_dump_dest='[path]/admin/cdump'
*.user_dump_dest='[path]/admin/udump'
*.background_dump_dest='[path]/admin/bdump'
*.compatible='10.2.0.1'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_files=1500
*.db_name='[dbname]'
*.global_names=FALSE
*.job_queue_processes=10
*.log_archive_format='[dbname]%t%s%r.arc'
*.log_checkpoint_interval=10000
*.max_dump_file_size='10240'
*.open_cursors=1000
*.optimizer_mode='CHOOSE'
*.pga_aggregate_target=629145600
*.processes=400
*.query_rewrite_enabled='true'
*.remote_login_passwordfile='EXCLUSIVE'
*.service_names='[dbname]'
*.session_max_open_files=40
*.sga_target=1610612736
*.shared_pool_reserved_size=0
*.undo_management='AUTO'
*.undo_retention=100000
*.undo_tablespace='UNDO_TS'

* create password file for new database:
orapwd file=orapw[dbname] password=[pass]

* add new database to listener.ora and tnsnames.ora,

* create dirs for new database file,

* create dirs for trace logs as admin with subdirectories: adump, udump, cdump, bdump,

* set $ORACLE_HOME,$ORACLE_SID

* startup nomount

* run script:
spool crt_db.spool
startup nomount
create database [dbname]
user sys identified by [pass]
user system identified by [pass]
maxinstances 5
maxloghistory 5
maxlogfiles 10
maxlogmembers 5
maxdatafiles 1000
character set EE8ISO8859P2
national character set AL16UTF16
datafile '[path]/system01.dbf' size 512M autoextend on next 10M maxsize unlimited
sysaux datafile '[path]/sysaux01.dbf' SIZE 1024M
logfile group 1 ('[path]/redo01.log') size 100m,
group 2 ('[path]/redo02.log') size 100m,
group 3 ('[path]/redo03.log') size 100m
default temporary tablespace TEMP tempfile '[path]/temp01.dbf' size 2048M
undo tablespace UNDO_TS datafile '[path]/undotbs01.dbf' size 3000M autoextend off,
'[path]/undotbs02.dbf' size 512M autoextend on next 10M maxsize unlimited;
spool off
* run script:
spool catalog.spool
@$ORACLE_HOME/rdbms/admin/catalog.sql
spool off
spool catproc.spool
@$ORACLE_HOME/rdbms/admin/catproc.sql
spool off
spool catrep.spool
@$ORACLE_HOME/rdbms/admin/catrep.sql
spool off
spool initjvm.spool
@$ORACLE_HOME/javavm/install/initjvm.sql
spool off
spool dbmsrand.spool
@$ORACLE_HOME/rdbms/admin/dbmsrand.sql
spool off
spool utlrp.spool
@$ORACLE_HOME/rdbms/admin/utlrp.sql
spool off

2009-11-10

POSTGRESQL

all informations are inside great documentation
psql
psql [option] -d [dbname] -h [hostname] -U [username]
psql -ldb list
psql syntax:
\timingset show sql execution time
\qquit
\passwordset password
\psetchange psql settings
\lshow databases
\d [table]table desc
\c [database]connect to db
\daagregation functions
\db+tablespaces
\dcconversions
\df+functions
\dg+ \du+roles
\di+indexes
\ds+sequences
\dt+tables
\dv+views
\dSvtis+system views,tables,indexes,sequences
\dn+schemas
\dooperators
\dpprivileges
\encodingdb encoding
\l+db description
\zobjects with privileges
\o [file]spool file
\![command]run OS command
help commands:
\?info about commands with backslash
\hsql help
parameters:
show all;db parameters
show [parametr];show search_path
show search_pathcurrent schama
set search_path to [other_schema]now you can see objects from other schema

administrating:

variable PGDATA point to cluster catalog
pg_ctl status #db state
pg_ctl -D [directory] [action]
pg_ctl start | stop |restart #db start,stop you can add -l [logfile]
pg_ctl stop -m [smart | fast | immediate] #db stop smart(default), fast(with rolleback transactions, immediate(shutdown abort)
pg_controldata [cluser_dir] #cluster info
SELECT pg_database_size('[dbname]'); #show db size SELECT pg_size_pretty(pg_database_size('[dbname]')); #show db size SELECT pg_size_pretty(pg_total_relation_size('[table]')); #show table size with index SELECT pg_size_pretty(pg_relation_size('[table]')); #show table without index

DUMP:

-- export:
pg_dump [db_name] > [file] #dump in plaintext format
pg_dump -t '[table]' [db_name] > [file]
pg_dump -Fc #dump in pg_restore format
pg_dumpall > [file] #dump all databases
-- import:
psql [db] < [plik] #import from plaintext format
psql -f [file] postgres #import from plaintext format
pg_restore -d [baza] [plik] #import from pg_restore format
pg_restore -l [plik] #content of dumpfile

CREATE:

initdb --pgdata | -D [cluster_dir] [-E encoding] #cluster initialization,create template1 and postgres database
createdb [dbname] [-D tablespace] [-E encoding] [-O owner] [-T template to create new database]

change host database IP:

change in $PG_DATA/postgresql.conf
change in $PG_DATA/pg_hba.conf (according manual - chapter 20: Client Authentication)

misc:

ALTER TABLE [table] ALTER COLUMN [column] TYPE int USING [column]::int; #change column type from char to int

MANAGE ROLES:

--check
\dg #check system privs
SELECT * FROM pg_roles;
create role [role_name]; #create role
--change
ALTER ROLE [role_name] SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN | CONNECTION LIMIT [connlimit] | PASSWORD [password] | ENCRYPTED | UNENCRYPTED | VALID UNTIL [timestamp]
--change password
ALTER ROLE [role] PASSWORD '[pass]';

change object privs:

\z #check privs
=xxxx #privileges granted to PUBLIC
uname=xxxx #privileges granted to a user
group gname=xxxx #privileges granted to a group
r -- SELECT ("read")
w -- UPDATE ("write")
a -- INSERT ("append")
d -- DELETE
R -- RULE
x -- REFERENCES
t -- TRIGGER
X -- EXECUTE
U -- USAGE
C -- CREATE
T -- TEMPORARY
arwdRxt -- ALL PRIVILEGES (for tables)
* -- grant option for preceding privilege

GRANT [privs] ON [object] TO [role];