quiz image

LPIC-1 Exam 102 Topic 105: Shells and Shell Scripting

GuiltlessAshcanSchool avatar
GuiltlessAshcanSchool
·
·
Download

Start Quiz

Study Flashcards

5 Questions

What is the main strength of aliases and functions in shell scripting?

They offer the possibility of putting together a series of repetitive or recurrent commands

What is the syntax for declaring an alias in shell scripting?

The keyword alias followed by the alias assignment

What is the purpose of an alias in shell scripting?

To provide a substitute name for another command(s)

What is the relationship between variables, aliases, and functions in shell scripting?

They influence each other

What is the benefit of using aliases and functions in shell scripting?

They offer flexibility and time-saving

Study Notes

Customize and Use the Shell Environment

  • Set environment variables at login or when spawning a new shell, e.g., PATH.
  • Write Bash functions for frequently used sequences of commands.
  • Maintain skeleton directories for new user accounts.
  • Set command search path with the proper directory.

Environment Variables

  • /etc/bash.bashrc and /etc/profile are used to set environment variables.
  • env, export, set, and unset are used to manipulate environment variables.
  • ~/.bash_profile, ~/.bash_login, ~/.profile, ~/.bashrc, and ~/.bash_logout are used to set environment variables for individual users.

Bash Commands

  • source command is used to load a file into the current shell.
  • function command is used to define a function.
  • alias command is used to define an alias.

Setting Language and Working Directory

  • export LANG=es_ES.UTF-8 sets the language of the current shell to Spanish UTF-8.
  • pwd command prints the name of the current working directory.

Setting and Using Variables

  • export PATH=$PATH:/home/carol/scripts sets the PATH environment variable to include a new directory.
  • my_path=$PATH sets the value of my_path to the value of PATH.
  • mammal=gnu sets a local variable mammal to the value gnu.
  • var_sub="The value of mammal is $mammal" sets a local variable var_sub using variable substitution.

Creating and Searching Environment Variables

  • export mammal=gnu turns a local variable into an environment variable.
  • set | grep mammal and env | grep mammal are used to search for an environment variable.

Creating and Managing Directories

  • mkdir ~/bin creates a new directory named bin in the home directory.
  • export PATH=$PATH:~/bin adds the ~/bin directory to the PATH environment variable.

Adding to ~/.profile

  • if [ -d ~/bin ]; then export PATH=$PATH:~/bin; fi is used to add the ~/bin directory to the PATH environment variable in the ~/.profile file.

Customize and use the shell environment. Set environment variables, write Bash functions, and maintain skeleton directories for new user accounts.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Bash Shell Scripting Parameters Quiz
15 questions
Bash Shell Scripting Basics
18 questions

Bash Shell Scripting Basics

ConfidentTechnetium avatar
ConfidentTechnetium
Introducción a Bash
10 questions

Introducción a Bash

VeritableMystery avatar
VeritableMystery
Use Quizgecko on...
Browser
Browser