UNIX Commands

These are some interesting UNIX Commands are used during the middleware administration.

1. To set the “tree” alias to list all the directory in the UNIX terminal as tree structure.

tree=’ls -R | grep :$ | sed -e ‘\”s/:$//’\” -e ‘\”s/[^-][^\/]*\//–/g’\” -e ‘\”s/^/ /’\” -e ‘\”s/-/|/’\’

Output of the above command is like this:

/home/mqm$tree
|-mqsc_scripts
|—logs
|-omegamon
|—Deploy
|—InstallITM
|—–plugin
|——-plugins
|—REPORTS

2. “find” command.
One of the useful command to find the files and directories in the UNIX file system is “find” command. The find command takes the following argument to identify the files or directory in UNIX file system.

find . -type f -print -exec grep -i “type your string here to find” {} \;

To find out the result and we can use the output to filter the result strings.

find . -name *.txt | xargs du -h|grep -i M

The below command gives the same output, but we can not use the output to other grep commands.. (may be I don’t know how to use that)

find . -name “test*” -exec du -sh {} \;

 

http://www.oracle.com/us/support/library/lifetime-support-middleware-069163.pdf

3. Software (Package) installation and query details:

$which gcc
/usr/bin/gcc

$whereis gcc

$ locate httpd

redhat$rpm -q python

redhat$ rpm -qf /etc/httpd

freebsd@pkg which /usr/local/sbin/httpd

/usr/local/sbin/httpd was installed by package apache-24-2.x.x

ubuntu@dpkg -query -S /etc/apache2
apache2: /etc/apache2

4. Installing new software/package in UNIX/Linux:

ubuntu$sudo apt-get install
redhat$sudo yum install
freebsd$sudo pkg install -y

 

5. Simple HTTP Server using python.

python m SimpleHTTPServer 8000

6. sar command will help to get the CPU and Memory utilization for any unix servers. Usage the following command to get the current and past history report.

sar -A               (To get the current report)

sar -A -f /var/log/sa/sa23  ( To get the past reports e.g. 23rd of the month)

Use the ksar tool to analyses this report.

https://sourceforge.net/projects/ksar/

 

 



 

 

 

python -m SimpleHTTPServer 8000
Advertisements

Responses

  1. Command to delete logs that are older than 365 days

    find . -name “*.log” -mtime +365 -exec rm {} \;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: