Murphy Mac - Screencasts and Tutorials » Page 'Navigating the Terminal'

Navigating the Terminal

Share

Murphy MacThis Snippet will ease us into the Terminal. There’s a ton to cover so this is just a brief introduction to a very powerful tool.

IMPORTANT: The Terminal is dangerous. An ill-formed command will wipe files from your disk without warning. You can severely damage your Mac with seemingly harmless intentions. Always proceed with caution when using the Terminal. And back up your files frequently.

See this Snippet for a demonstration of the harm Terminal can cause.

What about MS Windows?

Watch Now | Permalink

4 comments to “Navigating the Terminal”

  1. Tip: to make your Terminal just a little bit safer, open up the file ~/.bash_profile in your favorite text editor. Create it if it does not exist. Add the following three lines:

    alias cp=”cp -i”
    alias mv=”mv -i”
    alias rm=”rm -i”

    Make sure you save the file with the exact name above (no .txt extension! no extension at all!).

    Now, the cp, rm and mv commands will ask for your permission before overwriting or removing any file. (Note, you must close and re-open your Terminal before this takes effect).

    Note that the ~/.bash_profile is only read for interactive shells, meaning that if you use rm, mv or cp in a shell script, they will still overwrite or remove files without warning. However, the file ~/.bashrc is read whenever a new shell is invoked — so if you want that behavior add the aliases in that file. (Script authors can always use the -f option to these commands to force dangerous behavior)

  2. Followup: to clarify, if you choose to add the aliases to ~/.bashrc, do that instead of putting them in ~/.bash_profile. (it doesn’t hurt if they are in both places, but is redundant and you might potentially confuse yourself later).

    Also, bash is the default shell for recent versions of MacOS X. Earlier versions used tcsh as the default instead. I don’t recall exactly when this was changed, but if your shell is tcsh, the syntax is slightly different and the “dot” files have different names.

  3. so how does one see a file that starts with “.” in order to edit it? I tried using bbedit to look for a file named “.bash_profile” but of course the file is hidden. So since this is a tutorial for rank beginners, please explain how I would be able to open a hidden file, edit it and save it. Thanks!!

  4. ls -a

    I probably left that out so beginners wouldn’t go digging around in hidden files, until they got more comfortable.

    You can use other commands on the files that start with a dot, for example
    cat .notes
    will display the contents of hidden file .notes.

    btw – the first comment for this post – by bryan – has been turned into a screencast.

Leave a comment