1 / 18

UNIX Basics

UNIX Basics. What is UNIX?. Operating System An  operating system  ( OS ) is software that enable the computer to function Developed in 1960’s at Bell Laboratories OS for servers Fundamental building block of the Internet Characteristics Multi-user, multi-tasking Powerful & efficient

urbano
Download Presentation

UNIX Basics

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. UNIX Basics Internet Technology

  2. What is UNIX? • Operating System • An operating system (OS) is software that enable the computer to function • Developed in 1960’s at Bell Laboratories • OS for servers • Fundamental building block of the Internet • Characteristics • Multi-user, multi-tasking • Powerful & efficient • Reliable & robust • First “open” system • Freeware → created to develop as a public collaboration • A command line interface • Types (flavors) of Unix • BSD (Berkley): most well-known • System V (AT&T) : first commercial Unix • Linux: Unix on PC • Mac OS X: Unix by Apple Internet Technology

  3. Unix Basics • Unix: The Good, Bad & Ugly • It does what you say • no prompting, "Are you sure?" • It's not intuitive • Designed by & for engineers • It's CASE SENSITIVE • Unix Fundamentals • Know the difference between a directory and a file • Know what directory you are in • When in directory doubt, type ‘pwd‘ Internet Technology

  4. Unix Basics: File System • Hierarchical Naming • No explicit disk drives • e.g., /home/kiyang (vs. C:\Document and Settings\kiyang) • Top level is called the root (e.g. cd /) • Absolute (full) vs. relative path (filename) • Full path: /home/kiyang/file1.txt • Relative path: file1.txt (current directory = /home/kiyang) • Navigation • No graphical interface or desktop utility • Command line using Unix commands • Command line using Unix commands • pwd (where am I?) • ls -l (what are the files in the current directory?) • cd dirname(move to a directory named dirname) Internet Technology

  5. Unix: Directories • File and directory paths use the forward slash “/” • / "root" directory • /home/kiyang subdirectory “home” → subdirectory “kiyang” root ~ Home directory shorthand ~kiyang = /home/kiyang ~batman = /home/stud/batman ~/ = user’s home directory ~/public_html/ = user’s web directory ~/IT/homework/ = user’s homework directory home usr stud kiyang batman catwoman /home/stud/catwoman/public_html (http://widit.knu.ac.kr/~catwoman/) public_html IT IT public_html homework ithw homework symbolic link created by ‘ln –s’ command /home/stud/batman/IT/homework Internet Technology

  6. Unix: Command Syntax • Unix command syntax: command[space]option switches [space] arguments • To get help on a command • Type ‘man command’ • e.g., man ls (example) ls -l/home/kiyang/share Internet Technology

  7. Unix Basics: lsCommand • ls lists files in a directory • Default argument = current directory • Common options: • -a → list all files including dot files • -l→ display detailed info • -sh → list files sizes • Options can be combined, for example: ls–la • List detailed info of all files (including dot files) in current directory • ls-al • List detailed info of hw1.txt in kiyang’s share directory • ls-l /home/kiyang/share/hw1.txt • List detailed info of files that starts with hw in current directory • ls-l hw* Internet Technology

  8. Unix Basics: cdCommand • cd dir_name • Change directory to the directory named dir_name • To change to userid’s homework directory • cd/home/stud/userid/IT/homework • cd~userid/IT/homework • To change to your own homework directory • cd~/IT/homework • cdIT/homework (from home directory) • cdhomework (from IT directory) • Default argument = home directory • e.g., cd (change to home directory) • .. parent directory • e.g., cd .. (change to parent directory) Internet Technology

  9. Unix Basics: OtherCommand • cp file1 file2copy file1 to file2 • mv file1 file2rename file1 to file2 • rm file1delete file1 • mkdir dir_name to create a directory named dir_name • rmdir dir_name to delete a directory named dir_name • cat filenamedisplay the content of filename • more filenamedisplay filename content a screen at a time • less filenamesame as more & scroll back Internet Technology

  10. UNIX Shortcuts • Up arrow • Cycles through previous commands • Tab key after partial filename • Completes the filename if enough has been typed (like auto-complete) • Aliases (~/.aliases) • Use shorter commands in place of longer one. • Syntax: alias short_cmd=‘long command’ • e.g., alias dir='ls -al |more' alias cdit='cd ~/IT/homework' alias cdw='cd ~/public_html' alias chmo='chmod 755 ~/IT/homework/*' Internet Technology

  11. Unix Basics: Working with Files • Files have owners and permissions • Owner = person who created the file • Permission • read, write, execute by owner, group, everyone • Cannot "more" all files • read permission needed • Special files • Dot files: ls –a to list • Symbolic links: ls –I to list the original file • "ls" to list • "cp" to copy • "mv" to rename. • "rm" to delete • "more" (less, cat) to view the content Internet Technology

  12. Unix Basics: Working with Directories • Directories are special types of files • Unix filesystem is hierarchical • use "cd" and "ls" to get around • cannot "cd" everywhere due to file access restrictions • execute permission needed • ~/  your home directory • ~/public_html = /home/kiyang/public_html • "cd" to change directory • "mkdir" to create • "rmdir" to remove • "pwd" to print current working cirectory Internet Technology

  13. Unix Basics: Permissions • The system administrator sets the default permissions • Permissions allow you to share or protect information • Set up into three user groups • owner, group, and world. • chmod to change permissions • e.g., chmod 755 hw1.txt Internet Technology

  14. Unix Permissions Unix file permissions are represented in octal (based on binary) 1 -rwxr-xr-- 1 kiyang users 30 May 25 16:17 80test 000 = 0 = --- 001 = 1 = --x 010 = 2 = -w- 011 = 3 = -wx 100 = 4 = r-- 101 = 5 = r-x 110 = 6 = rw- 111 = 7 = rwx owner group world - rwx r-x r-- 1=Allowed 0=Not Allowed 111 101 100 7 5 4 In decimal number So, the permissions for the file 80test are 754. Internet Technology

  15. Unix Permissions • Shows files and directories, owners, file sizes, last modified date, and permissions • File hw1.txt has read, write, and execute permissions for owner (yangk) and read permissions for group (users) and the world • test is a directory • ithw is a symbolic link to ~/IT/homework WIDIT: ~/public_html -> ls -l total 118 -rwxr--r-- 1 robin robin 30 2013-03-19 16:17 hw1.txt -rw-r-xr-x 1 robin robin 221 2013-03-19 16:19 index.htm -rw-r--r-- 1 robin robin 28672 2013-03-22 16:21 lab1.doc lrwxrwxrwx 1 robin robin 15 2013-03-22 16:20 ithw -> ../IT/homework/ drwx--x--x 2 robin superG 4096 2013-03-31 16:21 test file type permission owner group size last modified date name Internet Technology

  16. Changing Unix File Permissions • Use the chmodcommand • Syntax: chmod permissionsfilename • e.g., chmod 644hw1.txt • This would change the permissions to?(Hint: 6 = 110, 4 = 100 in binary) • Important in web authoring • Web pages • Must be world readable → chmod 644 index.htm • Server-side Programs • Must be executable → chmod 755 roster.cgi • User group depending on web server configuration • Directories • Must be world executable → chmod 711 public_html Internet Technology

  17. Unix Permissions: In English • Whose permission? • u (owner), g (group), o (world), a (all) • What action? • + (give), - (take away) • What rights? • r (read), w (write), x (execute) • Syntax • chmod who+action+rights • Examples • chmod u+rwx file (give owner read, write, execute rights) • chmod go+rx file (give group & world read and execute rights) • → after both of these commands have executed, the file rights will be 755. Internet Technology

  18. UNIX Network Tools • nslookup • UNIX command for a DNS name look up • Translates hostname to IP address • Syntax: nslookup hostname • e.g., nslookup widit.kmu.ac.kr • Ping • Utility for determe if an Internet host is alive & responding • e.g. ping –c 5 www.knu.ac.kr Internet Technology

More Related