Helpful Unix and Mac commands

I am for the most part a Windows user. I was kind of moving towards Linux, Ubuntu in particular, but that ship pretty much sailed when I got my hands on Windows 7. Awesome, awesome operating system. But, I still have to use some Unix and Mac systems once in a while. And then there are certain commands that I often use, but always forget since it usually goes a bit of time between times I do it. So, what follows is basically just a list of commands that I keep forgetting, but keep having to look up again.

Remove .DS_Store files

Removes all those stupidannoying DS_Store files that Mac litters around wherever it goes. Works in the current directory and downwards.

find . -name *DS_Store -exec rm {} \;

Recursivly download a whole website

wget -T 5 -t 0 -m -np -w 5 --random-wait -E -k -p -P output/dir http://website

Show hidden files on in OS X

Swap TRUE with FALSE to hide them again. The second line kills and relaunches Finder.

defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder && open /System/Library/CoreServices/Finder.app

Redirect std error to std out

ls -ld /home /qwerty 1>log 2>&1

Compress and decompress files

# Compress
tar czvf archive.tar.gz filedir filedir
tar cjvf archive.tar.bz2 filedir filedir

# Decompress
tar xzvf archive.tar.gz
tar xjvf archive.tar.bz2

Find open files

lsof | grep filename

SSH filesystem on Mac

First download and install sshfs for Mac OS X. Then to mount

mkdir -p ~/sshfs/server1
/Applications/sshfs/bin/mount_sshfs server1_hostname: ~/sshfs/server1

And to unmount (and uninstall the sshfs)

umount ~/sshfs/server1
sudo /Applications/sshfs/uninstall.sh

About Torleif

Was born in Hønefoss (Norway) the 20th of January 1985 around 16:05. I am a Seventh-Day Adventist, a software developer and a hobby juggler.
This entry was posted in Technology and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>