Presentation is loading. Please wait.

Presentation is loading. Please wait.

Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer,

Similar presentations


Presentation on theme: "Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer,"— Presentation transcript:

1 Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer, except for: No collaboration (email/text/chat/forums/facebook/etc…) or copying (plagiarism)

2

3 Review Please hand in your homework & practical with your quiz Directories - /bin & /sbin, /dev, /etc, home, /var Flags – different between commands Questions?

4 Today We already had a quiz Redirection Grep /var and /tmp

5 Folders /tmp – called ‘temp’ Directory for short-term storage, scratch space, and staging areas Is always the first place to have stuff deleted Don’t plan on having anything in this folder last /var – variable files that change during runtime Mail files, log files, web files, etc… Files that should change with the system Most accessed file: /var/log/messages

6 Grep Grep is a lot of power in a single command We’re only going to start looking for ‘static’ strings Static strings are things that don’t change (match 1:1) grep grep sea teams.txt grep -i sea teams.txt To the manual pages! (For the next slide)

7 Your Turn grep -i sea teams.txt grep -n Bears teams.txt grep Sea* teams.txt grep Sea teams*

8 Redirection Quick jump to another topic, but they tie together Redirection is the process of taking output and sending it to another location Almost useless example: ls > lsoutput.txt The > takes the STDOUT of the ls command (the listing of files), and instead of printing it to the screen, it redirects it into a file called lsoutput.txt

9 Redirection Characters STDOUT, STDIN, and STDERR are important because you can chain commands together What if we want to search a logfile for the word error? grep syntax is grep We ‘redirect’ the cat output to grep cat /var/log/messages | grep error can also do: grep error /var/log/messages

10 Style Note Grep’s syntax is grep string file You could easily grep error /var/log/messages However I do not – I always do: cat file | grep string This is a stylistic deviation, both do the same This is why I drinking scotch while grading And by drinking scotch I mean I don’t care if you do it my way or your way If it runs on the shell and answers the question, it will be counted as correct

11 Redirection Characters and | < is useless Not really, but we won’t cover it in this class I’ve been an admin for over a decade and never seen it outside of people in courses like this trying to contrive examples for it | is called pipe and chains commands together In the previous slide I posted cat file | grep string This takes the standard output of the cat command, and turns it into the standard input of the grep command

12 Redirection With > > will take STDOUT and put it into a file cat teams.txt > tmp The tmp file now contains a copy of the teams.txt file Often used to capture the output of a script ls > tmp The tmp was overwritten and now contains ONLY the output of the ls command (it deleted the teams.txt info before putting the ls output in there)

13 Quick Aside The ps command prints out the processes running on the system Think of it as a simple, text-based task manager You run scripts in Linux by putting./ in front of the script file./script.sh would execute the script.sh file These may or may not be practical (useful) applications of redirection and used as examples in the next slide

14 Redirection, Your Turn [test@dev /etc/init.d]#./network > ~/network.out Command: Redirection character: Output: Description: [user@system ~]# ps –ef | grep bash Command: Redirection character: Output: Description:

15 One Last Aside - Sudo Wednesday we talked about su – switch user su student su ndillon su sudo is the utility that lets you (as another user) run a single command as root [ndillon@it136centos65vm ~]$ sudo cat /var/log/messages As the user ndillon I can run one command as the root user

16 Sudo, pt2 Sudo config file is /etc/sudoers Inside this file you can set who can use sudo, as well as what commands they can use sudo with Yes on cat, no on grep or ip You will have to put your password in

17 Practical Question on directories, grep, or redirection? Today: You’ll grep the directories and play around with redirecting the output to files and commands

18 Own Study Directories – Sobell p82 /tmp /var Grep – Sobell, p56, 144, 438, 450, 833-837 And flags Redirection – Sobell, p135 < (just kidding on the above) > |


Download ppt "Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer,"

Similar presentations


Ads by Google