Open main menu

CDOT Wiki β

Changes

Tutorial12: Shell Scripting - Part 2

34 bytes added, 11:37, 21 March 2021
INVESTIGATION 4: USING START-UP FILES
# Use the '''more''' command to view the contents of the '''default start-up''' file called '''/etc/profile''' <br><br>This file contains the '''default settings''' when you open your Bourne shell (eg. if issuing the command '''sh''').<br><br>
# Use the '''more''' command to view the contents of the start-up file called '''/etc/bashrc'''<br><br>This file contains the '''default settings''' when you '''open your Bash shell''' (eg. if issuing the command '''bash''').<br><br>Since we are using the '''Bash shell''' by default, let's create a '''customized Bash start-up file'''.<br>This startup file is located in your '''home''' directory using the name "'''.bashrc'''"<br><br>Let's move your <span style="font-weight:bold;font-family:courier;">.bashrc</span> file to prevent '''accidental overwrite'''.<br><br>
# Issue the following linux command:<br><span style="color:blue;font-weight:bold;font-family:courier;">mv ~/.bashrc ~/.bashrc.bk</span><br><br>If you experience an error message "''No such file or directory''", just ignore this command since there is no startup '''~/.bashrc''' file to backupin your home directory.<br><br>
# Use a text editor like vi or nano to create the text file called '''~/.bashrc''' (eg. <span style="color:blue;font-weight:bold;font-family:courier;">vi ~/.bashrc</span>)<br><br>If you are using the nano text editor, refer to notes on text editing in a previous week in the course schedule.<br><br>
# Enter the following lines in your shell script (the symbol "<span style="font-family:courier;font-weight:bold;">[</span>" is the open square bracket symbol):<br><span style="font-family:courier;font-weight:bold;">clear<br>echo -e -n "\e[0;34m"<br>echo "Last Time Logged in (for security):"<br>echo<br>lastlog -u $USER<br>echo<br>echo -e -n "\e[m"</span><br><br>
13,420
edits