introduction to unix
play

Introduction to Unix Editing with emacs Compiling with gcc What is - PowerPoint PPT Presentation

Introduction to Unix Editing with emacs Compiling with gcc What is Unix? q UNIX is an operating system first developed in the 1960s - by operating system, we mean the suite of programs that make the computer work q There are many different


  1. Introduction to Unix Editing with emacs Compiling with gcc

  2. What is Unix? q UNIX is an operating system first developed in the 1960s - by operating system, we mean the suite of programs that make the computer work q There are many different versions of UNIX, although they share common similarities - the most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X q The UNIX operating system is made up of three parts: - the kernel, the shell and the programs

  3. Files and Processes q Everything in UNIX is either a file or a process: - A process is an executing program identified by a unique process identifier - a file is a collection of data created by users using text editors, running compilers, etc. q All the files are grouped together in the directory structure - The file-system is arranged in a hierarchical structure, like an inverted tree

  4. Tree Directory Structure root directory home directory current directory

  5. Concepts q Root directory q Current directory q Home directory q Parent directory q Absolute path q Relative path

  6. Tree Directory Structure Unix command: root directory ls Output: Sub a b c Unix command: home ls /home/jane/data directory current Output: directory Sub a b c Unix command: ls ~/data Output: Sub a b c

  7. Tree Directory Structure Unix command: root directory ls ~ Output: data setup Unix command: home ls .. directory current Output: directory data setup Unix command: ls ./../.. Output: jim jane Unix command: ls ./../../jim Output: calendar

  8. Tree Directory Structure Unix commands: root directory cd ./../../../work current ls directory Output: setups bkup home Unix command: directory ls ./.. Output: home work Unix command: ls / Output: home work Unix command: ls /home Output: jim jane

  9. Tree Directory Structure Unix commands: root directory ls ~/.. current Output: directory jim jane Unix command: home ls ~/../.. directory Output: home work Unix command: ls setups Output: generic

  10. Unix file security q Each file has user and group q Permissions set by user - Read, write, execute - User, group, other q Only user, root can change permissions - This privilege cannot be delegated or shared

  11. A Sample UNIX Directory Listing

  12. Changing Access Rights Use the command chmod q For example, to remove read write and execute permissions on the file biglist for the group and others, type chmod go-rwx biglist This will leave the owner’s permissions unaffected. To give read and write permissions on the file biglist to all, chmod o+rw biglist

  13. Basic Unix Commands (1) ls list files and directories ls -a list all files and directories cd name change to named directory cd change to home directory cd ~ change to home directory cd .. change to parent directory mkdir name make a directory pwd display current directory path

  14. Tree Directory Structure root Unix command: directory current mkdir ./bkup/zzz directory Unix command: pwd home Output: directory /work zzz

  15. Basic Unix Commands (2) cp file1 file2 make a copy of file1 into file2 cp -r dir1 dir2 make a copy of directory dir1 into dir2 mv file1 file2 move or rename file1 to file2 rm file remove a file rm –r directory remove a directory cat file display a file less file display a file a page at a time who list users currently logged in * match any number of characters ? match one character man read online manual for a command

  16. Unix command: cp ~/data/a . root directory current directory home a directory zzz

  17. Unix command: cp –r /home/jim/calendar ./bkup/zzz root directory current directory home a directory zzz

  18. Unix command: cp –r /home/jim/calendar/* ./bkup/zzz root directory current directory home a directory zzz

  19. Unix command: rm –r /home/jim/calendar/* root directory current directory home a directory zzz

  20. Unix command: rm –r /home/jim/calendar/* root directory current directory home a directory zzz

  21. Unix command: mv ./bkup/zzz ./bkup/www root directory current directory home a directory zzz www

  22. Basic Unix Commands (3) command > file redirect standard output to a file command >> file append standard output to a file command < file redirect standard input from a file grep keyword file search a file for keywords wc file count number of words in file sort sort data (numerically or alphabetically

  23. Text editor EMACS

  24. Text Editor emacs q Configurable, extensible text editor q To start emacs just “ call it ” emacs q Basic editing in emacs is somewhat intuitive - use arrows, “ PG UP ” and “ PG DOWN ” to move cursor - use DEL key to delete - typing inserts text at the cursor position q To edit an existing file type emacs filename

  25. Using emacs: keyboard commands q We use the following abreviations “ C ” is the “ Control ” key “ - ” between two letters mean both have to be pressed simultaneously q Basic commands C-x, C-s to save the file C-x, C-c to exit Emacs C-g to get out of trouble

  26. Basic emacs Commands q Cursor movement Copy q C-c - C-a (begin of line) Paste q - C-e (end of line) C-v - C-v (page up) Undo q - alt-v (page down) C-x u Delete q Save/Quit q C-k (delete line) - C-x C-c (quit w/out saving) Cancel q - C-x C-s (save) C-g - C-x C-w (write to a new file) q Load file - C-x C-f (delete line)

  27. Searching in Emacs q C-s : search for a string – this search is incremental and goes as you search – typing C-s again will search for the next occurrence of the same string – to go back to the editing, just press any arrow key – after you go back, typing C-s twice resumes the search

  28. GCC Compiler

  29. What is gcc? q Stands for GNU C/C++ Compiler q Popular console-based compiler for Unix platforms q Compile and link C programs: gcc filename.c output is an executable called a.out q Another option (we will be using this one): gcc filename.c –o xfilename output is an executable called xfilename q If you want to learn more, use the manual man gcc

  30. Helpful Hints q HOME = ~ = /csc/f19/USERNAME q #include <stdio.h> q Use arrows, not mouse q Mac: Use Ctrl not Cmd q Windows: Edit -> Settings -> Keyboard -> [X] Backspace sends Delete

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend