SysAdmin Blog, TechTips and Reviews

An (ex) System Administrator's Blog



Archives Posts

UNIX Tip: Backspace Key Does Not Work?!?

October 30th, 2007 by elizar

Here’s a common problem that our users complains about:

The Problem

When they telnet or ssh or connect to a remote host, the backspace key doesn’t seem to work. When pressed, all it shows are caret characters but it does not erase.

The Solution

Here’s one way of solving it…

  1. Type in: stty erase
  2. Then press the ‘backspace’ key
  3. Enter

It should now work. ūüėČ
Read the man page of stty for more information.

Filed under Commands, Tips having 2 Comments »

Archives Posts

Monitoring User Logins In UNIX

October 28th, 2007 by elizar

Here are some of the commands and files that you may want to check out if you want to monitor your users’ login activity on a Unix box (BSD/Solaris)

The concerned files (Solaris):

  • /var/adm/utmp(x)
  • /var/adm/wtmp(x)
  • /var/adm/lastlog

The Commands:

  • users*
  • who
  • w
  • ac*
  • last
  • *may not be available in Solaris?

All sample outputs show on this post are from: `uname -a`

SunOS unixbox 5.9 Generic sun4u sparc SUNW,Ultra-5_10

Read the rest of this entry »

Filed under Tips, Unix having 3 Comments »

Archives Posts

Less is More

October 26th, 2007 by elizar

In a Linux system (and in Solaris 5.8, 5.9, 10, Solaris in general apparently), there are two (identical? opposite?) commands that are very easy enough to remember. How is that? Well, first the command names speak for itself or do exactly what it is called. What are those commands? Well, they are:

more and and less.

more

The more command is a filter for paging through text one screenful at a time. For example if your viewing one large text file, you could use more to view the content of the file one screenfull at a time.

# more /path/to/file/filename

more also has an interactive mode that uses the commands based on vi. So if you’re viewing a file using more, it will pause on the first screenfull and just in case you would want to ‘search’ for a particular string you could use the slash (‘/’) or the question mark (‘?’) just like you would if you’re using vi.

less

The command less, is just like more but unlike more which only goes one way, less allows backward movement in the file as well as forward movement.

Also, since more is a lot primitive than less, less also has tons of command line options. See it’s man pages for details.

Filed under Commands, Linux, Solaris having 1 Comment »

Archives Posts

View Network Traffic From Solaris Command Line

October 21st, 2007 by elizar

A request from a colleague was to check if there are traffic coming from a specific host to the local host. Both are running Solaris Unix, one is an Ultra5 (pretty old) and a Sparc Ultra 250, still old.

specific interface

There are many commands used by many UNIX admins to monitor network traffic going to and from a specific UNIX box.

Here are some of them:

  • netstat -k
  • ntop
  • kstat
  • snoop

It all depends on the admin’s approach and the required information that needs to be gathered.

In our case here snoop serves the purpose very well.

“Snoop” capture and inspect network packets. It captures both TCP and UDP traffic. It is a tool that is shipped with Solaris.

Here’s a sample output we did on the Unix box:

# snoop
Using device /dev/hme (promiscuous mode)
server40 -> serverfs01 TCP D=49678 S=22 Ack=3304463642 Seq=13090730 Len=80 Win=24820
serverfs01 -> server40 TCP D=22 S=49678 Ack=13090810 Seq=3304463642 Len=0 Win=24820
serverws12 -> server40 NIS C MATCH 149.122.32.31 in hosts.byaddr
server40 -> serverws12 NIS R MATCH OK

From

TCP D=49678 S=22

TCP packet with source port of 22 (ssh) and destination of 49678 (some application)

Here’s link for other third party software used in monitoring network traffic.

Filed under Commands, Solaris having 2 Comments »

Archives Posts

Server refused to allocate pty Warning: no access to tty (Bad file number)

October 14th, 2007 by elizar

(Also for Solaris PTY. Setting up number of PTYs)

That error was experienced when trying to connect to a server through ssh. The server being accessed here is a Sunfire V20 running Solaris 2.6.

First glance, looks like that the maximum number of allowed ssh connection has been reached. This is a knows issue for old version of Solaris but not in 5.8 and newer. Solaris kernel tuning is required.

All jobs/services were transferred from one box to another. From the old server, there was no reported login problem (“Server refused to allocation pty”) ever.

Setup maxuser on Solaris 2.6

To change the default value of ‘maxuser’ on a Solaris 2.6, we need to edit /etc/system and add the required value.

The default value is set to either the number of MB of physical memory or MAX_DEFAULT_MAXUSERS, whichever is lower.

For Solaris 2.5.1-7, MAX_DEFAULT_MAXUSERS is 1024. For Solaris 8-10, MAX_DEFAULT_MAXUSERS is 2048.

maxusers can be set explicitly in the /etc/system file, but is limited to 2x MAX_DEFAULT_MAXUSERS.

After editing the /etc/system file, the box need to be restarted.

More information can be seen here and here.

Filed under Kernel Tuning, Solaris having 1 Comment »

Archives Posts

Loop Kill Mutiple PID On Bourne Shell

October 8th, 2007 by elizar

Just want to document it here. A colleague request to kill multiple PID owned by different users. They don’t have any special privilege to kill process other than their own.

Here’s a simple for…loop script that will look for and kill each PID it found.

#!/bin/sh -x
ps -ef | grep nobody | awk ‘{print $2}’ > /tmp/PID
filePID=”/tmp/PID”
for PID in `cat $filePID`
do
kill -9 $PID
done
#

Line 1, tells which shell will execute the script

Line 2, gets all the PID to be killed and store them on a file.

Line 3, assigns a variable for the file

Line 4 to 7 is the for…do loop which basically gets each line on the file, store the value on $PID and then kill whatever value is in it on line 6.

Yucky script. Post a better one.

Thanks.

Filed under Linux, Scripting, Solaris, Unix having 4 Comments »

Archives Posts

Are You Into Ubuntu?

October 2nd, 2007 by elizar

Well if you are, you better check the most popular Ubuntu blog on the blogosphere!

Here’s the Top 5 on the list:

  1. Ubuntu Geek
  2. Ubuntu Blog
  3. Mark Shuttleworth
  4. The Fridge
  5. All About Linux
Filed under Internet, Linux having No Comments »

Archives Posts

Checking and Repairing File system with fsck

October 1st, 2007 by elizar

fsck is the command used in UNIX for checking filesystem for any inconsistencies, usually caused by abnormal shutdown. These abnormal shutdown may be caused by some hardware failure or power failure.

fsck also has options to repair filesystem as well.

Syntax:

fsck  [ -F fstype]  [-V]    [-yY]    [-o options]  special

-F fstype     type of file system to be repaired ( ufs , vxfs etc)

-V verify the command line syntax but do not run the command 

-y or -Y  Run the command in non interactive mode Рrepair all errors encountered without waiting for user response.

-o options  Three options can be  specified with -o flag

b=n   where n is the number of next super block  if primary super block is corrupted in a file system .

p option used to make safe repair options during the  booting process.

f    force the file system check regardless of its clean flag.

Most  *NIX machines has fsck, but special attention should be made when dealing with Sparc hardware or Solaris UNIX in general.

When doing fsck, make sure that you are checking the ‘raw’ device and not just the logical disk.

Check this out to determine the raw device of a solaris server. We’ll post more of the topic soon.

I was here...