2.1 Introduction to Bash Scripting Flashcards

1
Q

What is Bash scripting?

A

It is a powerful way to automate tasks in the Linux environment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a shell script?

A

It is a text file that contains a series of commands for a Unix-based operating system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why should you use shell scripting/what are the advantages of shell scripting?

A
  1. Automation: Scripts can be used to automate repetitive tasks, reducing errors and manual effort.
  2. Efficiency: Scripts can process tasks faster than a human could, especially for bulk or complex operations.
  3. Customization: They allow users to tailor their environment and workflows to meet specific needs.
  4. Integration: Shell scripts can integrate various commands and tools, enabling seamless workflows.
  5. Portability: Shell scripts can be run on any Unix-like system without modification.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a shell?

A

It is a command line interpreter that provides a user interface for Unix operating systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the most commonly used shell in Linux systems?

A

Bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some common shells you know?

A
  1. Bash
  2. C shell
  3. Korn Shell
  4. sh
  5. Z shell
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does Bash stand for?

A

Bourne Again Shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does sh stand for?

A

Bourne Shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you verify what shell you are currently using?

A

echo $SHELL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you list all your available shells?

A

cat /etc/shells

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Where are shells found in the Linux file system?

A

/etc/shells

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when you run a script file?

A
  1. The shell reads the file.
  2. It breaks the commands down into understandable units.
  3. It executes each command in a sequence.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the preferred file extension for script files?

A

.sh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In a script file what is the purpose of the Shebang (#!)?

A

It is used to specify the interpreter to be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the importance of comments in scripts?

A
  1. 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.
  2. Maintenance: Well-commented code is easier to maintain, debug, and update. It helps in identifying the purpose of code segments quickly.
  3. Collaboration: When working in a team, comments help other team members understand the logic and functionality of the script, facilitating better collaboration.
  4. Documentation: Comments serve as inline documentation, explaining the purpose and functionality of the script, which is helpful for both users and developers.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly