Presentation is loading. Please wait.

Presentation is loading. Please wait.

BASH Shell Primer Scott Russell IT Support Engineer Distributed Support Services Office of Information Technologies.

Similar presentations


Presentation on theme: "BASH Shell Primer Scott Russell IT Support Engineer Distributed Support Services Office of Information Technologies."— Presentation transcript:

1 BASH Shell Primer Scott Russell IT Support Engineer Distributed Support Services Office of Information Technologies

2 Basic Shell Commands ls -- list directory contents ls -- list directory contents touch -- change file access and modification times (create files) touch -- change file access and modification times (create files) mkdir -- make directories mkdir -- make directories cp -- copy files cp -- copy files mv -- move (rename) files mv -- move (rename) files grep -- print lines matching a pattern grep -- print lines matching a pattern man -- format and display the on-line manual pages man -- format and display the on-line manual pages

3 ls ApplicationsLibraryPictures DesktopMoviesPublic DocumentsMusicSites

4 ls -aFlh drwxr-xr-x64srussel2srussel22KJun 28 22:04./ drwxr-xr-t4rootadmin136BJul / -rw-r--r--1srussel2srussel221KJul 10 20:11.DS_Store drwx srussel2srussel2136BJul 10 20:34.Trash/ -rw srussel2srussel211KJul 9 20:21.bash_history -rw-r--r--1srussel2srussel2797BJan profile drwx srussel2srussel2102BJul ssh/ -rw srussel2srussel26KJun 28 20:59.viminfo drwx srussel2srussel22KApr 26 15:28Applications/ drwx srussel2srussel2884BJun 20 19:13Desktop/ drwx srussel2srussel23KJul 10 20:44 Documents/ drwx srussel2srussel21KJan Library/ drwx srussel2srussel2408BSep Movies/ drwx srussel2srussel2374BJan Music/ drwx srussel2srussel21KJan Pictures/ drwx srussel2srussel2238BDec Public/ drwx srussel2srussel21KAug Sites/

5 touch and mkdir touch file.txt touch file{1,2,3}.txt mkdir ~/BASH\ Primer mkdir -p ~/Projects/BASH\ Primer

6 cp and mv COPY cp old_script.sh ~/Applications/new_script.sh MOVE mv old_script.sh ~/Applications/new_script.sh RENAME mv old_script.sh new_script.sh

7 grep grep grep grep dscl ~/Applications/UNIX/*.sh adduser.sh: ASSIGNED=`dscl localhost -list /NetInfo/Users uid | grep $UNIQUE_ID` adduser-panther-new.sh: ASSIGNED=`dscl localhost -list /NetInfo/Users uid | grep $UNIQUE_ID` changeHome.sh: sudo dscl localhost -change /Users/$1 NFSHomeDirectory "$OLDHOME" "$NEWHOME” adduser-panther-new.sh: dscl localhost create /users/$USERNAME grep ^\# ~/Applications/UNIX/*.sh

8 man dscl NAME dscl -- Directory Service command line utility dscl -- Directory Service command line utilitySYNOPSIS dscl [options] [datasource [command]] dscl [options] [datasource [command]] options: options: -p prompt for password -u user authenticate as user -P password authentication password -raw don't strip off prefix from DirectoryService API constants constants -url print record attribute values in URL-style encod- ing ing -q quiet - no interactive prompt

9 man -k uuid apropos uuid mbr_uid_to_uuid(3), mbr_gid_to_uuid(3), mbr_uuid_to_id(3), mbr_sid_to_uuid(3), mbr_uuid_to_sid(3) - translate user and group identifiers from one form to another uuid(3) - DCE compatible Universally Unique Identifier library uuid_clear(3) - reset value of UUID variable to the NULL value uuid_compare(3) - compare whether two UUIDs are the same uuid_copy(3) - copy a UUID value uuid_generate(3), uuid_generate_random(3), uuid_generate_time(3) - create a new unique UUID value uuid_is_null(3) - compare the value of the UUID to the NULL value uuid_parse(3) - convert an input UUID string into binary representation uuid_unparse(3) - convert an UUID from binary representation to a string uuidgen(1) - command-line utility to generate a new UUID value

10 Environment Variables printenv = print out the environment printenv = print out the environment HOME, USER HOME, USER PWD, OLDPWD PWD, OLDPWD PATH PATH

11 Configuring Your Prompt PS1='\h:\w \u\$ ' Scott-Russells-iBook-G4:/etc srussel2$ \h = hostname to the first “.” \w = present working directory \u = current user shell-setup-prompt.html shell-setup-prompt.html

12 Handful of BASH Utils bbman -- converts man pages to plain text and opens them in your favorite text editor bbman -- converts man pages to plain text and opens them in your favorite text editor smb.sh -- mount NetFile drives using mount_smbfs smb.sh -- mount NetFile drives using mount_smbfs touchx -- creates a new executable with boilerplate text in a default folder and opens it for editing touchx -- creates a new executable with boilerplate text in a default folder and opens it for editing

13 BASH Resources Advanced BASH Scripting Guide PDF and HTML versions available AWK One-Liners AWK One-Liners liners/ liners/ NDMAC Home Page


Download ppt "BASH Shell Primer Scott Russell IT Support Engineer Distributed Support Services Office of Information Technologies."

Similar presentations


Ads by Google