EzDevInfo.com

aix interview questions

Top aix frequently asked interview questions

How to mkdir only if a dir does not already exist?

I am writing a shell script to run under the KornShell (ksh) on AIX. I would like to use the mkdir command to create a directory. But the directory may already exist, in which case I do not want to do anything. So I want to either test to see that the directory does not exist, or suppress the "File exists" error that mkdir throws when it tries to create an existing directory.

Any thoughts on how best to do this?


Source: (StackOverflow)

Remote debugging with Eclipse CDT

We're using the Eclipse CDT 5 C++ IDE on Windows to develop a C++ application on a remote AIX host.

Eclipse CDT has the ability to perform remote debugging using gdbserver. Unfortunately, gdbserver is not supported on AIX.

Is anyone familiar with a way to debug remotely using Eclipse CDT without gdbserver? Perhaps using an SSH shell connection to gdb?


Source: (StackOverflow)

Advertisements

Linux: How to find the list of daemon processes and zombie processes

I tried checking on Google, but I couldn't find much information related to the actual question.

How do I get a consolidated list of zombie processes and daemon processes? How do I do it on different operating systems. Linux? AIX? Windows?

I am sure that, based on PID, we cannot identify the type of process. Running through a terminal might not help either.


Source: (StackOverflow)

Java startup is very slow in AIX7.1

AIX 64bit, 7G RAM

$ uname -a
AIX server3 1 7 00036073D600

$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap6460_26sr1-20111114_01(SR1))
IBM J9 VM (build 2.6, JRE 1.6.0 AIX ppc64-64 20111113_94967 (JIT enabled, AOT enabled)
J9VM - R26_Java626_SR1_20111113_1649_B94967
JIT  - r11_20111028_21230
GC   - R26_Java626_SR1_20111113_1649_B94967
J9CL - 20111113_94967)
JCL  - 20111112_01

$ time /opt/IBM/WebSphere/AppServer/java/bin/java
...
real    0m40.62s
user    0m0.43s
sys     0m0.04s

It takes 40s to start java command without any application. The JRE(64bit) is part of WebSphere V8, and need 20 min. to start Application Server.

In the same AIX, there is another JRE(32bit), it works very well.

$ /usr/java6/bin/java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr9fp2-20110627_03(SR9 FP2))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr9-20110624_85526 (JIT enabled, AOT enabled)
J9VM - 20110624_085526
JIT  - r9_20101028_17488ifx17
GC   - 20101027_AA)
JCL  - 20110530_01

$ time /usr/java6/bin/java
real    0m0.70s
user    0m0.64s
sys     0m0.05s

I found some thing using truss.When java is going to startup, it is blocked at thread_tsleep() for a long time. Why? How to correct it?

kopen("/etc/irs.conf", O_RDONLY)                Err#2  ENOENT
_thread_self()                                  = 26738737
getdomainname(0x09001000A00E44F8, 1024)         = 0
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
getdomainname(0x09001000A00E44F8, 1024)         = 0
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
kopen("/etc/hesiod.conf", O_RDONLY)             Err#2  ENOENT
_thread_self()                                  = 26738737
getdomainname(0x09001000A00E44F8, 1024)         = 0
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
getdomainname(0x09001000A00E44F8, 1024)         = 0
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
getdomainname(0x09001000A00E44F8, 1024)         = 0
_thread_self()                                  = 26738737
_thread_self()                                  = 26738737
socket(2, 2, 0)                                 = 4
getsockopt(4, 65535, 4104, 0x000001001012A934, 0x000001001012A930) = 0
connext(4, 0x00000100103F37B8, 16)              = 0
_esend(4, 0x000001001012B860, 40, 0, 0x0000000000000000) = 40
_poll(0x000001001012AA00, 1, 5000)              = 1
_enrecvfrom(4, 0x000001001012CBB0, 1024, 0, 0x000001001012B1C0, 0x000001001012A9E8, 0x0000000000000000) = 56
close(4)                                        = 0
socket(2, 2, 0)                                 = 4
getsockopt(4, 65535, 4104, 0x000001001012A934, 0x000001001012A930) = 0
connext(4, 0x00000100103F37B8, 16)              = 0
_esend(4, 0x000001001012B860, 40, 0, 0x0000000000000000) = 40
_poll(0x000001001012AA00, 1, 5000)              = 1
_enrecvfrom(4, 0x000001001012CBB0, 1024, 0, 0x000001001012B1C0, 0x000001001012A9E8, 0x0000000000000000) = 94
_esend(4, 0x000001001012B860, 25, 0, 0x0000000000000000) = 25
_poll(0x000001001012AA00, 1, 5000)              = 1
_enrecvfrom(4, 0x000001001012CBB0, 1024, 0, 0x000001001012B1C0, 0x000001001012A9E8, 0x0000000000000000) = 25
close(4)                                        = 0
socket(2, 2, 0)                                 = 4
_esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F37C8, 16, 0x0000000000000000) = 25
thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
_poll(0x000001001012AA00, 1, 5000)              = 0
close(4)                                        = 0
socket(2, 2, 0)                                 = 4
_esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F37C8, 16, 0x0000000000000000) = 25
thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
_poll(0x000001001012AA00, 1, 5000)              = 0
close(4)                                        = 0
socket(2, 2, 0)                                 = 4
_esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F37C8, 16, 0x0000000000000000) = 25
thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
_poll(0x000001001012AA00, 1, 10000)             = 0
close(4)                                        = 0
socket(2, 2, 0)                                 = 4
_esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F37C8, 16, 0x0000000000000000) = 25
thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
_poll(0x000001001012AA00, 1, 20000)             = 0
close(4)                                        = 0
getdomainname(0x000001001012CD10, 256)          = 0
kopen("/etc/hosts", O_RDONLY)                   = 4
kioctl(4, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
kfcntl(4, F_SETFD, 0x0000000000000001)          = 0
kioctl(4, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
kread(0x0000000000000004, 0x0000010010416538, 0x0000000000001000) = 0x00000000000007B0
     0x00000000: " #   = = = = = = = = = ="..
kread(0x0000000000000004, 0x0000010010416538, 0x0000000000001000) = 0x0000000000000000
     0x00000000: " #   = = = = = = = = = ="..
close(4)                                        = 0
__libc_sbrk(0x0000000000020020)                 = 0x0000010010421C20

with timestamp

1.8662:        socket(2, 2, 0)                  = 4
1.8666:        _esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F38A8, 16, 0x0000000000000000) = 25
3.8671:        thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
1.8669:        _poll(0x000001001012AA00, 1, 5000) = 0
6.8705:        close(4)                         = 0
6.8710:        socket(2, 2, 0)                  = 4
6.8715:        _esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F38A8, 16, 0x0000000000000000) = 25
8.8723:        thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
6.8720:        _poll(0x000001001012AA00, 1, 5000) = 0
11.8726:        close(4)                        = 0
11.8729:        socket(2, 2, 0)                 = 4
11.8732:        _esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F38A8, 16, 0x0000000000000000) = 25
13.8738:        thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
11.8736:        _poll(0x000001001012AA00, 1, 10000) = 0
21.8741:        close(4)                        = 0
21.8744:        socket(2, 2, 0)                 = 4
21.8748:        _esendto(4, 0x000001001012B860, 25, 0, 0x00000100103F38A8, 16, 0x0000000000000000) = 25
23.8754:        thread_tsleep(0, 0x09001000A030F400, 0x0000000000000000, 0x0000000000000000) (sleeping...)
21.8752:        _poll(0x000001001012AA00, 1, 20000) = 0
41.8756:        close(4)                        = 0
41.8760:        getdomainname(0x000001001012CD10, 256) = 0
41.8763:        kopen("/etc/hosts", O_RDONLY)   = 4
41.8767:        kioctl(4, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
41.8770:        kfcntl(4, F_SETFD, 0x0000000000000001) = 0
41.8773:        kioctl(4, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
kread(0x0000000000000004, 0x0000010010416618, 0x0000000000001000) = 0x00000000000007B0
     0x00000000: " #   = = = = = = = = = ="..
kread(0x0000000000000004, 0x0000010010416618, 0x0000000000001000) = 0x0000000000000000
     0x00000000: " #   = = = = = = = = = ="..
41.8782:        close(4)                        = 0

tp

Quit in sem_wait at 0x9000000002632d8 ($t3)
0x9000000002632d8 (sem_wait+0x98) e8410028          ld   r2,0x28(r1)

 thread  state-k     wchan            state-u    k-tid mode held scope function
>$t1     run                          blocked  31391751   u   no   sys  _event_sleep
_event_sleep(??, ??, ??, ??, ??, ??) at 0x9000000008365c4
_event_wait(??, ??) at 0x900000000837064
_cond_wait_local(??, ??, ??) at 0x90000000084521c
_cond_wait(??, ??, ??) at 0x900000000845808
pthread_join(??, ??) at 0x90000000082d2b0
unnamed block in ContinueInNewThread(continuation = 0x6c6f636b6c002e66, stack_size = 7310577395057127012, args = 0x5f6f72002e666574), line 2286 in "java_md.c"
ContinueInNewThread(continuation = 0x6c6f636b6c002e66, stack_size = 7310577395057127012, args = 0x5f6f72002e666574), line 2286 in "java_md.c"
unnamed block in main(argc = 0, argv = 0x000001001000c178), line 532 in "java.c"
main(argc = 0, argv = 0x000001001000c178), line 532 in "java.c"

 thread  state-k     wchan            state-u    k-tid mode held scope function
>$t2     run                          running  54329549   u   no   sys  __fd_poll
__fd_poll(??, ??, ??) at 0x90000000012c0d4
res_send.poll(??, ??, ??) at 0x9000000001021ac
res_nsend(0x100103f37a8, 0x1001012b860, 0x1900000019, 0x1001012cbb0, 0x40000000400) at 0x9000000001011d4
res_nquery(??, ??, ??, ??, ??, ??) at 0x90000000012b5d8
res_nquerydomain(??, ??, ??, ??, ??, ??, ??) at 0x90000000012ab14
res_nsearch(??, ??, ??, ??, ??, ??) at 0x90000000012af08
res_search(??, ??, ??, ??, ??) at 0x900000000107b50
dns_ho.ho_byname2(??, ??, ??) at 0x90000000013a384
gen_ho.ho_byname2(??, ??, ??) at 0x900000000163888
gethostbyname2(??, ??) at 0x9000000001060ec
getaddrinfo2(??, ??, ??, ??, ??) at 0x900000000102ba0
getaddrinfo(??, ??, ??, ??) at 0x900000000104d34
j9sock_getaddrinfo() at 0x9000000053caad8
populateRASNetData() at 0x900000005347fc0
VMInitStages() at 0x9000000053086b0
runJ9VMDllMain() at 0x90000000530bb9c
pool.pool_do() at 0x9000000052f29c8
runInitializationStage() at 0x90000000530b890
protectedInitializeJavaVM() at 0x900000005306478
j9sig_protect() at 0x9000000053a2b9c
initializeJavaVM() at 0x90000000530585c
jniinv.JNI_CreateJavaVM() at 0x90000000530ea14
jvm.JNI_CreateJavaVM() at 0x900000000ccc510
redirector.JNI_CreateJavaVM() at 0x900000000cb5574
InitializeJVM(pvm = (nil), penv = (nil), ifn = (nil)), line 1801 in "java.c"
main(argc = 0, argv = (nil)), line 810 in "java.c"

 thread  state-k     wchan            state-u    k-tid mode held scope function
>$t3     run                          running  52887625   k   no   sys  sem_wait
sem_wait(??) at 0x9000000002632d8
asynchSignalReporter() at 0x9000000053a3dcc
thread_wrapper() at 0x900000000d00ad0

!!!! ThreadDump Completed- detached from debugger !!!!

Update

I found this topic, and test the program on my AIX. When using hostname, it delayed for about 40s for DNS query. IP Address is normal.

Java cannot resolve DNS address from AIX: UnknownHostException

By the way, the hostname shows server3, when I ping the name, it shows : PING server3.cf1.xx.xxxx.com ..... I run the program using server3.cf1.xx.xxxx.com, there is no delay.

Update2:

It is IPV6 problem. If I add -Djava.net.preferIPv4Stack=true, the java application runs well. But java command still uses IPV6 to query DNS. So java command has 40s delay, and java application has no deley on DNS query.

Can I set the default protocol to IPV4 in AIX, not java parameter?


Source: (StackOverflow)

Unix: fast 'remove directory' for cleaning up daily builds

Is there a faster way to remove a directory then simply submitting

rm -r -f *directory*

? I am asking this because our daily cross-platform builds are really huge (e.g. 4GB per build). So the harddisks on some of the machines are frequently running out of space.

This is namely the case for our AIX and Solaris platforms.

Maybe there are 'special' commands for directory remove on these platforms?

PASTE-EDIT (moved my own separate answer into the question):

I am generally wondering why 'rm -r -f' is so slow. Doesn't 'rm' just need to modify the '..' or '.' files to de-allocate filesystem entries.

something like

mv *directory* /dev/null

would be nice.


Source: (StackOverflow)

ORA-00060: deadlock detected while waiting for resource

I have a series of scripts running in parallel as a nohup on an AIX server hosting oracle 10g. These scripts are written by somebody else and are meant to be executed concurrently. All the scripts are performing updates on a table. I am getting the error,

ORA-00060: deadlock detected while waiting for resource

As I googled for this, I found, http://www.dba-oracle.com/t_deadly_perpetual_embrace_locks.htm

Even though the scripts are performing updation on the same table concurrently, they are performing updates on different records of the table determined by the WHERE clause with no overlaps of records between them.

So would this have caused the error?.

Will this error happen regardless of where the updates are performed on a table?.

Should I avoid concurrent updates on a table at all times?.

Strangely I also found on the nohup.out log, PL/SQL successfully completed after the above quoted error.

Does this mean that oracle has recovered from the deadlock and completed the updates successfully or Should I rerun those scripts serially? Any help would be welcome.

Thanks in advance.


Source: (StackOverflow)

RPM ignore conflicts

I have a bunch of rpm files in a folder. I am trying to install them using: rpm -ivh *.rpm so rpm can take care of the correct installation order.

On some of these rpms I have a newer version installed in my system so I get for example:

package info-5.0-1 (which is newer than info-4.13a-2) is already installed

/opt/freeware/man/man1/infokey.1 from install of info-4.13a-2 conflicts with file from package info-5.0-1

Is there a way to ignore the old .rpm file and resolve the dependency with the new version that is already installed? I thought of the --force option. But how --force resolves the conflicts? Overwrites them with the older version or just ignores them leaving the new version?

Any thoughts are welcome.


Source: (StackOverflow)

Running UNIX commands as different user, from Java

Trying to write a Java program capable of running a UNIX command as a different UNIX user. I have the user's password, and I know the command I want to run, but the command has to be run as that user - so I have to login as that user first.

For example: say we have a user, jim, who wants to see what's in bob's home directory, and (for whatever reason) jim has access to execute ls whereas bob does not. We are currently logged in as bob. Here is what we (could) do:

bob@host$ su jim && ls ~bob

Problem is, we get prompted for jim's password. Since this is run from a Java program, i.e.

Process p = Runtime.getRuntime().exec("su jim && ls ~bob");

we get prompted for jim's password and hung up. We know jim's password. However, I can't enter it.

Additionally, we can't use an Expect script (don't have it installed) and we can't become the superuser. I also looked into using SSH to try this, since we could technically do

bob@host$ ssh jim@host "ls ~bob"

but this also doesn't work since I don't have permission to setup passwordless SSH.

My last-ditch effort is to try and use an SSH library for Java, since the password is available to the Java program and I would be able to login with that (and execute the proper command). But since I'm going to be running on the same host, it seems like overkill.

Any suggestions?

P.S: Java version 1.4.2, can't upgrade; AIX UNIX 5.3.


Source: (StackOverflow)

Substitute or workaround for asprintf on AIX

I'm trying to build python-kerberos on AIX. kerberospw.c uses a call to asprintf, but from what Google is telling me, asprintf does not exist on AIX.

I saw http://www.koders.com/c/fidAA9B130D588302673A28B568430A83131B7734C0.aspx?s=windows.h, which looks like I could create a stand-in asprintf, but I don't know where this would go or how I would #include it in kerberospw.c.

Is there a way I can use the koders.com example or some other code to "fake" asprintf? Can I just include the asprintf function as shown in kerberospw.c? I am not a C coder, but

asprintf (char **resultp, const char *format, ...)

doesn't look like a valid signature to me with the dots at the end. The relevant line from kerberospw.c is below

asprintf(&message, "%.*s: %.*s", (int) result_code_string.length,
(char *) result_code_string.data,
(int) result_string.length,
(char *) result_string.data);

I realize I could contact the author of python-kerberos, but a) I think it would be helpful to have a potential patch if I did so, and b) there might be other software I run across that uses asprintf, and it would be nice to have a workaround.


Source: (StackOverflow)

What is the unix command to see how much disk space there is and how much is remaining?

I'm looking for the equivalent of right clicking on the drive in windows and seeing the disk space used and remaining info.


Source: (StackOverflow)

Unix cp argument list too long

I am using AIX.

When I try to copy all the file in a folder to another folder with the following command:

cp ./00012524/*.PDF ./dummy01

The shell complains:

ksh: /usr/bin/cp: 0403-027 The parameter list is too long.

How to deal with it? My folder contain 8xxxx files, how can I copy them very fast? each file have size of 4x kb to 1xx kb.


Source: (StackOverflow)

Find files in terminal between a data range

I use AIX via telnet here at work, and I'd like to know how to find files in a specific folder between a data range, for example: I want to find all files in folder X that were created between 01-Aug-13 and 31-Aug-13.

Observations:

  • The TOUCH trick (where you create 2 empty files to use the -newer option) does not work for me, once the user roles that I have on the server does not allow me to create files.
  • I need to find between specific dates, not days (like: files that were created more than 30 days ago, etc...)

Thanks in advance!


Source: (StackOverflow)

Changing a linux password via script?

I am trying to change a password of a user via script. I cannot use sudo as there is a feature that requires the user to change the password again if another user changes their password.

AIX is running on the system.

unfortunately chpasswd is unavailable.

I have expect installed, but it I am having trouble with that also.

here is what i thought would work

echo "oldpassword\nnewpasswd123\nnewpasswd123" | passwd user

however once run the script i am prompted with "please enter user's old password" shouldn't they all be echoed in?

I am a beginner with shell scripting and this has be baffled.


Source: (StackOverflow)

Is there a moment where a file "doesn't exist" during a rename?

We have a black-box third-party Java program that takes input files from a location and makes PDFs. It puts a manifest file in the same location every time for each input which necessitates us feeding the file in a controlled manner. Does the manifest (or .xen/.que) still exist? Don't feed an input file.

We're getting VERY rare (one out of tens of thousands of files) instances of our feed script not finding anything, feeding a file, and the resulting error when the manifest is overwritten and things don't match up. I wrote a perl script that does nothing but print the time down to 100-thousandths, glob anything in the directory that we care about, and print it. Below you can see .xen and .que files where .xen is the input and .que is a renamed version of it to indicate processing.

My question then is this: How is the lack of files at 94.26493 possible? Does the OS hide a file while it is renaming? We're getting our problem when the feed program looks for files at that moment so my planned hack is to check for files twice; hopefully slow enough to catch either end of the rename. I should also point out that once 2 files show up on a line, that is where the feed program has put another file in. It is not the same file as before the rename.

1421417394.26392/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen
1421417394.26416/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen
1421417394.26442/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen
1421417394.26468/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen
1421417394.26493
1421417394.26907/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen.que_142_1421417394265
1421417394.27426/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen /gpfs/fsdd/projects/corr_esch/corr_esch.d.xen.que_142_1421417394265
1421417394.27456/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen /gpfs/fsdd/projects/corr_esch/corr_esch.d.xen.que_142_1421417394265
1421417394.27486/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen /gpfs/fsdd/projects/corr_esch/corr_esch.d.xen.que_142_1421417394265
1421417394.27528/gpfs/fsdd/projects/corr_esch/corr_esch.d.xen /gpfs/fsdd/projects/corr_esch/corr_esch.d.xen.que_142_1421417394265

Source: (StackOverflow)

How to autocomplete at the KornShell command line with the vi editor

In the KornShell (ksh) on AIX UNIX Version 5.3 with the editor mode set to vi using:

set -o vi

What are the key-strokes at the shell command line to autocomplete a file or directory name?


Source: (StackOverflow)