PROG1901 TEST 1 PRACTICE QUIZ

LyricalCelebration avatar
LyricalCelebration
·
·
Download

Start Quiz

Study Flashcards

30 Questions

How can you display the value of a variable in PowerShell?

Use the Write-Host cmdlet with the variable name within double quotes

In PowerShell, how is selection logic formatted similar to C#?

if (condition) { true statements } else { false statements }

Which operator is used before a comparison in PowerShell?

-not

How should user-defined functions be placed in a PowerShell script?

Before any other code as they must be declared before being called

What array holds values passed to a function in PowerShell?

$args

Which logical operator in PowerShell means 'only one can be true'?

-xor

What is the correct comparison operator for 'greater than' in PowerShell?

-gt

To output text along with a variable value to the screen in PowerShell, which cmdlet should be used?

Write-Host

In PowerShell, what should a condition evaluate to in selection logic?

$true or $false values indirectly

What keyword is used to create a function in PowerShell?

function

How can you store the output of a command in a variable in Bash by using command substitution?

Placing the command in round brackets preceded by the $ sign

What happens when the output of a command in Bash is more than one line and stored in a variable?

The entire output is converted to a single line and stored in the variable

How can you make a variable available in other bash shells in Bash scripting?

Use the export keyword before the variable name

What is the scope of variables declared in a script in Bash by default?

Local to the script only

In Bash scripting, what effect does 'export' have when used with a variable?

It makes a copy of the variable available in other shell instances

Which symbol is used for command substitution in Bash scripting?

$(

What happens if you declare a variable without using 'export' in a Bash script?

The variable is only accessible within that script instance

How does exporting a variable affect its modifications in Bash?

'export' reflects changes globally across all instances of the shell

What does exporting a variable allow you to do in Bash?

Access the variable across multiple scripts and shell instances

In Bash scripting, what does 'o myVar=$( ls /etc ) o' demonstrate?

Command substitution to assign output to a variable

What is the main focus of information security according to the text?

Protecting information stored, manipulated, and transmitted

Which aspect of information security ensures that only approved individuals can access important data?

Confidentiality

What does authentication aim to achieve in information security?

Verifying the identity of users

In what way do attacks on information security demonstrate increased sophistication?

Attack tools vary their behavior to evade detection

Which element ensures that the individual is who they claim to be in information security?

Authentication

What is a threat vector?

The means by which an attack can occur

Why do organizations find it challenging to provide security for personal devices under BYOD?

Organizations face difficulty in securing a wide array of personal devices

What is a vulnerability in the context of information security?

A flaw or weakness that allows a threat agent to bypass security

How are attacks different due to the availability and simplicity of attack tools?

No longer limited to highly skilled attackers

What defines a threat agent in the context of information security?

A person(s) or element capable of carrying out a threat

Study Notes

Windows Scripting Overview

  • Windows supports various scripting languages, including Batch, PowerShell, VBScript, and JScript, which use text files for source code and automate tasks at the operating system level.
  • These languages offer basics such as creating and using variables, input from the user and output to the user, use of control structures like if, switch, for, and while, and support for functions and arrays.

Batch File Scripting

  • Batch files have a .bat or .cmd extension, with .cmd being the preferred extension.
  • Functions in batch files:
    • Are defined with a label and a colon
    • The body of the function contains any logic and commands
    • The last line of a function is usually exit /B 0, which exits the script with an error code of zero
    • Functions don't return to the line of code they are called from
    • To call a function, use the call keyword followed by the label name and any values to be passed
  • Example batch file script:
    • Creates folders and files in the Documents directory
    • Uses verbs like Get, Set, Start, Stop, Out, and New to perform actions

PowerShell

  • PowerShell is a powerful scripting language based on .NET
  • To get help, use the get-help command (cmdlet)
  • Examples of get-help usage:
    • get-help for an overview of the help system
    • get-help dir to get help on the dir command
    • get-help about* to get a list of conceptual help files
    • get-help clear* to list cmdlets starting with the word clear

Linux Scripting (BASH) Overview

  • BASH (Bourne Again shell) is the default shell for most Linux distributions
  • Other shells include Korn Shell (ksh), C Shell (csh), and variations like tcsh

BASH Scripting Basics

  • Shell scripts are text files that end in .sh (but it's not required)
  • The first line of the script must indicate the shell that should be used to execute the script (#!/bin/bash)
  • Comments start with #
  • To execute a script, change the file permissions for the user, group, and other categories using chmod ugo+x or chmod 755
  • Example of changing file permissions:
    • chmod ugo+x adds execute rights to the user, group, and all other users
    • chmod 755 sets the file permissions to rwx r-x r-x

Variables in BASH

  • Variables are not declared, and values are assigned using the assignment operator (=)
  • Variables are assigned as strings but can be converted to numbers when necessary
  • Access the value of a variable using the $ sign
  • Output the value of a variable using echo
  • Input a value using read
  • Bash scripts have access to command line arguments (positional variables) and environment variables.

Test your knowledge of PowerShell commands with this quiz! Identify the corresponding actions to common verbs used in PowerShell commands and understand their functionalities. Learn about using the get-help command to navigate and utilize the help system effectively.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser