Search This Blog

Showing posts with label Linux administration. Show all posts
Showing posts with label Linux administration. Show all posts

Wednesday, July 6, 2011

How to find the port of particular application?

Question : How do I find the port which is used by a particular application ?
Answer :
Consider Tomcat application is running on port 8080.
To check whether the Tomcat is running or not.

Initially you need to understand the output presented by
netstat -ntpl .
In above case Tomcat is using java as their process so i grep with java. Your application might be using different name.

#netstat -ntpl | grep java
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 6375/java
tcp 0 0 :::8009 :::* LISTEN 6375/java
tcp 0 0 :::8080 :::* LISTEN 6375/java

You should see at least one java process and you can use ps to identify if this is Tomcat.

# ps -ef | grep 6375
root 6375 1 0 May18 pts/2 00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root 9222 5091 0 18:29 pts/2 00:00:00 grep 6375

for killing the process just use.
kill -9

The above article is with reference to my question posted on below forum .
http://www.linuxquestions.org/questions/showthread.php?p=4010963&posted=1#post4010963

Monday, June 20, 2011

Puppet Configuration and Installation.

Puppet server is used to implement mass changes throughout the organization.

For example:
If a Organization requires you to disable ctr+alt+del on all of its servers by commenting
ca::ctrlaltdel:/sbin/shutdown -t3 -r now line of /etc/inittab file.

You will end up modifying /etc/inittab file of each and every linux distribution.

However the task will be easily done if you install puppet server all you need to do is to keep a copy of /etc/inittab on puppet server and then distribute it on linux distributions throughout your organization(provided they all have same version of /etc/initab files) .
There is lot other things that can be implemented using puppet .

For a basic configuration please refer the below article.

Server Side configuration:
Make sure you have following rpms .

ruby-lib
ruby
facter
puppet-server
puppet

# rpm -ivh ruby-libs-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby-libs ########################################### [100%]
# rpm -ivh ruby-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby ########################################### [100%]
# rpm -ivh facter-1.5.1-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:facter ########################################### [100%]
# rpm -ivh puppet-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet ########################################### [100%]
# rpm -ivh puppet-server-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet-server ########################################### [100%]

After installing the necessary rpms Now its time to configure the server.

Store all your files at following location(If the location doesnt exists then create it using # mkdir -p /etc/puppet/files).
/etc/puppet/files
We will store /etc/inittab file (with ctr+alt+del disabled) in above location .

Now we will create /etc/puppet/manifests/site.pp file.
This file holds all the puppet rule in form of classes.

class inittab_implement {
file { "/etc/inittab": #This file will be modified at client
ensure => present, #Check file existence . if not exists ,creates the file
mode => 744, #Permission
owner => root, #Ownership
group => root, #Group Owner
source => "puppet:///files/inittab" #source motd file
}
}
node 'default' {
include inittab_implement
}

Now the last step is to modify /etc/puppet/fileserver.conf.
This file ensures
1) Default location of puppet files.
2) which client machines should be allowed to get service from puppet server(This can be different on what is given in below example depending upon your network configuration).

edit the file and add following .
[files]
path /etc/puppet/files
allow 10.0.0.0/8

Start the puppetmaster service on server.

#service puppetmaster start
It would be nice if you add it to startup.
#chkconfig puppetmaster on
This is all about Server configuration now lets talk about client configuration.

Client Side configuration:
Make sure you have following rpms .

ruby-libs
ruby
facter
puppet

# rpm -ivh ruby-libs-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby-libs ########################################### [100%]
# rpm -ivh ruby-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby ########################################### [100%]
# rpm -ivh facter-1.5.1-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:facter ########################################### [100%]
# rpm -ivh puppet-
puppet-0.24.5-1.el5.noarch.rpm puppet-server-0.24.5-1.el5.noarch.rpm
# rpm -ivh puppet-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet ########################################### [100%]

Now edit the /etc/puppet/puppet.conf file and add the below parameter:
server = PuppetMaster.domain.com #(Host name of my puppet server is PuppetMaster)
Make sure you have proper entry in /etc/host file on both puppet server and puppet client side.

Edit /etc/sysconfig/puppet file as mentioned below.

# The puppetmaster server
PUPPET_SERVER=PuppetMaster.domain.com

# If you wish to specify the port to connect to do so here
#PUPPET_PORT=8140

# Where to log to. Specify syslog to send log messages to the system log.
PUPPET_LOG=/var/log/puppet/puppet.log

# You may specify other parameters to the puppet client here
PUPPET_EXTRA_OPTS=--waitforcert=60 #this defines the time interval for puppet client to look for any update on puppet server.

For testing purpose the time is made as 1 minute you may set it little higher once the testing is done.

Now start the puppet service and add it on startup
# service puppet start
# chkconfig puppet on


You should now be able to run below command.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test

Unfortunately i was getting below error .
You may get this kind of error when both server and client time is not sync.(source google)
So i synced the time
Yet i was facing the same issue.
The problem was with the clients ssl certificate so i deleted the client cert using
# rm -rf /var/lib/puppet/ssl/

Next time when i run the command i got the following output.
So it has created new certificate.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test
info: Creating a new certificate request for test-ovs-2.domain.com
info: Creating a new SSL key at /var/lib/puppet/ssl/private_keys/test-ovs-2.domain.com.pem
warning: peer certificate won't be verified in this SSL session
notice: Did not receive certificate
notice: Set to run 'one time'; exiting with no certificate

warning: Certificate validation failed; considering using the certname configuration option
err: Could not retrieve catalog: Certificates were not trusted: certificate verify failed
warning: Not using cache on failed catalog

Now run the below command on puppet server.
It should now list the puppet client.
# puppetca --list
puppetclient.domain.com
Now sign the puppet client using
# puppetca --sign test-ovs-2.domain.com
Signed test-ovs-2.domain.com

Now try to execute previous command on client.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test
warning: peer certificate won't be verified in this SSL session
notice: Got signed certificate
info: Caching catalog at /var/lib/puppet/localconfig.yaml
notice: Starting catalog run
53c53
< x:5:respawn:/etc/X11/prefdm -nodaemon
---
> #x:5:respawn:/etc/X11/prefdm -nodaemon
info: Filebucket[/var/lib/puppet/clientbucket]: Adding /etc/inittab(5528f318b4fa5604efe51f3a8c5ca734)
info: //Node[default]/inittab_implement/File[/etc/inittab]: Filebucketed to with sum 5528f318b4fa5604efe51f3a8c5ca734
notice: //Node[default]/inittab_implement/File[/etc/inittab]/source: replacing from source puppet:///files/inittab with contents {md5}a43ac1c17a59b1facea7db112e69fb42
notice: Finished catalog run in 0.38 seconds

Now check the /etc/inittab file on client machine it should match to puppet server's(/etc/puppet/files/inittab) file.

I hope this article solved your basic queries over puppet configuration and installation.

Wednesday, June 1, 2011

How to find Big Size File and Folder in Linux?

Here is the trick

Use the following to find the spacious directory.
#find / -type d -exec ls -ld {} \; |sort -nrk5|head

Use the following to find the spacious file.
#find / -type f -exec ls -ld {} \; |sort -nrk5|head

The output may take time depending on your system performance.

How to Extend Root partition using LVM?

In this article,I am using a virtual instance of linux machine hosted on SUN virtual box.

The linux machine is allocated a harddisk space of 5 gb .
The root partition itself occupied 4 GB of space and the rest was allocated to Swap.

It was all clear from a beginning that i m going to face space crunch on the newly created machine.

Thankfully root was partitioned with LVM.

So i added a new Hardisk of 8 GB and extended the / size.

I found following post very useful .

http://www.turnkeylinux.org/blog/extending-lvm

I described my problem on following forum and the reply was so informative.
http://www.unix.com/unix-dummies-questions-answers/160635-how-extend-root-partition.html#post302526559

http://www.linuxquestions.org/questions/showthread.php?p=4372596#post4372596

I learned not to grow the partition when it is mounted(Especially /) and rather use live CD to do the same.

Wednesday, May 25, 2011

How Find out number of Machines (IP address) connected to Linux Server?

Use below Command to find out number of Machines connected to Server.

#netstat -nat | awk '{ print }' | cut -d: -f1 | sed -e '/^$/d' | uniq

Thursday, May 5, 2011

How to check a file being used by a process?

It would be a best practice to check if the file is being used by any process before deleting it.

This can be easily done by using lsof utility .

for example if i want to delete a file System.img . I will first check whether it is being used by any process or not.


# lsof System.img
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
qemu-dm 19376 root 10u REG 0,26 80015523840 1763 System.img

As you can see the qemu-dm process is using the file so i better of first find what qemu-dm is doing on the file and then delete it.

Monday, January 24, 2011

Single user mode.

Before bringing your machine is single user mode
Make sure
1)you inform other users logged in about the event using wall command.
2)If you are sharing a files using NFS protocol Make sure you disable network access to shared file systems using exportfs -ua.
3)Make sure no critical process such as backupjobs are running in background.
4)run.
#/sbin/telinit 1
5)confirm the runlevel using runlevel command.

Here is a different way of doing it at system boot.

http://www.cyberciti.biz/faq/grub-boot-into-single-user-mode/

Here are some issues faced by me during single user mode.

http://www.unix.com/unix-dummies-questions-answers/155269-not-able-log-into-single-user-mode.html


http://www.linuxquestions.org/questions/showthread.php?p=4277312&posted=1#post4277312

Wall command in linux

This command has lot of usage to System Administration.
wall command becomes very handy in situation where superuser is forced to restart the machine or need inform other user about next scheduled downtime .

#wall "We are going to restart this server .Kindly log off or save all your work within next 15 minutes"

above message will get displayed on every terminal user of the server .

IP tables Simplified.

IPtables in unix are nothing but firewall rules defined for the machines.

There are four types of IPtables.

  1. Filter Table(default table)
  2. NAT table
  3. Mangle table
  4. Raw table

To list the iptables you need to type following command.

1) Filter table:
# iptables --list (if you dont specify -t (type) filter tables will be displayed)
or
# iptables -t filter --list

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

2) To list mangle tables.

# iptables -t mangle --list

3) To list NAT tables.

#iptables -t nat --list

4) To list raw tables.

# iptables -t raw --list

start or stop iptables rules

To start (Enforce) iptable rules:

#Service iptables start

To stop (rollback) iptables rules:

#Service iptables stop

More Information over iptables can be obtained from below link.

http://www.thegeekstuff.com/2011/01/iptables-fundamentals/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29

Friday, October 22, 2010

Interesting Linux Commands.

Index:

1)Command to find the Installation date of O.S.

2)How to find Most Used Linux commands of your machine?
3)
Blink LED of Network Card to find physical port
4)Command to scare people.
5)Prevent accident Play safe use Echo.

===================================================
1)Command to find the Installation date of O.S.

Still dont remember last time you have installed an OS.
Dont worry Following command can help you get the exact date.

Method 1:

# tune2fs -l /dev/root | grep created
Filesystem created: Wed Oct 13 19:08:13 2010


Method 2:
First find the location of install.log in your machine.
# find / -name install.log
/root/install.log
then you can check the detail using ls -ltr /root/install.log.
# ls -ltr /root/install.log
-rw-r--r-- 1 root root 14038 Oct 13 13:40 /root/install.log
in above example install.log is created on Oct 13 So the OS is installed on 13th Oct.
===================================================
2)How to find Most Used Linux commands of your machine?

I know the question is quite simple but yet interesting.You can use following command to find out which is the most used command of your Linux Machine .

# cut -f1 -d" " .bash_history | sort | uniq -c | sort -nr | head -n 10
113 cd
98 ls
83 xm
64 cat
59 dir
59 df
55 find
48 sysctl
42 vi
36 mount

other way of doing the same thing.

# history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
113 cd
98 ls
80 xm
64 cat
59 dir
59 df
55 find
48 sysctl
42 vi
36 mount


from above output its very clear that "cd" is the most used command in my distribution.
I know there are no practical usage of this command but sometime its good to know which command stress your fingers :)

===================================================

3) Blink LED of Network Card to find physical port corresponds network interfaces(eth0,eth1,...)... (Use this in-case of multiple network ports).

If you want to make sure which physical interface is eth0 and which is eth1 or eth2 and so on

run:

#ethtool -p eth0 20

This blinks the LED on the interface for five seconds–without interrupting network traffic.
More commands will be updated soon.

===================================================
4)Command to scare people.

Well this one is one of my favorite.

It just produces random sound from your machine.
I use this command for following usage.
1)To scare people.
2)To find the machine location especially when you dont know the physical location.

how it works ?
Just type
#dd if=/dev/urandom of=/dev/dsp
The random sound will start coming up from your machine.
Well this may not be the fun but imagine if you can scare your
colleague who sits in same LAN of yours.

Just use SSH to do this.

# ssh username@Ipaddressofmachine dd if=/dev/urandom of=/dev/dsp

It will then ask you the password just type it and you are done.

To stop the noise you can find the process using following steps.
Step 1: Find process id of dd command.
# ps -ef |grep dd
root 4861 1 0 11:35 ? 00:00:00 /usr/bin/hidd --server
68 5318 5311 0 11:36 ? 00:00:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
68 5323 5311 0 11:36 ? 00:00:00 hald-addon-keyboard: listening on /dev/input/event0
root 5556 1 0 11:58 ? 00:00:00 dd if /dev/urandom of /dev/dsp
root 5597 5571 0 11:59 pts/0 00:00:00 grep dd

As you can see from above output the process ID is
5556.

Step 2: Just kill it using.

# kill 5556
---Process id can be different please run step 1 to check whats your process id and substitute in front of kill.



5)Prevent accident Play safe use Echo.

Its always a good idea to foresee what would be the impact of your command.
for example
# echo rm *.txt

above command will not delete all the txt files but will display what files will get deleted if you run
#rm *.txt


===================================================

Monday, October 11, 2010

Disable SSH Version 1

For a best practice it is recommended to disable SSH version 1 and instead use version 2.

A good article over how to disable SSH version 1 is given in following link.

http://www.skullbox.net/disablessh1.php

Sunday, October 10, 2010

changing Kernal parameters for security reasons.

Disable Source Routing:

The kernel parameter net.ipv4.conf.all.accept_source_route must be set to "0" (zero) to disallow source routing.

IP Forwarding:

The kernel parameter net.ipv4.ip_forward must be set to "0" (zero) to disallow IP Forwarding.

ICMP Broadcast Response:

The kernel parameter icmp_echo_ignore_broadcasts must be set to "1" (one).

Syn Flood Protection:

The kernel parameter net.ipv4.tcp_syncookies must be set to "1" (one) in order to defend against Syn Flood attacks .

Reverse Path Filter:

The kernel parameter net.ipv4.conf.all.rp_filter must be set to “1” so that the network subsystem will validate source addresses against the Routing Table.

Accepting ICMP redirects:

The kernel parameter net.ipv4.conf.default.accept_redirects must be set to “0” so that the network subsystem will not accept ICMP redirects.

Sending ICMP Redirects

The kernel parameters net.ipv4.conf.all.send_redirects and net.ipv4.conf.default.send_redirects must both be set to “0” so that the network subsystem will not send out ICMP redirects.

Tuesday, October 5, 2010

Message of the day (/etc/motd)

It would be nice to inform the users of the machine that you are going to make it shutdown for some time .

Being a Linux System administrator You have several ways of informing users.
/etc/motd file is one of them.

Just edit the file with whatever content you want to display .

once some user logged into machine using terminal session.He will be greeted with message in /etc/motd.

Remove rsh, rcp and rlogin

It is highly recommended to remove following command on production server .
There are several ways of not using the command choose one that is suitable for your need.

Method 1:

Just try to find the rpm for the above command.
This can be done using.

rpm -qa | grep -i rsh
rsh-0.17-38.el5
rpm -qa | grep -i rcp
rpm -qa | grep -i rlogin

As you can see only first command return any output.

We need to further see what command rsh-0.17-38.el5 contains.

This can be done using

# rpm -ql rsh-0.17-38.el5
/usr/bin/rcp
/usr/bin/rexec
/usr/bin/rlogin
/usr/bin/rsh
/usr/share/man/man1/rcp.1.gz
/usr/share/man/man1/rexec.1.gz
/usr/share/man/man1/rlogin.1.gz
/usr/share/man/man1/rsh.1.gz


From the output you can assume that by uninstalling the rpm you can achieve the removal of those command from production server.


Method 2:

Change the file permisisons:

(First check the location of command using which command name.Below examples are given considering the commands are located under /usr/bin/rcp This could be different for different Linux Distributions.)

chmod 000 /usr/bin/rcp

chmod 000 /usr/bin/rsh

chmod 000 /usr/bin/rlogin

Method 3:

just remove execute bit of the command using.


(First check the location of command using which command name.Below examples are given considering the commands are located under /usr/bin/rcp This could be different for different Linux Distributions.)


chmod -x /usr/bin/rcp

chmod -x /usr/bin/rsh

chmod -x /usr/bin/rlogin

Method 4:

Remove the command itself using.

rm -rf `which rcp`
rm -rf `which rlogin`
rm -rf `which rsh`

Monday, October 4, 2010

Display a legal warning before login(SSH).

Create a file called /etc/ssh/sshd-banner.

Paste the customized banner message in it.
For example:
"This Machine is for the exclusive use of XYZ organization and Unauthorized access or breach of these terms may result in termination of your authorization and/or criminal penalties."

edit /etc/ssh/sshd_config with following entry

Banner /etc/ssh/sshd-banner


Restart sshd service using.

#service sshd restart

To validate the changes:
Try to login to the server using putty.
put username and press enter .
You should get banner displaying text under /etc/ssh/sshd-banner file.

For example:

login as: root
"This Machine is for the exclusive use of XYZ organization and Unauthorized access or breach of these terms may result in termination of your authorization and/or criminal penalties."
root@'s password:


Click here for more reference:
http://www.cyberciti.biz/tips/change-openssh-sshd-server-login-banner.html




Monday, August 23, 2010

Linux Administration

Today i have decided to give a try on Linux administration.

Not to use root account anymore:
First all all i will make a firm decision not to use root account for my daily purpose.
How how do i do my daily task?
I will make two users named admin and worker.
Admin:
Admin user will be given admin privilege to do Admin specific tasks.
Worker:
Normal user of the machine, who is restricted from admin tasks.
Step 1:
Create two users:
Login with root
# useradd admin
# passwd admin
Changing password for user admin.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# useradd worker
# passwd worker
Changing password for user worker.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Now its time to give Admin user some more privileges than worker user.
Login with root user.

Just keep the backup of /etc/sudoers file using

#cp /etc/sudoers /etc/sudoers.old

type
#visudo in command prompt.(This will modify /etc/sudoers file.This command is better way to modify /etc/sudoers than issuing vi /etc/sudoers .)

Modify the file accordingly
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS

User_Alias ADMINS = admin

## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

%admin ALL=(ALL) ALL

save it using esc :wq.


Now you have added admin user in sudoers file with all command execution rights.
Note : visudo is a command line utility to edit /etc/sudoers file.
Its recommended to avoid vi editor.

Now its time to check if whatever is done is working or not.

Lets open two separate terminals.
one for admin user and one for worker user.
Now try to run any command which need root privileges to run.(I m using ifconfig here).
[admin@localhost ~]$ ifconfig
-bash: ifconfig: command not found
[worker@localhost ~]$ ifconfig
-bash: ifconfig: command not found
As you observe both users are unable to run the command.

With admin terminal type following.
#/sbin/ifconfig
It will display the output as admin user is added in sudoer file with all command privilege.
The same can't be done with worker user.

Monday, August 9, 2010

Actual script( Doctortux)

After a long discussion with various forums i have decided to name it as doctortux.

I m going to post modified content of Performance monitoring script.


#######################################################################
#!/bin/bash
#########################UPTIME########################################
fn_uptimeinfo()
{
echo "Machine Uptime Information:"
echo -e "\033[32m uptime"
tput sgr0 #restores the terminal settings to normal.
uptime
echo "Command Description:"
echo " "
echo "Number of users logged in to machine"
echo "load average ,,"
echo "________________________________________________________________"
}
fn_terminalinfo()
{
echo "Terminal Information:"
echo -e "\033[32m w"
tput sgr0
w
echo "________________________________________________________________"
}
#################################################################
#####################CONNECTION INFO############################
fn_numberofconnection()
{
echo "Connection Information"
echo -e "\033[32m netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq"
tput sgr0
netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq
}
#################################################################
######################CPU INFO########################################
fn_cpuinfo()
{
echo -e "\033[32m cat /proc/cpuinfo"
tput sgr0
cat /proc/cpuinfo
echo "________________________________________________________________"
}
fn_cpueaterprocess()
{
echo "Top 10 C.P.U Consumer Processes:"
echo -e "\033[32m ps -auxf | sort -nr -k 3 | head -10 "
tput sgr0
ps -auxf | sort -nr -k 3 | head -10
echo "________________________________________________________________"
}
######################################################################

#########################Memory Information###########################
fn_meminfo()
{
echo -e "\033[32m cat /proc/meminfo"
tput sgr0
cat /proc/meminfo
echo "________________________________________________________________"

echo -e "\033[32m free -m"
tput sgr0
free -m
echo "________________________________________________________________"

}

fn_memeaterprocess()
{
echo "Top 10 Memory Consumer Processes:"
echo -e "\033[32m ps -auxf | sort -nr -k 4 | head -10 "
tput sgr0
ps -auxf | sort -nr -k 4 | head -10
echo "________________________________________________________________"
}
######################################################################
#######################Disk Information###############################
fn_diskinfo()
{
echo "Disk Utilization"
echo -e "\033[32m df -h"
tput sgr0
df -h
echo "________________________________________________________________"
}
fn_partitioninfo()
{
echo "Disk Partition Information"
echo -e "\033[32m cat /proc/partitions"
tput sgr0
cat /proc/partitions
echo "________________________________________________________________"
}
######################################################################
fn_automatic()
{
echo "########CPU Information########"
fn_uptimeinfo
fn_terminalinfo
fn_cpuinfo
fn_cpueaterprocess
echo "########Memory Information########"
fn_meminfo
fn_memeaterprocess
echo "########Disk Information########"
fn_diskinfo
fn_partitioninfo
echo "#######Connection Information#######"
fn_numberofconnection
}
if [ $# -eq 0 ]
then
echo "Automatic Mode Selected"
fn_automatic
else
while getopts ai option 2>/dev/null
do
case "$option" in
a) echo "Automatic Mode Selected"
fn_automatic
echo "Thanks";;
i) echo "Interacive Mode Selected";;
?) echo "Please select proper option"
echo list of available options
echo "-a automatic -i interactive" ;;
esac
done
fi