In the Linux shell, which symbol adds the output of a command to the end of an existing file without erasing its contents?
- A.A single greater-than sign
- B.Two greater-than signs
- C.The vertical bar
- D.A single less-than sign
Correct answer
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
Practice Questions
View allWhich of the following is an internal command of MS-DOS?
- A.FORMAT
- B.CHKDSK
- C.DIR
- D.XCOPY
Show answer
An internal command is written into the command interpreter COMMAND.COM and is loaded into memory along with the operating system, so it can be used even when no separate program file is present on the disk.
Read the full explanation →Which Linux command displays the full path of the directory you are currently working in?
- A.ls
- B.pwd
- C.cd
- D.path
Show answer
The name stands for print working directory, and the command prints the complete path of the directory in which the shell is placed at that moment, counted from the root directory written as a single forward slash.
Read the full explanation →The MS-DOS command TYPE, which displays the contents of a text file on the screen, corresponds to which Linux command?
- A.cat
- B.touch
- C.echo
- D.grep
Show answer
The cat command, short for concatenate, writes the contents of one or more files to the standard output, which is normally the screen, and so does the work of TYPE in MS-DOS.
Read the full explanation →Who developed the first Linux kernel, and in which year was it released?
- A.Dennis Ritchie, 1972
- B.Richard Stallman, 1983
- C.Linus Torvalds, 1991
- D.Ken Thompson, 1969
Show answer
Torvalds, then a student at the University of Helsinki in Finland, wrote a free kernel for personal computers and released it in 1991 under the GNU General Public Licence, which allowed anyone to study, change and redistribute it.
Read the full explanation →In Linux, the command chmod 777 on a file gives which set of permissions?
- A.Read and write to the owner only
- B.Read, write and execute to the owner, the group and others
- C.Read and execute to everyone, write to nobody
- D.Execute to the owner, read to the group, nothing to others
Show answer
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.
Read the full explanation →