Topic 5 - The command-line interface Flashcards
what is the outcome of typing
Grep ‘sat’ -I ‘datefile’
into a linux terminal
in a linux terminal:
this will search for the text pattern ‘sat’ while ignoring letter cases in the file named ‘datefile’
this is used to redirect the STDOUT (standard out stream) of a command to a file
what is the > symbol used for
Standing for ‘global regular expression print’. is a tool for finding a given text pattern in a given text.
Text can be pipelined into this command or can be held inside a file
describe the linux
grep
command
give a description of the linux
cat
command
this command will concatenate files and print on the standard output
what is the outcome of typing
Touch existing-filename
into a linux terminal
in a linux terminal:
this will update the access and modification timestamps of the given filename
what is the name and purpose of the ~ symbol in linux
in linux this is called a
tilde and points / references your home directory
in a linux terminal:
this will redirect the output from the date command into the given filename, creating a new file if it does not exist
what is the outcome of typing
Date > filename
into a linux terminal
in a linux terminal:
this will update the access and modification timestamps of the given filename
what is the outcome of typing
Touch existing-filename
into a linux terminal
The OS is also able to optimize this efficiently since the output of one command can be written to main memory and as soon as data starts to arrive the other command can start to consume it without the need for the first command to finish execution
how can the operating system
optimize pipelining
the shell used on this was named sh (bourne shell) as was written by stephen bourne
what was the shell used on UNIX systems called and who created it
what is the outcome of typing
Rm filename -f
into a linux terminal
in a linux terminal:
this will suppresses the prompt confirming removal of write protected files and overrides the write protection. in turn deleting the file
what is the outcome of typing
Cp my-file my_directory
into a linux terminal
in a linux terminal:
this will copy the file my-file into the directory my-directory
this is a file that contains the paths of available shells on the linux system
describe the linux
/etc/shells
file
when this occurs the operating system will set:
- the input stream as the keyboard
- the output stream as the terminal window
when a terminal is opened what are the default input and output streams configured by the operating system
give a description of the linux
mv
command and how it works
in a linux terminal:
This is used to move files and directories. If the source file given is moved to the same location this command then renames the file using the destination
• it prompts a user to type a command line
• it deals with editing within the line, accepting the line when Enter is pressed
• some special characters are picked out and handled specially, such as:
◦ quotation marks preserve spaces but are themselves stripped out
◦ > and ◦ wildcards such as * cause filenames to be expanded
• the completed command line is broken into pieces (tokens) by spaces
• the first token on the line is taken as the command
• if the command is built-in, then:
◦ the corresponding action is taken
• otherwise the file system is searched for a matching filename
• if a matching file is found, then:
◦ the type of file is determined
◦ if the file is a script, then:
– the script commands are interpreted recursively line by line
– until the end of the file
◦ if the file is an executable program:
– a system call obtains a chunk of memory from the memory management module
– a system call loads the contents of the program from the file system into that memory
– the remainder of the command-line arguments are copied to it
– a final system call is made to execute the program, relinquishing control of the processor through a context switch
– until the program ends and a context switch returns control to the shell
• else if no matching file is found, report an error
This process is then repeated.
how the linux cli operates
(come back to this at the end of the module)
this will redirect the STDOUT (standard output) of the command to a given file.
- If the file contains content it will be overwritten
- if the file does not exist it will be created
in a windows and linux terminal what is the (>) used for and 2 considerations to take into account before its use
in a linux terminal:
this will make a new directory with the name as the value given
what is the outcme of typing
Mkdir value
into a linux terminal
this can be used to give STDIN (standard input) to a command from a file for example
in a windows or linux terminal what does the (
in a linux terminal:
this will tell you the file type of the filename you have given
what is the outcome of typing
File filename
into a linux terminal
what is the outcome of typing
Ls -l
into a linux terminal
in a linux terminal:
this will output detailed information about the contents of the directory
note
- if the first character of a line is a (-) it represents a file
- if the first character of a line is a (d) it represents a directory
Because linux was developed from UNIX many of the linux shells maintain traditions from UNIX such as syntax this in turn has kept compatibility alive between linux systems
also many of the linux shells are derivitives of the unix sh shell although they will contain many new features
why are commands from UNIX seen in linux
what is the outcome of typing
Touch non-existing filename -c
into a linux terminal
in a linux terminal:
this will find no file and will also not create a new file. execution ends silently
this linux shell
- is a widely used shell in linux distributions
- maintains compatibility with the original sh shell
- maintains compatibility with the original sh shell
give three points about the linux:
Bash (bourne again shell)