Basic Commands Flashcards

1
Q

What does the [cat] command do?

A

It lists the contents of a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a [stream]?

A

A source of input or output that processes use to read or write data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is difference between the commands: [CTRL-D] and [CTRL-C]?

A

[CTRL-D] tells the running process that it has reached the EOF (End of File) and this usually terminates the process because it cannot receive any further input.

[CTRL-C] terminates the process regardless of its input/output stream.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do [stdin] and [stdout] mean?

A

Standard Input (Default Input source)
Standard Output (Default Output Source)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where do many commands read from if you do not specify an input file?

A

[stdin] Standard Input - The Default Input Source.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where do programs send output?

A

Some programs send output to stdout (like [cat]).

Others send output directly to files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the third standard I/O stream?

A

Standard Error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the best feature of standard streams?

A

You can easily modify them to read or write data to streams other than the terminal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the [ls] command do?

A

It lists all the contents of a directory. By default, this is set to the current directory (input stream).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Is the [ls] command limited to the current directory?

A

No. I can change the program’s argument from the default current directory to any other file or directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does [ls -l] argument do?

A

It gives a detailed (long) list of the contents of a directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What doe the [ls -F] argument do?

A

It gives details of file types in a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the [cp] command do?

A

It copies files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Using the [cp] command, what is the syntax for copying one file to another?

A

[cp file1 file2]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Using the [cp] command, what is the syntax for copying one file to a directory?

A

[cp file dir]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the [mv] command do?

A

It moves (cuts) files/directories from one location to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the [echo] command do?

A

It displays whatever text you type in the terminal.

18
Q

What does the [touch] command do?

A

It creates a new file. If the target file already exists [touch] doesn’t change the file, but it modifies its date of creation.

19
Q

What is the syntax for the [touch] command?

A

[touch filename]

20
Q

What does the [rm] command do?

A

It removes (deletes) a file.

21
Q

Where does the unix directory hierarch start?

A

It starts at [/] called the root directory.

22
Q

What is the directory seperator?

A

The slash [/]

23
Q

What does it mean to refer to a file or directory?

A

You are specifying its [path], or [pathname].

24
Q

What does it mean when a path starts with a [/], such as [/usr/lib]?

A

That means it’s a full or absolute path.

25
Q

What does a path component identified by two dots (..) do?

A

It specifies the parent of a directory.
Example
If in [/usr/lib] [../lib] refers to /usr/bin.

26
Q

What does one dot (.) refer to?

A

It refers to the current directory.

27
Q

Why won’t you have to use the single dot (.) very often?

A

Because most commands default to the current directory.

28
Q

What is a path beginning without [/] called?

A

It is called a relative path.

29
Q

What is the current working directory?

A

It is the directory that a process is currently running in.

30
Q

What does the [pwd] command do?

A

It shows me my current working directory.

31
Q

What does the [cd] command do?

A

It changes the shell’s current working directory.

32
Q

What is the syntax for the [cd] command?

A

[cd dir]

33
Q

What happens if you omit the name of a directory when using the [cd] command?

A

The command defaults to its default stdin argument and returns me to my home directory.

34
Q

What do some programs abbreviate the home directory to?

A

A tilde (~) symbol.

35
Q

Why is the [cd] command considered a shell built-in that wouldn’t work as a separate program?

A

Because if it were to run as a subprocess, it could not (normally) change its parent’s current working directory.
NOTE: There are times when knowing this fact can clear up confusion.

36
Q

What does the [mkdir] command do?

A

It creates a new directory.

37
Q

What does the [rmdir] command do?

A

It removes (deletes) directories.

38
Q

What is the limitation of the [rmdir] command?

A

It cannot delete directories that are not empty.

39
Q

What does the [rm -r] command do?

A

It deletes a directory whether or not its empty.

40
Q

What is Globbing?

A

The process of matching simple patterns to file and directory names.

41
Q

What does the asterisk (*) glob character do?

A

It tells the shell to match any number of arbitrary characters.

42
Q

What does the question mark (?) glob character do?

A

It instructs the shell to match exactly one arbitrary character.