+ All Categories

Review

Date post: 24-Feb-2016
Category:
Upload: duane
View: 46 times
Download: 0 times
Share this document with a friend
Description:
Review. Did you get an email from me? Last class we had an introduction to Linux and the command-line Linux: Kernel vs OS It is a kernel (brain of an OS) It’s a reference to OS’ that use Linux kernel ‘Logical leap’ of command-line - PowerPoint PPT Presentation
Popular Tags:
31
Review Did you get an email from me? Last class we had an introduction to Linux and the command-line Linux: Kernel vs OS It is a kernel (brain of an OS) It’s a reference to OS’ that use Linux kernel ‘Logical leap’ of command-line Today we are going to review all these and learn basic commands
Transcript
Page 1: Review

Review Did you get an email from me? Last class we had an introduction to Linux and

the command-line Linux: Kernel vs OS

It is a kernel (brain of an OS) It’s a reference to OS’ that use Linux kernel

‘Logical leap’ of command-line Today we are going to review all these and

learn basic commands

Page 2: Review

Today

The shell 3 File Channels Files Directories Moving around Looking around

Page 3: Review

A Quick Note

• Plagiarism is highly frowned upon, even more so in the Open Source world (which Linux is a huge part of)

• If I can take any four words in a row and match them to an article, you have plagiarized

• Don’t just copy wikipedia or a manpage• Rewrite it in your own words• You’ll get a 0 for that assignment and have to

take plagiarism training

Page 4: Review

First – Please Log In Ensure VM’s are on your systems: C:\Users\Public\Documents\Shared Virtual

Machines If not, we have to add them from

\\srv12\FileShare\Instructor Images\Nathaniel Dillon

Page 5: Review

VM’s Are Now Available While it copies, we’re going to go on, however

once it’s complete: Open VMWare Double-click VMWare icon on desktop VMWare will open, so click ‘Open a Virtual

Machine’ Scroll to your VM’s folder, click our vm file Click this, click okay, then, the green arrow

starts it up

Page 6: Review

Linux – What is it? Like Windows, but better It’s what you see when you boot the computer and

are ready to tell it to do stuff (can be GUI, can be command line)

The kernel is like the brain of what you see when you boot up – it tells everything else how to behave (Windows has a kernel too)

The “bodies” (flavors) are as diverse as people – RedHat (CentOS) is for business, Ubuntu is the “popular” one, Slackware is the jerk I don’t like

Like using Mozilla web browser vs Opera vs Chrome vs IE

Page 7: Review

Why is it Good?

Linux allows the admins more power and more control over everything

Commands came first – the GUI maps to the command

Windows is the opposite Linux is free You can modify it and see what it's doing – all

source code is out there A bunch of really smart people add to it

Page 8: Review

Equivalencies Linux has everything Windows has (almost) What it doesn't have – .NET (Eclipse?) What it does have – everything else Word processor – Open Office looks exactly like MS

Office; Libre is getting more popular Mail – Evolution; Media Players – Brasero, VLC Photoshop – GIMP; Eclipse – Eclipse Backups - tar/gzip/bz2 What is does better – Security Tools – Backtraq

(metasploit, sniffers, aircrack, etc...) - Cloud – Hadoop, OpenStack – Monitoring/Automation

Page 9: Review

Directory Structure In a ‘hierarchical’ file structure, you care about

two things: 1) Where you want to go 2) Where you are right now

You can get these things two ways: 1) Starting at the root or ‘top-level’ directory 2) Moving up levels from where you are

In the next slide, there is no direct connection between C:\Windows and E:\Jack

You have to go back up to My Computer

Page 10: Review

Directory Structure Windows

Page 11: Review

Directory StructureLinux is also a ‘tree’ or ‘hierarchical’ directory structure

http://www.linux4windows.com/Articles/linux_directory_structure.png

Page 12: Review

First Login When you log in, you will be taken to the home

directory of the user you logged in as Windows Vista/7/8 has this at C:\Users\

<username> Linux is /home/<username> We use the student user

/home/student Any other user: /home/anyotheruser Previous slide had: /home/tom This is a ‘path’ or a ‘file path’

Page 13: Review

First Login, pt 2 The only thing displayed will be this funky thing: [student@it136centos65vm ~]$ That is our shell The shell (command prompt/command line) is

how we will interact with the system This is the default look for the BASH shell Tells us our current username (student) Hostname (it136centos65vm) Directory (~) And we can type in commands after the $

Page 14: Review

A note on commands We will be talking about many different

commands We looked at the command prompt [student@it136centos58vm ~]$ ls This is an example of a command ready at the

command prompt, to see the result of the command, press enter

We have a model for commands command <flag> <arg> Does the ls command above fit or break our

model?

Page 15: Review

Inside Tom’s Home Folder [tom@example ~]$ ls

documents

Notice we don’t see inside documents, nor do we see /home/tom

Our VMs: [student@it136centos65vm ~]$ ls pslist teams.txt teams2.txt script.sh

Page 16: Review

$PATH [student@it136centos65vm ~]$ ls pslist teams.txt teams2.txt script.sh So what just happened? The BASH shell took our ‘standard input’ We provided two letters (not a file path), so the

BASH shell looked in something called the PATH variable to see if it knew what to do with those letters

It found a program called /bin/ls (which is our ls command), and ran it

This ‘listed’ the items in our directory

Page 17: Review

Standard Input/Output/Error The Shell classifies three file channels

STDIN – standard input STDOUT – standard output STDERR – standard error

Standard input is what you type into the shell (commands)

Standard output is what the shell outputs if the command (STDIN) works

Standard error is what the shell outputs if the command (STDIN) doesn’t work

Page 18: Review

Command, Flag, Argument

• So we have the command, flag, argument model

• What is what?• Command: anything we type into the system to

get it to do something useful (ls, cd)• Argument: usually a path to what we want to

work on (/home/tom)• Flag: symbol that modifies how a command is

run (-l, -cvf)

Page 19: Review

Command, Flag, Argument, ex• Running ls -l command• [student@it136centos58vm ~]$ ls -ltotal 12-rw-rw-r-- 1 student student 0 Jan 24 00:34 mytest-rw-rw-r-- 1 student student 0 Jan 24 00:34 pslist-rw-rw-r-- 1 student student 0 Jan 24 00:34 teams.txt-rw-rw-r-- 1 student student 0 Jan 24 00:34 teams2.txtpermissions user date

filename• The -l changed the way ls showed the information

Page 20: Review

Flags Are Very Useful

• Flags allow us to do more specific stuff• Show more data about a file/directory• Add arguments (to make commands more

specific, or more general)• In useradd command, we add arguments to tell the system

to not use its own defaults, but the values we give it• In the grep command we add arguments to tell the system to

not worry about capitalization, but to look for upper and lower case

• How do you find them?• Remember our best friends?

Page 21: Review

Flags 2• Flags change the output of a given command, but are

different per command• command <flag> <argument>• [student@it136centos65vm ~]$ rm –f • The rm command removes or deletes a file, the –f flag

is ‘force’ and will remove without asking• When run as the root user this will kill an entire

system• [student@it136centos65vm ~]$ tail –f messages• The tail command shows the last 10 lines of a file, the

–f flag is persistent follow so it will show updates to the file as they occur

Page 22: Review

Arguments• cmd <flag> <argument>[student@it136centos65vm ~]$ ls –l /home/student• ls is the command, -l is the flag, and /home/student/

is the argument• In this case the argument is a directory path• The argument could also be something we want to

create• [student@it136centos65vm ~]$ useradd ndillon• This would add a new user (named ndillon) to the

system

Page 23: Review

Commands So we have ls to ‘list’ what files are in our folder We can use cp to ‘copy’ files from one place to

another cp teams.txt newfile cmd <flag> <arg> <arg>

We can use rm to ‘remove’ our extra file rm newfile

We can use less to look through files without changing them less teams.txt

Page 24: Review

More Commands• We can use hostname to determine the name of

the system we are on• hostname

• We can use head and tail to look at the beginning/end of a file• head pslist• tail pslist

• We can get info on a file with the file command• file script.sh

• We can show the differences between files with diff• diff teams.txt teams2.txt

Page 25: Review

Even More Commands We can use echo to print things out to the

command line echo “Hello!” echo $PATH

We can print the system’s date with date

We can use whereis and find to locate things on the system whereis ifconfig find / -name authlog

Page 26: Review

Final Group of Commands We can list users on a system with w, who, or

finger w who finger

We can display memory useage info with free

We can make/restore backups of things with the tar command tar -cvf scratchspace.tar /tmp /home tar -xvvf scratchspace.tar

Page 27: Review

Command Flag Argument When typing on the shell, commands are

always required Most other stuff will depend on what you want

to do cmd <flag1> <flag2> <arg1> <arg2> tar -cvf backup.tar /home /tmp tar is the command, -cvf are flags (3), and the

arguments (3) are the new file to create, as well as the two directories to back up

Page 28: Review

I Lied (One More Command) cmd <flag> <arg> useradd will allow us to add/change accounts

and account details on a system useradd -d /home/newuser -s /bin/zsh newuser Cannot do useradd -ds /home/newuser /bin/zsh newuser Order matters with the useradd command!

So what tells you the order, what is/isn’t required?

Page 29: Review

Practicals and Homework Questions on anything up to this point? Practicals Today and Monday everything will be for a

completion grade (homework & practicals) After that, grades will be for accuracy

Page 30: Review

Topics For Own Study Keywords:

Command, flag, argument Commands: ls, rm, tail, echo, diff, whereis, copy, cat Chapter 3 of Sobell Online Surrey Unix Tutorial for Beginners tutorials

one and two Online Stanford tutorial – First two under intro section

and first two under search section

Page 31: Review

VMWare You can get it for free! Go to: http://seattlecentralitprograms.com/ Click on the VMWare link Register with your SID as the username and fill

out the remaining info Download/order software of your choosing


Recommended