Self Test Questions Answers on Unix 1

1. The correct unix command to display the contents of a file is

a) cat 
b) more 
c) less 
d) all of the above
e) none of the above

2. Write the command to display the current date in the form dd/mm/yyyy.

a) date +%d/%m/%Y,
b) date +"%d/%m/%Y"
c) date +/%d/%m/20%y
d) date +"/%d/%m/20%y".

3. What command is used to copy files and directories? 

a) copy 
b) cp 
c) rn 
d) cpy

4. Which command is used to rename a file?

a) ren
b) rn 
c) mv 
d) mvdir 

5. How do you show lines 5 to 10 of the file {\tt foo}?

a) tail +5 foo | head 
b) tail +10 foo | head -5
c) head foo | tail +5 
d) head -5 foo | tail +10

6. Which one is used to select only one copy of the repeated lines?

a) uniq -u 
b) uniq -d 
c) uniq -c 
d) uniq –I

7. The permission -rwxr--r-- represents in octal expression is (IV)

a) 777 
b) 666
c) 744 
d) 711

8. How do you search for blank lines 

a) grep '^$' files
b) grep –v ‘\.$’ files 
c) grep -l ‘1,$’ files
d) grep –empty files

9. Indicate the right option to search for BOB, Bob, BOb or BoB ,

a) grep –i Bob files
b) grep 'B[oO][bB]' files
c) grep '[BOB]' files
d) grep -v 'Bob’ files

10. Indicate the right option to search for anything not a letter or number

a) grep '^[a-zA-Z0-9]’
b) grep '[^a-zA-Z0-9]’
c) grep '[a-zA-Z0-9]’
d) None of the above

11 The command syntax to display the file 'sample.txt' one page at a time is 

a) man sample.txt>more
b) cat sample.txt<more
c) cat sample.txt|more
d) None of the above 

12. Which one shows the name of the operating system?

a) uname -n 
b) uname -r 
c) uname 
d) uname –m

13. How do you remove duplicate lines from the file foo using uniq?

a) sort foo|uniq –u
b) sort -u foo|uniq -d 
c) sort foo| uniq –c
d) sort foo| uniq –I

14 Which of these commands will set the permissions on file textfile to read and write for the owner, read for the group, and nothing for everyone else?

a) chmod 046 textfile
b) chmod 640 textfile
c) chmod 310 textfile
d) chmod rw r nil textfile

---

Answers:

  1) d

  2) b

  3) b

  4) c

  5) a

  6) a

  7) c

  8) a

  9) b

10) b

11) c

12) a

13) a

14) b

Read Also
Self Test Questions for Understanding Unix

Self Testing Knowledge

Short Self-Test Questions on Unix

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.