O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Mac OSX Terminal 101

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Linux administration training
Linux administration training
Carregando em…3
×

Confira estes a seguir

1 de 20 Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Semelhante a Mac OSX Terminal 101 (20)

Anúncio

Mais recentes (20)

Mac OSX Terminal 101

  1. 1. Terminal 101 Unix Commands for Mac OSX
  2. 2. History of the Mac ● Unix Based (Free BSD / AT&T 6th Edition Unix) ● Kernel called Darwin (open sourced) ● Xnu – Developed by NeXT later bought by Apple (Tim invented the internet on NeXT, while at CERN. So the internet was created on the MAC...) ● uname -a (to see the version) ● Basically they got Mach Kernel (Carnegie Mellon University) and built new drivers using the Objective C apis.
  3. 3. Finding Help ● man --help , xman (if you have X11 or XQuartz), whatis, info ● Developer.apple.com ● Macrumors.com (Forums) ● Lifehacker.com ● Ss64.com/osx ● Mac OSX Unix Toolbox (Book)
  4. 4. Types of Commands ● Core or Default Set ● File or Folder Management ● System Administration ● Networking, Email & Internet ● Text, Editors and Manipulation ● Pipes, Redirection and scripting ● Developer Commands
  5. 5. Types of Shells ● bash – Bourne Again 1989 (Default) ● zsh – Z Shell 1990 ● tcsh – C Shell 1978 ● sh – Bourne Shell 1977 ● Korn Shell 1983 ● Thompson Shell 1971 ● echo $SHELL ; chsh -s /bin/zsh
  6. 6. for version in "${maya_versions[@]}"; do echo -n "Checking for ..... Maya $version"; maya_script_dir="$HOME/Library/Preferences/Autodesk/maya/$version-x64/scripts"; # echo $maya_script_dir if [ -w "$maya_script_dir" ]; then echo " ... Yes Found!"; echo "... $maya_script_dir"; echo -n "... Checking for existing files ..."; if [ -f "$maya_script_dir/mkUtils.pyc" ]; then echo " Yes Found!"; echo "... $maya_script_dir/mkUtils.pyc"; mv "$maya_script_dir/mkUtils.pyc" ~/.Trash/; echo "... mkUtils.pyc moved to Trash!" else echo " Not Found!"; fi cp ./mkUtils.py $maya_script_dir echo "... Installed mkUtils.py" else echo " ... Not found!"; fi done Lets get started...
  7. 7. Navigating... ● ls - List ● pwd – print working directory ● cd – change directory ● clear – Clear Screen ● ./ - current directory ● ../ - parent directory ● ~ - user home directory ● - - last path Example... $ cd ~ $ ls -a $ ls -l $ ls -R $ ls -lh $ cd ../Shared/ $ pwd
  8. 8. File and Folder Management ● touch – create new file ● cp – copy ● mv – move / rename ● rm – remove ● mkdir – create new directory ● rmdir – remove directory (empty only) Example $ cd ~/Desktop $ mkdir -p Test/First $ touch ./Test/First/newFile.txt ● $ cd Test/First ● $ ls ● $ cp newFile.txt ../secondFile.txt ● $ rm newFile.txt ● $ cd .. ● $ rmdir First/ ● $ cd .. ● $ rm -r Test/
  9. 9. System Administration 1 ● top – currently running processes ● ps – process status ● kill – stop running process ● open – open files and directories ● pgrep – find process by name ● installer – install mac packages ● softwareupdate – mac updates ● df – display free disk space ● du – display disk usage ● diskutil – mac disk utils Example $ open -a firefox $ ps -ax $ pgrep firefox $ kill 905 $ df -h $ du -h $ installer -pkg Package.pkg / $ softwareupdate --list
  10. 10. Permissions, Groups & Users ● chown – change ownership ● chmod – change access permission ● dscl – directory service command line (create, modify users and groups) ● Example $ chmod u+x $ chown kumar file.txt drwx------+ Directory File Link | User Read Write Execute Group Read Write Execute Other Read Write Execute
  11. 11. Viewing Text (Logs) ● cat – concatenate ● less – view less ● more – view more ● head – view head ● tail – view tail ● syslog – view system.log Examples $ cat /var/log/system.log $ less /var/log/system.log $ more /var/log/system.log $ head /var/log/system.log $ tail /var/log/system.log $ ls ~/Library/Logs/ $ ls /var/log
  12. 12. Selecting Searching Sorting ● grep – text pattern search ● find – path file search ● locate – indexed search, disabled by default ● mdfind – Spotlight cli ● sort – sort text ● uniq – find duplicates Examples $ grep AppleTalk /etc/services $ find /Volumes/Data/Magazine/ -iname "*mac*" $ mdfind -name TextEdit $ mdfind -onlyin ~/Desktop/ Artist $ ls -l | sort -fi $ sort sortingTest.txt $ sort sortingTest.txt | uniq
  13. 13. Manipulating Text ● awk - pattern-directed scanning and processing language ● sed - stream editor language ● vim - Vi IMproved, a programmers text editor ● emacs - GNU project Emacs ● nano - Nano's ANOther editor, an enhanced free Pico clone ● pico – pine package text editor Vim - : , i , :wq , :help, :x CTRL-] to jump to a subject under the cursor. CTRL-O to jump back (repeat to go further back). Emacs – Control + x followed by Control + c (to quit) ^ means Control ● ls -l | awk '{print $3}' ● echo Hi there how are you? | sed s/you/me/ ● $ ls -l | sed s/staff/Kumaran/ ● emacs ● Esc + x ● tetris
  14. 14. Pipes and Redirection ● | - pipe or pass ● > - redirect output ● >> - Append ● < - Read input ● curl -s http://www.angeltv.org | grep Description | awk -F = '{print $3}' | sed 's/>//' ● cat /usr/share/dict/words | grep -E '(Aaron|Moses)' ● echo "Hi there how are you" >> test.txt ● tr "[:lower:]" "[:upper:]" < test.txt ● ifconfig | grep broadcast | ping -c 3 “$(awk '{print $6}')” | grep 'bytes from' | awk '{print $4}' | sort | unique
  15. 15. Networking 1 ● ifconfig – network card configuration ● ipconfig - view and control IP ● traceroute - print the route packets take to network host ● nslookup - query Internet name servers ● ping - check a remote host for reachability ● telnet - TELNET protocol Examples $ ping -c 3 www.google.com $ ping -i 60 182.19.95.34 $ ping -S 192.168.1.73 192.168.1.1 $ ipconfig getifaddr en0 $ nslookup openmail.angeltv.org $ telnet towel.blinkenlights.nl
  16. 16. Networking 2 Examples # Get ip address $ ipconfig getifaddr en1 # Enable Network Interface $ ifconfig en1 up # Disable Network Interface $ ifconfig en1 down # Set ip address $ ifconfig en1 inet 192.168.2.1 # Set netmask $ ifconfig en1 netmask 255.255.255.0 Examples # Change MTU $ ifconfig en1 mtu 1000 networksetup -listallnetworkservices networksetup -getdnsservers Wi-Fi networksetup -setmanual Wi-Fi 10.0.0.2 255.255.255.0 10.0.0.1 netstat -nr # routing tables netstat -at # all sockets lsof -n -i4TCP # ports binary iostat -d disk0 # disk stats dscacheutil -flushcache # 10.5-6 sudo killall -HUP mDNSResponder arp -ad # Flush arp cache
  17. 17. Internet ● mail ● sendmail ● curl - transfer a URL ● wget – Need to install (Popular) ● ftp - Internet file transfer program $ curl -s http://www.angeltv.org $ curl http://edge.sin1.swiftserve.com/ange ltv/angeltvlfd/downloads/GOTK_Englis h_Ver4.pdf -O $ curl -u user:pass -O ftp://.../file.zip $ echo “Hi how are you?” | mail -s “From Mac” kumar@angeltv.org $ printf “Subject: Hi how are you?” | sendmail -f kumar@angeltv.org kumar@angeltv.org
  18. 18. Misc... Stuff ● date – Date and Time ● time – time processes ● cal – calender ● dc – desktop calculator ● GetFileInfo - HFS+ ● history – command history ● pbcopy – clipboard copy ● pbpaste – clipboard paste ● zip – PKZip zip ● unzip – PKZip unzip ● shutdown ● who, whoami, hostname, finger ● wc – word/line count ● say – speak ● caffeinate – prevent sleep ● yes – stress test ● md5, shasum – file hash ● alias, unalias, ln
  19. 19. Closing Thoughts... There are many more commands, too much to cover in one sitting. If needed we could do a 202 level course and cover more advanced stuff. Example : remote connection to another system, transferring files, mounting and partitioning raids, scheduling commands to run at a specific date and time and further automation. If needed, we could do a 303 level course and cover bash scripting and other such workflows. A 404 level course will be the highest, where we go into the developer commands, like make and git. But we should consider, moving on to python, ruby or other such scripting languages to better automate things and build better applications. Mac has python and ruby already inside it...
  20. 20. Thank you, The end...By : Kumar (kumar@angeltv.org)

×