2.1 Introduction to Bash Scripting Flashcards
What is Bash scripting?
It is a powerful way to automate tasks in the Linux environment.
What is a shell script?
It is a text file that contains a series of commands for a Unix-based operating system.
Why should you use shell scripting/what are the advantages of shell scripting?
- Automation: Scripts can be used to automate repetitive tasks, reducing errors and manual effort.
- Efficiency: Scripts can process tasks faster than a human could, especially for bulk or complex operations.
- Customization: They allow users to tailor their environment and workflows to meet specific needs.
- Integration: Shell scripts can integrate various commands and tools, enabling seamless workflows.
- Portability: Shell scripts can be run on any Unix-like system without modification.
What is a shell?
It is a command line interpreter that provides a user interface for Unix operating systems.
What is the most commonly used shell in Linux systems?
Bash
What are some common shells you know?
- Bash
- C shell
- Korn Shell
- sh
- Z shell
What does Bash stand for?
Bourne Again Shell
What does sh stand for?
Bourne Shell
How do you verify what shell you are currently using?
echo $SHELL
How do you list all your available shells?
cat /etc/shells
Where are shells found in the Linux file system?
/etc/shells
What happens when you run a script file?
- The shell reads the file.
- It breaks the commands down into understandable units.
- It executes each command in a sequence.
What is the preferred file extension for script files?
.sh
In a script file what is the purpose of the Shebang (#!)?
It is used to specify the interpreter to be used.
What are the importance of comments in scripts?
- Code Readability: Comments make the script easier to read and understand, especially for someone who did not write it or is revisiting the code after a long time.
- Maintenance: Well-commented code is easier to maintain, debug, and update. It helps in identifying the purpose of code segments quickly.
- Collaboration: When working in a team, comments help other team members understand the logic and functionality of the script, facilitating better collaboration.
- Documentation: Comments serve as inline documentation, explaining the purpose and functionality of the script, which is helpful for both users and developers.