html5-img
1 / 28

A Small UNIX Tutorial

A Small UNIX Tutorial. By CGS3063 staff. What’s UNIX?. An operating system claimed to be “standard” “from microcomputers to supercomputers” Invented by AT&T Bell Labs in late 60’s

cynara
Download Presentation

A Small UNIX Tutorial

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. A Small UNIX Tutorial By CGS3063 staff

  2. What’s UNIX? • An operating system claimed to be “standard” “from microcomputers to supercomputers” • Invented by AT&T Bell Labs in late 60’s • Currently there are different versions of UNIX such as SunOS, Linux, DEC OSF/1, AIX, HP-UX 10, Solaris, IRIX, SCO UNIX, etc.

  3. Why we need UNIX? • For this class you need to work from your class grove account to finish your homework and/or submit your term paper • Knowing basic UNIX commands is essential to finish your homework

  4. UNIX Commands • ls [names] – list files contained in a directory name or that match a file name. If no name is givenlist those files in current directory. • ls –a list all files including hidden files • ls –l list in long format (including details like permissions, owner, size, etc.), works very much like dir • ls –al list all files (including hidden files) in long format • ls –dl dir_name lists information about the directory, “dir_name”.

  5. What is a Directory? Your home directory might contain a public_html directory. Your public_html directory might contain an “index.html” file. c3063xxx public_html index.html

  6. What is a Directory? A file cannot hold a directory or a file! c3063xxx public_html index.html New_file_or_directory

  7. What is directory? Directories can hold files and other directories / tmp users bin etc backup usern file1 user2 … … public_html user1 index.html

  8. What’s a directory? • Files are grouped in the directory structure. The file-system is arranged like hierarchical tree (inverted)structure. • The top of the tree is called “root” which usually contains several sub-directories. In UNIX “/”(forward slash) is used to present the “root”.

  9. Absolute Pathnames In the previous tree /users/usern/file1 is an absolute pathname. Relative pathnames If you are already in the users directory, the relative pathname for file1 is usern/file1. Pathnames

  10. Specifying Paths What is the absolute path to index.html? / tmp users bin etc backup usern file1 user2 … … public_html user1 index.html

  11. Specifying Paths What is the relative path to index.html (assuming that usern is your pwd)? / tmp users bin etc backup usern file1 user2 … … public_html user1 index.html

  12. More UNIX commands • pwd –let you know the absolute pathname of your current working directory (Print Working Directory) • cd [dir] – changedirectory • cd .. –go back to parent directory. “..” is the relative pathname to the parent directory. • “.” -stands for current (working) directory. • “~” – the tilde ~ character can refer your home directory

  13. More UNIX commands • mkdir directories– create one or more directories. You can specify them by absolute or relative pathnames. • cp • cp file1 file2 – copy file1 to file2. If there’s already a file2, the old one will be overwritten. • cp file(s) directory – file(s) will be copied to the directory.

  14. More UNIX commands • mv sourcefiletargetfile – basically mv renames sourcefile to targetfile. If there’s a file with the same name as targetfile, it will be overwritten. mv works for directories in a similar fashion.

  15. More UNIX commands • rmfile(s) – delete file(s). • rmdir directories – delete one or more empty directories. • rm –r directories – can be used to delete non empty directories. !!!WARNING!!! This will DELETE EVERYTHING in that directory!!! • You can not recover your files after you removed them (unlike Windows OS).

  16. Permissions • There are three types of file access supported by UNIX. • r – read, view the contents of a file or a directory • w –write, edit file/directory contents • x –execute, run executable file

  17. Permissions Here’s an example • Suppose you type in ls -l and the result is • rwxr-xr-- 1 hansdoc 858 Aug 22 22:28 hw1 What do all these symbols mean?

  18. Permissions - rwxr-xr-- 1 hansdoc 858 Aug 22 22:28 hw1 owner links type File name size Modification date/time group User permissions Group permissions Other Permissions

  19. Permissions • User – the person who created the file. • Group – the group owns the file. • Other – the rest of the world • “754” is a decimal number. But you can represent each digit with a binary number. 4=>read permission, 2=> write permission, 1=> execute permission

  20. Permissions read=4;write= 2;execute=1 rwx r-xr-- 4 + 2 + 1 4 + 0 + 1 4 + 0 + 0 7 5 4

  21. Permissions rwxr-xr--is a symbolic way to specify file modes, while 754is a numeric way (remember 7  111, 5 101, 4100 ? ). How would you represent this file mode numerically? --x--x–wx How would you represent this bit string symbolically? 614

  22. Permissions • chmod mode file(s) – another UNIX command! Change the access mode of one or more files. Examples: • chmod 751 my_file – the owner of my_file has rwx(7) permission, the group has r-x(5) permission, others have --x permission. • Tell me what the following command will do? chmod u=rwx, g=r, o=wr my_file Remember user, group and others?

  23. Get started • Create a new directory in your grove account named public_html by using the following command, • mkdir public_html • Go to this directory • cd public_html • Use pico to createa new file named index.html

  24. Editor in UNIX Some short cuts for the pico editor • ^G Get Help • ^O WriteOut • ^R Read File • ^Y Prev Pg • ^K Cut Text • ^C Cur Pos • ^X Exit • ^J Justify • ^W Where is • ^V Next Pg • ^U UnCut Text • ^T To Spell

  25. Get started After you save the file index.html, change the mode of this file by using the following command, chmod 644 index.html (u=rw-, g=r--, o=r--) Check whether you did it right ls –l or dir (What result should be displayed?)

  26. Get started Then go back to parent directory cd .. Change the mode of public_html directory chmod 755 public_html ( What’s the meaning of this command?) Check if you got the mode set right ls –dl public_html

  27. Where to get help? • Come to see us during the office hours • The CGS3063 tutorial available on line (technical info) • man subject(s) – the UNIX help command. e.g.: to get help info about mv command you can type man mv to get detailed manual of mv command.

  28. Thank you and good luck!

More Related