Linux Shells, Scripting, and Data Management
The Linux+ certification exam from CompTIA requires knowledge of scripting and data management. The table shows the subtopics, weights, descriptions, and key knowledge areas for this topic — the first of the 102 exam.
|Customize and use the shell environment||4||Be able to modify global and user profiles||Set environment variables and work within bash|
|Customize or write simple scripts||4||Customize existing bash scripts and write new ones||Be able to write code that includes loops and tests|
|SQL data management||2||Query databases and manipulate data with SQL||Know basic SQL commands|
To adequately address these topics, focus on the following files, terms, and utilities: /etc/profile, ~/.bash_login, ~/.bash_logout, ~/.bash_profile, ~/.bashrc, ~/.profile, alias, delete, env, export, for, from, function, group by, if, insert, join, lists, order by, read, select, seq, set, test, unset, update, where, and while.
Here are the top ten items to know as you study for this domain:
Logic can be added to scripts by testing conditions with test or [. Commands can execute using if-then-fi deviations or through looping (while, until, or for). You can leave a script with the exit command or leave a loop with break.
Variables can be given at the command line and referenced as $1, $2, and so on, or entered into the executing file with the read command.
The alias command can be used to create an alias for a command to operate by another name (for example, being able to type dir and have ls –l performed).
Environmental variables can be viewed with the env command.
Variables can be added to the environment using the set command and export; they are removed using unset.
The /etc/profile configuration file is executed whenever a user logs in.
For those using the bash shell, the shell first looks for .bash_profile; if it does not file that profile, it looks for .bash_login.
When the bash user logs out, the shell will look for .bash_logout and execute any commands found there.
While other configuration files run only when the user logs in or out, the .bashrc file can execute each time a shell is run.
Shell scripts must have executable permissions to run, or be called by a shell (for example: sh script). The normal exit status of any script or application is 0 and anything else signifies a non-normal exit.