bash shell scripting Flashcards
what is a kernel in Linux?
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.
what is a shell in Linux?
In Linux, a shell is a program that lets you interact with the operating system using text commands.
name some shells you know
- Bash (Bourne Again Shell)
- Zsh (Z Shell):
- Ksh (Korn Shell)
- Fish (Friendly Interactive Shell) etc…….
how can you see all the shells you have installed in your Linux machine?
cat /etc/shells
what is the command to find the shell you are currently using ?
echo $0
what is a shell script ?
A shell script is a file containing a series of commands that are executed by a shell.
what is in the first line of a shell script?
the shell eg #!/bin/bash
what kind of permissions should a shell script have ?
executable permissions eg (-rwx r-x r-x)
how can you call a shell script ?
- use the absolute path (eg /home/file1/install.sh)
-use the relative path ./install.sh
run a script that will output “hello world”
!/bin/bash
-touch a file
echo “hello world”
- give it execute permission (chmod +x filename)
- run the script (./filename)
run a script from an absolute path
what is a variable in shell scripting ?
In shell scripting, a variable is a placeholder that stores a value, which can be used and manipulated throughout the script.
create a script, define some variables and call the variables.
- 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).