Recent Changes - Search:

Softwares

.

Linux-questions-and-answers

Main.Linux-questions-and-answers History

Hide minor edits - Show changes to output

December 13, 2012, at 02:01 AM by 15.211.153.77 -
Changed lines 9-12 from:
This command will find all the files under root, which is /, with file type is file. -atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call 30.files.

2.%blue% $ (date ; ps -ef | awk {print $1} | sort | uniq | wc -l ) >> ps.log
to:
This command will find all the files under root, which is �/�, with file type is file. �-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call 30.files.

2.%blue% $ (date ; ps -ef | awk �{print $1}� | sort | uniq | wc -l ) >> ps.log
Deleted lines 84-87:
(:Google1:)
(:Googletxt:)
----
Changed lines 87-89 from:
1. How do you find out what’s your shell? - echo $SHELL

2. What’s the command to find out today’s date? - date
to:
1. How do you find out what�s your shell? - echo $SHELL

2. What�s the command to find out today�s date? - date
Changed line 91 from:
3. What’s the command to find out users on the system? - who
to:
3. What�s the command to find out users on the system? - who
Changed line 93 from:
4. How do you find out the current directory you’re in? - pwd
to:
4. How do you find out the current directory you�re in? - pwd
Changed lines 101-102 from:
8. How do you send a mail message to somebody? - mail somebody@1.com -s ‘Your subject’ -c ‘cc@1.com‘
to:
8. How do you send a mail message to somebody? - mail somebody@1.com -s �Your subject� -c �cc@1.com�
Changed line 126 from:
20. What’s the conditional statement in shell scripting? - if {condition} then fi
to:
20. What�s the conditional statement in shell scripting? - if {condition} then � fi
Changed line 136 from:
25. What’s a way to do multilevel if-else’s in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi
to:
25. What�s a way to do multilevel if-else�s in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi
April 12, 2009, at 08:58 AM by 118.95.6.52 -
Changed lines 2-3 from:
(:Googlemmm:)
to:
(:Googlemm:)
----
Changed line 86 from:
(:Googlemm:)
to:
(:Googletxt:)
Changed lines 152-154 from:
31. How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.
to:
31. How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.
----
(:Googletxt:)
Added lines 1-151:
(:Google1:)
(:Googlemmm:)

1.%blue%Write a command to find all of the files which have been accessed within the last 30 days.

find / -type f -atime -30 > 30.files

This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call 30.files.

2.%blue% $ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> ps.log

This writes the date and time into the file ps.log together with the number of distinct users who have processes running on the system at that time.

3. %blue%What is NFS

NFS Protocol Overview

The Network File System (NFS), developed by Sun Microsystems, is the de facto standard for file sharing among UN*X hosts. NFS Version 3 is documented in RFC 1813. The Mount Protocol is closely related.

NFS is implemented using the RPC Protocol

4. %blue%What is the command one can use to list only the directories.

ll | grep "^d"
This will display only the lines staring with letter "d" from the "ll" command.

This following command will list only the directory in the current path
$ ls -l | grep ^d


It would list the names of all the directories in current directory recursively.
find . -type d

5.%blue%What is the difference between the commands sleep, wait and killall?

sleep:

This command is used in UNIX operating system to suspend execution of the system for the specified time limit mentioned in it as parameter.

The general format of sleep command is

sleep no_of_seconds

The sleep suspends the execution of the shell in UNIX operating system for the no_of seconds specified.

For instance

sleep 5

The above suspend the execution of the shell in UNIX operating system for 5 seconds specified.

wait:

wait causes waiting of the process specified in parameter or the job specified in parameter to wait. If nothing is specified all jobs in pipeline are put to waiting state that is all current child process which are currently active are put to wait status. Wait also return the return status. The return status is generally the exit status of last job in the pipeline process which was put to waiting state. In case of scenario in which no job or process is specified the return status would be zero.

The general syntax of wait command in UNIX operating system is

wait n

where n is optional which denote the process or job

killall:

The command killall is used to kill processes which are active. The main aspect in this is killall command can be issued only by the super user.


6.%blue%What happens when a compress command is used in UNIX system?


compress command is for compressing the file and it can uncompress when ever required.

compress <filename> - to compress
uncompress <filename> - to uncompress

After compressing a file of 3.5 KB size will get reduce to 1.5 KB (aprx).

If still the size need to be reduced use "gzip" which reduce the same size of 3.5 KB file to 0.7 KB (aprx)

gzip <filename> - to compress
gunzip <filename> - to uncompress



(:Google1:)
(:Googlemm:)
----

* Credit - Reference: http://www.techinterviews.com/

1. How do you find out what’s your shell? - echo $SHELL

2. What’s the command to find out today’s date? - date

3. What’s the command to find out users on the system? - who

4. How do you find out the current directory you’re in? - pwd

5. How do you remove a file? - rm

6. How do you remove a - rm -rf

7. How do you find out your own username? - whoami

8. How do you send a mail message to somebody? - mail somebody@1.com -s ‘Your subject’ -c ‘cc@1.com‘


9. How do you count words, lines and characters in a file? - wc

10. How do you search for a string inside a given file? - grep string filename

11. How do you search for a string inside a directory? - grep string *

12. How do you search for a string in a directory with the subdirectories recursed? - grep -r string *

13. What are PIDs? - They are process IDs given to processes. A PID can vary from 0 to 65535.

14. How do you list currently running process? - ps

15. How do you stop a process? - kill pid

16. How do you find out about all running processes? - ps -ag

17. How do you stop all the processes, except the shell window? - kill 0

18. How do you fire a process in the background? - ./process-name &

19. How do you refer to the arguments passed to a shell script? - $1, $2 and so on. $0 is your script name.

20. What’s the conditional statement in shell scripting? - if {condition} then … fi

21. How do you do number comparison in shell scripts? - -eq, -ne, -lt, -le, -gt, -ge

22. How do you test for file properties in shell scripts? - -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability

23. How do you do Boolean logic operators in shell scripting? - ! tests for logical not, -a tests for logical and, and -o tests for logical or.

24. How do you find out the number of arguments passed to the shell script? - $#

25. What’s a way to do multilevel if-else’s in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi

26. How do you write a for loop in shell? - for {variable name} in {list} do {statement} done

27. How do you write a while loop in shell? - while {condition} do {statement} done

28. How does a case statement look in shell scripts? - case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac

29. How do you read keyboard input in shell scripts? - read {variable-name}

30. How do you define a function in a shell script? - function-name() { #some code here return }

31. How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.
Edit - History - Print - Recent Changes - Search
Page last modified on December 13, 2012, at 02:01 AM