Transcript Linux

November 2011
LINUX
A UMass Amherst M5 workshop
Sean Klaiber
1
November 2011
2
GENERAL INFORMATION
November 2011
Why Use Linux?
• Save Money
• Initial purchase and maintenance
• Resume
• Linux is used by MANY organizations
• More choices
• Tons of Linux operating systems
3
November 2011
4
What is Linux?
1.
Contains the Linux kernel
• The kernel is the low-level software that manages hardware, multi-
tasks programs, etc.
2.
Linux Operating System
• Includes the kernel
• Also various utilities to get things done (program to copy files, etc)
3.
Linux Distributions
• Software companies will sell extra software
• E.g. the desktop environment, games, etc.
• Ubuntu is one of many Linux distributions
November 2011
5
Licensing
The GNU General Public License
Linux is under
This means that Linux can be:
1. Freely copied, changed, and distributed
2. No distribution restrictions can exist
3. The source code must be made available to the public
November 2011
6
How Can It Be Free?
• Linux developers make money by:
1. Custom applications for large companies
2. Tech support
3. Other jobs that don’t involve Linux
Linux (and the Open Source movement as a
whole) is an example of how the highest quality
results come from those who do work of their own
free will
November 2011
Ubuntu
• Just one of many distributions or “distros” of Linux
• Oneiric Ocelot is version 11.10
• Released October 2011
• Developed by Canonical Ltd.
• About 500 paid workers and thousands of volunteers
• Features:
• Unity Desktop Environment
• LibreOffice suite
• Ubuntu Software Center
7
November 2011
8
LibreOffice
• Fork of OpenOffice
• Development began January 2011
• Oracle purchased Sun Microsystems in Jan 2010
• Sun owned OpenOffice and developers didn’t trust that
Oracle would continue development
• Discontinued development on Sun’s OpenSolaris operating system
November 2011
9
Package Management
• Maintains a database of software dependencies & version
info
• Prevents software redundancies
• Automatically organizes software
• Ian Murdoch has called it “the single biggest advancement
Linux has brought to the industry”
• Ubuntu uses the “Ubuntu Software Center”
• Can browse, download, and remove software
November 2011
Common Problems with Linux
• Cannot develop or pre-install proprietary drivers
• Doesn’t always work fluidly with all hardware
• E.g. Mac touchpads
• Cannot run many proprietary software packages
• Larger learning curve
10
November 2011
QUESTIONS SO FAR?
11
November 2011
BOOT TIME
12
November 2011
13
Boot Time
• Hold ‘c’ while turning on a Mac to boot from the disk drive
• Will probably need to install Wireless Card drivers
• Top right hand corner
• There should be a pop-up announcement
• Turn on two-finger scrolling (Macs)
• System Preferences
• Very top right
November 2011
THE COMMAND LINE
14
November 2011
Why Use The Command Line?
A relatively simple string of
text provides direct and
unambiguous access to
complicated tools
15
November 2011
POSIX
16
Portable Operating System Interface for UniX
• As set of standards that Unix-y (including Linux) operating
systems follow to provide portability
• Most basic command line tools are POSIX compliant
• Means that code written with Ubuntu can be easily run
with Mac OSX or Debian or Gentoo or Damn Small
Linux…
… but not Windows
November 2011
17
OPEN THE TERMINAL
Useful Commands
cd
ls
cp
cat
echo
mkdir
pwd
man
less
find
date
=> change directory
=> list directory contents
=> copy files/directories
=> concatenate and print files
=> print text
=> make directories
=> prints working directory
=> open manual pages
=> read file with scrolling
=> search for files
=> print / modify date
November 2011
TASK #1
Navigate, Create, Destroy
18
November 2011
19
Navigation
/
~
..
.
=> root directory
=> home directory (also ‘/home/<user>/’)
=> directory one level up
=> current directory
• ‘cd’ allows movement between directories
• Syntax: ‘cd PATH_NAME’
• PATH_NAME can be any of the symbols above, a directory name,
or some combination for complex movement
• ‘pwd’ will print the current directory in case you get lost
November 2011
20
Task #1: Navigate, Create, Destroy
1. Using the ‘cd’ command, navigate to the Desktop
• Hints: The ‘ls’ command will help you find the Desktop
2. Create a directory in the Desktop using ‘mkdir NAME’
• NAME can be anything you desire
3. Navigate into this new directory
4. Create a file and fill it with junk
• Use command ‘echo JUNK > FILE_NAME’
5. Read the contents with ‘cat FILE_NAME’
6. Read the contents with ‘less FILE_NAME’
• Exit ‘less’ by hitting ‘q’
7. Remove the file with ‘rm FILE_NAME’
November 2011
21
Standard Files
• Standard Output is printed to the computer screen
• ‘>’ will overwrite a file with a functions standard output
• ‘>>’ will append the standard output to the end of a file
• Standard Input is by default what we type on the
keyboard
• Use ‘<‘ to take input from a file
• Standard Error is an alternative type of output for errors
• Use ‘2>’ to overwrite a file with standard error
November 2011
22
Try…
$
$
$
$
$
cd ~
ls Desk > FILE_NAME
cat FILE_NAME
ls Desk 2> FILE_NAME
cat FILE_NAME
Note that the standard error is not only being
written to the FILE_NAME but is being redirected
from the terminal to FILE_NAME
November 2011
23
Input Arguments
• Try deleting the directory with the ‘rm’ command. Tricky?
Command line tools often use input
arguments to extend their functionality
• Delete the directory with ‘rm –r DIRECTORY_NAME’
• ‘-r’ stands for ‘recursive’ and will delete any file in the directory
November 2011
24
Save Time
• Hit the  button at any point to recall the last command
• ‘tab’ will fill in the remaining characters for file and
directory names if there is only one possible option
Use  and tab often
November 2011
TASK #2
Process Handling
25
November 2011
What’s a Process?
• A process is a program in action
• Programs in executable form reside on
disk, when run, they are moved into
memory and become a process
• Linux assigns each process a
Process Identification or PID
26
November 2011
27
Task #2: Process Handling
$ gbrainy
‘ctrl-c’ to kill
$ gbrainy &
$ ps
$ baobab &
$ ps
$ kill <PID>
$ history
(do in new terminal)
$ ps
$ ps aux | grep gbrainy
$ top
$ tty
November 2011
28
Nano Text Editor
Nano is one of the simplest command line text editors
• To create a file, save it, and exit nano:
$ nano FILE
BWONGG wubwubwubwub <- enter text
ctrl-o
<- command to save
ctrl-x
<- command to exit nano
November 2011
29
Piping
• Symbol is the vertical line, ‘|’
• Found at ‘shift+backslash’
• Takes standard output left of pipe and uses it as standard
input to the function on the right of the pipe
November 2011
30
Piping Hot Example
• Create a file with a whole bunch of random words OR
random text
• Make it so each SET of words or numbers have their own line
• While in that directory:
$ sort FILE
- if using numbers, ‘sort –g’
$ sort FILE | grep ITEM
$ sort FILE | grep ITEM | uniq
$ sort FILE | grep ITEM | uniq -c
November 2011
TASK #3
Bach and Forth Between Audio Formats
31
November 2011
32
APT Package Manager
• The Advanced Packaging Tool is what Ubuntu Software
Center is built on
• ‘apt-get install PACKAGE’ will install and organize
software
• ‘apt-cache list PACKAGE’ will search for PACKAGE in the
local database
• ‘apt-get update’ update the local package database
November 2011
33
FFMpeg
FFMpeg is a multimedia transcoder
• Command line tools to convert sample rates, bit rates, file
types, cut, copy, stream, and filter almost any audio,
video, or image file
• We’ll convert a lossless .flac file to an .mp3 for iTunes
$
$
$
$
sudo apt-get install ffmpeg
cd DIRECTORY_OF_FLAC_FILE
ffmpeg –i FILE.flac NEW_FILE.mp3
man ffmpeg
November 2011
WASN’T THAT EASY?
34