bash shell scripting Flashcards

1
Q

what is a kernel in Linux?

A

It manages the computer’s hardware, like the CPU and memory, and allows software programs to use these resources. Think of it as the bridge between the computer’s hardware and the applications you run.

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

what is a shell in Linux?

A

In Linux, a shell is a program that lets you interact with the operating system using text commands.

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

name some shells you know

A
  • Bash (Bourne Again Shell)
  • Zsh (Z Shell):
  • Ksh (Korn Shell)
  • Fish (Friendly Interactive Shell) etc…….
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how can you see all the shells you have installed in your Linux machine?

A

cat /etc/shells

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

what is the command to find the shell you are currently using ?

A

echo $0

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

what is a shell script ?

A

A shell script is a file containing a series of commands that are executed by a shell.

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

what is in the first line of a shell script?

A

the shell eg #!/bin/bash

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

what kind of permissions should a shell script have ?

A

executable permissions eg (-rwx r-x r-x)

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

how can you call a shell script ?

A
  • use the absolute path (eg /home/file1/install.sh)
    -use the relative path ./install.sh
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

run a script that will output “hello world”

A

!/bin/bash

-touch a file

echo “hello world”

  • give it execute permission (chmod +x filename)
  • run the script (./filename)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

run a script from an absolute path

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

what is a variable in shell scripting ?

A

In shell scripting, a variable is a placeholder that stores a value, which can be used and manipulated throughout the script.

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

create a script, define some variables and call the variables.

A
  1. touch a file
    #!/bin/bash

a=apple
b=pear
c=oranges

echo “my favorite fruit is an $a”
echo “my sister loves $b”
echo “I use $c to make juice”

  • give it execute permission (chmod +x filename)
  • run the script (./filename).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly