Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Tuesday, September 11, 2012

How to easily identify your trace file

It can be hard to identify individual trace files. One way to
make it easier is to specify a trace file identifier for your session. This can be done
by setting the TRACEFILE_IDENTIFIER parameter from within your session:

ALTER SESSION SET tracefile_identifier=GUY

Now when we look in the trace file directory, the tracefile can be identified
by the trailing “GUY

Thursday, August 23, 2012

Procedure to reset an account on Aix

When this message is received you'll have to reset the account:

3004-303 There have been too many unsuccessful login attempts; please see
the system administrator.

Procedure to reset the account:

chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s <username>
 
chuser "account_locked=false" <username>

Chsec is the command needed to change an user's security attributes.

Sunday, August 12, 2012

How to enable or disable user tracing

User tracing is enabled or disabled at the session or instance level by using the following commands and
parameter:

• Session level using the ALTER SESSION command: ALTER SESSION SET SQL_TRACE = TRUE
• Session level by executing DBMS procedure: dbms_system.SET_SQL_TRACE_IN_SESSION
• Instance level by setting the initialization parameter: SQL_TRACE = TRUE


Friday, June 8, 2012

User / Group management in Red Hat Linux Enterprise

One of the most common administrative tasks is working with user and group accounts. The commands i use most often are
  • useradd — Creates user login accounts 
The useradd command creates new user accounts and, when invoked with the
-D option, modifies the default values applied to new accounts. As a result, it can
be invoked in two ways. The syntax of the first form is

useradd [-c comment] [-d home_dir] [-e expire_date]
[-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir] | -M]
[-p passwd] [-s shell] [-u uid [-o]] [-n] [-r] username

  • userdel — Deletes user login accounts
  • usermod — Modifies user login accounts
  • passwd — Sets or changes account passwords
The  passwd command, generally regarded as  “the password changing utility,”
actually has more capabilities than merely changing passwords. In general, it
updates all of a user’s authentication tokens, of which the login password is only
one. Its syntax is:

passwd [-dkluf] [-S] username

-d removes the password for username, disabling the account. -k causes passwd
to update only expired authentication tokens (passwords, in this case). -l or -u lock
or unlock, respectively, username’s password by placing and removing a ! in front
of username’s password in /etc/shadow. The -S option, finally, displays a short
status message about  username, indicating whether the account is locked or
unlocked, the kind of encryption used, and so forth.
  • chsh — Sets or changes a user’s default shell
chsh [-s shell ] [-l] [username]

-s  shell sets  username’s login shell to  shell. Unless configured otherwise,
shell can be the full pathname of any executable file on the system. One common
way to take advantage of this feature is to disable an account by setting shell to
/bin/false or another command that does not give the user a login prompt. Using
the -l option displays the shells listed in /etc/shells
  • chage — Modifies password expiration information


Saturday, May 26, 2012

oracle resource management scripts

Create resource manager plan

begin
 
  begin
     dbms_resource_manager.create_simple_plan
        (simple_plan => 'MY_PLAN'
        ,consumer_group1 => 'USERS', group1_cpu => 90
        ,consumer_group2 => 'ADMIN', group2_cpu => 10 );
     exception when others then
      null;
  end;

end;
/
 

List the configuration of the Database Resource Manager 

set linesize 1000 
col plan form a40 heading "Plan Name"
col group_or_subplan form a15 heading "Sub-Plan"
col status form a6 heading "Status"
col cpu_p1 form 999 heading "CPU1"
col cpu_p2 form 999 heading "CPU2"
col cpu_p3 form 999 heading "CPU3"
col cpu_p4 form 999 heading "CPU4"

PROMPT
PROMPT Plans on database

select plan, cpu_method, status from dba_rsrc_plans; 

PROMPT
PROMPT Resource Plan Directives

select plan, group_or_subplan, type, cpu_p1, cpu_p2, cpu_p3, cpu_p4, status 
  from dba_rsrc_plan_directives 
order by 8,1,2,3,4,5,6; 

PROMPT
PROMPT Consumer Group Privileges

select * from dba_rsrc_consumer_group_privs; 

PROMPT
PROMPT Default User Consumer Groups

select username, initial_rsrc_consumer_group from dba_users; 

assign a resource manager plan to users

Parameters

&1 - The resource consumer group
&2 - The user to be assigned the consumer group

set verify off

define consumer_group = UPPER('&1')
define user = UPPER('&2')

begin
 
dbms_resource_manager_privs.grant_switch_consumer_group  
      ( grantee_name => &user
      , consumer_group => &consumer_group
      , grant_option => FALSE);

dbms_resource_manager.set_initial_consumer_group
     (user => &user
     ,consumer_group  => &consumer_group ); 

end;
/

exit
 

Monitor Database Resource Manager Sessions

col sid form 999 heading "SID"
col serial# form 99999 heading "Serial"
col program form a28 heading "Program"
col username form a12 heading "Username"
col resource_consumer_group form a22 heading "Consumer Group"
col name form a12 heading "Name"
col active_sessions form 99999 head "Active"
col consumed_cpu_time form 99999999 heading "Con CPU"
col sessions_queued form 99999 heading "Queued" 

spool monrsrc.lst

select sid,serial#,username,program,resource_consumer_group 
from v$session
/

select name,active_sessions,consumed_cpu_time
       ,requests,cpu_wait_time,cpu_waits, sessions_queued
from v$rsrc_consumer_group
/

spool off
 

Drop a resource manager plan and any associated subplans

Parameters

&1 - The Plan Name to drop

set serveroutput on

col plan form a12 heading "Plan Name"

select plan, cpu_method, status from dba_rsrc_plans; 

ACCEPT plan_name PROMPT 'Enter value for Plan to Drop : '

spool drop_rsrc.lst

DECLARE

l_plan_name DBA_RSRC_PLANS.plan%TYPE := UPPER('&plan_name') ;

BEGIN

   dbms_output.put ('Creating Pending Area...');
   dbms_resource_manager.create_pending_area(); 
   dbms_output.put_line ('Pending Area Created.');

   dbms_output.put ('Deleting Plan '||l_plan_name||'...');
   dbms_resource_manager.delete_plan( plan => l_plan_name); 
   dbms_output.put_line ('Plan Deleted.');

   FOR con_grp IN ( SELECT group_or_subplan 
                    FROM  dba_rsrc_plan_directives 
                    WHERE plan = l_plan_name 
                     ) LOOP

      dbms_output.put ('Deleting Consumer Group '
               ||con_grp.group_or_subplan||'...');
      dbms_resource_manager.delete_consumer_group( 
            consumer_group => con_grp.group_or_subplan ); 
      dbms_output.put_line ('Consumer Group Deleted.');

   END LOOP;

   dbms_output.put ('Submitting Pending Area ...');
   dbms_resource_manager.submit_pending_area(); 
    dbms_output.put_line ('Pending Area Submitted.');

EXCEPTION WHEN others  THEN
   
   dbms_output.new_line ;
   dbms_output.put_line ('Error Occurred  :'||SQLERRM);
   
   dbms_resource_manager.clear_pending_area();

   dbms_output.put_line ('... Pending Area Cleared.');

END;
/

spool off

Lists usage information of consumer groups

SELECT name,consumed_cpu_time
FROM   v$rsrc_consumer_group
ORDER BY name;
 

Lists all resource plans

SET LINESIZE 200
SET VERIFY OFF

COLUMN status FORMAT A10
COLUMN comments FORMAT A50

SELECT plan,
       status,
       comments
FROM   dba_rsrc_plans
ORDER BY plan;

Lists all consumer groups

SET LINESIZE 200
SET VERIFY OFF

COLUMN status FORMAT A10
COLUMN comments FORMAT A50

SELECT consumer_group,
       status,
       comments
FROM   dba_rsrc_consumer_groups
ORDER BY consumer_group;
 
 

 

 

Thursday, May 10, 2012

Apply chmod recursively on directories

suppose you want to chmod all subdirectories of current directory
find . -type d -exec chmod 755 {} \;


Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;