I've been using Ubuntu for the last four years.
I have a basic knowledge of shell commands and I prefer working in a terminal rather than using a GUI. Recently I've started using a Mac.
I've tried a few terminal commands (that I use on Ubuntu) in the Mac terminal and it seems to respond in mostly the same way.
Are there any significant differences in the commands I use, the task(s) they perform or the shell environment that I should be aware of?
Mac OS X is a Unix OS and its command line is 99.9% the same as any Linux distribution. bash is your default shell and you can compile all of the same programs and utilities. There's no notable difference. You can also find various projects like MacPorts which provide package management for Mac.
Mac OS is based on a BSD code base, while Linux is an independent development of a unix-like system. This means that these systems are similar, but not binary compatible. Furthermore, Mac OS has lots of applications that are not open source and are build on libraries that are not open source.
On Windows it is PowerShell or Command Prompt. On the old Amiga OS it is simply called "CLI". Terminal is the program or application ("app") that is used to access the Command Line Interface. On macOS terminal is located in the /Applications/Utility folder and called Terminal.
If you did a new or clean install of OS X version 10.3 or more recent, the default user terminal shell is bash.
Bash is essentially an enhanced and GNU freeware version of the original Bourne shell, sh. If you have previous experience with bash (often the default on GNU/Linux installations), this makes the OS X command-line experience familiar, otherwise consider switching your shell either to tcsh or to zsh, as some find these more user-friendly.
If you upgraded from or use OS X version 10.2.x, 10.1.x or 10.0.x, the default user shell is tcsh, an enhanced version of csh('c-shell'). Early implementations were a bit buggy and the programming syntax a bit weird so it developed a bad rap.
There are still some fundamental differences between mac and linux as Gordon Davisson so aptly lists, for example no useradd
on Mac and ifconfig
works differently.
The following table is useful for knowing the various unix shells.
sh The original Bourne shell Present on every unix system ksh Original Korn shell Richer shell programming environment than sh csh Original C-shell C-like syntax; early versions buggy tcsh Enhanced C-shell User-friendly and less buggy csh implementation bash GNU Bourne-again shell Enhanced and free sh implementation zsh Z shell Enhanced, user-friendly ksh-like shell
You may also find these guides helpful:
http://homepage.mac.com/rgriff/files/TerminalBasics.pdf
http://guides.macrumors.com/Terminal
http://www.ofb.biz/safari/article/476.html
On a final note, I am on Linux (Ubuntu 11) and Mac osX so I use bash and the thing I like the most is customizing the .bashrc (source'd from .bash_profile
on OSX) file with aliases, some examples below. I now placed all my aliases in a separate .bash_aliases file and include it with:
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
in the .bashrc or .bash_profile file.
Note that this is an example of a mac-linux difference because on a Mac you can't have the --color=auto
. The first time I did this (without knowing) I redefined ls
to be invalid which was a bit alarming until I removed --auto-color
!
You may also find https://unix.stackexchange.com/q/127799/10043 useful
# ~/.bash_aliases # ls variants #alias l='ls -CF' alias la='ls -A' alias l='ls -alFtr' alias lsd='ls -d .*' # Various alias h='history | tail' alias hg='history | grep' alias mv='mv -i' alias zap='rm -i' # One letter quickies: alias p='pwd' alias x='exit' alias {ack,ak}='ack-grep' # Directories alias s='cd ..' alias play='cd ~/play/' # Rails alias src='script/rails console' alias srs='script/rails server' alias raked='rake db:drop db:create db:migrate db:seed' alias rvm-restart='source '\''/home/durrantm/.rvm/scripts/rvm'\''' alias rrg='rake routes | grep ' alias rspecd='rspec --drb ' # # DropBox - syncd WORKBASE="~/Dropbox/97_2012/work" alias work="cd $WORKBASE" alias code="cd $WORKBASE/ror/code" # # DropNot - NOT syncd ! WORKBASE_GIT="~/Dropnot" alias {dropnot,not}="cd $WORKBASE_GIT" alias {webs,ww}="cd $WORKBASE_GIT/webs" alias {setups,docs}="cd $WORKBASE_GIT/setups_and_docs" alias {linker,lnk}="cd $WORKBASE_GIT/webs/rails_v3/linker" # # git alias {gsta,gst}='git status' # Warning: gst conflicts with gnu-smalltalk (when used). alias {gbra,gb}='git branch' alias {gco,go}='git checkout' alias {gcob,gob}='git checkout -b ' alias {gadd,ga}='git add ' alias {gcom,gc}='git commit' alias {gpul,gl}='git pull ' alias {gpus,gh}='git push ' alias glom='git pull origin master' alias ghom='git push origin master' alias gg='git grep ' # # vim alias v='vim' # # tmux alias {ton,tn}='tmux set -g mode-mouse on' alias {tof,tf}='tmux set -g mode-mouse off' # # dmc alias {dmc,dm}='cd ~/Dropnot/webs/rails_v3/dmc/' alias wf='cd ~/Dropnot/webs/rails_v3/dmc/dmWorkflow' alias ws='cd ~/Dropnot/webs/rails_v3/dmc/dmStaffing'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With