0% found this document useful (0 votes)
134 views3 pages

Unix Interview2

List the files in current directory sorted by size? - ls -l grep - sort -nr. Display the last appended lines of a file during appendingdata to the same file by some processes? - tail.f Debug.log.

Uploaded by

api-3780913
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views3 pages

Unix Interview2

List the files in current directory sorted by size? - ls -l grep - sort -nr. Display the last appended lines of a file during appendingdata to the same file by some processes? - tail.f Debug.log.

Uploaded by

api-3780913
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

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 current Directory ?

- 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 your username ?

- 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 | col .b > 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 traffic ?

- netstat -i

25. Display the parent/child tree of a process ?

- ptree Example: ptree 1267

26. Show the working directory of a process ?

- pwdx Example: pwdx 1267

27. Display the processes current open files ?

- pfiles 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

General UNIX Interview Questions »


0 Comments
1. What are the main differences between Apache 1.x and 2.x?

2. What does the “route” command do?

Typical usage of route:

/sbin/route -n:

DISPLAY KERNEL ROUTING TABLES.

Or

To manipulate the routing table.

3. What are the read/write/execute bits on a directory mean?

Access rights (read/write/execute) on a directory means:


->read indicates that it is possible to list files in the directory.
->write indicates that it is possible to delete or move files in the directory.
->execute indicates that it is possible to read files in the directory provided we must have read permission on individual files of that directory.

or

Access rights (read/write/execute) on a directory means:

execute permission allows a user to enter the directory and perform read/write/execute files according to the permissions of the file. But you cannot ‘ls’ the
directory until you have a read permission.
It means you should know the filename.
eg:

[amar@darkstar ~]$ ls -l | grep Book


d–x—— 6 amar amar 4096 Sep 5 11:27 BookScripting # directory only has
execute permission

[amar@darkstar ~]$ ls -l BookScripting/ # no read permission


ls: BookScripting/: Permission denied # so ‘ls -l’ denied

[amar@darkstar ~]$ ls -l BookScripting/test.sh


-r-x—— 1 amar amar 37 Sep 5 11:27 BookScripting/test.sh
[amar@darkstar ~]$ BookScripting/test.sh
you can execute

[amar@darkstar ~]$

4. What does iostat do?

iostat Will show the status of INPUT & OUTPUT.

5. what does vmstat do?

vmstat–To know the memory related status

6. What does netstat do?

netstat–To know the network status.

7. What is the most graceful way to bring a system into single user mode?

The most graceful way is to use the command init s.


If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s.

8. How do you determine disk usage?

The disk usage can be determined by using the command, du.This command outputs the number of kilobytes used by each sub-directory.

9. What is AWK?

AWK is a complete pattern scanning and processing language, it is most commonly used as a Unix command-line filter to reformat the output of other commands.

For example, to print only the second and sixth fields of the date command (the month and year) with a space separating them, at the Unix prompt, you would
enter:
date | awk ‘{print $2 ” ” $6}’

10. What is SED?

SED (which stands for Stream EDitor) is a simple but powerful computer program used to apply various pre-specified textual transformations to a sequential
stream of text data.

It reads input files line by line, edits each line according to rules specified in its simple language (the sed script), and then outputs the line.

11. What is the difference between binaries in /bin, and /usr/bin?

/bin - would contains the binaries frequently used by the normal user (as well as system administrator)
/usr/bin - would contains the binaries rarely used by the normal user (as wel as system administrator)

Or

Under Solaris, there is no difference. /bin is a symbolic link pointing to /usr/bin. Under Linux (RHAS3) /bin is seemingly for standard unix programs like vi, cp, mv,
rm which you’d need in a single user environment where as /usr/bin contains programs you’d want for a multiuser environment. Keep in mind that sometimes /usr
is a different disk partition and when you start up in single user mode you only have / mounted.

The /sbin directories are *supposed to* contain statically linked programs. This mas morphed into the idea of bin for user programs, sbin for admin programs.

12. What is a dynamically linked file?

A dynamically linked program is one that, when executed, loads shared libraries from /lib or /usr/lib in order to execute. The idea is that most programs use many
of the same functions, so include a copy of a common function in *every* program on the file system. Instead, the function is placed in a shared library and when
the program starts executing, the library is loaded which provides the program access to the function.

13. What is a statically linked file?

A statically linked program is one that contains all the information (libraries) it needs to run. It does not need to load additional libaries in order to execute.

14. What is MUTEX?

Short for mutual exclusion object. In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such
as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. After this stage, any thread that needs the resource
must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished.

15. What is INODE?

A unique number associated with each filename. This number is used to look up an entry in the inode table which gives information on the type, size, and location
of the file and the userid of the owner of the file.

16. Where INODE will be stored?

Inode is stored in File Management system ie in the Secondary Memory where os is stored

You might also like