Tuesday, March 18, 2014

Basic Solaris interview questions and answers for L1 level

Basically this article will help you to make confident in solaris basic level,which will help you in the L1 interview panel. Below I have given some of basic solaris interview question with answer,  these question generally will ask in L1 interview panel for solaris in all the IT company's. Some of the commands are common  for all the UNIX platform . Later I will update some more L1 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 -al | grep "^-."

3. Delete blank lines in a file ? 
#cat test | grep -v '^$' > test1

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.log Here 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 /opreat* Here original directory name is /opreation_application_sap.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 user1 Here user1 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 -nrk 5

13. How to save man pages to a file ?
# man <command> | col .b > <output-file>Example :  man prstat | col -b > prstat_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 on ufs file system?
#quot -af

19. How to create null file ? 
#cat /dev/null > filename i.e cat /dev/null > messages.0

20. Show non-printing characters 
#cat -v -t -e [file]  i.e cat -v -t -e /etc/vfstab

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 4563

26. Show the working directory of a process ?
#pwdx <pid> Example: pwdx 4571

27. Display the processes current open files ?
#pfiles <pid> Example: pfiles 6556

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

31. To view the superfblocks available
#newfs -Nv /dev/rdsk/c0t0d0s2 

32. To view disk geometry and partitioning info
#prtvtoc /dev/rdsk/c0t0d0s2 

33. To copy partition table from one disk to another
#prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2

34. To see all IP variables set in the kernel
#ndd /dev/ip \? 

35. To display the Number of lines in a file
#awk ' END {print NR}' /var/adm/messages.old

36. To list files by size
#ls -l | sort +4n 

37. File sizes of current directory
#ls -la | awk '{ print $5," ",$9 }' | sort -rn

38. Remount root to make it writeable
#mount -F ufs -o rw,remount / 

39. To compares files, and shows where they differ
#diff filename1 filename2

40. Tells you how many lines, words, and characters there are in a file
#wc filename

41. Processes that are running from /var
#fuser -uc /var

42. List the current swap devices
#swap -l

43. List the amount of swap space availabl
#swap -s

44. Check /etc/group file syntax
#/usr/sbin/grpck 

45. Check /etc/passwd file syntax
#/usr/sbin/pwck

46. Add a new user to the system
#/usr/sbin/useradd 

47. To see system configuration
#/usr/platform/`/bin/uname -i`/sbin/prtdiag -v
#/usr/sbin/prtconf -vp

48. To checkout if machine is in 32 or 64 bit mode
#isainfo -kv
#isainfo -bv

49. To see the reboot log
#last reboot

50. Display number of processors
#psrinfo | wc -l 

51. Report CPU Utilization
#sar -u 1 3

52. Displays system information
#uname -a 
#uname -X

53. Displays the date of the last system reboot
#who -b 

54. Displays summary of what the system is doing every 10 seconds
#vmstat 10

55. To determine what kind of memory demand was causing a system to page
#vmstat -p 

0 comments:

Post a Comment