Here they are:
- whats $# in a shell script?
>> Answer: Count of arguments provided to a script
- whats a $* in shell script?
>> Answer: All arguments provided to the script as a single word
- Explain nohup with an example
>> Answer: A UNIX command that allows a command to continue running even after the user is logged out. Basically it prevents the handler for the HUP (hangup) signal from executing. For example,
$nohup ls -lR >a_very_long_running_list_command.txt &
Note that & at the end. Execute this command-line without the nohup prefixed and the job will get killed the moment you logout.
>> Answer: $0 (dollar zero) represents the command name. For example:
here $0 = my_script.sh and $1 = param1. Also, note that $# will be 1 (since there's only one command line parameter provided)
- How do you see the return code of the last executed command?
>> Answer: By checking the value of $? (Dollar Question mark)
- Explain Cron with an example
>> Answer: Cron is the UNIX scheduler component (or daemon as it is more appropriately called). It can be used to schedule tasks for run at a specific time or times. It is driven by a crontab file (usually /etc/crontab). See more info on Cron at wikipedia.org.
- What is rsync
- Whats the advantage of using ssh over telnet?
- Have you used vi? provide example of searching an expression across multiple files (say *.sh) from within vi
- How can i find all /tmp/*.zip and move them to, say, /home/to_examine (assuming the target already exists?)
- Whats the kill command used for? Whats the difference between kill and kill -9
- Whats the "nice" command used for?
>> Answer: It is used to change the priority of a running process. This utility is particularly useful in taming processes that demand higher CPU time with the scheduler. See nice on wikipedia.
- Provide a regular expression for searching email addresses within a script file
>> Answer: In it's simplest form, the regular expression would look like this:
Tip: Try looking here for more comprehensive options. There's also a Firefox addon for this or simply use a web version here.
- Compare /etc/fstab and /etc/mtab
>> Answer: Both are used by UNIX to maintain information on filesystems and mounting-related information. The only difference is that fstab contains the master list which is used by the mount command, whereas mtab contains a list of filesystems that are currently mounted.
- What do you know of inodes?
- Compare Unix FS with, say, Windows/DOS FS
- Does UNIX FS require defraging? If yes, whats the command. If no, why? ;-)
- How do you redirect std error to std output?
- whats the command line for listing the names of the 10 biggest files under /home/
Update: (article originally authored in June 2006) It seems these questions have started making the rounds of forums. But I didnt see any answers (yet) So i have answered some ;-)
See also: Combine commands in DOS - like you do in UNIX.