The Command Line Module #40 Flashcards

1
Q

How can you add an argument to the ls command?

A

By simply adding the path that you want to see into. For example ls /users returns “Shared” and “tomphillips”

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

How are parameters denoted in the terminal window?

A

With a dash such as ls -a which shows hidden files. Try this on the hosts file.

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

How can you display the manual page for ls commands?

A

Type ls man

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

How would you attempt to change permissions for a file or directory?

A

Type the chmod command with args. For more info type man chmod.

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

How would you change the owner of a file or directory?

A

Type the chown command with args for more info type man chown

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

How can you exit a manual page in the terminal?

A

Type q

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

What is the cat command used for?

A

Allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files. Examples below.

General Syntax cat [OPTION] {FILE]
Display contents of a file = cat /path/to/file.html
Display content of two files cat file1.txt file2.txt

create a file: cat >tets2

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

What is the tail command used for?

A

Prints the last 10 lines of a given file

Syntax is tail [OPTION] [FILE]

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

How and why is the grep command used?

A

Grep searches for a file for a particular pattern of characters and displays all lines that contain the pattern.

Syntax: grep [OPTIONS] pattern {FILE]
Parameters:
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.

  • A n : Prints searched line and nlines after the result.
  • B n : Prints searched line and n line before the result.
  • C n : Prints searched line and n lines after before the result.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you print out all of the commands that you typed during your terminal session?

A

Type “history” and see the magic!

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