WorksheetsLinux2 - Quizz 5 -bash scripting
Total questions: 16
Worksheet time: 12mins
How can I print the current system variables?
echo bash
echo $bash
print bash
printf bash
How can I input data into a shell script in an neat way?
read -p "Enter your age"
read -p "Enter your age" age
read "Enter your age"
read "Enter your age" age
How can I check if an file is readable?
if [[ -r $file ]]; then
echo "File is not readable"
exit 0
fi
if [[ -d $file ]]; then
echo "File is not readable"
exit 0
fi
How to compare if 2 integers (a = 1, b = 2) are equal?
if [a -eq b]
if [a = b]
if [a isequal b]
if [ b equal a]
How can I check if a directory exists ?
path = "/tmp/sound"
if [ -d "$path" ];
if [ -r "$path" ];
if [ -e "$path" ];
if [ -w "$path" ];
Cron at 16:00 on day-of-month 1 in every month from January through December
00 16 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh
00 04 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh
16 00 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh
16 16 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh
How can I edit a cronjob?
crontab -l
crontab -e
crontab
crontab -m
The correct way to redirect stderror and stdout in a cronjob
1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log 2>&1
1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log
1 12 * * * /home/frank/BackUpAll.sh >>/tmp/mycommand.log 2>&1
1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log 2>&@
When using the crontab -e option, how to delete a single line?
dd
d
press the del-key
<ctrl> d
How can you search for a text-string in the crontab when using crontab -e
Using the ‘l’ command
Using the ‘f’ command
Using the ‘s’ command
Using the ‘/’ command
Which port is the default SSH port?
9999
2222
22
8080
Which of the following statements is true (more answers might be correct)?
Apache is an open source application and webserver
Runs as HTTPD on RHEL systems, otherwise as Apache2
Uses httpd.conf for configuration
You need to check rights and permissions on files in /var/www and config-files
What can you perform with the function ‘test –e "string"’ in your script
It will return false if length of string is not zero
It will return true if a file exists
It will return 1 if length of string is not zero
It will return 0 if a string is empty
Which of the following anwsers is correct about the WHILE-statement (more answers can be correct)?
A while statement is used to determine if a condition is true or false
If it is true then a series of actions takes place and the condition is checked again
If the condition is false, then no action takes place and the program continues
The while statement along with the block of statements to be executed when it is true is also know as a while loop
What command can be used to view the Exit Status of the last run script?
print status
echo status
echo $?
print $cc
How to end a for-loop in a linux script?
ROF
DONE
END
STOP
