one Flashcards

1
Q

Starting off with a Sha-Bang

A
#!
tells the script to be fed to a specific interpreter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

If the sha-bang is incorrect

A

Probably I will get “Command not found”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what will #!/bin/sh invoke

A

It will invoke the default shell interpreter, namely, bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to interpret a file manually using bash?

A

bash filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Find out the current shell name

A

cat /etc/shells
echo $SHELL
ps $$
ps -p $$

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to get manuals of commands

A

man command

command –help

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to find out a command is a built-in or an external binary file

A

type -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

bash startup scripts

A

script of commands executed at login to set up environment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

login shell

A
when login shell is started:
1  /etc/profile runs first
2 /etc/profile.d
3 $HOME/.bash_profile which will cass $HOME/.bashrc
   $HOME/.bash_login
   $HOME/.profile
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

logout shell

A

If log out, it will call $HOME/.bash_logout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

find out available binary packages shell list

A

yum search shell

apt-cache search shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Display the full path of shell commands

A

which command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

multiple line comment

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

remove permission

A

chmod ugo= filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

debug bash script

A

bash -x scriptname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to use set to turn on debug mode or turn off debug mode

A

set -x turn on the debug mode

set +x turn off the debug mode

17
Q

How to check the syntax error in the bash script

A

set -n Read the script and check the syntax but don’t output it

18
Q

display the input lines and show if the line is implemented and show the result

A

set -v or bash -v

19
Q

set the bash debug in the bash script without set

A

!/bin/bash -xv

20
Q

enable the backslash in echo

A

echo -e

while disable it by echo -E

21
Q

view system variables

A

set
env
printenv

22
Q

check bash version

A

echo $BASH_VERSION

23
Q

how to initialize the environmental variables

A

write them in the ~/.bash_profile

24
Q

can we use like $(HOME)

A

no, the right answer is ${HOME}