1. Chapter 1 - Introduction to Command Shell Scripting (Bash)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

String together commands develop tools automate process manipulate files

According to the textbook, what are four things shell scripts allow penetration testers to do?

Command lines args are accessed in the shell by adding them to the command script to run ARGV[0]=programitsselfandrest represent the positional arguments as they are typed into the shell. Storing them in an aray

How are command line arguments accessed in a Bash shell script? What is the meaning of ARGV[0], ARGV[1], etc? See Table 1.1. in the textbook.

Variables are created in Bash either global or local local MESSAGE="-----" MESSAGE="----"

How are variables created in Bash? What is the proper syntax for assigning a value to a variable in Bash?

creation - def "f

How is a function created in Bash? How is a function called in Bash?

Integer math is perfomred in the bash by use of the expr command can do + - / * use mod for floating point

How is integer math performed in Bash? How do you handle floating point calculations in Bash?

program written in scripting language to interface with the shell of os

What are shell scripts

They are HOME HOSTNAME OSTYPE PATH PWD SHELL UID USER and order for them to be printed and echoed the script must user either, - double qoute - back tick - $(command) format

What are some predefined shell variables (e.g., HOME, HOSTNAME, etc) in Bash and how are the value of one of these variables printed.

if then if then else elif case structure

What are the different types of decision statements (e.g., if-then) in Bash? What is the proper syntax for each? Identify all the syntax errors in the following if-then statement (Refer to Lab 1, p. 31 for the solution).

while loop while [ test condition ] do command done do loop for loop for variable in list do command done

What are the different types of repetition statements in Bash? What is the proper syntax for each?

Korn shell z shell

What are the names of two other Bourne-compatible shells?

The interface between the user and the s allows running of programs and manipulating of files, can be graphical or text based

What is a shell

an exit status is used to convey whether a command was successful or not 0 means successful and all others mean unsucessful 1 = permission denied 2 = no parameter 126 = not a command 127 = not in system 128+ Ctrl c termination

What is meant by an "exit status" in a Bash shell script? What value indicates successful script execution? Unsuccessful script execution?

scripting language is interpreted and not compiled, it converts it o machine language as the code is run and a programming language uses a compiler to convert everything into machine language all at once

What is the difference between scripting such languages such as Bash and Python and programming languages like C and C++?

single qoutes will not execute variables or commands but will simply read back all that is between the single qoutes double qoutes will echo text but will also interpret a variable single q = variable no work double q = variable work

What is the difference between single and double quoting in Bash?

The first one will add execute permissions to just the user the second will add execute permissions to all the third will give the user all permissions, group will recieve read and execute permissions, and the others will receive read and execute

What is the difference between the following commands? chmod u+x helloworld.sh chmod +x helloworld.sh chmod 755 helloworld.sh

running from current directory and root

What is the difference between the following two forms of script execution? ./path/scriptname.sh /path/ scriptname.sh

permission denied

What is the output when running a script that does not have execute permission?

to print the value of a variable use $variable name the -n means ------

What is the proper syntax for printing the value of a variable in Bash shell scripting? What is the purpose of the -n option to the echo command?

Telling the shell you are running a file from the current directory allows the shell to tell kernel to run program

What is the purpose of "./" when executing a script? See Figure 1.4 in the textbook.

back qoutes or ticks allow command execution the new way though is $(command)

What is the purpose of back quotes in a Bash shell script? What is the syntax of the newer method that does not use back

Used to tell the shell where the interpreter is located

What is the purpose of the "shebang" line in a Bash script?

It changes the file permissions for the user and it can be executed octal numbers or with alphanumeric characters such as chmod +x "file name" chmod ### "file name"

What is the purpose of the chmod command in relation to any programming script? How is the chmod command executed?

because it is written in c

Why might a penetration tester choose to use the C shell over the Bash shell?

ctrl +c

Your running script is misbehaving. How can you terminate a Bash shell script?

Two ways - echo -n "Prompt" read (variable) - read -p "prompt" variable the p can be used so that the read command and the prompt can be commanded on the same line

• What is the proper syntax for obtaining user input in Bash shell scripting using the read command? What is the purpose the -p option to the read command

To debug a shell script use - bash -x ./file.sh - insert #!/bin/bash -x in the shebang this will display the commands and arguments as they are executed in the shell for line debugging also use (on, off) - set -x - set +x

• What methods are available for debugging (e.g., -x) a Bash shell script?


Set pelajaran terkait

Bio-Chapter 20-Viruses, Bacteria, and Archaea

View Set

Chapter 34: Comfort and Pain Management

View Set

Modales - Preguntas y Respuestas

View Set

MGMT 452 chapter 13 AND LAST PART

View Set