Monday, September 19, 2011

UNIX questions

Q: What is the output of % echo $DATE?
Ans: Nothing is displayed.
Note: Here we are trying to display the value stored in the variable DATE, which not declared nor initialized, hence nothing is displayed

Q: What is the output of %date?
Ans: date with time

Q: In my directory /u/home/phoenix I have one file name magazine.txt and a directory magazine. What will be the output for ls -l magaz* ? Will it list both the file and directory or only one among them? If one, which one?

Ans: ls -l magaz* will list the magazine.txt file only.
If you need to see the directory then you should run ls -ld magaz*

Q: Does the command mkdir has arguments?
Ans: No

Q: What if you create a directory with same name as one that exist already?
Ans: Will throw error saying file already exist

Q: umask is set to 0222, decode the default permission for this value.
Ans:
The value for umask is just opposite of what the real privilege is set, hence
0 indicates owner has all access except execute : rw-
2 indicates group has all privilege except write and execute: r--
2:r--
Hence finally we have: -rw-r--r--

Q: What is command use for moving a file?
Ans: mv

Q: What is the command used for renaming a file?
Ans: mv

Q: I have a directory in which there are many directories and files and some are as below:
directories:DIR1, DIR2,DIR3
files:DIR1.txt, DIR2.txt
there are no files in DIR1 and DIR2, whereas DIR3 has two files hello.txt and hi.txt
Now i ran

ls- l DI*, what will be the output?

ls -ld DI* what will be the output?

Q: What is the result, cp newdir latestdir, where newdir is a directory?
cp: omitting directory 'newdir'

Q: what is the resutl, cp newfile.txt
Ans: cp: missing destination file operand after newfile.txt
Try 'cp --help' for more information.

What is the result on executing umask 77777?
bash: umask: 777777: octal number out of range

I have changed the umask value from the default one (022) to 777 and then I exit from the terminal and logged in again. What will the value of umask.

ans:022.
Each time you login to the terminal umask value get reset always.

****
Hope this is helpful. Thanks Phoenix..

No comments:

Post a Comment