Open community for all Linux users!

Welcome, Guest. Please login or register.
Did you miss your activation email?
September 06, 2008, 09:31:12 PM

Login with username, password and session length

HomeHome HelpHelp SearchSearch LoginLogin RegisterRegister
Open community for all Linux users! Discussion & Documentation Howto's for System Administrator Topic: Advance command for System Administrator 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Advance command for System Administrator  (Read 3968 times)
« on: August 09, 2006, 02:36:52 AM »
Offline sysconfig
Full Member
*
Posts: 112
Gender: Male

View Profile WWW
To get the list of username with its user ID in formatted way:

Quote
# awk -F":" '{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd

Find the particular string from the list of files in current directory:

Quote
# cd /etc
# for i in $(find -type f); do grep -iH nfsnobody $i; done

Or

Quote
# grep -iH nfsnobody *

Get the no of occurrences of particular word in file:

Quote
# awk '/ServerName/ {i=i+1} END {print i}' /etc/httpd/conf/httpd.conf
# grep ServerName /etc/httpd/conf/httpd.conf

To delete resources of semaphore arrays from memory:

Quote
# ipcs -s | grep apache | perl -e 'while (<STDIN>) { @a=split(/\s+/); print`ipcrm sem $a[1]`}'

To check whether perl module is installed correctly or not:
 
If all is correct then output of this command nothing

Quote
# perl -e 'require Mail::SPF::Query'


To install CPAN module:
Quote
#cpan
 cpan> install Mail::SPF::Query
 CPAN: Storable loaded ok
 Going to read /root/.cpan/Metadata
 Database was generated on Thu, 24 Nov 2005 14:54:20 GMT
 Mail::SPF::Query is up to date.


To get the list of IP addresses in the server:

Quote
#ifconfig | grep -vw inet6 | grep -w inet | cut -d : -f 2 | cut -d \  -f 1

Find list of IP address along with eth device and network mask:

Quote
# ifconfig | cut -d " " -f1,12,16 | grep -A 1 eth | tr -d - | tr -s "\n" |sed -e :a -e N -e 's/\n/ /'

Know the performance of your HardDisk:

change the device address as per your servers configuration

Quote
# hdparm -Tt /dev/sda   


Get the customized output of raw accesslog of httpd:
Navigate the folder where your http access log reside

Quote
# tail -f access_log | awk '{if ($11 ~"\"-\"") print $1, $7, $12; else print $1, $10, $11, $12}'

The details of the present http connections can be found by using:

Quote
# netstat -plan | grep ":80 " | awk {'print $5'} |awk -F: {'print $1'}|sort
# cat /proc/net/ip_conntrack | grep "port=80" | wc -l

Number of connection from perticular IP addfess:

Quote
# netstat -ntu | awk '{print $5}'| cut -d: -f1 | sort | uniq -c | sort -nr | more

No of conections:

Quote
# netstat -alntp

#/sbin/ldconfig /usr/local/lib   - Update the system linker cache

Port scanning using nmap:
You can customized it to get more informative output

Quote
# nmap -sS localhost  -
instead host localhost, it could be IP address of another server which is in question

You can execute bash command a certain number of times by using something similar to the following:

   
Quote
n=0;while test -$n -gt -10; do echo n=$n; n=$[$n+1]; done

That code will print "n=0", "n=1", and so on 10 times.

Only get the listing of directories:

Quote
ls -F $1 | grep \/ | sed -e 's/\/$/4/g'

Real Time Network Activity Examples:
Quote
root# watch -d "netstat -nalp |grep -v DGRAM |grep -v STREAM |grep -v LISTEN"
root# watch "netstat -nalp"|grep ":TCP PORT Number"
root# watch "netstat -nalp"|grep ":22"
« Last Edit: October 10, 2006, 03:09:05 AM by sysconfig » Logged

Strat with Linux || Optimize, Secure and increase performance of Apache || Already Started
The visionary conceives the impossible, The missionary makes it possible.  ...Gita.
« Reply #1 on: August 26, 2006, 03:26:52 AM »
Offline nancy
New Member
*
Posts: 8

View Profile
Good collection. However, we can create any command according to our requiremnt by concatinating with other commands.
Logged
« Reply #2 on: August 29, 2006, 05:21:47 AM »
Offline cursor
Jr. Member
*
Posts: 60
Gender: Male

View Profile WWW
I think below command will be use to know the highest process used by IP address for particular services

Quote
netstat -tnp | awk -F':|/|\t*| *' '{if( $7 == "25" ) {print; $cmd=sprintf("ps -uwwwp %d",$9);system($cmd);}}'

thanks
Logged
« Reply #3 on: August 30, 2006, 02:52:31 AM »
Offline sysconfig
Full Member
*
Posts: 112
Gender: Male

View Profile WWW
Return which ports are currently being listened :

Quote
netstat -ant | grep LISTEN | sed -n 's/^[^:]*:\([0-9]\+\) .*$/\1/p'

Logged

Strat with Linux || Optimize, Secure and increase performance of Apache || Already Started
The visionary conceives the impossible, The missionary makes it possible.  ...Gita.
« Reply #4 on: August 30, 2006, 06:22:59 AM »
Offline mits
Administrator
New Member
*
Posts: 49
Linuxwebadmin
Gender: Male

View Profile WWW
I think below command will be use to know the highest process used by IP address for particular services

Quote
netstat -tnp | awk -F':|/|\t*| *' '{if( $7 == "25" ) {print; $cmd=sprintf("ps -uwwwp %d",$9);system($cmd);}}'

thanks

Please note that you will have process ID of only connection when it is in ESTABLISED stat, so you need to grep the output the netstat , I think below mentioned command will work:

Quote
netstat -tnp |grep EST |  awk -F':|/|\t*| *' '{if( $8 == "21" ) {print; $cmd=sprintf("ps uwwwp %d",$15);system($cmd);}}'

cheers
Logged

« Reply #5 on: September 01, 2006, 06:14:51 AM »
Offline cursor
Jr. Member
*
Posts: 60
Gender: Male

View Profile WWW
I think you should also check the below mentioned URL:

http://forums.linuxwebadmin.info/index.php/topic,35.0.html

thanx
Logged
« Reply #6 on: September 03, 2006, 03:39:21 PM »
Offline sysconfig
Full Member
*
Posts: 112
Gender: Male

View Profile WWW
Hello,

Please check the useful guide on how to find files and directories using different search criteria at:

http://forums.linuxwebadmin.info/index.php/topic,35.0.html

If you want to know more about rpm packages, how to install it, check it queries it, at;

http://forums.linuxwebadmin.info/index.php/topic,41.0.html

thanx
Logged

Strat with Linux || Optimize, Secure and increase performance of Apache || Already Started
The visionary conceives the impossible, The missionary makes it possible.  ...Gita.
« Reply #7 on: September 14, 2006, 07:26:25 AM »
Offline cursor
Jr. Member
*
Posts: 60
Gender: Male

View Profile WWW
   
netstat -tupl   :List internet services on a system

netstat -tup     :List active connections to/from system
 
# lsof -p $$    :List paths that process id has open

# lsof ~   :List processes that have specified path open

# last reboot   :Show system reboot history.

# ls -lSr   :Show files, biggest last

# du -s * | sort -k1,1rn | head    :Show top disk users in current dir. See also dutop

# cat /proc/partitions   :Show all partitions registered on the system

« Last Edit: September 14, 2006, 07:42:59 AM by cursor » Logged
Pages: [1] Go Up Print 
Open community for all Linux users! Discussion & Documentation Howto's for System Administrator Topic: Advance command for System Administrator « previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
SMFone design by A.M.A, ported to SMF 1.1 RC3 by Aäron.
Valid XHTML 1.0! Valid CSS!
http://forums.linuxwebadmin.info/links.html