3.2 Commanding the Command Line Flashcards
You can use the command ls -S to list files by __________.
You can use the command ls -S to list files by filesize.
By default, ls simply lists out the files in the current directory. The -S option modifies that behavior to list by size, largest first.
The syntax for the above command:
○ ls is the command.
○ -S is the option.
What does this command do?
head -n 4 logfile.txt
This command previews the first four lines of logfile1.txt.
By default, head displays the top 10 lines of a file.
The option -n changes the number of lines displayed.
○ -n requires a parameter specifying the number of lines.
○ Parameters provide additional details on how to modify a command’s default behavior.
IT and security professionals can learn and manage options with a valuable resource known as _______ pages.
IT and security professionals can learn and manage options with a valuable resource known as manual (man) pages.
What does the wc line do?
wc command allows you to count the number of lines, words, characters, and bytes of each given file or standard input and print the result.
What does this command do?
wc -w *
This will run the word count command for all the files in the current directory with a single command.
To run the word count command against all the files, you have to use a wildcard: *. (Wildcards will be covered in more detail in the next lesson.)
The command will be :
wc -w *
The ________ command searches for files and directories with one command.
The find command searches for files and directories with one command.
By default, find will search through the current directory and the subdirectories within that current directory.
However, find does not look at the contents within a file, only the file name or directory name.
What does this command do?
find -type f
- This command finds all files in our current directory and its subdirectories.
- We use the option -type and the required parameter f for files.
What does this command do?
find -type f -name log.txt
This example will find a specific file.
We use the option -name to search for an exact match of the specified parameter, log.txt.
What will this command do?
find -type f -iname log.txt
This example will find the files called log.txt
(lowercase) or LOG.TXT (uppercase) in our current directory and its subdirectories.
To find a specific file with case insensitivity, we change the -name option to -iname.
Explain this command?
find /root/desktop -type f -iname log.txt
This examples uses find to search for a file located in another directory. Specifically, we’re looking for the case insensitive log.txt in the /root/desktop directory.
We place the desired directory after the find command and before the the -type option.
Explain this command?
find /root/desktop -type f -iname log.txt
This examples uses find to search for a file located in another directory. Specifically, we’re looking for the case insensitive log.txt in the /root/desktop directory.
We place the desired directory after the find command and before the the -type option.
Explain this command?
find -iname recipe -a -iname peanut
Uses a wildcard to search for filenames with the words “recipe” and “peanuts”
What does grep stand for and what does it do?
grep (global regular expression print) is a
command to search for data inside of files.
grep is a command-line command to find a data point inside of a file.
One of the most used commands
What does grep stand for?
grep (global regular expression print) is a
command to search for data inside of files.
One of the most used commands
We can use ________ command to search a file or multiple files for a specific data point.
grep