Tuesday, November 24, 2009

Clear Print Queue System

When you have a printer queue stock or a job that cannot be canceled or the printer is not responding etc etc there are some methods to force the printer, queue, job to continue working 

First let check the current status of the printer 

# lpstat

If the job stock cannot be removed with the following command then try

enq -x job -P printer

to manipulate the daemon (qdaemon) use the following

startsrc -s qdaemon
stopsrc -s qdaemon

I think the commands speak by their own ;-)

Stop associated processes: 

ps -ef | grep qd
kill -9 PIDNumbers
ps -ef | grep pio
kill -9 PIDNumbers

with the qdaemon don client those paths that store the queues, jobs etc etc with the following

rm  /var/spool/lpd/qdir/*
rm  /var/spool/lpd/stat/*
rm  /var/spool/qdaemon/*

Once everything has been cleared restart the qdaemon

News on certification

The process still going today we request the founds and hopefully we will get a response during the week
I'll kept you posted ;-)

Thursday, November 12, 2009

Unix Popular Tools (Your Swiss Army Knife)

UNIX is known not only for its longevity and versatility as an operating system, but also for the variety and number of utility programs that provide. UNIX users have long called these programs tools because of the neat little things each one does and for their capability to be combined into more specialized utilities.

Tools usually provide information or manipulate files and their contents.

Pocketful of handy things that you use all the time and those special few that you keep at hand for certain special jobs. These tools enable you to do mathematical calculations without your pocket or desk calculator, check the time and date, get information about yourself and other users, find out details about commands on
your system, and check your disk space. After dealing with these tools for a while, you'll find yourself using them without thinking.

Making Calculations

UNIX has a calculator programs that you can use from the command line:
 The bc (basic calculator) program uses the familiar algebraic notation.

Calculating with bc

The basic calculator, bc, can do calculations to any precision that you specify.

Therefore, if you know how to calculate pi and want to know its value to 20, 50, or 200 places, for example, use bc. This tool can add, subtract, multiply, divide,
and raise a number to a power. It can take square roots, compute sines and cosines of angles, calculate exponentials and logarithms, and handle arctangents and Bessel functions. In addition, it contains a programming language whose syntax looks much like that of the C programming language. This means that you can use the following:

l   Simple and array variables
l   Expressions
l   Tests and loops
l   Functions that you define

Also, bc can take input from the keyboard, from a file, or from both.

Here are some examples of bc receiving input from the keyboard:

$ bc
2*3
6

To do multiplication, all you have to do is enter the two values with an asterisk between them.

To exit from bc, just type Ctrl+d. 

However, you can also continue giving bc more calculations to do.

Here's a simple square root calculation

$bc
sqrt(11)
3

Oops! The default behavior of bc is to treat all numbers as integers.
To get floating-point numbers, use the scale command. For example, the following input tells bc that you want it to set four decimal places and then try the square root example again:





$ bc
scale=4
sqrt(11)
3.3166

In addition to setting the number of decimal places with scale, you can set the number of significant digits with length.

You need not always use base-10 for all your calculations, either. For example, suppose that you want to calculate the square root of the base-8 (octal) number, 11. First change the input base to 8 and then enter the same square root
command as before to do the calculation:


$bc
ibase=8
sqrt(11)
3.0000
Ctrl+D
$

This result is correct because octal 11 is decimal 9 and the square root of 9 is 3 in both octal and decimal.

Here's a simple loop in bc's C-like syntax:

y=1
while(y<5){
y^2
y=y+1
}
1
4
9
16

Finding the Date and Time

When used by an ordinary user, the date command does only one thing: it displays the date and the time. The system administrator can use date to set the date and the time.

Here's how you use date to find out the current date and time:

$ date
Sat Sep 28 1:45:58 EDT 1991

This is the simplest form of executing the date command, but not the most useful. This command has many options that let you extract any part of the usual output and display that part alone or with other parts. First, look at the individual options. Unlike most UNIX commands, which usually have single letters as options, date's options are strings of characters. The option string begins with a plus sign (+) and each option is preceded with a percent sign (%). You can include ordinary text in the option string, as you will see in the next example.

The a option outputs the abbreviated name of the day, and the A option provides the unabbreviated name:

$ date +%a
Sat
 
$ date +%A
Saturday

The b option outputs the abbreviated name of the month, and the B option provides the unabbreviated name:

$ date +%b
Sep

$ date +%B
September

The d option provides the day of the month in two-digit numeric form, and the e option outputs the day of the month with a space preceding the day for days 1 to 9. In the following example, the date is the 28th day of the month:

$ date +%d

28

$ date +%e
28

If you execute these two commands again early the next month—on the fourth, for example—you would see the following:

$ date +%d
4

$ date +%e
4

A complete list of options here

Displaying a Monthly or Yearly Calendar with cal

The cal command is very simple but quite handy when you need to see the calendar of any month (or all 12) in any given year. Used with no arguments, cal simply prints a calendar of the current month:

$ cal
February 1994
S   M  Tu  W  Th  F   S
1   2   3     4   5
6   7   8     9   10  11 12
13 14 15   16 17  18 19
20 21 22   23 24  25 26
27 28
$

If you specify a year, as in cal 1993, you get a calendar for all 12 months, but if you specify a month and a year, as in cal 4 1992, you get just that month.

Getting Information About Users

To get information about users (including yourself), you can use several commands. The who command reports on users who are presently logged in, and finger reports on anyone who has an account on the computer. The id command
reports information about the user who invokes it.

The who Command

The who command normally reports certain information about logged-in users. By using its options, you can specify that it report information about the processes initiated by init, and that it report reboots, changes to the system clock, and logoffs. If you invoke who with no options or arguments, you get the following output:

$ who
juucp tty00 Sep 28 11:13
pjh slan05 Sep 28 12:08

The output shows that two users are currently logged in: the user juucp, who logged in at 11:13, and the user pjh, who logged in at 12:08. Notice that juucp is logged in on a tty line (actually, juucp is a neighboring site that is called in over
a modem) and that pjh logged in over a network (STARLAN, which is shortened to slan in who's output).

The -u option adds the "time since the last activity" (also called the idle time) and the process ID number for each logged-in user. A "process ID number" or PID is an interger number assigned by UNIX to uniquely identify a given process (usually, a process is a program that is running). PIDs are needed in UNIX because they allow—yea, encourage—simultaneous running of multiple processes.

$ who -u
juucp tty00 Sep 28 11:13 . 5890
pjh slan05 Sep 28 12:08 . 7354

The finger Command

You can use the finger command with or without arguments. Without arguments, finger's output looks a little like who's:

$ finger
Login Name TTY Idle When Where
pjh Pete Holsberg pts000 6d Mon 13:03
ajh Alan Holsberg sxt/002 Sat 15:00

This output lists all currently logged users—with a heading line—plus the user's full name and the name of the remote computer (in the "Where" column) if the person is logging in over a network.

This command is more useful if you give it a person's login ID as an argument, as in the following example:

$ finger lam
Login name: lam In real life: Pak Lam dp168
Directory: /home/stu/lam Shell: /usr/bin/ksh
On since Feb 23 19:07:31 on pts016 from pc2
2 days 21 hours Idle Time
No unread mail
No Plan

Here, finger displays personal information for the user lam: his real name, home directory, which shell he uses, and when he last logged in and from which computer (pc2). The last line indicates that he does not have a text file called
.plan in his home directory. The finger command displays the contents of .plan and .project if they exist. As you can see, users can reveal as much or as little of themselves as they choose.

If your computer is on a network and you know another person's e-mail address, you can display information about that person by issuing a command such as the following:

$ finger holsberg@pilot.njin.net

The finger command provides many options that can suppress one or more fields of the normal, long output. However, because finger responds so quickly, simply disregarding that extra information when it appears onscreen is easier than
learning the appropriate option.

The id Command

The id command reports four things: the user ID number, login name, group ID number, and group name of the person who invokes it. If the real and effective IDs are not the same, id prints both sets of values.

When a system administrator creates an account for a user, that user is given a login ID and also placed in a group. This is important because UNIX provides access to files according to whether the user is the owner of the file and whether
In the following example, the user ID is 102, the login name is pjh, and the user belongs to the root group, which is group number 0:

$ id
uid=102(pjh) gid=0(root)

Enjoy =)

Tuesday, November 10, 2009

Setting the System PROMPT "$"

The system primary prompt is set with the environment variable PS1.  
The secondary prompt is set with the environment variable PS2.   

You can set these variables by typing:

        export  PS1=’(system name)#’


Example:

      System1#

For the present working directory to show on your prompt, type:

        export  PS1=’(system name):$PWD>>’


Example:

       System1:/etc>>

For the userid and the present working directory to show on your prompt, type:

        export  PS1=’(system name):$LOGNAME:$PWD>>’


Example:

       System1:(user name):/etc>>

Note:  If you want to set a default prompt, put one of the above lines in the .profile file in your /home directory.  Every time you log in, it will create the desired prompt.

If you want to set a default prompt, the idea is the same but put it in the global profile file located at /etc/profile 


As always let me know if you have any question


;-)

Friday, November 6, 2009

REGEXP - Regular Expressions

A regular expression is a string of characters designed to search for or replace another string of characters. This looks pretty basic but the power of a regular expression should not be underestimated.

Regular expressions are used by some of the most powerful unix tools (grep, sed, awk) and some programming languages like Perl.

Learning regexp's is the step required to move from a regular basic Unix user to a power user.

The basics

If you use "golf" in your regexp you won't find the word "Golf" 

If you use "[Gg]olf" in your regexp you will find "golf and Golf"

You can also use "g[oe]lf" to find "golf or gelf"

But what if you want to find also gilf?

you can use "g.lf"
or maybe "g..f" 

Are we clear so far?

Searching files with grep

Now let's go a little bit further

let's say you have a file called myfile.txt with the following text...

I like golf.
Golf is played on grass.
I created gilf.

The basic sintax for the grep command is:

grep regexp filename

If you type:
    grep golf mytext.txt
you will get:
    I like golf.

If you type:
    grep [gG]olf mytext.txt
you will get:
    I like golf.
    Golf is played on grass.

Etc. etc. etc.... You got the idea right?

Take a look at the following table ...


And this is all for today!

The power of the command line

This is a short version not so fancy of the article published by Martin Streicher at ibm.com in the Speaking Unix Series

One of the better features of UNIX is the command line. With just a few keystrokes you can do magic.

For example to find the list of unique filenames in the folder hierarchy rooted at the current working directory you can type the following

find . -type f -print | sort | uniq

Combining three commands...

find - To find all the files starting from "." "here" and print them as a list
sort - To sort them in alphabetical order (default)
uniq - To remove any duplicate value in the list

Data in, data out, data all about

A typical UNIX command-line utility reads from stdin and writes to stdout


 Some utilities read data from system resources and write results to stdout





UNIX commands emit errors to a special channel, standard error



 A conceptual model of three utilities linked by pipes



 Redirecting standard input to read from a file
 

 Combining the standard output and standard error devices




The AIX Operating System


What is AIX? 

AIX 5L is an open UNIX operating environment from IBM. It provides high levels of integration, flexibility and reliability—essential for meeting the high demands of today's e-business applications. It operates over IBM pSeries, IBM Cluster 1600 and IBM RS/6000 servers and workstations.

AIX is fully integrated to support the concurrent operation of 32- and 64-bit applications in their full range of scalability, with key internet technologies such as Java and XML parser for Java included as part of the base operating system. Best of all, a strong affinity between AIX and Linux permits popular applications developed on Linux to run on AIX with a simple recompilation.

What does that mean??? 

AIX was developed by combining the BSD and System V versions of UNIX.  Most of the difference between AIX and other UNIX operating systems can be found in the way the OS is managed, most noticeably with the System Management Interface Tool, or SMIT.

AIX will run in either 32- or 64-bit mode.  It will not run 32- and 64-bit applications at the same time.

IBM offers several different types of hardware platforms, including the pSeries, which  is what runs the AIX operating system.


The Reduced Instruction Set Computing System 6000 is a hardware platform that supports the AIX operating system.

RISC has been in existences since the 1970s, when it was developed by IBM.  The basic premise was to reduce the number of instructions needed to carry out a given task, which in turn reduces processor time.


The operating system is responsible for resource allocation, including CPUs, memory, processes, and devices.  The operating system will manage these resources based on factors such as schedule, priority, ownership, and access privileges.  It is comprised of three layers:

·         Command layer (shell)
·         Service layer
·         Kernel (manages resources)

Figure 1.1 displays the hierarchy of how responsibilities are divided up in an operating system.




Installing AIX

There are several options when installing the AIX base operating system (BOS).

·         New and Complete Overwrite - This method installs AIX on a new machine or completely overwrites any BOS that exists on your system.

·         Preservation - This method replaces an earlier version of the BOS but retains the root volume group, the user-created logical volumes, and the /home file system. It overwrites the /usr, var, tmp, and / (root) file systems. Product (application) files and configuration data are lost.

·         Migration (POWER-based systems only) - This method upgrades from an older version of AIX.  A migration installation preserves most file systems, including the root volume group, logical volumes, and system configuration files. It overwrites the /tmp file system.

When installing AIX, the easiest method is to use the SMIT menu, which will be covered in a later section.

Any AIX operating system software can be installed in two different states:

·  Applied: The software has been installed, but the previous version has been retained. The new version can be uninstalled without needing additional files.

·  Committed: The software has been installed, and the previous version has been destroyed.  If the new version must be uninstalled, it will need to be downloaded or installed from installation media.

And there are different types of files that can be installed. Between the most common we can find

RPM (RedHat Packages previously compiled for AIX) you can find them at ftp.software.ibm.com

installp packages that is the AIX package standard

and source code packages that can be compiled directly in the system.

Thursday, November 5, 2009

For those that still want to know "Final AIX test Answers"

1 What is the correct command to save the output of the command in one file and the error messages in another?

A command 1>file1 2>&1
B command 1>file1 2>file2
C command 1>file1 2>file1
D command 2>file2 1>&2

2 A directory with files can be deleted with which of the following commands?

A rm -r
B mvdir
C touch
D rmdir

3 Where will the final output be placed after this sequence of piped commands? ls -l | pg

A list
B terminal screen
C root directory
D default system printer

4 Which command will invoke the man pages for the pwd command?

A catman -w pwd
B man pwd
C man -k pwd
D man -f pwd

5 Which command will measure the network response time of a remote machine?

A ftp
B ping
C trace
D netstat

6 Which dd command is using a relative path name as the source argument and an absolute path name as its target argument?

A dd if/home/blue of=/
B dd if=blue of=/dev/rmt0
C dd if=blue of=./dev/fd0
D dd if=/home/green of=/u/blue/green

7 Which of the following commands will save the file the user is editing and not exit vi?

A :wq
B :w
C :x
D ZZ

8 What file can be used to alter a user's login environment in the Korn Shell?

A /ENV
B .kshrc
C /etc/.profile
D /home/profile

9 Which method would be used to cancel the print job number 321 that was submitted to the color print queue using system V printer subsystem commands?

A cancel color
B cancel -u 321
C cancel 321
D cancel -u color

10 What is necessary to use the contents of a file as input for an AIX command?

A redirect standard input
B append standard input
C redirect standard output, then standard input
D type the contents of the file onto the command line

11 Which command can be used to enter vi editor and create the file "myfile" without generating any errors?

A vi myfile
B vi -c myfile
C vi -y myfile
D vi -t myfile

12 When ftping what is the command to send a file to a remote machine?

A put
B open
C ntrans
D stream

13 Which keystroke sequence can be used to suspend a process in the Korn Shell so it may be restarted at a later time?

A Ctrl-c
B Ctrl-q
C Ctrl-x
D Ctrl-z

14 What is the correct flag to telnet to a remote machine as a specific user?

A tn -f
B tn -d
C tn -p hostname
D tn -l user hostname

15 How can permissions for the chmod command be written?

A As a hex number
B In either octal or symbolic notation
C As string of "rwx" to picture the layout of the permissions
D In the first line of a file when it is created, and then interpreted by the shell

16 Which command will display all lines in file1 that contain the string abc but NOT the string xyz?

A grep -E "abc&!xyz] file1
B grep abc file1 | grep -v xyz file1
C grep [abc][^xyz] file1
D grep -v xyz "abc" file1

17 Which key should be pressed in the vi editor to enter text-input mode and begin inserting text BEFORE the cursor position

A a
B i
C $
D o

18 If the current directory is /tmp which command will display the available file system space in the user's current directory?

A df .
B du $tmp
C du .
df $tmp

19 Which command should be used to permit ONLY the owner to use the script file named savemachine as an executable script?

A chmod 777 savemachine
B chmod -x ./savemachine
C chmod u=rwx,go= savemachine
D chmod go-w+x savemachine

20 Which of the following commands will cause a syntax error?

A cd; ./.profile
B ps -ef | grep init
C TERM=ibm3151 / export TERM
D find / etc -print | grep motd

21 what is the correct user command to remove the link foo?

A ln -s foo /dev/null
B ln foo garbage
C unlink foo
D rm foo

22 Which of the following commands should be used to list all files in the root filesystem that are named .profile?

A find . -name .profile
B find / -name .profile -print
C find * -name "*profile" -ls
D find ../. .profile -exec ls -l

23 What is the Korn Shell variable PS1 used for?

A To specify the first process running
B To specify the shell's parent process
C To specify the priority setting of a Korn Shell
D To specify the string to be used as the primary system prompt

24 A user is trying to read a logfile that gets updated every minute. What is the correct command to view the new incoming messages in real time?

A more logfile
B cat -v logfile
C pg logfile
D tail -f logfile

25 Which vi command is used to reverse the last action taken

A r
B c
C u
D x

26 Which command is used to exit the vi editor without saving the data?

A :q!
B :e!
C :wq!
D ZZ

27 Which of the following describes the function of the -p flag of the mkdir command?

A It preserves the permissions of the parent directory for subordinate directories and files
B It creates missing intermediate path name directories
C It causes the mkdir command to execute as a background process
D It preserves the date and timestamp information of the parent directory and applies it to the subordinate directories and files

28 Which of the following will cancel all print jobs on the print queue named ascii for the user guest_user?

A lprm ascii guest_user
B lprm guest
C lprm -P guest_user
D lprm -P ascii guest_user

29 What is displayer by the command     grep -v "^#"

A All lines that begin with a ^
B All lines that begin with a ^ or #
C All lines that do not begin with a #
D Lines that do not begin with a # or ^

30 Write the corresponding number of the command in the correct description

1 ls                  _5_ Updates the access and modification times of a file
2 pwd              _6_ Determines the file type
3 cd                 _8_ Changes file system object's base file mode bits
4 mkdir           _3_ Changes the current directory
5 touch           _4_ Creates one or more new directories
6 file                _10_ Links files
7 istat              _1_ Displays the contents of a directory
8 chmod            _9_ Changes the owner or group associated with a file
9 chown            _7_ Examines i-nodes
10 ln                  _2_ Displays the path name of the working directory

Bonus Question (5 Points)

What does AIX stands for? 

 Advanced Interactive eXecutive

Bussy Week

This week was a nightmare I didn't have time to check the blog until today ...

What is contained in the .exrc file?

Correct answer: B - The list of environmental commands

The exrc file is also known as the .vimrc file and will save all the environmental commands of the vim editor so you can configure it as you wish like the following example: 

"Tabulator size
    set ts=4
"File Encoding
    set fileencodings=utf-8,big5,gbk,cp936,iso-2022-jp,sjis,euc-jp,euc-kr,utf-bom,iso8859-1
    set encoding=utf-8
    set tenc=utf-8
"Gui Font
    set guifont=DejaVu\ Sans\ Mono\ 12
    if exists("&ambiwidth")
    set ambiwidth=double
    endif
"Line numbers  
    set nu
"HighLight the matched string
    set incsearch
"Make vim more compatible with vi
    set nocompatible
"Indentation Level
    set autoindent  "...
"Do smart indentation
    set smartindent         "...
    syntax on

    color torte