Online Unix Bits
Online Unix Bits
Online Unix Bits
1. Portable refers to the ability of the operating system to be moved to new platforms
without the need for a major rewrite. Portable operating systems are typically imple-
mented in a high level language such as C, which is available on many platforms.
2. In a time-sharing environment many users are connected to one or more computers,
and all users share output and storage devices. All computing and shared resources are
controlled by a central computer. In a client-server environment computing functions
are split between a central computer (server) and a users' computer (client).
3.A unix command contains Verb (command name), options, and arguments.
4.Primary shells are three, Bourne shell, Korn shell, and C shell.
5. An editor is a UNIX utility that can be used to create and change text files. It differs
from a word processor in that it does not perform typographical formatting such as
bolding, centering, underlining, or varying fonts within a document.
6. vi is a screen editor.
7. The current character is the character at the cursor.
8. Two vi modes were discussed: command mode and text mode.
9. vi starts in command mode.
10. When moving the cursor, you are in command mode.
11. To delete the current character, use the x key.
12.i,I and a move from the command mode to the text mode.
13.o,h and x move from the command mode to the text mode.
14. To move from the eighth to the ninth character on a line, use the l (lower case L) key.
15. To move to the beginning of the current line, use the 0 (zero) key.
16. After all four keystrokes, the cursor would be on line 12 character 3.
17. After the two keystrokes, the cursor is on the fifth character of line 11.
18. The number of the last line on the screen is 25.
19. To discard all changes, use c (:q!).
20. To save and continue editing, use a (:w).
21. Some rules for naming files:
a. Start your names with an alphabetic character.
b. Use dividers to separate parts of the name. Good dividers are the underscore,
period, and the hyphen.
c. Use an extension at the end of the file name, even though UNIX doesn't recognize
extensions. Some applications, such as compilers, require file extensions. In addi-
tion, file extensions help you classify files so that they can be easily identified.
d. Never start a file name with a period. File names that start with a period are hidden
files in UNIX. Generally, hidden files are created and used by the system. They will
not be seen when you list your files.
22. The * matches zero or more characters, the ? matches any single character, and [?]
matches a single character in the given set.
23. The [?] matches a single character from the set of characters within brackets
24. The seven UNIX file types are: regular, directory, character special, block special,
symbolic link, FIFO, and socket
25. A directory is a file that contains the names and locations of files stored in a file
system. A user's home directory is one such example.
26. A block-special file represents a physical device, such as a disk, that reads or writes
Prepared by Ram Kumar 1
Send sms as JOIN MRITSCSE to 567678 to join in MRITS CSE 2nd year group
Send sms as JOIN MRITSIT to to 567678 to join in MRITS IT 2nd year group
MRITS UNIX & SHELL PROGRAMMING IMPORTANT BITS FOR FIRST ONLINE EXAM
COMMON TO CSE-A AND IT-B www.mritsunix.co.nr
44. In UNIX, everyone who logs into the system is called a user.
45. The home directory of a superuser user is root.
Prepared by Ram Kumar 2
Send sms as JOIN MRITSCSE to 567678 to join in MRITS CSE 2nd year group
Send sms as JOIN MRITSIT to to 567678 to join in MRITS IT 2nd year group
MRITS UNIX & SHELL PROGRAMMING IMPORTANT BITS FOR FIRST ONLINE EXAM
COMMON TO CSE-A AND IT-B www.mritsunix.co.nr
46. The three security levels are: system level, directory level, and file level.
47. At the system level, who accesses the system is controlled by log ins and passwords. At
the directory and file levels, security is controlled by permission codes to determine
who can access and manipulate a directory or file.
48. There are seven fields in /etc/passwd: login name, password, user-id, group-id, user
info, home directory, login shell.
49. The field lengths in the /etc/passwd file cannot be predetermined since they contain
variable length information.
50. Each permission code contains three triplets.
51. The second permissions triplet controls the group read/write/execute permissions.
52. A directory has read (r), write (w), and execute (x) permissions. Although for a
directory, execute really means permission to navigate to and through a directory.
53. Write permission for a directory allows entries to be added to and deleted from a
directory.
54. A file has read (r), write (w), and execute (x) permissions.
55. Permission w for a file allows a file's contents to be changed.
56. The command to change a directory or file permission is chmod.
57. symbolic codes can be used to totally reset permissions.
58. When using symbolic codes, unreferenced permissions are unchanged.
59. The octal code always uses three octal digits when specifying file permissions, so
all permissions are assigned by the three octal digits.
60. To copy the contents of a directory requires read and execute permissions (o+rx).
61. To execute a program, read permission (o+r) is required for the directory and execute
permission (o+x) is required for the programs in the directory.
62. The system default permission for a new directory is 777.
63. If there is no user mask, the permissions for a newly created directory is 777. If there
is a user mask, it must be xor'd by 777 to get the new user mask.
64. The command to set the user mask is umask.
65. The command to change the ownership of a file is chown.
66. There can be multiple permission sets for a file or a directory in the sense that there
are separate read/write/execute permissions for user, group, and others.
67. To restrict file deletions to the owner requires u=rwx,g=rx,o=rx permissions.
68. It is possible to destroy a file even if it cannot be deleted. To delete a file, you must
have write permission for the containing directory. But to "destroy" a file, you only
need to be able to change the file's contents, which is determined by a separate write
permission for the file.
69. The first is the interpreter. The interpreter reads user commands and works with the
kernel to execute them. The second part of the shell is programming capability that
allows you to write a shell (command) script.
70. The login shell can be verified by entering echo $SHELL at the command line.
71.The login shell is not always the same as the current shell. The user can change
shells.
72. Shells can be nested.
73. The file descriptor for standard input is 0, standard output is 1, and standard error is 2.
74. The standard output stream is normally associated with the monitor
75. Redirection is the process by which a user specifies that a file is to be used in place of
Prepared by Ram Kumar 3
Send sms as JOIN MRITSCSE to 567678 to join in MRITS CSE 2nd year group
Send sms as JOIN MRITSIT to to 567678 to join in MRITS IT 2nd year group
MRITS UNIX & SHELL PROGRAMMING IMPORTANT BITS FOR FIRST ONLINE EXAM
COMMON TO CSE-A AND IT-B www.mritsunix.co.nr
92.Filters discussed in this chapter: cat, cmp, comm, cut, diff, head, paste, sort, tail, tr,
uniq, and wc. Other filters mentioned in this chapter: more, grep, sed, and awk.
93.head [-options] [file-list]—The head command outputs lines at the beginning
of a file. Input can come from the keyboard, a file, or several files. Output can go to the
monitor or be redirected to a file. The head command does not output to multiple files.
94.cut [-options] [file-list]—The cut command select portions of each line of a
file. Input can come from the keyboard, a file, or several files. Output can go to the
monitor or be redirected to a file. The cut command does not output to multiple files.
95.sort [-options] [field-specifiers] [file-list]—The sort command arranges
data in ascending or descending order. Input can come from the keyboard, a file, or
everal files. Output can go to the monitor or be redirected to a file, or a specified
output file that can even be the same as one of the input files. The sort command does
not output to multiple files.
96.uniq [-options] [file-list]—The uniq command displays unique lines in a file
(adjacent repeated lines are treated as one line). Input can come from the keyboard, a
file, or input redirection. Output can go to the monitor or be redirected to a file, or can
go to an output file specified in a command line argument. The uniq command does
not output to multiple files.
97.The paste and cat commands both combine files. The cat command concatenates files
vertically, the paste command concatenates files horizontally.
98.The cmp command compares two files for equality and if they do not have identical
contents, reports where the two files start to differ. The comm command compares two
files and optionally shows the lines that are only in the first, lines that are only in the
second, and lines that are common to both.
99. The comm command can be used to show lines that are common to two files, whereas
the diff command can be used to show the differences between two files.
100. Change lowercase to uppercase: tr "[a-z]" "[A-Z]" < filename.
101. we can change uppercase and lowercase in one command. The command is:
tr "[a-z][A-Z]" "[A-Z][a-z]"
102. To create a file of 10 lines, enter the command tail +1 > filename and enter at least
10 lines from standard input.
103. The command head -5 file1 | head -3 | head -2 demonstrates that head is a
filter because it is used on the left of a pipe, between two pipes, and on the right of a
pipe.
104. The command cut -f1,3 file1 | cut -f1,2 | cut -f1 demonstrates that cut is
a filter because it is used on the left of a pipe, between two pipes, and on the right of a
pipe.
105. The command tr "l" "L" file1 | tr "i" "I" | tr "n" "N" demonstrates that
tr is a filter because it is used on the left of a pipe, between two pipes, and on the right
of a pipe.
106. The command wc -l file1 | wc -l | wc -l demonstrates that wc is a filter
because it is used on the left of a pipe, between two pipes, and on the right of a pipe.
The result is always one since the output of the wc -l is a single line, and the final wc
-l provides a count of the one line, which is 1.
107. A regular expression is a character pattern that is matched against text. A regular
Prepared by Ram Kumar 5
Send sms as JOIN MRITSCSE to 567678 to join in MRITS CSE 2nd year group
Send sms as JOIN MRITSIT to to 567678 to join in MRITS IT 2nd year group
MRITS UNIX & SHELL PROGRAMMING IMPORTANT BITS FOR FIRST ONLINE EXAM
COMMON TO CSE-A AND IT-B www.mritsunix.co.nr