Skip to content
GK24
Computer AwarenessHard

In the Linux shell, which symbol adds the output of a command to the end of an existing file without erasing its contents?

  1. A.A single greater-than sign
  2. B.Two greater-than signs
  3. C.The vertical bar
  4. D.A single less-than sign

Correct answer

B. Two greater-than signs

Explanation

The correct answer is B, two greater-than signs. Writing a command followed by two greater-than signs and a file name appends the output to the end of that file and keeps whatever was already in it, which is how log files are built up. Option A is wrong because a single greater-than sign also redirects output to a file but truncates it first, so the earlier contents are lost; confusing the two is a common mistake and a favourite question. Option C is wrong because the vertical bar is the pipe, which hands the output of one command to another as its input, as when a long listing is passed to less for reading page by page. Option D is wrong because a single less-than sign redirects input, that is, it makes a command read from a file instead of from the keyboard. These three ideas, redirection, appending and piping, are the heart of working at the shell.

Read the full article: MS-DOS and Linux Commands: Internal, External and Shell

View all
Q5.Computer AwarenessMedium

In Linux, the command chmod 777 on a file gives which set of permissions?

  1. A.Read and write to the owner only
  2. B.Read, write and execute to the owner, the group and others
  3. C.Read and execute to everyone, write to nobody
  4. D.Execute to the owner, read to the group, nothing to others
Show answer
Correct answer: B. Read, write and execute to the owner, the group and others

In the numeric form of chmod each of the three digits stands for one set of users, in the order owner, group and others, and each digit is the sum of read as 4, write as 2 and execute as 1.