1 / 17

UNIX / Linux Primer

UNIX / Linux Primer. July 22, 2008 Nicholas F. Polys Ph.D. UNIX. Many flavors Enterprise / Industrial strength kernel Macs are based on BSD Unix Under Win, install CygWin Linux and Open Source are ‘Free’ as in Puppy- not ‘Free’ as in beer . The Command Line.

merry
Download Presentation

UNIX / Linux Primer

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. UNIX / Linux Primer July 22, 2008 Nicholas F. Polys Ph.D.

  2. UNIX • Many flavors • Enterprise / Industrial strength kernel • Macs are based on BSD Unix • Under Win, install CygWin • Linux and Open Source are ‘Free’ as in Puppy- not ‘Free’ as in beer 

  3. The Command Line • Accessible through the wire • Real power to control the system through a terminal running a shell • Typical forms: $ somecommand –optiona value –optionb value $ somecommand –optionaoptionb • Cntrl-c will quit a running command

  4. Commands • When you log in, you are in a ‘shell’ • You interact with the system by typing at the prompt or running scripts • To find out the options for a command, use manual e.g. $ man somecommand • :q will quit (like vi)

  5. The Filesystem • Your home directory is ~username • Typically /home/username • pwd shows your current directory • ls –al list files in current dir • mkdir dira make a dir • touch filea create a file • mv filea fileb move • cp filea fileb copy • diff filea fileb difference • rm … remove …careful! -f forces it –r means recursive

  6. Permissions • Files and folders can be owned and permissions set • chmod a+x targeta • user, group, other, all • +, - • read, write, execute

  7. Inspecting files • more filea show the whole file • less filea show one screen atat • :q will quit (like vi) • tail filea show the last screen

  8. Environment Variables • Your account has a default shell; env variables can be set there (for the bash shell, e.g. ~username/.bashprofile or .bashrc • Env shows your current settings such as your PATH • You can set you own env vars for a shell session with: export SOMEVAR=value

  9. Processes • ps –ef show active processes • kill -9 pid kill the process with pid • mozilla & add ‘&’ to the end of a command to run it in the background (and keep your command prompt) Compression • tar wrap up multiple files/folders .tar -cvf wrap -xvf unwrap (force, verbose) • gzip ; gunzip (.gz)

  10. Vi editor • Text editing on the remote files system (through a terminal shell) • Text editor for shell / keyboard interaction • Insert vs Command mode <esc> • See basic usage handout • Try it out • Takes practice

  11. Other Typical Apps • cat – concatenates files • awk – manipulate rows and columns of data efficiently • grep / egrep – searching files for patterns (aka ‘regular expressions’)

  12. Pipes • | send a stream of data • > write a stream of data to file • >> append a stream of data to file e.g. • ps -ef | grep ‘npolys’ • ls –al > filea.txt

  13. Shell scripts Collect commands and env vars so you don’t have to type them every time • Typically use .sh file extension • Invoke with ./myscript.sh • File begins with #!/bin/sh • Perl • begins with #!/usr/bin/perl • Find where perl is: which perl

  14. Connecting to other machines • Shell • ssh npolys@bug.sv.vt.edu • Files • secure copy (remote file copy program) • scp • interactive secure ftp sessions • sftp npolys@bug.sv.vt.edu • get file • put file • ‘cd’ versus ‘lcd’

  15. Compilation • gcc GNU C and C++ compiler • Most apps have a configure script and a Makefile which automates compilation and installation; always check the README • Makefiles

  16. Debugging • gdb • Requires flags during compilation (-g) which will create an a.out file • ‘gdb a.out’ will begin the debugger • See • http://sourceware.org/gdb/current/onlinedocs/gdb.html

  17. Profiling • gprof • Requires flags during compilation (-pg) which will create an a.out file • Run the app once (eg $> ./a.out ) • Then ‘gprof a.out’ will begin the profiler, showing timings and the application’s call graph • http://sourceware.org/binutils/docs/gprof/index.html

More Related