The Command Line Module #40 Flashcards
How can you add an argument to the ls command?
By simply adding the path that you want to see into. For example ls /users returns “Shared” and “tomphillips”
How are parameters denoted in the terminal window?
With a dash such as ls -a which shows hidden files. Try this on the hosts file.
How can you display the manual page for ls commands?
Type ls man
How would you attempt to change permissions for a file or directory?
Type the chmod command with args. For more info type man chmod.
How would you change the owner of a file or directory?
Type the chown command with args for more info type man chown
How can you exit a manual page in the terminal?
Type q
What is the cat command used for?
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
What is the tail command used for?
Prints the last 10 lines of a given file
Syntax is tail [OPTION] [FILE]
How and why is the grep command used?
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 can you print out all of the commands that you typed during your terminal session?
Type “history” and see the magic!