105.1 Lesson 1 Flashcards
Is a tty a login shell?
yes
What is the command in the output of ps aux | grep bash for pts bash?
bash
Which Bash specific file configures the user environment?
~/.bash_profile
Which files can ~/.bash_profile source?
~/.bash_login and ~/.profile
Which file will be executed if there is no ~/.bash_profile?
~/.bash_login
Is ~/.profile Bash specific?
no
When is ~/.profile sourced?
when neiter ~/.bash_profile nor ~/.bash_login exist.
Which file does ~/.profile source?
~/.bashrc
Which Bash specific file does clean-up operations when exiting the shell?
~/.bash_logout
Which file is run first when starting a shell: /etc/profile or ~/.profile?
/etc/profile
Where is an interactive Non-Login Bash configured globally?
/etc/bash.bashrc
Where is an interactive Non-Login Bash configured locally?
~/.bashrc
Which file does ~/.bashrc source?
~/.bash_aliases
How can bash be invoked as an non-interactive shell?
bash script.sh
Force a non-interactive bash shell to behave like a login shell!
bash -l script.sh
bash –login script.sh
How do you test if /etc/profile and ~/.profile are executed when running a shell?
Add an echo statement
Which files are loaded when a user logs into a machine via ssh?
/etc/profile
~/.profile
Where do scripts look for a startup file?
in the environment variable BASH_ENV
What does su do?
Execute commands with the privileges of another user account.
What does su do when no user id is specified?
Uses the superuser account.
Whats the difference between
su jane
su - jane
su - jane
starts a login shell. The login shell loads janes environment. The environment is not loaded when using
su jane
List the synomys to
su -
su -l
su –login
What does !$ expand to in a bash command?
the last argument of the previous command
How do you source the file ~/.bashrc?
. ~/.bashrc
source ~/.bashrc
What does the skel directory contain?
A template for the file system structure of user’s home directories.
Where is the variable SKEL defined?
/etc/adduser.conf
Where are the configuration files for shells configured?
In the skel directory.
What does echo$0 output in a login shell?
-bash or -su
What does echo $0 output in a non-login shell?
bash or /bin/bash
Use sudo to launch an interactive login shell as user2!
sudo su - user2
sudo su -l user2
sudo su –login user2
Use su to launch an interactive login shell as root!
su -
su - root
Run an interactive-non-login shell as root using su
su root
su
When do you need to use sudo su?
When the root user is disabled for security reasons. E.G. Ubuntu
Is /etc/profile read when an interactive login shell is started as root?
yes
Is /etc/bash.bashrc read when an interactive login shell is started as root?
yes
Is ~/.profile read when an interactive login shell is started as root?
no
is ~/.bashrc read when an interactive login shell is started as root?
no
is /etc/profile read when an interactive non-login shell is started as root?
no
Is /etc/bash.bashrc read when an interactive non-login shell is started as root?
yes
Is /etc/profile read when an interactive non-login shell is started as user2?
no
Is /etc/bash.bashrc read when an interactive non-login shell is started as user2?
yes
Is ~/.profile read when an interactive non-login shell is started as user2?
no
Is ~/.bashrc read when an interactive non-login shell is started as user2?
yes
What is a superuser?
A special user account used for system administration.
What defines the superuser on Unix-like systems?
Her/His user identifier (UID) is zero.
Where do you put code that should be executed every time user2 opens a terminal from an X Window session?
/home/user2/.bashrc
Which type of shell is a terminal opened from an X Window session?
interactive non-login
Where is the skel directory?
/etc/skel
Why does a tty not source /etc/bash.bashrc or ~/.bashrc?
Because a login shell runs .bash_profile. bashrc can but must not be sourced from there
Which command modifies a user account?
usermod
Which command deletes a user?
deluser
Which command adds a user?
adduser