The default shell for Leopard users is Bash. Although many GNU/Linux users are familiar with it, not all Mac users take full advantage of its power. Here are some very useful commands and tips I use routinely.
Users and login
Use the root superuser
sudo su -Alter login variables (such as $PATH, $EDITOR)
nano ~/.profileOther available shells
- /bin/ksh
- /bin/tcsh
- /bin/csh
- /bin/zsh
Files management
Output the contents of a file
cat /some/thingGet 20 lines from the end of a file
tail -n 20 /some/thingGet the first 20 lines of a file
head -n 20 /some/thingCreate an empty file
touch /some/thingRedirect the output of a command to a file (overwrites)
command > /some/thingRedirect the output of a command to a file (appends)
command >> /some/thingAppend the timestamp to a file
touch /backups/backup_`date +%s`.txtChange to the last directory you were in
cd /var
cd /etc
cd - # will take you to /var
List file size in human-readable units
ls -lh /dir/or/file
Available editors
- /usr/bin/vi
- /usr/bin/vim
- /usr/bin/nano
Applications and processes
Run a process in the background
command &List running processes
ps axThe first column will be the PID
Kill a process by pid
kill -9
Kill a process or processes by name (e.g: the Dock)
killall DockOpen an application (Mac-only)
open /Applications/iTunes.app/
One Comment
Pingback: How to install Lua 5 in Mac OS X Leopard | BYOHosting.com Blogs