A Brief Introduction to Unix-2019-AMS

A Brief Introduction to Unix-2019-AMS

Brief Intro to Linux/Unix Brief Intro to Unix (contd) A Brief Introduction to o Brief History of Unix o Compilers, Email, Text processing o Basics of a Unix session o Image Processing Linux/Unix – AMS 2019 o The Unix File System Pete Pokrandt o Working with Files and Directories o The vi editor UW-Madison AOS Systems Administrator o Your Environment [email protected] o Common Commands Twitter @PTH1 History of Unix History of Unix History of Unix o Created in 1969 by Kenneth Thompson and Dennis o Today – two main variants, but blended o It’s been around for a long time Ritchie at AT&T o Revised in-house until first public release 1977 o System V (Sun Solaris, SGI, Dec OSF1, AIX, o It was written by computer programmers for o 1977 – UC-Berkeley – Berkeley Software Distribution (BSD) linux) computer programmers o 1983 – Sun Workstations produced a Unix Workstation o BSD (Old SunOS, linux, Mac OSX/MacOS) o Case sensitive, mostly lowercase o AT&T unix -> System V abbreviations 1 Basics of a Unix Login Session Basics of a Unix Login Session Basics of a Unix Login Session o The Shell – the command line interface, o Features provided by the shell o Logging in to a unix session where you enter commands, etc n Create an environment that meets your needs n login: username n Some common shells n Write shell scripts (batch files) n password: tImpAw$ n Define command aliases (this Is my password At work $) Bourne Shell (sh) OR n Manipulate command history IHateHaving2changeMypasswordevery3weeks!!! C Shell (csh) n Automatically complete the command line (tab) The password speech… [use good passwords] DoIT Password guidelines: TC Shell (tcsh) n Edit the command line (arrow keys in tcsh) https://it.wisc.edu/guides/select-manage-protect-passwords Korn Shell (ksh) n Can log in more than once, in several windows Bourne Again Shell (bash) [OSX terminal] Basics of a Unix Login Session Basics of a Unix Login Session Basics of a Unix Login Session o Logging in to a unix session o Logging off from a Unix session o Changing your password n logout, exit, ^d n passwd (will ask for your old password, then your n Many people can be logged in at the same time via the network n For CentOS Linux, choose System/Log out new one, then new one again to confirm) n Remote login – secure shell [cat3/cat4/cat5.aos.wisc.edu] n In x-windows, click EXIT, right-click in n Windows – SecureCRT or putty (Xming for graphics) background, select logout/exit, try various n If you forget your password – see the systems buttons in the background. n OSX/Linux – from Terminal window administrator, they can change it for you. ssh [email protected] –Y (or –X) n MAKE SURE you are logged out, or others can n Starts in your home directory access your files, do things as you. Also, if the screen locks, others can’t user the machine 2 Basics of a Unix Login Session The Unix File System The Unix File System o Who are you? o What is a file? o Types of files (contd) n id o Types of files .. – A special directory that refers to the n groups – what groups you belong to - Ordinary Files (text, programs, images, etc) parent directory (the one above where you are - Directories (file that holds other files, dirs) n root – the Superuser - administrator now) - Special files (used to represent physical . – A special directory that refers to the devices (printers, disks, etc) - Pipes (temporary file used to hold output from directory that you are in now one command until it is ready to be read by another All directories contain . and .. The Unix File System The Unix File System The Unix File System / o Organized as a heirarchy of directories /bin o Home Directory – where you are when you starting with / (the root directory) /home1 first log in (usually under /home - here, /home1/class/fall06 under /home1/class/fall18) /home1/class/fall06/poker /dev o / is similar to the Windows My o Open Terminal starts in home or /etc Desktop directory Computer, or the Mac Desktop/Finder. /home /home/aos o Current Working Directory (pwd) /home/user1 /lib o Absolute vs Relative Path Names /tmp /home1/class/fall18/poker/dir1/file1 /sbin dir1/file1 3 The Unix File System The Unix File System The Unix File System o Change directory (cd) to dir1 o Common System Directories o Common System Directories (contd) cd dir1 o / - root directory o /usr/include – C include files o /bin – binary executable files o /home/aos– home directory for user aos Now, ways to refer to that same file o /dev – special device files o /tornado/home1/class/fall06/poker – home directory for user poker o /etc – administrative/configuration files/programs o /usr/local – locally added programs, libraries, etc /home1/class/fall18/poker/dir1/file1 o /home – user directories o /usr/local/bin o /lib – libraries used by programs and languages file1 o /tmp – scratch area for temporary files o /usr/local/lib ../dir1/file1 o /usr – system files/directories shared by users ./file1 Using Unix Commands Using Unix Commands Using Unix Commands o Case Sensitive! (ls not the same as Ls or LS) o Use backspace or delete to correct errors o Processes – unique process ID number for stty erase [hit the key you want to every process that is running o The Prompt: where you enter your commands use] o Commands to identify processes agnes[poker] %1 (csh, tcsh) n ps (sh, ksh, bash) agnes$ o Online manual pages for almost all commands n ps –flu poker man man n ps –efl o General command syntax man passwd n ps –aux (bsd type systems) command [-flags] arg1 arg2… man –k compiler 4 Using Unix Commands Using Unix Commands Using Unix Commands o ps –flu poker o Jobs – per shell shortcut of programs running o Killing processes kill pid # ps -flu poker agnes 27% jobs kill –STOP pid F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD [1] + Running firefox kill -9 pid 8 S poker 1047 1 0 99 20 70cb0ec0 155 70cb0f2c o Job Control Jan 16 ? 0:00 /bin/sh ^Z – stop a running job 8 S poker 1049 1048 0 40 20 70ccd5f0 269 7015587a jobs Jan 16 ? 0:00 /var/tmp/lm_TMW12.ld fg %1 8 S poker 1048 1047 0 41 20 70ccceb8 133 70641c1c Jan 16 ? 0:00 sh -c while read line; bg %1 Using Unix Commands Using Unix Commands Using Unix Commands o Typical command locations o PATH environment variable – where linux looks for progs o Locating Programs – whereis, which n /bin agnes 1% echo $PATH n agnes 2% whereis pwd /research/linux_grads/grads-1.9b4/bin: n /usr/bin /research/linux_bin:/research/linux_idv: pwd: /bin/pwd /usr/bin/pwd n /usr/local/bin /research/linux_mcidas/bin: /research/ncl/bin: n agnes 3% which pwd n /home1/class/fall06/poker/bin /usr/local/weather/bin:/usr/local/bin: n /research/linux_bin /bin:/usr/bin:/usr/bin/X11:.: /usr/pwd /research/linux_gempak/GEMPAK7/os/linux/bin agnes 2% rehash agnes 3% ./prog 5 Using Unix Commands Using Unix Commands Using Unix Commands o Several commands can be entered on one o Command History (in C or TC shell) o Command History (in C or TC shell) command line, separated by a ; n history – list previous commands (numbered) n tcsh/bash – arrow keys ls ; date n !! – repeat previous command n up/down to cycle back/forward through command o Use output of one command as input to n !str – repeat previous command beginning with history another – separate by a | str n left/right to edit the command line ls -ltrF | tail n !N – repeat command number N n <ctrl>-a – beginning of line n o Run a command in the background n ^old^new – repeat previous command, replacing <ctrl>-e – end of line firefox & first occurrence of old with new n Dont need to move to end of line before running Using Unix Commands Using Unix Commands Using Unix Commands o o Standard input/output/error from commands Redirecting standard input/output/error o Pipes (the vertical bar | ) (csh/tcsh) n Input – usually the keyboard ls –ltrF | tail n Output – usually the screen > >> >& >>& < << o Aliases – roll your own commands n Error – usually the screen alias ll '/bin/ls –ltrF' ls > file std output overwrites file ls >> file std output appends at end of file alias lt '/bin/ls –ltrF | tail' alias arch 'cd /bigtemp/poker/archive' ls >& file std output/error into file ls >>& file std output/error appended to file o Line Continuation character - \ ls < file std input from file ls << WORD std input until line identical to WORD [WORD must be first and only thing on the line, and unique] 6 Using Unix Commands Using Unix Commands Working with Files and Directories o Line Continuation character - \ o Shell Scripts – group of commands entered o Creating files /bin/rm –r \ one by one in a file, executed as if you had n cat – concatenate files file1 \ typed them at the prompt file2 \ cat > file1 file3 \ this text will be put into file1 file4 #!/bin/csh echo Good Morning, Pete ^D echo Today is `date` echo Remember everything you need to do cat file1 file2 file3 > file4 exit cat file1 file2 > file1 o Used extensively for creating GEMPAK plots [overwrites original file1] Working with Files and Directories Working with Files and Directories Working with Files and Directories o echo – echo commands to stdout (the screen?) o Editing files o Text editors n What is a text editor compared to a word n vi(m) - cryptic text editor included with all unix echo this text will be put processor? n nedit - graphical editor simliar to notepad into file1 > file1 n gedit - another graphical editor n pico/nano - nicer character based text editor n vi, nedit, gedit, nano, pico, emacs echo this text will be n emacs- powerful, customizable text editor appended after the last >> vi file1 o touch – update the modification time of a file, or file1 nedit file1 & create an empty file if it doesnt already exist 7 Working with Files and Directories Working with Files and Directories Working with Files and Directories o Displaying files o Listing files – ls o Copying files - cp n Cat – file scrolls up the screen cat file1 n cp file1 file2 copies file1 to file2 n Pagers (more, less) – pause between screenfuls ls n cp file1 dir1 creates a copy of file1 less file1 a b dir1 file1 in dir1 n Text editors (vi, nedit, pico, emacs) ls –a n cp file1 file2 file3 dir1 n Head – displays the first 10 lines of a file .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us