If a command, filename, and a system call have the same name and are avaialble i
ID: 3845197 • Letter: I
Question
If a command, filename, and a system call have the same name and are avaialble in sections 1, 5, and 2 respectively, how will you display the man pages of each one of them?
If a command resides in a directory which is not in PATH, there are at least two ways you can still execute it. Explain.
What is an escape sequence? Name three escape sequences used by the echo command and explain the significance of each.
Which command does the nonprivileged user use to change the system date and time?
Explain why it is possible to key in the next command before the previous command has completed execution?
Explanation / Answer
If a command, filename, and a system call have the same name and are avaialble in sections 1, 5, and 2 respectively, how will you display the man pages of each one of them?
Ans)
man -a <command name>
Example:
man -a read
man -a option will show you all the sections of a commnd instead of displaying each section of the page. Like for example, read command is both a shell builtin and a system call. So if we want to list the shell builtin man page we have to use "man 1 read " and for system call man page of read command you have to use "man 2 read". Whereas you can do the same with one command using "man -a read" where the first section 1 which is read command shell builtin displayed and once you quit by pressing 'q' in the man page it will take you to the next section 2 which is system call man page of read command.
If a command resides in a directory which is not in PATH, there are at least two ways you can still execute it. Explain.
Ans)
Yes there are atleast two ways to execute the command
a) If you know the absolute path of command, you can give entire path and execute the command. Like specifying the full path of the command.
Example:
/bin/cat filename
Here we are assuming 'cat' command directory is not specified in the path.
b) We can enter into the directory where the command exists using "cd" command and execute the command like below.
Example:
> cd /bin
> ./cat filename
What is an escape sequence? Name three escape sequences used by the echo command and explain the significance of each.
Ans) Escape sequence is a sequence of characters which tells shell to interpret the character differently and not get in the output. Escape sequences generally start with backslash().
We need to use '-e' option to interpret the characters that are backslashed.
:
stands for horizontal tab where you use to print tab spaces
Example:
> echo -e "hello world"
hello world
:
stands for vertical tab where you can use to print vertical tab spaces
Example:
> echo -e "helloworld"
hello
world
: stands for new line and is used to print new line
Example:
> echo -e "hello world"
hello
world
Which command does the nonprivileged user use to change the system date and time?
Ans)
We can use 'date' command with -s option to change system date and time. Either the command has to be executed by root user or we need to use command using sudo like "sudo date -s '2017-06-01 12:20:50'"
Example:
> date -s '2017-06-01 12:20:50'
Explain why it is possible to key in the next command before the previous command has completed execution?
Ans)
The reason is every command we execute in Unix will have a subshell created when the command is executed which means the parent shell is available to take our commands. This is the reason why shell is able to take our commands even though previous command is still executing. Another example on child process createion is when we write a shell script which is also considered like a command and will have the variables set inside the script not visible outside. Following are the steps happen when we execute a command.
a) shell interpret the command
b) shell creates a child process and executes command on that child process
c) shell waits for the child process completion
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.