Unix for LibrariansRavi Mynampatysearchguy@hbs.edu
About meJust a hustler making a living by pretending toknow more about search than he actuallydoes...
Workshop Goals● Remember the roaring 90s?● Geared towards beginners● Lifetime guarantee!
What is Unix?Multi-userMulti-taskingHierarchical filesystemEverything is a file
PhilosophyDoug McIlroy:● Write programs that do one thing and do it  well.● Write programs to work together.● Write progra...
Lets get startedThese slides:- SlideshareUse your own shell   orGo here:http://bellard.org/jslinux/
A brief note about shellsMany flavorsBourne (sh)Korn (ksh)Bourne-again (bash)C-shell (csh)tcshecho $0
How do I get in/out?login: searchguyPassword:Authentication successfulLogout  > exit, logoutid, whoamipasswd
Where am I?hostnameuname -apwdcdls
ExerciseLogin to JS shell1.   Who are you logged in as?2.   What is the name of the machine?3.   What is the OS? and versi...
Whats around me?catless is better than more
Documentation/Locationsmanaproposwhichwhereis
Exercise1. Examine the /etc/passwd file   a. what are a couple of ways of doing this?2. Where is the "less" utility locate...
Whos around?whofingerwlast
Directoriesmkdir new_dircd dir_namepwdyour home dir
Filescp old_file new_filemv old_file new_filegrep search_str filenamehead filenametail filename
Exercise1. Navigate to /etc/ directory2. Take the file named "passwd"   a. Make 4 copies in /var/tmp/   b. Name them as fo...
Filessort filenameuniq filenamedos2unix oldfile newfilefind path -name *htmlwc filenamecut: selected fields from each line
File compressiongzip filenamegunzip filename.gzzcat filename.gztar cvf all.tar file1 file2 file3 ...tar tvftar xvf
Hidden Filesls -a.profile.cshrc.login.aliases. and ..
File/Directory permissionsls -l-rwxr-xr-x-u, g, ochmod 775 filenamechmod g+w filename
Linkingln old_file new_fileln -s old_file new_file
Exercise: Linking1. Navigate to /var/tmp2. Create a hardlink to the passwd3 file3. Create a symlink to the passwd4 fileWha...
Editing filesviemacs...
What did I do?![and can I do it again?]history!!!13
I/O Redirection, Pipes><>>|xargs
Exercise: I/O, Redirectioncommand arg1 arg2 ... > filename● cat > io.txtUnix is great, much better than many other ossmake...
Exercise: Pipes● Your merged file in /var/tmp   ○ find the uniq lines   ○ sort the file   ○ now lets pipe it!● sort filena...
More on pipes...history | perl -pe s/^ +[0-9]+// | sort | uniq -c | sort -nr | head"Top 200" list of directory sizes (unde...
Processespsps -ups -eps -auxwwtop
Dealing with processeskill pidbg a process: command &jobsfg job_numbernice
Remotelyscprsyncsftppingtracerouteifconfig
Automationatcron
Theres plenty more...But for now......thanks for attending!                 searchguy@hbs.edu
Upcoming SlideShare
Loading in …5
×

Unix for Librarians

490 views

Published on

Workshop

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Unix for Librarians

  1. 1. Unix for LibrariansRavi Mynampatysearchguy@hbs.edu
  2. 2. About meJust a hustler making a living by pretending toknow more about search than he actuallydoes...
  3. 3. Workshop Goals● Remember the roaring 90s?● Geared towards beginners● Lifetime guarantee!
  4. 4. What is Unix?Multi-userMulti-taskingHierarchical filesystemEverything is a file
  5. 5. PhilosophyDoug McIlroy:● Write programs that do one thing and do it well.● Write programs to work together.● Write programs to handle text streams, because that is a universal interface.
  6. 6. Lets get startedThese slides:- SlideshareUse your own shell orGo here:http://bellard.org/jslinux/
  7. 7. A brief note about shellsMany flavorsBourne (sh)Korn (ksh)Bourne-again (bash)C-shell (csh)tcshecho $0
  8. 8. How do I get in/out?login: searchguyPassword:Authentication successfulLogout > exit, logoutid, whoamipasswd
  9. 9. Where am I?hostnameuname -apwdcdls
  10. 10. ExerciseLogin to JS shell1. Who are you logged in as?2. What is the name of the machine?3. What is the OS? and version?4. What dir are you working in?5. Change dir to /bin a. Look at a listing of all files in that dir b. are there any that begin with z (just eyeball it for now)
  11. 11. Whats around me?catless is better than more
  12. 12. Documentation/Locationsmanaproposwhichwhereis
  13. 13. Exercise1. Examine the /etc/passwd file a. what are a couple of ways of doing this?2. Where is the "less" utility located on the filesystem?
  14. 14. Whos around?whofingerwlast
  15. 15. Directoriesmkdir new_dircd dir_namepwdyour home dir
  16. 16. Filescp old_file new_filemv old_file new_filegrep search_str filenamehead filenametail filename
  17. 17. Exercise1. Navigate to /etc/ directory2. Take the file named "passwd" a. Make 4 copies in /var/tmp/ b. Name them as follows: i. passwd1, passwd2, passwd3, passwd43. Search for the string "daemon" in any one of the 4 files a. How many instances did you find?
  18. 18. Filessort filenameuniq filenamedos2unix oldfile newfilefind path -name *htmlwc filenamecut: selected fields from each line
  19. 19. File compressiongzip filenamegunzip filename.gzzcat filename.gztar cvf all.tar file1 file2 file3 ...tar tvftar xvf
  20. 20. Hidden Filesls -a.profile.cshrc.login.aliases. and ..
  21. 21. File/Directory permissionsls -l-rwxr-xr-x-u, g, ochmod 775 filenamechmod g+w filename
  22. 22. Linkingln old_file new_fileln -s old_file new_file
  23. 23. Exercise: Linking1. Navigate to /var/tmp2. Create a hardlink to the passwd3 file3. Create a symlink to the passwd4 fileWhat do you see?1. Delete passwd3 and passwd4What do you notice?
  24. 24. Editing filesviemacs...
  25. 25. What did I do?![and can I do it again?]history!!!13
  26. 26. I/O Redirection, Pipes><>>|xargs
  27. 27. Exercise: I/O, Redirectioncommand arg1 arg2 ... > filename● cat > io.txtUnix is great, much better than many other ossmakes me very productiveCONTROL-D● cat < io.txt● In /var/tmp merge all passwd* files into one
  28. 28. Exercise: Pipes● Your merged file in /var/tmp ○ find the uniq lines ○ sort the file ○ now lets pipe it!● sort filename | uniq● find . -name pass* | xargs grep -i nobody
  29. 29. More on pipes...history | perl -pe s/^ +[0-9]+// | sort | uniq -c | sort -nr | head"Top 200" list of directory sizes (under /dir-name - in KB)sorted by largest:du -dk /dir-name | sort -rn | head -200 > report.txtList of requesting IPs from a web server log, sorted bymost frequent first:cut -f1 -d access.log | sort | uniq -c | sort -rn[df: free disk blocks,du: disk usage]
  30. 30. Processespsps -ups -eps -auxwwtop
  31. 31. Dealing with processeskill pidbg a process: command &jobsfg job_numbernice
  32. 32. Remotelyscprsyncsftppingtracerouteifconfig
  33. 33. Automationatcron
  34. 34. Theres plenty more...But for now......thanks for attending! searchguy@hbs.edu

×