1 / 29

Introduction to Unix Editing with emacs Compiling with gcc

Learn the basics of Unix operating system, file system structure, commands, file security, and text editing with Emacs. Understand using GCC for compiling programs in Unix environment.

cpeacock
Download Presentation

Introduction to Unix Editing with emacs Compiling with gcc

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. Introduction to Unix Editing with emacs Compiling with gcc

  2. What is Unix? • UNIX is an operating system first developed in the 1960s • by operating system, we mean the suite of programs that make the computer work • 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 • The UNIX operating system is made up of three parts: • the kernel, the shell and the programs

  3. Files and Processes • Everything in UNIX is either a file or a process: • A process is an executing program identified by a unique process identifier • afile is a collection of data created by users using text editors, running compilers, etc. • 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 • Root directory • Current directory • Home directory • Parent directory • Absolute path • Relative path

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

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

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

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

  10. Unix file security • Each file has owner and group • Permissions set by owner • Read, write, execute • Owner, group, other • Only owner, 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 For example, to remove read write and execute permissions on the file biglist for the group and others, type chmod go-rwxbiglist This will leave the owner’s permissions unaffected. To give read and write permissions on the file biglist to all, chmodo+rwbiglist

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

  14. Tree Directory Structure root directory Unix command: mkdir./bkup/zzz current directory Unix command: pwd home directory Output: /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 mvfile1 file2 move or rename file1 to file2 rm file remove a file rm –r directory remove a directory catfile 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 directory zzz a

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

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

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

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

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

  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 keywordfile search a file for keywords wcfile count number of words in file sort sort data (numerically or alphabetically

  23. Text editor EMACS

  24. Text Editor emacs • Configurable, extensible text editor • To start emacs just “call it” emacs • 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 • To edit an existing file type emacsfilename

  25. Using emacs: keyboard commands • We use the following abreviations “C” is the “Control” key “-” between two letters mean both have to be pressed simultaneously • 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 Cursor movement C-a (begin of line) C-e (end of line) C-v (page up) alt-v (page down) Save/Quit C-x C-c (quit w/out saving) C-x C-s (save) C-x C-w (write to a new file) Load file C-x C-f (delete line) Copy C-c Paste C-v Undo C-x u Delete C-k (delete line) Cancel C-g

  27. Searching in Emacs • 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? • Stands for GNU C/C++ Compiler • Popular console-based compiler for Unix platforms • Compile and link C programs: gccfilename.c output is an executable called a.out • Another option (we will be using this one): gccfilename.c–oxfilename output is an executable called xfilename • If you want to learn more, use the manual man gcc

More Related