Podcast
Questions and Answers
What command would you use to create your own crontab file as an ordinary user?
What command would you use to create your own crontab file as an ordinary user?
Where can you see the output of a scheduled job?
Where can you see the output of a scheduled job?
What is the purpose of the 'select-editor' command?
What is the purpose of the 'select-editor' command?
What is the meaning of '*/5 * * * *' in a crontab file?
What is the meaning of '*/5 * * * *' in a crontab file?
Signup and view all the answers
What is the effect of specifying 'Fri' in the day of the week field of a crontab file?
What is the effect of specifying 'Fri' in the day of the week field of a crontab file?
Signup and view all the answers
Study Notes
Shell Environment Customization
- Setting environment variables like
PATH
during login or shell spawning is essential for configuring the shell's operating context. - Common files for environment settings include:
-
/etc/bash.bashrc
-
/etc/profile
-
~/.bash_profile
-
~/.bash_login
-
~/.profile
-
~/.bashrc
-
~/.bash_logout
-
- Use
source
to execute commands from files, which helps apply changes immediately.
Bash Functions and Variables
- Bash functions streamline frequent command sequences, improving efficiency in command line tasks.
- Use
export
to create global variables; local variables remain limited to the current shell session. - To list environment variables, use
printenv
andenv
commands.
Command Functions and Outputs
- Commands like
echo
assist in displaying variables and outputs:-
echo $HISTCONTROL
will show how Bash handles command history. -
echo $DISPLAY
indicates X server settings for display output. - Use
echo $MAILCHECK
to determine intervals for mail checking.
-
- The location for command history is defined by
$HISTFILE
.
Correcting Variable Assignments
- Improper variable assignments can yield unexpected results; ensuring correct syntax is crucial.
- Examples include ensuring assignments are correctly formatted, such as:
- Using
lizard=chameleon
for local scope. - Incorporating quotes for strings with spaces.
- Using
Common Shell Commands
- Set language environment with
LANG=es_ES.UTF-8
for localization. - Current working directory is retrievable via
echo $PWD
orpwd
. - SSH connection details can be accessed with
$SSH_CONNECTION
.
Demonstrating Functions with Positional Parameters
- Functions can take parameters, accessed within the function using
$1
,$2
, etc. - Example function
special_vars()
illustrates how parameters are passed and displayed.
Cron Job Scheduling
- Create personal crontab file with the command
crontab -e
, allowing editing of scheduled tasks. - Cron entries dictate job timing and execution, i.e.,
00 13 * * 5 date
for executing thedate
command every Friday at 1 PM. - Scheduled job output is typically emailed to the user, which can be viewed using the
mail
command.
Special Shell Variables
- Understand built-in variables:
-
$#
indicates the number of passed arguments. -
$@
and$*
represent all passed arguments. -
$_
holds the last parameter used in the previous command.
-
Function Variable Usage
- Variables can be effectively utilized within functions to manage specific tasks or outputs, enhancing script efficiency.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Practice questions and exercises for LPIC-1 (102) exam preparation. Covers various topics in Linux system administration. Helpful for system administrators and IT professionals.