Search This Blog

Monday, February 28, 2011

My solaris learning

Today i have decided to go for solaris certification.
Hope it would be great fun learning solaris.

Monday, February 21, 2011

difference between more and less.

The major difference between more and less is it allows more flexibility in terms of navigation on file.
Less allows you to go back where as more doesnt do the same.

To navigate back you press 'u'

Sunday, February 20, 2011

Problems and Resolution.


Today i found out most of our linux machine were not behaving as usual than any other day.
Whenever i tried taking putty of the linux server It used to hang after giving the password .

Later i realize that it was a DNS server issue all across the network .
Also i realize the fact that to avoid ip spoofing linux server validates the client ip/hostname by looking them in dns.As we were having dns issue linux server were not able to resolve the ip/hostname .and was taking time to log in.

However I was able to solve it temporarily by modifying
$ vi /etc/ssh/sshd_config
UseDNS no

#service sshd restart.

or by adding client's IP address in Server's /etc/hosts file.

Linux Log File Information.

The Best way to view log file is to use

#tail -f log_file_name

-f option helps to the changes online.

Boot log files:

You need to be super user to see these file contents.
This file contains log of processes that were started during the boot.
for example:NFS startup,print servers startup
Basically all the messages that you see during the boot processes such as
Starting up NFS service ok

You may see dmesg command for boot related information.

One of the major task of system administrator is to regularly check various log files.
So It is Very Important to know where your hosts keep their log files as the directory is different for different flavors of *nix.

Failed login attempts:

Following log file records failed login attempts to the system


Following line get added when xxx host tries to login with wrong login credentials of root.


Mail Logs:

All Mail Logs are stored in.


Log Rotate:

As log files grows in size .It is important to restrict their size limit.This can be done by a utility called logrotate.
:Important Files:
Here are the three important files used for log rotating.

1) /usr/sbin/logrotate : Original Log rotate command. Its a binary file and we can't see the contents inside it.

2) /etc/logrotate.conf : Configuration file used for logrotate .
Contents of files are as below.

# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# uncomment this if you want your log files compressed

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
minsize 1M
create 0664 root utmp
rotate 1

# system-specific logs may be also be configured here.

3) /etc/cron.daily/logrotate
By default logrotate script executed daily in cron.(This however a different file than binary logrotate we discussed )

content of logrotate file are as below.
# cat /etc/cron.daily/logrotate

/usr/sbin/logrotate /etc/logrotate.conf
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
exit 0

As you can see in /etc/cron.daily/logrotate each day binary /usr/sbin/logrotate is getting executed using /etc/logrotate.conf .

More information on Log rotate can be found very described in below article.

Tuesday, February 15, 2011

create delete cut copy file(s)/folder(s) in linux

Hi These are the most basic command a system administrator should aware of.

In this article i will try to cover all necessary commands.

Create Folder:

(1)Below command will create a folder named temp in root directory.

#mkdir /root/temp

Delete Folder:

(1)Below command will delete a folder named temp from root directory(provided there are no file(s) under temp directory.

#rmdir /root/temp

If the above directory contains any file(s) then we will get following error.

# rmdir /root/temp
rmdir: /root/temp: Directory not empty

Create file:

(1)Below command will create file named sample.txt under /root directory.

#touch /root/sample.txt

Delete file

(1)Below command will delete file named sample.txt from /root directory

# rm /root/sample.txt
rm: remove regular empty file `/root/sample.txt'? y

(2)To delete file without asking for confirmation use -f option along with rm command.

#rm -f /root/sample.txt

Copy file

(1)Copy one file to another folder.

# mkdir /tmp/dir1
# mkdir /tmp/dir2
# touch /tmp/dir1/file1.txt
# touch /tmp/dir2/file2.txt

To copy file1.txt from dir1 to dir2 issue following command.

# cp /tmp/dir1/file1.txt /tmp/dir2/

Now check the content of /tmp/dir2

# ls -ltr /tmp/dir2
total 8
-rw-r--r-- 1 root root 0 Feb 16 21:36 file2.txt
-rw-r--r-- 1 root root 0 Feb 16 21:38 file1.txt

As you can see file1.txt one is copied to dir2.

(2) Copy more than one file to another folder.

Now we will copy file1.txt and file2.txt to /tmp

# cp /tmp/dir2/file1.txt /tmp/dir2/file2.txt /tmp

Now check the content of /tmp

# ls -ltr /tmp
-rw-r--r-- 1 root root 0 Feb 16 21:44 file2.txt
-rw-r--r-- 1 root root 0 Feb 16 21:44 file1.txt

Move a file

(1) Lets move /tmp/file1.txt to root directory.

Check the content of /tmp directory
# ls -ltr /tmp
-rw-r--r-- 1 root root 0 Feb 16 21:44 file2.txt
-rw-r--r-- 1 root root 0 Feb 16 21:44 file1.txt

Move the file1.txt to /
#mv /tmp/file1.txt /

# ls -ltr /file1.txt
-rw-r--r-- 1 root root 0 Feb 16 21:44 /file1.txt

(2)Use mv to rename a file.

You can also use mv to rename a file .
for example.

mv /file1.txt /newfile1.txt

above command will rename file1.txt in root folder to newfile.txt .

# ls -ltr /file1.txt
ls: /file1.txt: No such file or directory
[root@TomcatServer tmp]# ls -ltr /newfile1.txt
-rw-r--r-- 1 root root 0 Feb 16 21:44 /newfile1.txt

Move a folder

(1) Move a folder having sub folders and files to another folder.

Consider we are having following file structure under /tmp directory

now move dir1 along with its sub directories and files to dir2

# mv /tmp/dir1 /tmp/dir2

The end result should look like this.

Wednesday, February 9, 2011

How to change memory for ORACLE VM Server?

Recommended memory size :512 MB.
You can change it by modifying dom0_mem kernel parameter in