In Bash we can write a simple Hello world! function by including the following code in an empty file:
function hello() {
echo "Hello world!"
}
What should we do next to make the function available to the shell?
Once it is available to the current shell, how would you invoke it?
To automate things, in what file would you put the function and its invocation so that it gets executed when user2 opens a terminal from an X Window session? What type of shell is it?
In what file would you put the function and its invocation so that it is run when root launches a new interactive shell irrespective of whether it is login or not?
Imagine you have changed the values of some variables in ~/.bashrc and want those changes to take effect without a reboot. From your home directory, how could you achieve that in two different ways?
John has just started an X Window session on a Linux server. He opens a terminal emulator to carry out some administrative tasks but, surprisingly, the session freezes and he needs to open a text shell.
Linda is a user of a Linux server. She kindly asks the administrator to have a ~/.bash_login file so she can have the time and date printed on the screen when she logs in. Other users like the idea and follow suit. The administrator has a hard time creating the file for all other users on the server so he decides to add a new policy and have ~/.bash_login created for all potential new users. How can the administrator accomplish that task?
What is going to happen when you press ALT + . in Bash?
What are !! and !$ used for, in Bash?
What is the command . ~/.bashrc going to do?
What is skel directory used for?
What is command echo $0 going to tell us?
What is CTRL + ALT + F2?
What is Sakura?
Are GNU tools using one or two dashes before the parameter passed to the command?
What is sudo -iu doing?
Read through login and non-login shell differences once again.
The above are some of the notes that I have noticed, during the live stream, that were not entirely clear to active students in chat. Please find answers to all of them.
H1/1 - executable sounds about right, but copying a script to “bin/bash” doesn’t sound right.
H1/2 - you CAN run the script like that, but if you run it like that it doesn’t have to be executable. scripts that are executable - you can simply execute them with ./script.sh
H1/3 - unfortunately no. only ~/.bashrc will execute in this scenario
H1/4 - I’d say it’s a trick question and it’s the same with root = ~/.bashrc
H2/1 - I’d say you are very correct/logical on this
H2/2 - this as well.
H3 - you have changed things in ~/.bashrc and you wish to apply the changes ASAP. you need to “source” the ~/.bashrc file with either source command or with the . command
H4/1 - yes
H4/2 - “all four” startup files will get executed: both local and system bashrc and both local and system profile