html5-img
1 / 82

Unix Tutorial

Unix Tutorial. CSU480. Outline. Getting Started System Resources Shells Special Unix Features Text Processing Other Useful Commands. The Unix Operating System. Kernel System calls Multi-user, multi-tasking OS. File System. FS is the focus point of Unix Looks like an inverted tree

huey
Download Presentation

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. Unix Tutorial CSU480

  2. Outline • Getting Started • System Resources • Shells • Special Unix Features • Text Processing • Other Useful Commands

  3. The Unix Operating System • Kernel • System calls • Multi-user, multi-tasking OS

  4. File System • FS is the focus point of Unix • Looks like an inverted tree • Root directory / • Each node is either a file or a directory • Path name Absolute path Relative path . The current directory .. The parent of current directory

  5. Directory, File and I-node • Every directory and file is listed in its parent directory • The root’s parent is itself • All Unix files are non-structured (bit stream) • A directory is a special file: • File name • I-node number

  6. Unix Programs • Shell: between user and the kernel • Commands: • Built-in shell command (pwd) • Source compiled, object code file (ls) • Shell script (**.sh) • $PATH=/bin:/usr/bin:/usr/local/bin, etc

  7. Getting started • Logging in • Linux Command Line Structure • Control Keys • stty – terminal control • Getting Help • Directory Navigation and Control • File Maintenance Commands • Display Commands

  8. Logging in • Username & password • Unux is case sensitive • Changing password • passwd • Choosing an hard-to-crack password • Exiting system • Ctrl-D

  9. Identity • username<->userid • groupname<->groupid • A user can belong to more than one group • Primary group: /etc/passwd • Additional groups: /etc/group

  10. Identity % id uid=1101(frank) gid=10(staff) % id uid=1101(frank) gid=10(staff) groups=10(staff),5(operator),14(sysadmin),110(uts) % groups staff sysadmin uts operator

  11. Unix Command Line Structure • Format: command [options] [arguments] • Arguments: action object, usu. files • Options: change the way it performs • command -[option][option][option] • ls -alR • command -option1 -option2 -option3 • ls -a -l -R

  12. Control Keys • Used to perform special functions • Ctrl-Key (^-Key) ^-U: “line-kill” signal ^-A: go to the beginning of the line ^-E: go to the end of the line ^-K: kill until the end of the line

  13. Getting Help • man command • % man -k password • passwd (5) - password file • passwd (1) - change password information • % man 5 passwd

  14. Getting Help

  15. Directory Navigation and Control

  16. cd

  17. mkdir & rmdir • mkdir -p create the intermediate (parent) directories, as needed -m mode access permissions (SVR4). • rmdir: directory must be empty

  18. ls

  19. ls

  20. File Maintenance Commands

  21. File Maintenance Commands • cp –r: recursively copy a directory • mv: Actually all you’ve done is to update the directory table entry to give the file a new name. The contents of the file remain where they were. • rm: Actually, all you’ve done is to remove the directory table entry and mark the inode as unused. The file contents are still on the disk, but the system now has no way of identifying those data blocks with a file name. -r: recursively -f: force

  22. chmod u – user g – group o – other read=4, write=2, execute=1 or read=r, write=w, execute=x + add permissions - remove permissions = set permissions

  23. chmod • chmod 755 file1 or chmod u=rwx,go=rx file1 • As for directory: r: can read the content of the directory w: can create/delete files of the directory x: can “go through” the directory

  24. chown • chown new_user:new_group file • Note: On most versions of Unix this can only be done by the super-user, i.e. a normal user can’t give away ownership of their files.

  25. Display Commands

  26. echo

  27. echo

  28. more, less, & pg

  29. more, less, & pg

  30. System Resources

  31. df • df is used to report the number of disk blocks and inodes used and free for each file system. • Options: -l local file systems only (SVR4) -k report in kilobytes (SVR4)

  32. du • du reports the amount of disk space in use for the files or directories you specify. • Options: -a display disk usage for each file, not just subdirectories -s display a summary total only -k report in kilobytes (SVR4)

  33. ps • ps is used to report on processes currently running on the system. • Options: -e Select all processes. -f does full-format listing.

  34. kill

  35. who • who reports who is logged in at the present time. • Syntax who [am i]

  36. whereis

  37. which • which will report the name of the file that is be executed when the command is invoked. This will be the full path name or the alias that’s found first in your path. • Syntax which command(s)

  38. hostname/uname • hostname (uname -n on SysV) reports the host name of the machine the user is logged into • uname has additional options to print information about system hardware type and software version.

  39. script • script creates a script of your session input and output. Using the script command, you can capture all the data transmission from and to your terminal screen until you exit the script program. This can be useful during the programming-and-debugging process, to document the combination of things you have tried, or to get a printed copy of it all for later perusal. • Syntax script [-a] [file] <. . .> exit

  40. date • date displays the current data and time. A superuser can set the date and time. • Syntax date [options] [+format]

  41. Shells • The shell sits between you and the operating system, acting as a command interpreter. • cat /etc/shells /bin/sh /bin/bash /sbin/nologin /bin/ash /bin/bsh /bin/ksh /usr/bin/ksh /usr/bin/pdksh /bin/tcsh /bin/csh /bin/zsh

  42. Shells • sh: Bourne shell (not suited for interactive) • csh: uses C type syntax (job control) • ksh: Korn shell • bash: Bourne Again Shell (GNU) • tcsh: T-C shell • cshe: extended C shell

  43. Built-in Commands • These commands are executed directly in the shell and don’t have to call another program to be run.

More Related