Cool Terminal Commands

These are some terminal commands that i didn’t know about but find them cool and very useful:

  1. ditto -V
    super useful in copying large amounts of data as it can run within a Terminal window that contains more information about its progress than the more traditional Finder copy window. This program especially useful for copying huge data.
    After typing ditto -V grab old folder to the terminal and then grab new folder and terminal will automatically determine and display paths to those folders:
    $ ditto -V /Users/anna/Desktop/old /Users/anna/Desktop/new
  2. Show hidden files and folders
    To view hidden files and folders in OS X:
    $ defaults write com.apple.finder AppleShowAllFiles -bool TRUE 
    $ killall Finder
    Once the Finder restarts, you’ll see a lot of files you never saw before, usually starting with a period (which denotes a hidden file in OS X).
    To revert the changes:
    $ defaults write com.apple.finder AppleShowAllFiles -bool FALSE
    $ killall Finder
  3. View the Contents of Any File
    Sometimes we have a file and we just don’t know what format it is. If it’s likely to be a text format, we can attempt to open it in TextEdit, but it doesn’t always work. We can investigate any file from the Terminal by using:
    $ cat /path/to/file
  4. Check up the time on you Mac 
    To see how long our Mac has gone without a restart, we can use:
    $ uptime 
    the result can be:
    21:09 up 1 day, 4:36, 2 users, load averages: 2.11 2.04 2.05
  5. Run the same command again:
    $ !!
  6. Shut down or restart your Mac with a delay: 
    To shut down with a delay
    $ sudo shutdown -h +60
    To restart with a delay
    $ sudo shutdown -r +60
  7. View all active processes 
    The app Activity Monitor can give us a detailed view of what our Mac is currently doing. We can replicate much of its functionality in Terminal:
    $ top
  8. See all list of the command you have entered
    $ history
  9. Search commands in your history by a key word
    If you want to see all commands that, i.e. includes word git, type
    $ history | grep git

Terminal helps you configure your Mac and make work more comfortable. There are even more cool commands. But do not get overwhelmed!