Note: You Will Not Be Able to Run Terminal from This PDF
Total Page:16
File Type:pdf, Size:1020Kb
MAC’S TERMINAL PRESENTED ON MARCH 8, 2016 BY BURT STEPHENS, OMUG MEMBER Note: You will not be able to run Terminal from this PDF. You are encouraged to try Terminal on your computer. Music: From the Terminal Movie, John Williams Conducting GETTING UNDER THE HOOD ABOUT TERMINAL • Included with All Versions of Macs’ OS X • Works under the hood (by providing an Interface to control the UNIX Operating System • Uses a Command Line rather than a Graphic Interface • “Terminal” is a terminal emulator - the devices people used in the days of mainframe computers http://www.macworld.co.uk/feature/mac-software/get-more-out-of-os-x-terminal-3608274/ SOME THINGS YOU CAN DO • Show Hidden Files (defaults write com.apple.finder AppleShowAllFiles TRUE) • Disable Window Animations (defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false) • Change Screenshot Formats (defaults write com.apple.screencapture type file-extension) • Show File Path Info (defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES) • Erase Free Hard Drive Space Securely (diskutil secureErase freespace 3/Volumes/hard-drive-name) OR ( sudo rm -rf /) • Enable AirDrop Over Ethernet (defaults write com.apple.NetworkBrowser BrowseAllInterfaces - bool true) How to open the command line • On OS X, open your Applications folder • Then open the Utilities folder • Then Open the Terminal application. • You may want to add this to your dock. • OR you can launch terminal by using Spotlight search in OS X, searching for “terminal”. SOME BASIC • cd - change directory TERMINAL COMMANDS • mkdir - make directory • pwd - path of current directory • touch - create multiple files • cp - copy • ls - list • mv - move (replace) • rm - remove or delete • open - opens a file • clear - clear the window http://www.macworld.co.uk/feature/mac-software/get-more-out-of-os-x-terminal-3608274/ FORMAT OF A COMMAND LINE •Command •Argument •Flags INSTANTLY GENERATE A CALENDAR COMMAND: CAL MONTH YEAR (CAL 3 2016) NAVIGATING TO FOLDERS EXAMPLE: CD /APPLICATIONS/UTILITIES THEN LS LIST CONTENTS OF DIRECTORY LIST - LS; VIEW IN A LIST FORMAT - LS -L ENABLE AIRDROP ON OLDER MACS AirDrop sends files between Macs quickly and easily. Trouble is, it’s only on WiFi and on more recent Macs. If your Mac doesn’t currently support AirDrop, you can enter the following command to use it, as well as to use it over ethernet: $ defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool TRUE You’ll need to restart the Finder, the quickest way is to use the killall command which will restart it: $ killall Finder To revert the changes, enter: $ defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool REBUILD SPOTLIGHT Spotlight can occasionally not work as well as we’d like. Sometimes, we just need to tell Spotlight to create a new index so it can find files as fast and efficiently as possible. To do this: $ sudo mdutil -E /Volumes/DriveName The above command will delete Spotlight’s index, forcing it to start a new one. SUDO requires a password which is your computer administrative password. It allow the user to execute a command as superuser or to another computer. BUT BE CAREFUL. MAKE YOUR MAC TALK Example of Talking with a Selected Voice: say -v Karen “Hello Jim” Example of Audio Text File Being Saved: say -v Alex -r 175 -o /Users/burtstephens/Music/Young_output.aiff -f / Users/burtstephens/Desktop/young.txt v = voice, -r =reading speed, -o = output type and location, -f = specific text file DOWNLOAD FROM UNSTABLE SERVER Sometimes you are downloading a big file, but it keeps failing, and you always have to hit RESUME. Your problems are over, with this code, if the download stops suddenly, it will automatically restart. This code have a 15kbps speed limit, delete –limit-rate 15k to remove the speed limit. while ! curl -C - -O --limit-rate 15k file-address- goes-here; do sleep 10; done ADDRESS BOOK DEBUG MENU If you have some trouble with Address Book it may be useful to open up the debug menu as well as this use some of the hidden features. Make sure address book is closed first before applying the code. If you want to revert it remove YES in the string. defaults write com.apple.addressbook ABShowDebugMenu -bool YES ENABLE TIME MACHINE ON UNSUPPORTED DRIVES Enable Time Machine to work on unsupported drives such as a NAS. Use with caution as it is unsupported. defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1 SET SCREEN SAVER AS WALLPAPER This command sets the currently selected screen saver as the desktop background. Use command + c or . to stop while in Terminal. Alternatively you can use wallsaver. /System/Library/Frameworks/ScreenSaver.framework/ Resources/ScreenSaverEngine.app/Contents/MacOS/ ScreenSaverEngine -background EJECT A STUCK OR DVD For a Single Optical Drive use the command: drutil eject If you have both an internal and external optical drive: Use either drutil eject internal or drutil eject external Some Terminal Commands to Speed up your Mac in OS X El Capitan 1.. Disable animations when opening and closing windows. 2. Disable animations when opening a Quick Look window. 3. Accelerated playback when adjusting the window size 4. Disable animation when opening the Info window in OS X Finder 5. Disable animations when you open an application from the Dock. 6. Make all animations faster that are used by Mission Control. 7. Disable the delay when you hide the Dock 8. Disable the animation when you sending and replying an e-mail 9. Disable the standard delay in rendering a Web page. 10. The keyboard reacts faster to keystrokes http://www.defaults-write.com/10-terminal-commands-to-speed-up-your-mac-in-os-x-el-capitan/ DEVELOP A LIBRARY OF COMMANDS • Appearance ◦ Transparency ◦ Wallpaper • Applications ◦ App Store ◦ Apple Remote Desktop ◦ Contacts Contacts ◦ iTunes Debug Mode ◦ Mail # Enable ◦ Safari defaults write com.apple.addressbook ABShowDebugMenu -bool true ◦ Sketch ◦ Skim # Disable (Default) ◦ TextEdit defaults write com.apple.addressbook ABShowDebugMenu -bool false • Backup ◦ Time Machine … https://github.com/herrbischoff/awesome-osx-command-line#shells For a large email database that hasn't been optimized for a while, this can provide significant improvements in responsiveness and speed. VACUUM MAIL INDEX TAKING THE NEXT STEPS PROGRAMMING WITH PYTHON Python is a clear and powerful object-oriented programming language, comparable to Perl, Ruby, Scheme, or Java. • Python is pre-installed with latest versions of OS X • (El Capitan comes with Python 2.7) • More serious users with want to download Xcode and Homebrew SIMPLE EXAMPLE WITH PYTHON: LISTING NAMES OF FRIENDS ANOTHER PYTHON EXAMPLE: IF, IF- ELSE, AND ELSE HOMEBREW Homebrew Cask extends Homebrew with support for quickly installing Mac applications like Google Chrome, VLC, and more. No more dragging and dropping applications! •Free and open-source software that simplifies the installation of software on Apple's OS X operating system. •Written in Ruby programming language which comes installed with oS X . X CODE The newest version of Xcode -7 includes everything you need to create apps for iPhone, iPad, Mac, and Apple Watch. The Swift programming language (Version 2) has been updated and is now faster than ever, with great features that make your code even easier to read and write. And with the new playgrounds you can experiment with new APIs or author gorgeous interactive documentation using embedded resources, additional source code, and rich text comments. Xcode’s user interface testing feature can even record your app in action and generate tests for you. To Install X Code: https://itunes.apple.com/us/app/xcode/id497799835?mt=12 OTHER USEFUL APPLICATIONS Automator or Hazel For OS X that implements point-and-click (or drag and drop) creation of workflows for automating repetitive tasks into batches for quicker alteration, saving time and effort over manually changing each file separately. https://www.noodlesoft.com/hazel.php YOU COULD WIN AT TONIGHT’S RAFFLE With Joe Kissell’s Book you will be able to - Figure out what’s preventing a disk from unmounting or ejecting Tell which applications are currently assessing the Internet Rename files in bulk (older OS Xs) Chase File Permissions Automate command-line activities with scripts Terminal Emulators for Mac and iOS Devices OS X • Terminal - default OS X terminal • iTerm2 - open-source terminal specifically for OS X • xterm - default terminal when the X Window System started • MacWise • SecureCRT • SyncTERM - includes serial line terminal • Terminator •ZOC • ZTerm - serial line terminal Mac OS • MacTerminal • Red Ryder • ZTerm BASIC TERMINAL USAGE https://www.youtube.com/watch?v=jDINUSK7rXE https://www.youtube.com/watch?v=MirG-vJOg04 Useful Python Modules See http://ubuntuforums.org/showthread.php?t=522688 Example of use of “say” command with say -v Alex -r 150 -o /Users/burtstephens/ output to stored say -v Music/Goodbye_output.aiff Alex -r 175 -o /Users/ -f /Users/ audio file, burtstephens/Desktop/Bye.txt followed by short quiz using keynote branching features BASH SUDO Question 1 What is the meaning to the computer term -“Bash”? A. a boastful command B. a UNIX shell C. a program that politicians use D. legacy programs developed by Steve Jobs Next Question You are Wrong • In ordinary language BASH means to strike violently or to attack physically or verbally, but this is not a computer term Return You Got it Literally BASH refers to Bourne Again Shell -a command line processor for Unix from the Free Software Foundation. It is the de facto command processor in Linux and Mac. Return You’re Wrong • These days politicians are said to slash and bash their opponents, but this is not a computer term. Return NO! NO! NO! According to Steve Wozniak "Steve Jobs didn't ever code. He wasn't an engineer and he didn't do any original design, but he was technical enough to alter and change and add to other designs." Return Question 2 What do you need to do to use SUDO as part of a terminal command line? A.