Tuesday, January 22, 2008

How to Deny users Telnet or FTP access.

vi /etc/inetd.conf

Comment the line starts with Telnet or
FTP. Save the file and exit.

Stop and start the inetd daemon now by
following commands:

/etc/rc2.d/S72inetsvc stop

/etc/rc2.d/S72inetsvc start

(Your flavor may be /etc/init.d)

send a hang-up (HUP) signal to the inetd process to force it to reread the configuration file:

# pkill -HUP inetd

From now on, no one can telnet or FTP to your
server from outside network.

How to change someones shell in NIS+

nistbladm -e shell=/bin/tcsh '[name=username]'passwd.org_dir


The -exec extension to the find command is a very useful and
flexible utility.

You can use it to get a nice list of all the files in a directory

find . -type f -exec ll {} \;

or to copy all the files in a directory tree into one, large

find . -type f -exec cp -p {} /newdir \;

Or say now that you've copied all those files into one directory
there are too many .bak files to delete all at once with the 'rm'
command (yes, that's possible):

find . -name \*bak -exec rm {} \;


Many times we have a file
systems which is too full.
To quickly find out which
are the file system
We could use:

df -k|awk '{if ( $4 >= 90 ) print $4," " $7 }'

Check the fields on your
flavor, it may not be $4 or $7.
Yours could be different.

basic subnetting

subnet 101


0 - 255 = 256

4 -2
16 -14
32 - 30
64 - 62
128 - 126
256 - class C

example : I need 18 new IPs so:

256 - 32 = 224 since you have to round off to the next highest.

.224 will be the new subnet

therefore I have 30 available to use on the new 224 subnet. 32 + 30 = 62

.32 .33 .34 .35 .36 .37 .38 ....... .62

Monday, December 31, 2007

How to view the time that it takes for a packet to cross the network

# ping -s (ip)

how to change a timestamp on a file?

# passwd -n 14 -x 84 -w 14 (file)

How to duplicate a drive--diskdup

# dd if =/dev/rdsk/(input file ex. c1t1d0s2) of= /dev/rdsk/(outputfile ex.c1t2d0s2) bs=64k

How to sort largest files first

# du -adsk | sort -rn | more

How to see if the account is locked in Nis

If you are running nis or nis+ and want to see if a user is locked out


# niscat passwd.org_dir | grep -i (user name)

To check CPU utilization

log on to the system

# su -

/usr/ucb/ps -aux | more

./ps -aux | more

how to bring up another xterm

# /usr/openwin/bin/xterm &

do a # which xterm to find your path, but most should be the above.

how to eject a tape

# mt -f /dev/rmt/0 offline

# mt -f off works also

Saturday, December 29, 2007

some system checks

The first thing I do when I take over a new system , is write a check script.
You can check several things and tailor it to your system, but here are a few to get you started:

check for users and groups that are equal with root

# grep ':00*:' /etc/passwd

check for invalid passwords
# grep invalid /usr/adm/syslog

list the last 20 logins

# last | head -20

#/usr/platform/sun4u (uname -n)/sbin/prtdiag -v

will show you useful hardware information.

#df -k -F ufs

will show you only local disks , and show you the total space used space, and free space

#/usr/sbin/psrinfo -v

will show you the cpus adn their speed.

see how many users are logged in

ps -ef | awk `{print $1}` | sort|uniq| wc -l

sort largest files first

# du -adsk | sort -rn | more

global replace in vi

nice bit of information , although who uses vi any more ? gvim, nedit maybe.

# : / $ s /(search for this)/( replace with this) / g

Friday, December 28, 2007

zero out a file

most sysadmins know this , but I am not sure who my audience is going to be yet.

anyway in order to zero out a file ...wtmp for example

cat /dev/null > wtmp (filename)

send an xterm

often in my business I have to tell customers to send me an xterm.

here is how

/usr/openwin/bin/xterm -display (ip):0.0 &

only second column of /etc/hosts

just a quick one to get things started
a command to look at only the second column(ie host names) in the /etc/ hosts file?

more /etc/hosts | awk `{print $2}`