1 / 31

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

duane
Download Presentation

Review

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. 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

  2. Today • The shell • 3 File Channels • Files • Directories • Moving around • Looking around

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

  9. 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

  10. Directory Structure Windows

  11. Directory Structure • Linux is also a ‘tree’ or ‘hierarchical’ directory structure • http://www.linux4windows.com/Articles/linux_directory_structure.png

  12. 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’

  13. 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 $

  14. 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?

  15. 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

  16. $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

  17. 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

  18. 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)

  19. Command, Flag, Argument, ex • Running ls -l command • [student@it136centos58vm ~]$ ls -l • total 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.txt • permissions user date filename • The -l changed the way ls showed the information

  20. 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?

  21. 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

  22. 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 ~]$ useraddndillon • This would add a new user (named ndillon) to the system

  23. 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 • rmnewfile • We can use less to look through files without changing them • less teams.txt

  24. 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

  25. 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

  26. 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

  27. 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

  28. 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/zshnewuser • Cannot do • useradd -ds /home/newuser /bin/zshnewuser • Order matters with the useradd command! • So what tells you the order, what is/isn’t required?

  29. 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

  30. 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

  31. 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

More Related