Podcast
Questions and Answers
What is the main prerequisite for a text document created in one system to be readable in another system?
What is the main prerequisite for a text document created in one system to be readable in another system?
Time zones are strictly divided by longitudinal distance from the prime meridian.
Time zones are strictly divided by longitudinal distance from the prime meridian.
False
What is the time at the prime meridian called?
What is the time at the prime meridian called?
Coordinated Universal Time (UTC)
Time zones are roughly proportional discrete bands of Earth's surface spanning the equivalent to one ___________.
Time zones are roughly proportional discrete bands of Earth's surface spanning the equivalent to one ___________.
Signup and view all the answers
Match the terms with their descriptions:
Match the terms with their descriptions:
Signup and view all the answers
Why do time zones not follow the exact longitudinal distance from the prime meridian?
Why do time zones not follow the exact longitudinal distance from the prime meridian?
Signup and view all the answers
All Linux-based systems have identical localisation settings.
All Linux-based systems have identical localisation settings.
Signup and view all the answers
What is a common aspect among all Linux distributions?
What is a common aspect among all Linux distributions?
Signup and view all the answers
Which of the following countries has four time zones?
Which of the following countries has four time zones?
Signup and view all the answers
Curaçao is a country in South America.
Curaçao is a country in South America.
Signup and view all the answers
What is the next step after choosing a country?
What is the next step after choosing a country?
Signup and view all the answers
The country information alone is not enough to set the time zone for ______________.
The country information alone is not enough to set the time zone for ______________.
Signup and view all the answers
Match the following countries with their regions:
Match the following countries with their regions:
Signup and view all the answers
How many countries are listed in the provided content?
How many countries are listed in the provided content?
Signup and view all the answers
St Maarten is a country in South America.
St Maarten is a country in South America.
Signup and view all the answers
What is the purpose of tzselect?
What is the purpose of tzselect?
Signup and view all the answers
What is the purpose of the ~/.bash_aliases file?
What is the purpose of the ~/.bash_aliases file?
Signup and view all the answers
Functions are less flexible than aliases in Bash.
Functions are less flexible than aliases in Bash.
Signup and view all the answers
What is the purpose of the alias 'git_info'?
What is the purpose of the alias 'git_info'?
Signup and view all the answers
The ~/.bash_aliases file is sourced by ___________________ with every system start.
The ~/.bash_aliases file is sourced by ___________________ with every system start.
Signup and view all the answers
What is a characteristic of functions in Bash?
What is a characteristic of functions in Bash?
Signup and view all the answers
Match the following aliases with their descriptions:
Match the following aliases with their descriptions:
Signup and view all the answers
There is only one valid syntax to define functions in Bash.
There is only one valid syntax to define functions in Bash.
Signup and view all the answers
What is the purpose of the 'function' keyword in Bash?
What is the purpose of the 'function' keyword in Bash?
Signup and view all the answers
What is the purpose of the export
command in shell scripting?
What is the purpose of the export
command in shell scripting?
Signup and view all the answers
The HISTFILE
variable is used to store the history of commands.
The HISTFILE
variable is used to store the history of commands.
Signup and view all the answers
What is the purpose of the readonly
command?
What is the purpose of the readonly
command?
Signup and view all the answers
The ~
symbol represents the _____________ directory.
The ~
symbol represents the _____________ directory.
Signup and view all the answers
What is the purpose of the env
command?
What is the purpose of the env
command?
Signup and view all the answers
The PATH
variable is used to store the current working directory.
The PATH
variable is used to store the current working directory.
Signup and view all the answers
Match the following shell commands with their functions:
Match the following shell commands with their functions:
Signup and view all the answers
What is the purpose of the unset
command?
What is the purpose of the unset
command?
Signup and view all the answers
Which environment variable stores information about ssh connections?
Which environment variable stores information about ssh connections?
Signup and view all the answers
Setting the value of my_path to PATH will overwrite the existing PATH variable.
Setting the value of my_path to PATH will overwrite the existing PATH variable.
Signup and view all the answers
What is the value of the mammal variable?
What is the value of the mammal variable?
Signup and view all the answers
To create a local variable named mammal, you would use the command: mammal = ______________.
To create a local variable named mammal, you would use the command: mammal = ______________.
Signup and view all the answers
What command would you use to search for the mammal environment variable?
What command would you use to search for the mammal environment variable?
Signup and view all the answers
Creating a new folder named bin in the home directory will automatically add it to the PATH.
Creating a new folder named bin in the home directory will automatically add it to the PATH.
Signup and view all the answers
To add the ~/bin folder to your PATH, you would use the command: export PATH=$PATH:_____________.
To add the ~/bin folder to your PATH, you would use the command: export PATH=$PATH:_____________.
Signup and view all the answers
Match the environment variables with their corresponding descriptions:
Match the environment variables with their corresponding descriptions:
Signup and view all the answers
Which file is sourced by default at login or when spawning a new shell?
Which file is sourced by default at login or when spawning a new shell?
Signup and view all the answers
What is the purpose of the env
command in shell scripting?
What is the purpose of the env
command in shell scripting?
Signup and view all the answers
Where would you typically define functions for frequently used sequences of commands?
Where would you typically define functions for frequently used sequences of commands?
Signup and view all the answers
What is the purpose of the export
command in shell scripting?
What is the purpose of the export
command in shell scripting?
Signup and view all the answers
What is the purpose of the unset
command in shell scripting?
What is the purpose of the unset
command in shell scripting?
Signup and view all the answers
Which of the following files is used to set the command search path?
Which of the following files is used to set the command search path?
Signup and view all the answers
What is the purpose of the ~/.bash_logout
file?
What is the purpose of the ~/.bash_logout
file?
Signup and view all the answers
What is the purpose of the source
command in shell scripting?
What is the purpose of the source
command in shell scripting?
Signup and view all the answers
What is the purpose of the /etc/bash.bashrc file?
What is the purpose of the /etc/bash.bashrc file?
Signup and view all the answers
Which file is sourced by default for interactive bash shells?
Which file is sourced by default for interactive bash shells?
Signup and view all the answers
What is the purpose of the ~/.bashrc file?
What is the purpose of the ~/.bashrc file?
Signup and view all the answers
What happens when bash is run interactively?
What happens when bash is run interactively?
Signup and view all the answers
What is the purpose of the ~/.bash_aliases file?
What is the purpose of the ~/.bash_aliases file?
Signup and view all the answers
What is the purpose of sourcing the ~/.bash_aliases file?
What is the purpose of sourcing the ~/.bash_aliases file?
Signup and view all the answers
What happens when the tilde (~) is used in a file path?
What happens when the tilde (~) is used in a file path?
Signup and view all the answers
In what order are the global and local configuration files executed?
In what order are the global and local configuration files executed?
Signup and view all the answers
What is the purpose of putting functions in shell initialization scripts such as /etc/bash.bashrc or ~/.bashrc?
What is the purpose of putting functions in shell initialization scripts such as /etc/bash.bashrc or ~/.bashrc?
Signup and view all the answers
What is the syntax to define a function in Bash when writing it in a single line?
What is the syntax to define a function in Bash when writing it in a single line?
Signup and view all the answers
What is the indication of a new line after a line break in the shell prompt?
What is the indication of a new line after a line break in the shell prompt?
Signup and view all the answers
What is the command to invoke a function?
What is the command to invoke a function?
Signup and view all the answers
What is the purpose of sourcing shell initialization scripts after adding aliases or functions?
What is the purpose of sourcing shell initialization scripts after adding aliases or functions?
Signup and view all the answers
What is the purpose of the /etc/bash.bashrc file?
What is the purpose of the /etc/bash.bashrc file?
Signup and view all the answers
What is the syntax to define a function with multiple commands in Bash?
What is the syntax to define a function with multiple commands in Bash?
Signup and view all the answers
What is the purpose of the ~/.bashrc file?
What is the purpose of the ~/.bashrc file?
Signup and view all the answers
What is the primary purpose of aliases and functions in the shell environment?
What is the primary purpose of aliases and functions in the shell environment?
Signup and view all the answers
What is the syntax for declaring an alias in the shell?
What is the syntax for declaring an alias in the shell?
Signup and view all the answers
What is the main advantage of using aliases and functions in the shell environment?
What is the main advantage of using aliases and functions in the shell environment?
Signup and view all the answers
What is the concept that enables aliases and functions to group together a series of commands?
What is the concept that enables aliases and functions to group together a series of commands?
Signup and view all the answers
What is the purpose of the shell environment?
What is the purpose of the shell environment?
Signup and view all the answers
What is the difference between an alias and a function?
What is the difference between an alias and a function?
Signup and view all the answers
What is the purpose of the command 'latest_music=$(ls -l1t ~/Music| head -n 6)'?
What is the purpose of the command 'latest_music=$(ls -l1t ~/Music| head -n 6)'?
Signup and view all the answers
What is the purpose of the 'head -n 6' command in the 'latest_music=$(ls -l1t ~/Music| head -n 6)' command?
What is the purpose of the 'head -n 6' command in the 'latest_music=$(ls -l1t ~/Music| head -n 6)' command?
Signup and view all the answers
What is the purpose of the LANG variable?
What is the purpose of the LANG variable?
Signup and view all the answers
What is the purpose of the SSH_CONNECTION variable?
What is the purpose of the SSH_CONNECTION variable?
Signup and view all the answers
How do you set the PATH variable to include /home/carol/scripts as the last directory to search for executables?
How do you set the PATH variable to include /home/carol/scripts as the last directory to search for executables?
Signup and view all the answers
What is the purpose of the command mammal=gnu?
What is the purpose of the command mammal=gnu?
Signup and view all the answers
How do you reference the value of the mammal variable?
How do you reference the value of the mammal variable?
Signup and view all the answers
What is the purpose of the command var_sub='The value of mammal is '$mammal?
What is the purpose of the command var_sub='The value of mammal is '$mammal?
Signup and view all the answers
What is the purpose of the command win_path=C:\path\to\dir?
What is the purpose of the command win_path=C:\path\to\dir?
Signup and view all the answers
Study Notes
Environment Variables
- The
PATH
environment variable stores information about SSH connections. - To set
PATH
to include a new directory, use the commandexport PATH=$PATH:/home/carol/scripts
. - Local variables are only accessible in the current shell session, while environment variables are accessible in the current and future shell sessions.
Creating and Using Variables
- To create a local variable, use the syntax
variable_name=value
. - To create an environment variable, use the syntax
export variable_name=value
. - To turn a local variable into an environment variable, use the
export
command. - To list all environment variables, use the
env
command orset
command withgrep
. - To make variables persistent across reboots, add the code to the
~/.profile
file.
Shell Environment
- Variables are used by the shell itself and other programs.
- There are differences between local and global (or environment) variables.
- Variables can be made readonly using the
readonly
command. - Startup scripts can be used to make variables persistent.
Common Environment Variables
-
DISPLAY
: used for graphical displays -
HISTCONTROL
,HISTSIZE
,HISTFILESIZE
,HISTFILE
: used for shell history -
HOME
,HOSTNAME
,HOSTTYPE
: used for user and system information -
LANG
,LD_LIBRARY_PATH
,MAIL
,MAILCHECK
: used for internationalization and email -
PATH
,PS1
(and other prompt variables),SHELL
,USER
: used for shell configuration
Tilde (~) and Paths
- The tilde (~) represents the home directory of the current user.
- To add a directory to the
PATH
environment variable, use the syntaxexport PATH=$PATH:/home/user/bin
. - To make the
PATH
variable persistent across reboots, add the code to the~/.profile
file.
Functions and Aliases
- Functions are more flexible and programmatic than aliases.
- Two syntaxes for creating functions: using the
function
keyword and using parentheses. - Functions can include logic through blocks or collections of other commands.
- Aliases are used to create shortcuts for commands.
Time Zones and Localization
- Time zones are regions of the world experiencing the same hour of the day.
- Time zones are relative to the prime meridian, where the Earth's longitude angle is defined to be 0.
- The time at the prime meridian is called Coordinated Universal Time (UTC).
- Time zones do not follow the exact longitudinal distance from the reference point.
Customize and Use the Shell Environment
- The objective is to set environment variables, write Bash functions, maintain skeleton directories, and set the command search path.
- Environment variables can be set at login or when spawning a new shell using files such as
/etc/bash.bashrc
,/etc/profile
,~/.bash_profile
,~/.bash_login
, and~/.profile
. - The
source
command is used to execute the content of a file in the current shell. - The
env
command displays all environment variables and their values. - The
export
command is used to set environment variables for the current shell and all child shells. - The
unset
command is used to remove environment variables. - Bash functions can be used to create frequently used sequences of commands.
- Bash functions can be written in the
~/.bashrc
file to make them persistent across system reboots. - The
function
keyword is used to declare a Bash function. - Bash functions can be written in one line using semicolons to separate commands.
- The
alias
command is used to create a substitute name for another command. - Aliases can be used to run a series of repetitive or recurrent commands.
- Aliases can be declared using the
alias
keyword followed by the alias assignment. - The
PS2
prompt is used to indicate a new line after a line break when writing a function in the shell prompt.
Interactive Non-Login Shell
- The global file
/etc/bash.bashrc
is executed for interactive bash shells. - The file checks if the shell is being run interactively and sets some variables.
- The local file
~/.bashrc
is executed for interactive bash shells at a user level. - The file checks the window size, sets history variables, and sources
~/.bash_aliases
if it exists.
Variable Assignment
- Variables can be assigned using the
=
operator. - Variables can be referenced using the
$
operator. - The tilde (
~
) expands to the absolute path of the file. - Variables can be assigned with spaces or special characters using quotes.
Command Search Path
- The command search path can be set using the
PATH
variable. - The
PATH
variable can be set to include a new directory using thePATH=$PATH:/new/directory
syntax.
Language and Localization
- The
LANG
variable can be set to change the language of the shell. - The
LANG
variable can be set toes_ES.UTF-8
to set the language to Spanish UTF-8.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Quiz on bash scripting variables, including environment variables, PATH, and variable substitution.