Grades
Post on 24-Feb-2016
52 Views
Preview:
DESCRIPTION
Transcript
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)
Review
Folders /var and /tmp
Redirection Grep and command-line grouping
Today
Folders /home /root /opt
Advanced redirection Text editors (vi/vim) Scripting
Folders (/home)
/home – user data Most accounts exist under /home useradd ndillon
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)
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)
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
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…
Redirection Quick Refresher – what do these do?
|
>
< What are the three file channels?
Standard
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
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
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
Quick Demo
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
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
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
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!
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
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
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?
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
Demo
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
Simple Script
What does this do?#!/bin/bash# this is a ‘comment’ and will not be runls –alh > filelist.txtcp filelist.txt /tmp/# ps –ef > /tmp/processlist
Own Study
• Folders – p81• Advanced Redirection – p135• Vi – Chapter 6, p159• Scripting – p284 (a bit inside Ch8)
top related