2008年11月25日 星期二

Solaris Command

Finding Large Directories

to output the 10 largest directories in /var, sorted in ascending size order, use the following command:

  • du -ko /var|sort -n |tail -10
  • du -kod /var|sort -n |tail -10

Finding Large Files

1. Example 1: To find all plain files (not block, character, symbolic links, and so on) in a file system larger than 200,000 512-byte blocks (approximately 100 Mbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:

  • find / -size +200000 -type f -ls |sort -k 7,7 -n

2. To find all plain files (not block, character, symbolic links, and so on) in a /var file system larger than 1,000 512-byte blocks (approximately 500 Kbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:

  • find /var -size +1000 -type f -ls |sort -k 7,7 -n

2008年11月16日 星期日

Using DBMS_SYS_SQL Package to grant Privilege

SQL> declare
2 sqltext varchar2(200);
3 c integer;
4 begin
5 for userlist in (select user_id,username from all_users where username not in ('SYS','SYSTEM','EYGLE')) loop
6 for tablelist in (select owner,table_name from dba_tables where owner = userlist.username) loop
7 sqltext := 'grant all on '||tablelist.owner||'.'||tablelist.table_name ||' to eygle with grant option';
8 c := sys.dbms_sys_sql.open_cursor();
9 sys.dbms_sys_sql.parse_as_user( c,sqltext,dbms_sql.native,userlist.user_id);
10 sys.dbms_sys_sql.close_cursor(c);
11 end loop;
12 end loop;
13 end;
14 /

PL/SQL procedure successfully completed.

SQL>
SQL> set pause on
SQL> select owner,table_name,privilege,grantable from dba_tab_privs where grantee='EYGLE' and owner='SCOTT';
OWNER TABLE_NAME PRIVILEGE GRA
------------------------------ ------------------------------ ---------- ---
SCOTT BONUS ALTER YES
SCOTT BONUS DELETE YES
SCOTT BONUS INDEX YES
SCOTT BONUS INSERT YES
SCOTT BONUS SELECT YES
SCOTT BONUS UPDATE YES
SCOTT BONUS REFERENCES YES
SCOTT DEPT ALTER YES
SCOTT DEPT DELETE YES
SCOTT DEPT INDEX YES
SCOTT DEPT INSERT YES

OWNER TABLE_NAME PRIVILEGE GRA
------------------------------ ------------------------------ ---------- ---
SCOTT DEPT SELECT YES
SCOTT DEPT UPDATE YES
SCOTT DEPT REFERENCES YES
SCOTT EMP ALTER YES
SCOTT EMP DELETE YES
SCOTT EMP INDEX YES....

2008年8月12日 星期二

Cisco switch port security

switchport port-security maximum {max # of MAC addresses allowed}:
You can use this option to allow more than the default number of MAC addresses, which is one. For example, if you had a 12-port hub connected to this switch port, you would want to allow 12 MAC addresses—one for each device. The maximum number of secure MAC addresses per port is 132.

switchport port-security violation {shutdown/ restrict/ protect}:
This command tells the switch what to do when the number of MAC addresses on the port has exceeded the maximum. The default is to shut down the port. However, you can also choose to alert the network administrator (i.e., restrict) or only allow traffic from the secure port and drop packets from other MAC addresses (i.e., protect).

switchport port-security mac-address {MAC address}:
You can use this option to manually define the MAC address allowed for this port rather than letting the port dynamically determine the MAC address.

Here's an example:
Switch)# config t
Switch(config)# int range fastEthernet 0/1 - 24
Switch(config-if)# switchport port-security


View the status of port security
Switch# show port-security address
Switch# show port-security interface fa0/18

2008年7月8日 星期二

List All users in Linux

cat /etc/passwd | grep "/home" |cut -d: -f1
Now what we have done is that we have piped the output of previous command to another variable "cut"
What we have done here is we have added
cut -d: -f1
-d: means delimiter :
-f1 means display first field of line i.e. username.

2008年6月27日 星期五

Reverse proxy


A reverse proxy dispatches in-bound network traffic to a set of servers, presenting a single interface to the caller.


mod_proxy.c for Apache Ver 2.2
Forward Proxy
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Deny from all
Allow from internal.example.com
</Proxy>

Reverse Proxy
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar

There are several reasons for installing reverse proxy servers:


  • Security: the proxy server may provide an additional layer of defense by separating or masquerading the type of server that is behind the reverse proxy. This configuration may protect the servers further up the chain - mainly through obfuscation.
    Encryption / SSL acceleration: when secure websites are created, the SSL encryption is sometimes not done by the Web server itself, but by a reverse proxy that is equipped with SSL acceleration hardware.

  • Load distribution: the reverse proxy can distribute the load to several servers, each server serving its own application area. In the case of reverse proxying in the neighborhood of Web servers, the reverse proxy may have to rewrite the URLs in each webpage (translation from externally known URLs to the internal locations).

  • Caching static content: A reverse proxy can offload the Web servers by caching static content, such as images. Proxy caches of this sort can often satisfy a considerable amount of website requests, greatly reducing the load on the central web server. Sometimes referred to as a Web accelerator.

  • Compression: the proxy server can optimize and compress the content to speed up the load time.

  • Spoon feeding: a dynamically generated page can be produced all at once and served to the reverse-proxy, which can then return it to the client a little bit at a time. The program that generates the page is not forced to remain open and tying up server resources during the possibly extended time the client requires to complete the transfer.

2008年6月18日 星期三

Using NFS - (Solaris)

The first thing to ensure is that the proper daemons for running NFS are started. If unsure, I will typically just run them when I cannot determine whether or not they are running:

$ su -
$ cd /usr/lib/nfs
$ ./mountd
$ ./nfsd


Sharing A File System
The following example will share a file system /software so that others may be able to mount it:
# share /software
If I want to check all file systems being shared from my system:
# share
- /software rw ""


How to NFS A File System
Now, from another machine, I want to NFS the file system that is being shared above:
# mount -F nfs alex:/software /mnt/software

How to Unmount an NFS File System
Finally, let's unmount the previously mounted file system:
# umount /mnt/software

nfs mount: mount: /sharepoint: Not owner

When trying to mount a share from a Linux server (RHEL5) Solaris (10) issues this very useful message:
bash-3.00# mount server:/nfsshare /sharepoint
nfs mount: mount: /sharepoint: Not owner

This appears to be an issue with NFS v4 on Linux and Solaris 10. To fix this edit:
/etc/default/nfs
and change
#NFS_CLIENT_VERSMAX=4
to
NFS_CLIENT_VERSMAX=3

Or of one time mounts simply add the following to the command line
mount -o vers=3 server:/nfsshare /sharepoint