Solaris interview questions

  1. List the files in current directory sorted by size ? - ls -l | grep ^- | sort -nr
  2. List the hidden files in current directory ? - ls -a1 | grep "^\."
  3. Delete blank lines in a file ? - cat sample.txt | grep -v ‘^$’ > new_sample.txt
  4. Search for a sample string in particular files ? - grep “Debug” *.confHere grep uses the string “Debug” to search in all files with extension“.conf” under current directory.
  5. Display the last newly appending lines of a file during appendingdata to the same file by some processes ? - tail –f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.
  6. Display the Disk Usage of file sizes under each directory in currentDirectory ? - du -k * | sort –nr (or) du –k . | sort -nr
  7. Change to a directory, which is having very long name ? - cd CDMA_3X_GEN*Here original directory name is – “CDMA_3X_GENERATION_DATA”.
  8. Display the all files recursively with path under current directory ? - find . -depth -print
  9. Set the Display automatically for the current new user ? - export DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
  10. Display the processes, which are running under yourusername ? - ps –aef | grep MaheshvjHere, Maheshvj is the username.
  11. List some Hot Keys for bash shell ? - Ctrl+l – Clears the Screen. Ctrl+r – Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a – Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently running process into background.
  12.  Display the files in the directory by file size ? - ls –ltr | sort –nr –k 5
  13. How to save man pages to a file ? - man <command> | col –b > <output-file>Example : man top | col –b > top_help.txt
  14. How to know the date & time for – when script is executed ? - Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, “timeinfo.inf” contains date & time details ie., when script is executed and history related to execution.
  15. How do you find out drive statistics ? - iostat -E
  16. Display disk usage in Kilobytes ? - du -k
  17. Display top ten largest files/directories ? - du -sk * | sort -nr | head
  18. How much space is used for users in kilobytes ? - quot -af
  19. How to create null file ? - cat /dev/null > filename1
  20. Access common commands quicker ? - ps -ef | grep -i $@
  21. Display the page size of memory ? - pagesize -a
  22. Display Ethernet Address arp table ? - arp -a
  23. Display the no.of active established connections to localhost ? - netstat -a | grep EST
  24. Display the state of interfaces used for TCP/IP traffice ? - netstat -i
  25. Display the parent/child tree of a process ? - ptree <pid> Example: ptree 1267
  26. Show the working directory of a process ? - pwdx <pid> Example: pwdx 1267
  27. Display the processes current open files ? - pfiles <pid> Example: pfiles 1267
  28. Display the inter-process communication facility status ? - ipcs
  29. Display the top most process utilizing most CPU ? - top –b 1
  30. Alternative for top command ? - prstat -a
This entry was posted in General, Networking, Unix/Linux. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

15 Comments on Solaris interview questions

  1. Alex
    Posted 5/6/2005 at 1:53 pm | Permalink

    I am looking to determine the total file size of my users, email the data daily, and have it reported in megs. I am using terminal and crontab sucessfully, but I can’t get the crontab entry to report the findings at the user account level. It seems to scan all the way to the end of a uses folder and then report that. Any suggestions?

    Alex

  2. Wing
    Posted 5/31/2005 at 4:23 am | Permalink

    I can’t install top in SunOS5.6 because of some administration issue.
    Furthermore, prstat -a didn’t run in my SunOS5.6. I would like to know whether are there any alternatives for top command in SunOS5.6?

  3. kumareasan
    Posted 6/27/2005 at 5:40 pm | Permalink

    pagesize, prtree, pfiles,pwdx,prstat this commends r not run in my system.
    THE CORRECT COMMAND IS :
    prtree : pstree(present user login tree)
    pwdx : pwd(present working path)
    prstate : pstat(present status)
    Thank U
    Regards,
    Kumareasan
    Linux Administrator in Tetra software India pvt ltd

  4. Posted 7/22/2005 at 9:18 am | Permalink

    This is pretty pathetic. Do folks actually expect candidates who can answer these questsions to be considered systems administrators in a Solaris environment?

    Where’s the questions about OBP?
    Where’s the questions about LOM?
    Where’s the hardware questions?
    Where’s the disksuite questions?
    What about packages? Jumpstart? JASS? SunVTS? obdiag, prtdiag, fmthard?
    What about slices versus disks?
    Shared memory? What’s /etc/system for?
    How about the ndd command? NFS? RPC?

  5. Robert
    Posted 7/22/2005 at 10:20 pm | Permalink

    I can’t install top in SunOS5.6 because of some administration issue.
    Furthermore, prstat -a didn’t run in my SunOS5.6. I would like to know whether are there any alternatives for top command in SunOS5.6?

    Tech Interviews comment by Wing

    Can you tell me what the administration issue is? Have you tried going to sun freeware and get the top package for SunOS 5.6 you will need Gzip to uncompress the file. Then you just run pkgadd -d {path}package-name and it will install without any issues.

  6. Robert
    Posted 7/22/2005 at 10:22 pm | Permalink

    How do you vi a file that is too big for the buffer. E.G. When I try to vi a file it says that it is too big and will not work. I know I can use wordpad or someother editor but I am wondering if it can be done with vi. Thanks in advance.

  7. Chris
    Posted 1/23/2006 at 9:57 pm | Permalink

    Comment to comment no. 4, I used to think it was pathetic too, until I got those kind of questions in an interview here in Singapore.

  8. Neil Hunt
    Posted 4/10/2006 at 11:15 pm | Permalink

    To sort by size in solaris use:
    ls -l | sort -nk5

  9. Rock
    Posted 4/25/2006 at 4:51 am | Permalink

    Just like we have “bdf” in HP-UX, is there any command in Solaris and Linux?

  10. Posted 10/28/2006 at 3:41 am | Permalink

    with respect to kumareasan comment :

    Those commands are in Solaris and Solaris is not Linux. If command not working in your system means commands not exists :)

    -Ravi

  11. Suresh
    Posted 5/13/2007 at 11:06 pm | Permalink

    Rock said,

    Just like we have “bdf” in HP-UX, is there any command in Solaris and Linux?

    In Linux u can use “df -h”
    I don’t know abt solaris i think u can use bdf in solaries

  12. Sivakumar - ACCENTURE
    Posted 9/5/2007 at 2:35 pm | Permalink

    For Solaris you can use df -k as an alternate for bdf of hp unix

  13. NamDesh
    Posted 5/12/2008 at 2:43 am | Permalink

    10. Display the processes, which are running under yourusername ?

    ps -u

  14. NamDesh
    Posted 5/12/2008 at 2:49 am | Permalink

    Display the processes, which are running under yourusername ?

    the command can be used as : ps -u username, or ps -fu username which will give the complete details of the processes running under a user.

  15. Posted 12/16/2008 at 3:30 pm | Permalink

    Answer for #1

    You can use this script under solaris(using “quot” as fundamental of script:-

    #!/usr/bin/bash

    cp /etc/passwd /tmp/passwd
    cut -f1 -d: /tmp/passwd>/tmp/userids
    quot -h / /usr /var > /tmp/quotaall
    for name in `cat /tmp/userids` ;
    do
    grep $name /tmp/quotaall | awk ‘{print $1}’ > /tmp/userusagelist
    sum=0;
    for i in `cat /tmp/userusagelist`;
    do
    sum=`expr $sum + $i`;
    done
    summbs=`expr $sum / 1024`;
    echo “$name is using $summbs MB”
    done

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*