EzDevInfo.com

solaris interview questions

Top solaris frequently asked interview questions

Portable way to get file size (in bytes) in shell?

On Linux, I use stat --format="%s" FILE, but Solaris I have access to doesn't have stat command. What should I use then?

I'm writing Bash scripts, and can't really install any new software on the system.

I've considered already using:

perl -e '@x=stat(shift);print $x[7]' FILE

or even:

ls -nl FILE | awk '{print $5}'

But neither of these looks sensible - running Perl just to get file size? Or running 2 commands to do the same?


Source: (StackOverflow)

How to get rid of the "No bootable medium found!" error in Virtual Box?

I am working withing Oracle VM Virtual box on Solaris 11. When the battery of my laptop became 0% and I wasn't beside my laptop, the system halted. So when I started the session I got the following:

Fatal: No bootable medium found! System halted. 

The problem is I already have a script written there.. Is there a way that I can get it back ?


Source: (StackOverflow)

Advertisements

Best OS for java development? [closed]

What is the best OS for Java development? People from Sun are pushing the Solaris, yes Solaris have some extra features included in itself such as (dTrace, possibility for Performance tuning the JVM, etc.. ). Some friends of mine, had port their application on solaris, and they said to me that the performances was brilliant. I'm not happy with switching my OS, and use Solaris instead.

What were your experiences?


Source: (StackOverflow)

How do I get the find command to print out the file size with the file name?

If I issue the find command as follows:

$ find . -name *.ear

It prints out:

./dir1/dir2/earFile1.ear
./dir1/dir2/earFile2.ear
./dir1/dir3/earFile1.ear

What I want to 'print' to the command line is the name and the size:

./dir1/dir2/earFile1.ear  5000 KB
./dir1/dir2/earFile2.ear  5400 KB
./dir1/dir3/earFile1.ear  5400 KB

Source: (StackOverflow)

P/Invoke in Mono

What's the current status of Mono's Platform Invoke implementation on Linux? And on Solaris?


Source: (StackOverflow)

gcc: undefined reference to _mcount (gprof instrumentation)

When compiling my c++ sources with the -pg option to inject gprof profile instrumentation code the compile fails with the undefined reference to _mcount error.

Without this option everything compiles (and runs) fine. What is wrong in my case? (Solaris 10 SPARC Platform)


Source: (StackOverflow)

How to test your code on a machine with big-endian architecture?

Both ideone.com and codepad.org have Little-Endian architechtures.

I want to test my code on some machine with Big-Endian architechture (for example - Solaris - which I don't have). Is there some easy way that you know about?


Source: (StackOverflow)

Identifying the preferred IPv6 source address for an adapter

If you have a IPv6 enabled host that has more than one global-scope address, how can you programmatically identify the preferred address for bind()?

Example address list:

eth0      Link encap:Ethernet  HWaddr 00:14:5e:bd:6d:da  
          inet addr:10.6.28.31  Bcast:10.6.28.255  Mask:255.255.255.0
          inet6 addr: 2002:dce8:d28e:0:214:5eff:febd:6dda/64 Scope:Global
          inet6 addr: fe80::214:5eff:febd:6dda/64 Scope:Link
          inet6 addr: 2002:dce8:d28e::31/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

On Solaris you can indicate a preferred address with an interface flag and it is available programmatically via SIOCGLIFCONF:

/usr/include/net/if.h:
#define   IFF_PREFERRED   0x0400000000    /* Prefer as source address */

As listed in the interface list:

eri0: flags=2104841<UP,RUNNING,MULTICAST,DHCP,ROUTER,IPv6> mtu 1500 index 2
        inet6 fe80::203:baff:fe4e:6cc8/10 
eri0:1: flags=402100841<UP,RUNNING,MULTICAST,ROUTER,IPv6,PREFERRED> mtu 1500 index 2
        inet6 2002:dce8:d28e::36/64 

This is not portable to OSX, Linux, FreeBSD, or Windows though. Windows is let off easy though as it has completely useless, from an administrators perspective, UUID based adapter names (depending upon the Windows version).

For Linux this article details how the parameter preferred_lft, where lft is short for "lifetime", can be altered to weight the selection process by the kernel. This setting doesn't appear conveniently available in the results of SIOCGIFCONF or getifaddrs() though.

So I want to bind to eth0, eri0, or whatever available interface name. The choices are a bit stark:

  1. Fail on adapter names resolving to multiple interfaces. I take this approach for handling multicast transports (OpenPGM) as the protocol MUST have one-only sending address.
  2. Bind to everything. This is a cop out and would be unexpected to users.
  3. Bind to the adapter with SO_BINDTODEVICE. This requires CAP_NET_RAW system capability on Linux which can be quite a cumbersome overhead for administrators.
  4. Bind to the first IPv6 interface on the adapter. The ordering tends to be completely bogus.
  5. Bind to the last interface. David Croft's article implies Linux does this, but is also a bit bogus.
  6. Enumerate over every interface and create a new socket explicitly for each.

With option #6 I would expect you could usually be smarter and take the approach that if only a link-local scope address is available bind to that, otherwise bind to just the available global-link scope addresses.

When connecting to another host then RFC 3484 can be used, but as you can see all the choices are dependent upon matching the destination address:

  1. Prefer same address. (i.e. destination is local machine)
  2. Prefer appropriate scope. (i.e. smallest scope shared with the destination)
  3. Avoid deprecated addresses.
  4. Prefer home addresses. Prefer outgoing interface. (i.e. prefer an address on the interface we're sending out of)
  5. Prefer matching label.
  6. Prefer public addresses.
  7. Use longest matching prefix.

In some circumstances we can use #7 here, but in the interface example above both global-scope interfaces have a 64-bit prefix length.

RFC 3484 has the following pertinent lines:

The IPv6 addressing architecture 5 allows multiple unicast
addresses to be assigned to interfaces. These addresses may have
different reachability scopes (link-local, site-local, or global).
These addresses may also be "preferred" or "deprecated" 6.

The link being to RFC 2462, similarly expanded:

preferred address - an address assigned to an interface whose use by upper layer protocols is unrestricted. Preferred addresses may be used as the source (or destination) address of packets sent from (or to) the interface.

But no methods to programmatically acquire this detail.

Props to Win32 API that exposes an ioctl SIO_ADDRESS_LIST_SORT that allows a developer to use not only RFC 3484 sorting but to take into consideration any system administrator overrides. Linux has /etc/gai.conf as used for RFC 3484 sorting in getaddrinfo() but no API for directly accessing the sorting. Solaris has the ipaddrsel command. OSX is following FreeBSD by adding ip6addrctl in 10.7.

edit: Some concerns with RFC 3484 sorting are listed and referred to in this additional IETF draft document:

http://tools.ietf.org/html/draft-axu-addr-sel-01

Solaris, for example, creates new alias-interfaces for each new
address assigned to a physical interface. So if_index could also be
used to uniquely identify a source address specific routing table on
that platform. Other operating systems do not work the same way.

The author likes Solaris's approach of giving each additional IPv6 interface a new alias, so that eri0 would become the link-local scope address, and eri0:1 or eri0:2, etc, must be specified to use a global-scope address.

Clearly whilst a nice idea one couldn't expect to see other OS change for quite some time.


Source: (StackOverflow)

Comprehensive methods of viewing memory usage on Solaris [closed]

On Linux, the "top" command shows a detailed but high level overview of your memory usage, showing:

Total Memory, Used Memory, Free Memory, Buffer Usage, Cache Usage, Swap size and Swap Usage.

My question is, what commands are available to show these memory usage figures in a clear and simple way? Bonus points if they're present in the "Core" install of Solaris. 'sar' doesn't count :)


Source: (StackOverflow)

Files being used by a unix process

The fuser command lets me know which processes are using a file or directory.

I'm looking for command that does the opposite: lets me know which files are being used by a process.


Update

Forgot to mention that it's for a Solaris system.


Source: (StackOverflow)

Installing GCC on Oracle Solaris 11

i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compilers, i needed GCC, any idea where can i get GCC or how to install it?

thanks


Source: (StackOverflow)

Test from shell script if remote TCP port is open

I'm looking for a quick and simple method for properly testing if a given TCP port is open on a remote server, from inside a Shell script.

I've managed to do it with the telnet command, and it works fine when the port is opened, but it doesn't seem to timeout when it's not and just hangs there...

Here's a sample:

l_TELNET=`echo "quit" | telnet $SERVER $PORT | grep "Escape character is"`
if [ "$?" -ne 0 ]; then
  echo "Connection to $SERVER on port $PORT failed"
  exit 1
else
  echo "Connection to $SERVER on port $PORT succeeded"
  exit 0
fi

I either need a better way, or a way to force telnet to timeout if it doesn't connect in under 8 seconds for example, and return something I can catch in Shell (return code, or string in stdout).

I know of the Perl method, which uses the IO::Socket::INET module and wrote a successful script that tests a port, but would rather like to avoid using Perl if possible.

Note: This is what my server is running (where I need to run this from)

SunOS 5.10 Generic_139556-08 i86pc i386 i86pc

Any help would be appreciated!


Source: (StackOverflow)

Display filename and match in grep

How to get the filename and matching line in grep output?

Something like, <filename> <match line>

Os version: SunOS 5.10


Source: (StackOverflow)

Get the date (a day before current time) in Bash

How can I print the date which is a day before current time in Bash?


Source: (StackOverflow)

sed edit the file in place

I am trying to find out if it is possible to edit a file in a single sed command without manually streaming the edited content into a new file and then renaming the new file to the original file name. I tried the -i option but my Solaris system said that -i is an illegal option. Is there a different way?


Source: (StackOverflow)