LX0-101 Flashcards
What are the main user configuration files for bash?
~/.bashrc and ~/.profile
What are the main global configuration files?
/etc/bash.bashrc and /etc/profile
How to view available variables in the environment?
env
How do you reference a variable?
The variable name preceded by a dollar sign. For example if we had a variable called VARIABLE and we wanted to have that printed to the console, we could type the following: echo $VARIABLE
How do you set a variable?
The name of the variable followed by an equal sign followed by the value you want to assign the variable. You also need to export this variable using the export command. For example, if we wanted to create a variable called VARIABLE and set it to be a value of some_variable, we can achieve that by doing either of the following:
export VARIABLE=some_variable
OR
VARIABLE=some_variable
export VARIABLE
How do you delete an environment variable?
unset followed by the name of the variable (no dollar sign preceding the variable name in this case).
For example if we wanted to delete a variable called VARIABLE we can do so by typing the following:
unset VARIABLE
What is less?
less (similar to more) is a reading utility that basically lets you read information one page at a time while also allowing you to move both forward and backward.
To move forward a page, you press spacebar
To move backward you press v
To quit you press q
Linux mans (manuals) use the less reader but you can apply it to any readable file
What is the text based help system available on linux and how do you access it?
man, which is short for manual and you can apply it to even the man command itself. For example if you type, man man, you get the manual for the man command.
How many different sections can there be to a manual?
9
What are the different sections to a manual?
- Executable programs and shell commands
- System calls provided by the kernel
- Library calls provided by program libraries
- Device files (usually stored in /dev)
- File formats
- Games
- Miscellaneous (macro packages, conventions, and so on)
- System administration commands (programs run mostly or exclusively by root)
- Kernel routines
If you’re only interested in one section of the manual for a given program, how do you access that?
man number_section_of_interest command
For example, if I was concerned only with the games section of the man for less, I would type the following:
man 6 less
Some programs have moved to an alternative to man pages. What are these called and what makes them different?
These are called info pages and they utilize hypertext format so that you can move more quickly between different sections of the documentation.
You call the info command the same way you’d call the man command
What are the three most important types of streams?
Standard input (stdin), standard output (stdout), and standard error (stderr)
How do you redirect streams?
> This redirects the stdout stream to a given file… if the file doesn’t exist, it’s created, if the file does exist, it’s overwritten
> > This redirects the stdout stream to a given file and appends that data to the file’s existing contents. If the file doesn’t exist, it’s created
2> Creates a new file for stderr info or overwrites an existing file with that info
2» Appends stderr to an existing file, if the file doesn’t exist it’s created
&> Creates a new file containing both stdout and stderr, if the file exits it’s overwritten
< Sends the contents of a file to be used as stdin
«_space;Accepts text on the following lines as stdin
Unlike most redirection operators, the text immediately following the «_space;code isn’t a fi lename; instead, it’s a word that’s used to mark the end of input. For instance, typing someprog «_space;EOF causes someprog to accept input
until it sees a line that contains only the string EOF (without even a space following it).
<> Causes the specified file to be used for both standard input and standard output
tee causes a specified file to capture stdout but also display that stdout immediately, by default this will overwrite files; however, if you want this to append to an existing file, you’ll need to apply the -a flag to it.
What can you do if you want to get rid of data or, for example, a program is generating too many error messages?
Redirect standard output and/or standard error to /dev/null
Say the program the that was being too noisy was called some_program and we wanted to achieve the task mentioned in the question, we could type the following:
some_program 2> /dev/null