#What is LILO?
LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.
#What is the main advantage of creating links to a file instead of copies of the file?
A: The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.
#Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > December.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 December.files.
#What is the most graceful way to get to run level single user mode?
A: 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.
#What does the following command line produce? Explain each aspect of this line.
$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log
A: First let’s dissect the line: The date gives the date and time as the first command of the line, this is followed by the a list of all running processes in long form with UIDs listed first, this is the ps -ef. These are fed into the awk which filters out all but the UIDs; these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort - uniq only works on sorted data - if the list is A, B, A, then A, B, A will be the output of uniq, but if it’s A, A, B then A, B is the output) which produces only one copy of each UID.
These UIDs are fed into wc -l which counts the lines - in this case the number of distinct UIDs running processes on the system. Finally the results of these two commands, the date and the wc -l, are appended to the file "Activity.log". Now to answer the question as to what this command line produces. This writes the date and time into the file Activity.log together with the number of distinct users who have processes running on the system at that time. If the file already exists, then these items are appended to the file, otherwise the file is created.
-------------------------------------------------------------------------------------------------
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@techinterviews.com -s ‘Your subject’ -c ‘cc@techinterviews.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.
Social Media Responsibility
12 years ago
No comments:
Post a Comment