Basic Commands Flashcards
What does the [cat] command do?
It lists the contents of a file.
What is a [stream]?
A source of input or output that processes use to read or write data.
What is difference between the commands: [CTRL-D] and [CTRL-C]?
[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.
What do [stdin] and [stdout] mean?
Standard Input (Default Input source)
Standard Output (Default Output Source)
Where do many commands read from if you do not specify an input file?
[stdin] Standard Input - The Default Input Source.
Where do programs send output?
Some programs send output to stdout (like [cat]).
Others send output directly to files.
What is the third standard I/O stream?
Standard Error
What is the best feature of standard streams?
You can easily modify them to read or write data to streams other than the terminal.
What does the [ls] command do?
It lists all the contents of a directory. By default, this is set to the current directory (input stream).
Is the [ls] command limited to the current directory?
No. I can change the program’s argument from the default current directory to any other file or directory.
What does [ls -l] argument do?
It gives a detailed (long) list of the contents of a directory.
What doe the [ls -F] argument do?
It gives details of file types in a list.
What does the [cp] command do?
It copies files.
Using the [cp] command, what is the syntax for copying one file to another?
[cp file1 file2]
Using the [cp] command, what is the syntax for copying one file to a directory?
[cp file dir]
What does the [mv] command do?
It moves (cuts) files/directories from one location to another.
What does the [echo] command do?
It displays whatever text you type in the terminal.
What does the [touch] command do?
It creates a new file. If the target file already exists [touch] doesn’t change the file, but it modifies its date of creation.
What is the syntax for the [touch] command?
[touch filename]
What does the [rm] command do?
It removes (deletes) a file.
Where does the unix directory hierarch start?
It starts at [/] called the root directory.
What is the directory seperator?
The slash [/]
What does it mean to refer to a file or directory?
You are specifying its [path], or [pathname].
What does it mean when a path starts with a [/], such as [/usr/lib]?
That means it’s a full or absolute path.
What does a path component identified by two dots (..) do?
It specifies the parent of a directory.
Example
If in [/usr/lib] [../lib] refers to /usr/bin.
What does one dot (.) refer to?
It refers to the current directory.
Why won’t you have to use the single dot (.) very often?
Because most commands default to the current directory.
What is a path beginning without [/] called?
It is called a relative path.
What is the current working directory?
It is the directory that a process is currently running in.
What does the [pwd] command do?
It shows me my current working directory.
What does the [cd] command do?
It changes the shell’s current working directory.
What is the syntax for the [cd] command?
[cd dir]
What happens if you omit the name of a directory when using the [cd] command?
The command defaults to its default stdin argument and returns me to my home directory.
What do some programs abbreviate the home directory to?
A tilde (~) symbol.
Why is the [cd] command considered a shell built-in that wouldn’t work as a separate program?
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.
What does the [mkdir] command do?
It creates a new directory.
What does the [rmdir] command do?
It removes (deletes) directories.
What is the limitation of the [rmdir] command?
It cannot delete directories that are not empty.
What does the [rm -r] command do?
It deletes a directory whether or not its empty.
What is Globbing?
The process of matching simple patterns to file and directory names.
What does the asterisk (*) glob character do?
It tells the shell to match any number of arbitrary characters.
What does the question mark (?) glob character do?
It instructs the shell to match exactly one arbitrary character.