Download
linux n.
Skip this Video
Loading SlideShow in 5 Seconds..
Linux PowerPoint Presentation

Linux

155 Views Download Presentation
Download Presentation

Linux

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Linux Joe Meehean

  2. How do I…? • Log in • Do basic stuff • Use the file system • Access my files from Windows • Edit files • Do C++ development • Hand in my programs

  3. Why are we using Linux, really? • Linux is wide spread • smartphones (Android): 64% worldwide • web servers: >60% • servers (general) : ~13% • animation/visual effects: 95% • Learning Linux allows you to learn other OS’s quickly • Solaris • OS X (low-level)

  4. Why are we using Linux, really? • Awful Windows C++ development tools • compiler inaccurate/misleading • compiler not to spec • limited support for Boost libraries • debugger also inaccurate/misleading

  5. How to I log in? • Remotely • Using a tool called FreeNX • like remote desktop but from Windows to Linux • What do I need to know? • Linux server name: mintaka.lynchburg.edu • your username & password on mintaka

  6. Linux Desktop

  7. Linux Desktop • I thought Linux was text-based • we’ll use KDE • a graphical user interface on top of Linux OS • can use a mouse, windows, etc… • KDE is nice, but… • at its heart Linux is text-based • people used to log in remotely using special dumb terminals • we’ll use the text-based interface too

  8. The Shell The text-based interface to Linux

  9. The Shell • The shell is • where users type commands • see results of those commands

  10. The Shell • Example commands • date: prints the date and time • who: prints who else is logged in • top: shows resource usage • like Windows Task Manager • man <cmd>: shows a manual for command cmd • e.g., man date • grep <word> [file]: search for a word or phrase in input or a file

  11. The Shell meehean_j@mintaka:~$ ps PID TTY TIME CMD 8578 pts/0 00:00:00 zsh 8630 pts/0 00:00:00 bash 8688 pts/0 00:00:00 sleep 8689 pts/0 00:00:00 ps meehean_j@mintaka:~$ kill 8688 meehean_j@mintaka:~$ ps PID TTY TIME CMD 8578 pts/0 00:00:00 zsh 8630 pts/0 00:00:00 bash 8690 pts/0 00:00:00 ps • Example commands • ps: prints commands you are currently running • kill <pid>: terminates the process with id pid • e.g.,

  12. The Shell • Can run commands in two modes: • Foreground • shells assumes command is interactive • user cannot run another command until foreground command finishes • default mode

  13. The Shell • Can run commands in two modes: • Background • shell assumes command is not interactive • shell starts command, doesn’t wait for it to finish • command output will still be printed to screen • command must be followed by & to put into background

  14. The Shell • Interacting with commands while running • Ctl-C: kills foreground command • Ctl-Z: suspends foreground command • fg: run background command in foreground • bg: run suspended command in background

  15. The Shell • Chaining commands together • cmd1 ; cmd2 ; cmd3 • run cmd1, then cmd2, then cmd3 • cmd1 | cmd2 | cmd3 • run cmd1 • run cmd2 using output of cmd1 as input • run cmd3 using output of cmd2 as input • e.g., who | grepmeehean_j

  16. The Shell • File input/output • cmd > out.txt • run cmd and store its output in out.txt • does not print output to screen • e.g., who > users.txt • cmd < in.txt • run cmd and use in.txt as its input • grepmeehean_j < users.txt

  17. The Shell • The wildcard: * • it means match 0 or more characters • e.g., who | grep m* • prints all logged in users whose name starts with m • e.g, who | grep *m* • prints all logged in users whose name has an m in it

  18. The Shell • Like everything in Linux the shell is really just a program • Many different options • bash (the default) • tcsh • zsh • In KDE, need a visual display for the shell • a terminal emulator • called Konsole

  19. Questions?

  20. How do I…? • Log in • Do basic stuff • Use the file system • Access my files from Windows • Edit files • Do C++ development • Hand in my programs

  21. The File System • Root directory • top of the file system • located at / • Each user gets a directory (folder) • called the home directory • located at: /home/<username> • Current working directory (cwd) • where your shell will look for files • can change your current working directory

  22. The File System • Directory name shortcuts • / : root • ~ : your home directory • ./ : your current working directory • ../ : the directory one up from the cwd • ../../ : the directory above ../ • Hidden files • start with a ‘.’

  23. The File System • commands • pwd: print working directory • ls: list the contents of the cwd • ls • ls *.txt : list all files that end in .txt • ls –a : list hidden files too • ls <directory>: list the contents of <directory> • ls /tmp: list all files in /tmp • cd <directory>: change cwd to <directory> • cd ../ : move up one directory • cd /tmp : move to the temporary directory

  24. The File System • commands • touch <filename>: make a file called <filename> • touch test.txt : make a file called test.txt in cwd • touch /tmp/a.wav : make a wav file in /tmp • rm <file> : remove (delete) <file> • rm test.txt : remove file test.txt in cwd • rm /tmp/a.wav : remove the file a.wav from /tmp • rm *.cpp: remove all files that end in .cpp

  25. The File System • commands • mkdir<dirname>: make a directorycalled <dirname> • mkdir cs242 : make directory called CS242 in the cwd • mkdir ~/cs242 : make cs242 directory in home dir • rmdir <dir> : remove directory <dir> • <dir> must be empty • rmdir cs242 : remove directory cs242 from cwd • rmdir ~/cs242 : remove directory cs242 from home • rm –r <dir>: remove directory <dir> • <dir> doesn’t need to be empty

  26. The File System • commands • cp <file1> <file2> : make a copy of <file1> called <file2> • cp a.cpp a.cpp.bkup : create a copy of a.cpp called a.cpp.bkup • mv <file1> <file2> : rename/move <file1> to <file2> • mv a.cpp b.cpp : change a.cpp to b.cpp • mv a.cpp.bkup a.cpp : overwrite a.cpp with a.cpp.bkup

  27. The File System • commands • cat <file> : print file contents to screen • cat a.cpp : print a.cpp to screen • less <file> : open file using file reader less • less a.cpp : read a.cpp using less • use arrows to move around • use q to quit

  28. Samba • Network file service for Linux • maps your home directory in Windows • Preparation • have system admin add you as samba user • log in to mintaka • set your samba password

  29. Samba • Mapping mintaka home directory in Windows • right click on Computer • select “map network drive” • folder: \\mintaka\<your_linux_username> • select log in as different user • user: \<your_linux_username> • password: <your_linux_password>

  30. Questions?

  31. How do I…? • Log in • Do basic stuff • Use the file system • Access my files from Windows • Edit files • Do C++ development • Hand in my programs

  32. Emacs • Simple extensible editor • can edit several different languages • can run the debugger • can read your email • can do everything really

  33. Emacs • Terminology • buffer: an open file • kill: cut • yank: paste • point: cursor • mark: a user-specified location • e.g., kill from cursor to mark • region: text between point and mark • window: emacs can be split into different buffers open at the same time

  34. Emacs • Starting it up • > emacs& • Emacs documentation abbreviations • Esc = M • Ctrl = C (called command) • Commands in emacs • C-x C-f: open a file • C-x C-s: save the current buffer to its file • C-x C-c: close and exit

  35. Emacs • Search and replace • C-s: search forward • C-s fool : move point to next fool after point • C-r: seach backward • C-s fool : move point to previous fool before point • M-% : find and replace • interactive • directions provided on screen

  36. Emacs • Kill and yank • copy and paste • C-k : kill to end of line • cut from point to end of line • C-y : yank back last thing killed • paste at point • C-w : kill region • multiple sequential kills are yanked back with one yank

  37. Emacs • Windows • C-x 2: split into two windows, above and below • C-x 3: split window, side-by-side • C-x 0: delete this window (unsplit) • C-x 1: delete all other windows beside this one • C-x o: move to another window • Buffers • C-x b: select another buffer (open file) • C-x C-b: select another buffer (from list)

  38. Vi

  39. Vi • Editor runs in terminal • cannot use the mouse • Two modes • command mode • for entering commands • text entry mode • for inserting text into file • Starting up • > vi file_to_edit

  40. Vi • Working with files <command mode> • :e file : open file • :w : save file • :q! : quit without saving changes • :x : save changes and quit • Inserting text • a : switch to text entry mode after cursor • i : switch to text entry mode before cursor • Esc: switch back to command mode

  41. Vi • Search <command mode> • /word: seach for word • n: search for next appearance of word • N: search for previous appearance of word

  42. Vi • Replace <command mode> • :rs/foo/bar/a: replace foo with bar • r is range, can be • nothing: works only on current line • number: works only on line number • % : whole file • a is argument, can be: • g: replace all occurrences in line, not just first • i,I: ignore case, don’t ignore case • c: confirm each replace • :%s/teem/team/g

  43. Vi • Cut/Copy/Past/Undo <command mode> • x: cut current character • dd: cut line • Xdd: cut X lines • 5dd • D: cut to end of line • yy: copy line • p: paste • u: undo

  44. Questions?

  45. How do I…? • Log in • Do basic stuff • Use the file system • Access my files from Windows • Edit files • Do C++ development • Hand in my programs

  46. Compiling by Hand • C++ compilation demystified • compile source files into binary object files • i.e., .cpp into .o • link together multiple object files into a program • i.e., combine multiple .o files into an executable

  47. Compiling by Hand • g++ is the Linux compiler for C++ • -c compile • e.g., g++ -c file1.cpp file2.cpp file3.cpp • -o link • e.g., g++ file1.o file2.o file3 –o executable • Useful options for g++ • -g: include debugging information • -Wall: print out any warnings

  48. Compiling with Help • make is a program that helps build other programs • if you have a lot of files • it only builds the ones that changed • or the ones that depend on the ones that changed • lcmap.cpp depends on declarations in lcmap.h • changing lcmap.h requires recompiling lcmap.cpp

  49. Compiling with Help • How does it determine the dependencies? • you tell it using a makefile • makefile • should be named makefile • contains instructions on how to build your program • variables: Variable = value • dependencies: file.cpp: depedency.h • commands: <tab>command