Linux Shells

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/3

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

4 Terms

1
New cards

Popular Shells

Feature

Bash

Fish

Zsh

Full Name

Bourne Again Shell

Friendly Interactive Shell

Z Shell

Scripting

It offers widely compatible scripting with extensive documentation available.

It has limited scripting features as compared to the other two shells.

It offers an excellent level of scripting, combining the traditional capabilities of Bash shell with some extra features.

Tab completion

It has a basic tab completion feature.

It offers advanced tab completion by giving suggestions based on your previous commands.

Its tab completion capability can be extended heavily by using plugins.

Customization

Basic level of customization.

It offers some good customization through interactive tools.

Advanced customization through oh-my-zsh framework.

User friendliness

It is less user-friendly, but being a traditional and widely used shell, its users are quite familiar and comfortable with it.

It is the most user-friendly shell.

It can be highly user-friendly with proper customization.

Syntax highlighting

The syntax highlighting feature is not available in this shell.

The syntax highlighting is built-in to this shell.

The syntax highlighting can be used with this shell by introducing some plugins.

2
New cards

Writing a Unix shell script

  1. Create a script file (scripts use .sh extension): nano first_script.sh

  2. Every script should start from shebang “#!”: #!/bin/bash

  3. Add commands to be executed.

  4. Save and exit

  5. Add execute permission to script: chmod +x first_script.sh

  6. Execute the script: ./first_script.sh

3
New cards

Loops

do indicates the start of the loop code, and done indicates the end.

#!/bin/bash
for i in {1..10};
do
echo $i
done

4
New cards

Conditional Statements

#!/bin/bash
echo "Please enter your name first:"
read name
if [ "$name" = "Stewart" ]; then
        echo "Welcome Stewart! Here is the secret: THM_Script"
else
        echo "Sorry! You are not authorized to access the secret."
fi