1 / 24

Grades

Grades. Please hand in your homework Quizzes coming back today Current grade on back with missing assignments Anything missing can be turned in late There will be a 2 point penalty (as with late assignments) plus whatever you miss You can re-submit any assignment

dutch
Download Presentation

Grades

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grades • Please hand in your homework • Quizzes coming back today • Current grade on back with missing assignments • Anything missing can be turned in late • There will be a 2 point penalty (as with late assignments)plus whatever you miss • You can re-submit any assignment • You must attach the original, and there will be a one-point penalty per re-submission (after the first)

  2. Review • Folders • /var and /tmp • Redirection • Grep and command-line grouping

  3. Today • Folders • /home /root /opt • Advanced redirection • Text editors (vi/vim) • Scripting

  4. Folders (/home) • /home – user data • Most accounts exist under /home • useraddndillon • Will create /home/ndillon by default • To not use /home you must specify this at the time the account is created • useradd -d /var/log audit_user • Individual users are then responsible for the structure of everything under /home/<username> • Root user has a special home directory (/root)

  5. Folders (/root) • /root – root user’s home directory • This is created on install • Permissions lock down to only the root user • Again, it is up to the admin (or admin team) to ensure structure of everything below this level • I usually have a backups directory, some admins use this as a staging area (instead of /tmp)

  6. Folders (/opt) • /opt – application directory • What is an application as it relates to a server? • This is the directory these things should be installed in (unless well-known database or web server) • If the company has more than 20 people, there’s a 90% chance it will install into /opt • If the company has a decent Linux/Unix admin it will install into /opt • If it doesn’t it’s a possible red flag that they don’t know ‘best practice’ or standards

  7. Quick Aside – ‘Best Practice’ • Does anyone know what this means as it relates to IT? • It is in every specialization under “IT” • For programmers there are ‘coding standards’ such as Google’s Java Standards • For sysadmins it’s how to set up and architect the system • For network admins it’s planning of a network, protocol handling, etc…

  8. Redirection • Quick Refresher – what do these do? • | • > • < • What are the three file channels? • Standard

  9. Advanced Redirection >> • What happens when you use > on an already existing file? • cat teams.txt > /tmp/teams2_copy.txt • We can use >> to append • cat teams.txt >> /tmp/teams2_copy.txt • >> Leaves all data that was in the original file, find the “EOF” marker at the bottom, and copies the newly redirected STDIN below the original file

  10. Advanced Redirection 2> • We can also redirect standard error • ./script.sh will return an error • ./script.sh 2> err.out will redirect ONLY the error • This is incredibly useful when debugging a script, especially one that has a lot of output • So what do you think 2>> does? • ./script.sh 2>> /tmp/system_errors.txt

  11. Advanced Redirection &> • We can also redirect everything • ./script.sh will output STDOUT and STDERR • ./script.sh &> all.out will redirect everything • Useful for “set it and forget it” tasks you’ve automated, or something that’s going to take a while • So what do you think &>> does? • ./script.sh &>> /tmp/all_output.txt

  12. Quick Demo

  13. Text Editors • On that note: text editors • So we created a user, how do we let it run administrative commands? • sudo - run single command as root • To add our new user, we use a text editor • There are three popular ones – vi, emacs, and nano • You can use whatever you want, but the homework (and the test) will be on vi

  14. Emacs - Probably Best • emacs <flag> <file_path> • emacs teams.txt • Has built-in menus, which make it easy to navigate • Emacs is written in Lisp • Built-in documentation and tutorial • Full Unicode support • (aka) Supported on Linux, BSD, Unix, Solaris, Windows, and Mac

  15. Nano is also very good as well • nano <flag> <file_path> • nano teams.txt • Originally a byte-by-byte match of Pico • Called TIP (TIP Isn't Pico – recursive name, like GNU – GNU's Not Unix) • FYI – Linux admins are weird about GNU & GPL • Now a 'superset' of Pico – includes Pico support, and more

  16. VIM – Just Awful • vi <flag> <file_path> • No nice menu • Very common • Two modes – 'command' and 'insert' • Command mode allows saving, quitting, skipping around text, copying/pasting, replacing, the arrow keys, etc... • Insert mode allows typing, deleting, etc... • OLD ARCHIAC EVERYWHERE!

  17. Guess What We’re Going to Use - vi • Two modes: command and insert • Very confusing • Usually (USUALLY) INSERT appears in bottom left • Insert mode – adding content to file (typing) • Command mode – manipulating content • copying, pasting, saving, moving, exiting, etc… • I always assume I’m in INSERT mode, and press Esc a few times, then go back to what I was doing

  18. Insert Mode • We opened a text editor, we probably want to type • The i key takes you into 'insert' mode – you can type wherever the cursor is • a is 'append' – it will move the cursor over one space and then be in insert mode • What else puts you into ‘insert’ mode? • Once you’re in insert mode, you can type all you want until you press the escape key

  19. Command Mode • Type in vi, you start in command mode • Already in vi, enter command mode by pressing, the escape key • Then the colon key • Save is <esc> :w • Quit is <esc> :q • Save & quit is <esc> :wq • You only have to press escape one time • Man vi (or Google ‘man vi’) • What does :wq! do?

  20. Quick Demo • I will access vi by editing our teams.txt file • I will show you I am in command mode by copying/pasting • I will enter edit mode and undo my copy/paste by manually writing • I will save the file • I will save the file as a new file • I will edit the file again, realize I didn’t want to edit it, and then discard my changes

  21. Demo

  22. Scripting • What differentiates Linux with Windows • A script is a file that holds multiple commands • Starts at the top, works its way down • Executes everything as if you were at the command line typing it in • Does not stop on error – each line will be run • Only needs one thing • First line must be the ‘invocation’ of the shell • #!/bin/bash

  23. Simple Script • What does this do? • #!/bin/bash • # this is a ‘comment’ and will not be run • ls –alh > filelist.txt • cp filelist.txt /tmp/ • # ps –ef > /tmp/processlist

  24. Own Study • Folders – p81 • Advanced Redirection – p135 • Vi – Chapter 6, p159 • Scripting – p284 (a bit inside Ch8)

More Related