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?
- Same file format
- Internet connection
- Same operating system
- Agreement on encoding format and character association (correct)
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 (B)
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 ___________.
Match the terms with their descriptions:
Match the terms with their descriptions:
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?
All Linux-based systems have identical localisation settings.
All Linux-based systems have identical localisation settings.
What is a common aspect among all Linux distributions?
What is a common aspect among all Linux distributions?
Which of the following countries has four time zones?
Which of the following countries has four time zones?
Curaçao is a country in South America.
Curaçao is a country in South America.
What is the next step after choosing a country?
What is the next step after choosing a country?
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 ______________.
Match the following countries with their regions:
Match the following countries with their regions:
How many countries are listed in the provided content?
How many countries are listed in the provided content?
St Maarten is a country in South America.
St Maarten is a country in South America.
What is the purpose of tzselect?
What is the purpose of tzselect?
What is the purpose of the ~/.bash_aliases file?
What is the purpose of the ~/.bash_aliases file?
Functions are less flexible than aliases in Bash.
Functions are less flexible than aliases in Bash.
What is the purpose of the alias 'git_info'?
What is the purpose of the alias 'git_info'?
The ~/.bash_aliases file is sourced by ___________________ with every system start.
The ~/.bash_aliases file is sourced by ___________________ with every system start.
What is a characteristic of functions in Bash?
What is a characteristic of functions in Bash?
Match the following aliases with their descriptions:
Match the following aliases with their descriptions:
There is only one valid syntax to define functions in Bash.
There is only one valid syntax to define functions in Bash.
What is the purpose of the 'function' keyword in Bash?
What is the purpose of the 'function' keyword in Bash?
What is the purpose of the export
command in shell scripting?
What is the purpose of the export
command in shell scripting?
The HISTFILE
variable is used to store the history of commands.
The HISTFILE
variable is used to store the history of commands.
What is the purpose of the readonly
command?
What is the purpose of the readonly
command?
The ~
symbol represents the _____________ directory.
The ~
symbol represents the _____________ directory.
What is the purpose of the env
command?
What is the purpose of the env
command?
The PATH
variable is used to store the current working directory.
The PATH
variable is used to store the current working directory.
Match the following shell commands with their functions:
Match the following shell commands with their functions:
What is the purpose of the unset
command?
What is the purpose of the unset
command?
Which environment variable stores information about ssh connections?
Which environment variable stores information about ssh connections?
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.
What is the value of the mammal variable?
What is the value of the mammal variable?
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 = ______________.
What command would you use to search for the mammal environment variable?
What command would you use to search for the mammal environment variable?
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.
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:_____________.
Match the environment variables with their corresponding descriptions:
Match the environment variables with their corresponding descriptions:
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?
What is the purpose of the env
command in shell scripting?
What is the purpose of the env
command in shell scripting?
Where would you typically define functions for frequently used sequences of commands?
Where would you typically define functions for frequently used sequences of commands?
What is the purpose of the export
command in shell scripting?
What is the purpose of the export
command in shell scripting?
What is the purpose of the unset
command in shell scripting?
What is the purpose of the unset
command in shell scripting?
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?
What is the purpose of the ~/.bash_logout
file?
What is the purpose of the ~/.bash_logout
file?
What is the purpose of the source
command in shell scripting?
What is the purpose of the source
command in shell scripting?
What is the purpose of the /etc/bash.bashrc file?
What is the purpose of the /etc/bash.bashrc file?
Which file is sourced by default for interactive bash shells?
Which file is sourced by default for interactive bash shells?
What is the purpose of the ~/.bashrc file?
What is the purpose of the ~/.bashrc file?
What happens when bash is run interactively?
What happens when bash is run interactively?
What is the purpose of the ~/.bash_aliases file?
What is the purpose of the ~/.bash_aliases file?
What is the purpose of sourcing the ~/.bash_aliases file?
What is the purpose of sourcing the ~/.bash_aliases file?
What happens when the tilde (~) is used in a file path?
What happens when the tilde (~) is used in a file path?
In what order are the global and local configuration files executed?
In what order are the global and local configuration files executed?
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?
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?
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?
What is the command to invoke a function?
What is the command to invoke a function?
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?
What is the purpose of the /etc/bash.bashrc file?
What is the purpose of the /etc/bash.bashrc file?
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?
What is the purpose of the ~/.bashrc file?
What is the purpose of the ~/.bashrc file?
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?
What is the syntax for declaring an alias in the shell?
What is the syntax for declaring an alias in the shell?
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?
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?
What is the purpose of the shell environment?
What is the purpose of the shell environment?
What is the difference between an alias and a function?
What is the difference between an alias and a function?
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)'?
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?
What is the purpose of the LANG variable?
What is the purpose of the LANG variable?
What is the purpose of the SSH_CONNECTION variable?
What is the purpose of the SSH_CONNECTION variable?
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?
What is the purpose of the command mammal=gnu?
What is the purpose of the command mammal=gnu?
How do you reference the value of the mammal variable?
How do you reference the value of the mammal variable?
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?
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?
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 displaysHISTCONTROL
,HISTSIZE
,HISTFILESIZE
,HISTFILE
: used for shell historyHOME
,HOSTNAME
,HOSTTYPE
: used for user and system informationLANG
,LD_LIBRARY_PATH
,MAIL
,MAILCHECK
: used for internationalization and emailPATH
,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.