Download presentation
Presentation is loading. Please wait.
Published byDiana Wells Modified over 9 years ago
1
1 Day 18 Bash and the.files
2
2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This will show you ALL files. Notice that any file which began with a “.” was omitted unless you give ls the –a flag.
3
3 Why? The Dot files are configuration files. Many programs you run need to store preferences and other information. –This is usually stored in a file called.programname Example –Each time you use vi to edit a file, it keep an autosave of the file in a file called.filename.swp –If you get kicked off the server, when you go back it will tell you that you can recover most of the changes you had made before you logged out. These are in the.swp file.
4
4 The.bash_history Each command you type is being stored in a history file. –This is why you can use the up and down arrows to get to previous commands you typed. Look at your.bash_history
5
5 The.profile and.bashrc The. profile is probably the most important file –On this particular version of Unix, its configured to just call.bashrc and let it do all the work..bashrc –It sets up the environment you use each time you log into Unix. –It sets some important shell variables PATH PS1 A lot of your settings come from the fact that.bashrc then calls /etc/profile which is a system wide default profile.
6
6 Fortune Want to get your day off to the right start. Make your shell give you your fortune each time you log in. –There is a program called fortune –Which each time its run, it gives you a “witty” comment. –Edit your.bashrc and add to the end the command fortune.
7
7 Rerun.bashrc You can make Unix pretend that you are just logging in again. –This is only useful if you have made changes to your.bashrc file –Execute:..bashrc
8
8 $PATH This lists all directories which Unix will look in each time you enter a command. Type: –echo $PATH See where all programs you run are. –which more Would show you which directory the program “more” is in. This directory is in your path, which is why you can run it.
9
9 Adding to your path. Imagine you have a directory called scripts in your home directory. –export PATH=$PATH:/home/enda/scripts Would add it to your path. Now any script you create and put in that directory, can be run from ANY directory you are in. –You no longer have to be in the directory where the script is, to run it.
10
10 $PS1 $PS1 is a variable which stores your prompt. Now your prompt looks something like: –enda@kahuna:~ > Bash has special characters you can put in the prompt: –\d -Date –\H -Hostname –\t - Current time (Also \T and \@) –\u - Current user –\w - Current working directory (pwd) For more options see man bash
11
11 Change your prompt: Make your prompt look like this: kahuna – 12:27:30 > Remember to make this a permanent change, put it into your.bashrc file.
12
12 Seeing all variables We know we can create variables: –read x –x=17 We know there are some magic default variables: –$PATH, $PS1 etc. How do we see a list of all variables and what they are currently set to? –set
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.