You are on page 1of 5

OSOS Practical Question.

1. What is the difference between the commands cp and cp – i


Ans : cp stands for copy. This command is used to copy files or group of files
or directory.

-i(interactive): i stands for Interactive copying. With this option system first
warns the user before overwriting the destination file.

2. What is the difference between ls – l and ls –x

Ans : ls -l : To show long listing information about the file/directory.


Ls –x options display in multiple columns.

3. If [ -d $filename ] is to test the directories what is used to test the executable file
Ans : -x
4. What is the use of -n option in echo
Ans : New Line Mate
5. Which command is used to record the whole session
Ans : script

6. Which command is used to display currently logged in users

Ans : Who

7. Terminal name and its type are displayed by which command


Ans : TTY

8. How can we can online help of any command


Ans : man , info

9. Which command (with option) is used to count the number of characters in a given
file
Ans : wc -c filename

10. How to get the details of the current working directory


Ans : pwd (present working directory)

11. Can the command cut –d used without -f option and why they are used
Ans : no
-d for delimeter and –f field (je field dis karvi hoy)
Cat filename | cut –d “:” –f2 (second line mate)

12. How to get the current system time


Ans : date+%T
13. Which command is used to display the machine name
Ans : hostname
14. which option of sort command will be used for sorting a file in descending order
Ans : sort -r

15. Can multiple directories be created using a single command


Ans: yes
mkdir {test1,test2,test3}
16. –k option in sort command is used for Sorting by columns or sorting by size
Ans : sorting by colums
17. Paste command is used to combine the files Horizontally or vertically
Ans : Horizontally
18. List any two data compression commands
Ans : tar and gzip
19. mv command is used to move the file or rename the file or both
Ans : both
20. How to delete the directories containing the files
Ans : rm –r directory name
21. What is difference between rm and rm –i
Ans :Rm thi remove
Rm –I thi puchje k file remove karva mango cho.
22. What is use of grep –c and grep –i
Ans : grep –I :small capital both
23. $# is used to count the number of command line arguments or count the files in
the current directory
Ans : count the number of command line arguments
24. How to display first five lines of the file 25.
Ans : head –5 filename
25. How to display the last three lines of the file
And : tail -3 filename
26. What is a shell script?
Ans: a file containing a series of commands.

27. Use of less Command


Ans: It lists all the commands which are recently used.
28. Use of tty Command
Ans: It displays the device name of your terminal.
29. Use of head command
Ans: It displays first 15 lines of the file.
30. Use of tail command
Ans: It displays last 15 lines of the file.
31. What are the default permissions of a file when it is created?
Ans: rw-rw-rw- is the default permission of a file, when it is created.
32. Use of cp command
Ans: It copies file1
33. Use of cat command
Ans: It displays contents of File
34. Give an example of tty command
Ans : $ tty
e.g. Output: /dev/pts/1
35. Give an example of gzip command Ans: $ gzip file1

The first argument is read by the shell into the parameter ___
Ans: $1
36. The complete set of positional parameters is stored in ______ as a single string.
Ans: $*
37. Use of Who command
Ans: to get information of
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
38. How to Show the present working directory.
Ans: pwd
39. How to display Day of month
Ans: date +%d
40. How to View Contents of Multiple Files in terminal
Ans: # cat test test1
41. How to use man command

Ans: The basic usage of man is very simple - just run the command with the name
of the tool whose reference manual you want to access. Ex: man ls

42. How to Sort file abc.txt and save this sorted file in xyz.txt
Ans: sort abc.txt > xyz.txt
43. How to display the login names that begin with ‘H’
Ans: who | grep ^H
44. Which command is used to display message in shell script? Ans: echo

45. How display the contents of the file text on the screen.
Ans: cat $FILE
46. Explain calendar command
Ans: cal command is a calendar command in Linux which is used to see the calendar of
a specific month or a whole year.
47. How to get value from user?
Ans: By using read command Ex: read <var_name> 48.
What is chmod in shell script?
Ans: It can change file system modes of files and directories
49. Use of ls Command
Ans: that lists directory contents of files and directories
50. Use of $date -u
Ans: It displays the time in GMT(Greenwich Mean Time) / UTC (Coordinated
Universal Time ) time zone.
51. Is there a way to erase all files in : rm -r

What is the command to find today's date? : date+%D


52. Explain any two options of date command with examples
Ans : -d (day of the month)
-m (month of year)
53. What is the output of date $date “+%Y-%m-%d”?
Ans : current date
54. Explain the option of chmod command
Ans : u-user
g-group
o-other
permission-rwx(read,write,execute)
55. Explain the types of permissions on file in UNIX

Ans :permission-rwx(read,write,execute)

56.Explain the use of grep command with example

Ans : globaly search for regular expression characters ni pettern search karva.

Cat stud.txt | grep –n “hetuki”(hetuki name kya number ni line par ch a batavse)

57.Give difference between rm and mv commands


Ans : Rm thi remove these

Mv : move and rename.

58. What is indicated by the output of who | wc –l


Ans : total lines of display who command (not sure)

59. How to count the number of lines in a particular file

Ans :Wc –l filename

60. What is the output of cal 01 2020

Ans : jan nu cal.

61. What is the output of date +”%T” :current time display

62. who | grep ^c will display the usernames starting with c or does not start with c

Ans : start with c

63. for a in * do echo $a done


what will be the output of above code
Ans : listing (all files dis)

You might also like