1 / 19

Linux environment

Linux environment. Graphical interface – X-window + window manager. Text interface – terminal + shell. Linux or Mac Desktop. Open up terminal ssh unid@kingspeak.chpc.utah.edu ssh –X unid@kingspeak.chpc.utah.edu. Windows. Need ssh client PuTTY

hedwig
Download Presentation

Linux environment

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. Linux environment • Graphical interface – X-window + window manager • Text interface – terminal + shell

  2. Linux or Mac Desktop • Open up terminal • ssh unid@kingspeak.chpc.utah.edu • ssh –X unid@kingspeak.chpc.utah.edu

  3. Windows • Need ssh client • PuTTY • http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html • XShell4 • http://www.netsarang.com/download/down_xsh.html • For X applications also need X-forwarding tool • Xming (use Mesa version as needed for some apps) • http://www.straightrunning.com/XmingNotes/ • Make sure X forwarding enabled in your ssh client

  4. New option from all - FastX • Give link to documentation • Good for • Can use to ssh to all interactive nodes – same usage rules apply! • Can also use the frisco{1-6}.chpc.utah.edu nodes for usage beyond that allowed on interactive nodes.

  5. Good resources for More Information • Some useful websites http://www.ctssn.com/ http://unix.t-a-y-l-o-r.com/Unix.html”

  6. Terminal basics • Two basic shells - slightly different command syntax • csh/tcsh • ksh/bash • Type commands on command line, send command by pressing Enter • Useful key combinations: • ctrl-a – start of line • ctrl-e – end of line • ctrl-c – cancel text typed on line • ctrl-z – put running command to background (come back via command fg)

  7. Basic commands • ls – list contents of a directory • pwd – display current directory • cd – change to directory (cd test) • cp – copy file (cp from_file to_file) • mv – move file (mv from_file to_file) • rm – delete file (rm test1) • mkdir – make directory (mkdir test) • rmdir – remove directory (rmdir test) • man – help for given command (man cp)

  8. Wildcards • more files can be specified via wildcards • * - matches any number of letters incl. none • ? - matches any single character • [] - encloses set of characters that can match the single given position • - used within [] denotes range of characters • ~ - followed by user name = home directory (~unid) • e.g. - *.csh, figure?.jpg, file[0-9].dat, figure[0-9].*

  9. Command flags • commands can take flags that modify their behavior • flags are formed with – (dash) and letter • consult man pages of each command for list of available flags • e.g. • ls -l – list files in long format • rm -r * – remove both files and directories (along with all files in those directories) -- very dangerous!

  10. Exercise 1 • Try to make and then cd to a new directory, e.g., IntroLinux1 • List contents of a directory, e.g., /uufs/chpc.utah.edu/common/home/u0028729/CHPCstuff/IntroLunix1 • Try to copy some files from this directory, e.g., to your IntroLinux1 directory • Work with ls, flags, and wildcards • Open man page for some command (e.g. ls) and try some of its flags (e.g. -l, -lt, -ltr)

  11. File view commands • cat – display contents of file • more – display contents of file with page breaks (next page with Space key) • head – display top of file • tail – display end of file • grep – search for pattern in file (grep “pattern“ test1) • vi – edit file (more on this later) file – tells you type of file

  12. Exercise 2 • View program files via cat, more, head and tail • Vary number of lines viewed with head and tail • Search for a string in a file with grep

  13. Command output redirection • > redirect to a new file (cat test1 > test3) • >> - append to a file (cat test2 >> test3) • | - pipe – redirect command output to another command • ls -l | more

  14. Exercise 3 • Use cat to concatenate two files • Use pipe, e.g. paginate result of ls

  15. Unix File Permissions • Shown with ls -l • User (u), group (g), other (o), all (a) • Permissions are read (r), write (w), execute or search for a directory (x) • chmod – to change permissions of file or directory • Executable and shell scripts must have executable permissions

  16. Some other useful commands • wc – e.g. wc -l file.txt • cut – e.g. cut -f 2 -d : file.txt • du – e.g. du -h • df – e.g. df -h • ln – e.g. ln -s ~/bin/prog.exe prog1.exe • Use man pages to find out what these commands do.

  17. The vi editor • two modes – command, input • command mode – commands input via keyboard keys • i, a, r, R – enter input mode - insert, append, replace character, replace • G – go to (1G – go to line 1, G – go to end of file) • x, dd – delete character, line • : - enter external command (:w – write file, :q – quit, :q! - quit discarding changes, :wq – write and quit) • /, ? - search forward, backward (/test) • input mode – works like any other text editor

  18. Use of the vi editor • to input text, enter input mode • to quit input mode, push Esc key • searching, deleting,... done in command mode • search and replace: :s/old_text/new_text – replace next occurence on current line :s/old_text/new_text/g – replace all occurence on current line :%s/old_text/new_text/g – replace all occurences in the whole file

  19. Exercise 4 • Open a file with vi - vi script.csh • Enter edit mode (i) and write text: #/bin/tcsh ls -1 | wc -1 • Exit edit mode (Esc), and save the file (:w). • Oops – we made a typo – last letter is l, not 1. Use replace to fix it. • Save file again and quit (:wq) • Change mode of the script to be able to execute it. chmod u+x script.csh • Practice some more editing with vi

More Related