one year agoDinky pocketbooks: the command-line reference edition

I have fulfilled my intention from to create a dinky pocket book as a reference for useful terminal commands (see below). I'll be printing a set of these out for my colleagues to find on their desks next week.

The printable pdf can be found here, but if you are running safari — or a recent gecko build as now it also uses -moz-transform — you can print directly from the browser.

The HTML for the reference booklet together with some minor updates to the original booklet css can be found on github.

I rarely use the terminal so these are commands that I will find useful as a reference and some of these I always end up having to look up. It is not designed to be an exhaustive list but if you have any suggestions I would love to hear them!

screenshot of dinky pocket book for terminal commands reference

Navigate the file tree

changing directory to dirname

cd dirname

move up a directory in the tree—dont forget you can drag a folder in from the finder to get a path to that directory.

cd ..

go back to the last directory I was in

cd -

where am I? (present working directory)

pwd

list what's in this directory

ls

now give me more information in the listing

ls -lah

ssh to server

ssh user@domain.com

Find & open

list all files recursively in subdomains

find .

find all files with '.css' in the name

find . | grep .css

find the string 'prose' in the contents of all the files in this directory

grep -r "prose" .

open a file as if you had double clicked it in the finder (mac only)

open filename

open the current directory in the finder

open .

make a directory called dirname

mkdir dirname

create a file called filename if it doesnt exist or update last modified date if it does

touch filename

Move, remove & copy

move or rename a file or directory

mv oldname newname

remove a file

rm filename

remove a directory and all its contents. BE VERY CAREFUL! you could easily delete everything!

rm -rf dirname

copy a file

cp oldfilename newfilename

copy a directory and everything in it

cp -r olddirname newdirname

securely copy a file to / on a remote server — you can also copy a directory using scp -r

scp file user@domain.com:

Subversion

check out a repository to the current directory

svn co http://domain.com/svn/ .

update local directory from repository

svn up

are there new or modified files?

svn status

add new files to the repository

svn add filename

remove a file from subversion

svn remove filename

mark a previously conflicted file as resolved

svn resolved filename

who changed what line number of this file

svn blame filename

commit all changes in this directory

svn commit -m "commit msg"

Subversion & download

is this directory checked out from svn? and where?

svn info

show everything that has changed

svn diff

show what has changed in one file

svn diff filename

open text editor in order to specify which files to ignore from svn

svn propedit svn:ignore .

download a file to the current directory

wget URL

show the contents of a file in the terminal

curl URL

Help & information

run any command as root

sudo your-command-here

get help for any command, eg svn

svn --help

how long has this computer been on?

uptime

what is the size of the current directory and all the contents

du -h

cancel the command you were currently typing

ctrl + c

go to the beginning of the line in the terminal

ctrl + a

go to the end of the line in the terminal

ctrl + e

39 comments

  1. This is a good collection! I have an advice to look deeper in the arguments the commands take. For example,
    find . | grep '.css'
    
    is not as idiomatic as
    find . -name '*.css'
    
    And talking about ctrl+a, ctrl+e, you may want to take a look at my own cheat sheet that lists all the other shortcuts.

    Peteris Krumins 24th May 2009 08:35permalink.

  2. I'm also going to comment on your find command.
    find . -type f -exec grep -l ".css" {}\;
    This is an example of find giving you back a filename that has ".css" in it. It's also important to note that exec can execute pretty much any command.
    find . -type f -exec mycommand {}\;
    Note: {} is going to be the filename of the file it currently is on. Also the backslash is required.

    J 24th May 2009 14:38permalink.

  3. Brilliant job !!
    I really love your practical css3 trick !

    Satoshi Kikuchi 1st June 2009 17:04permalink.

  4. can't but admire the way you do things:) it looks so simple in your performance. hope I'll also succeed in trying this.

    Mhunter 20th May 2010 07:04permalink.

  5. can't but admire the way you do things:) it looks so simple in your performance. hope I'll also succeed in trying this.

    Papaz Büyüsü 2nd June 2010 16:34permalink.

  6. Thanks for great reference editing, I think I will write about it in my essay in university.

    Jim D 15th June 2010 17:10permalink.

  7. Thanks for great reference editing, I think I will write about it in my <a href="http://www.customwritings.com">essay</a> in university.

    Jim D 15th June 2010 17:12permalink.

  8. Impressive work, really got me impressed.Pump in style advanced

    Pump in style advanced 25th June 2010 09:57permalink.

  9. This is an example of find giving you back a filename that has ".css" in it. It's also important to note that exec can execute pretty much any command.
    find . -type f -exec mycommand {}\;
    Note: {} is going to be the filename of the file it currently is on. Also the backslash is required.
    club penguin cheats

    ClubPenguin 25th June 2010 10:39permalink.

  10. hope I'll also succeed in trying this.

    batterie 27th June 2010 13:15permalink.

  11. Thanks for great reference editing

    labatterie 27th June 2010 13:15permalink.

  12. Your post is really informative for me. I liked it very much.

    blanc pain watch 10th July 2010 09:44permalink.

  13. I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else! Camera Lens Cheap Home Design

    camera lens cheap 13th July 2010 02:56permalink.

  14. This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article. women's winter boots

    women's winter boots 13th July 2010 03:37permalink.

  15. very informative posts and with great resource. Thanks for sharing 4shared mp3 downloads

    alexis 13th July 2010 11:43permalink.

  16. Hrmm that was weird, my comment got eaten. Anyway I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere. This was the first place that told me the answer. Thanks. Link Building Service

    Link Building Service 13th July 2010 14:54permalink.

  17. I can see that you are putting a lots of efforts into your blog. Keep posting the good work.Some really helpful information in there. Bookmarked. Nice to see your site. Thanks! overhead dvd players

    overhead dvd players 14th July 2010 14:26permalink.

  18. I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.

    Home design ideas 14th July 2010 19:03permalink.

  19. Great stuff from you, man. Ive read your stuff before and youre just too awesome. I love what youve got here, love what youre saying and the way you say it. You make it entertaining and you still manage to keep it smart. I cant wait to read more from you. This is really a great blog.

    free music download mp3 15th July 2010 10:01permalink.

  20. Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates

    jaibreak iphone 15th July 2010 13:52permalink.

  21. You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

    How To Flirt Girls 15th July 2010 16:10permalink.

  22. I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful

    Business Innovation 15th July 2010 18:52permalink.

  23. I can see that you are putting a lots of efforts into your blog. Keep posting the good work.Some really helpful information in there. Bookmarked. Nice to see your site. Thanks!

    Always Health and Beauty 16th July 2010 04:39permalink.

  24. Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case

    Health Lifesyle 16th July 2010 08:42permalink.

  25. I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored to their needs.

    Radar7 News 17th July 2010 04:08permalink.

  26. Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates.

    Supplements and Vitamins Articles 17th July 2010 17:45permalink.

  27. I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post.

    Home Based Business Articles 19th July 2010 08:00permalink.

  28. Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case

    Mesothelioma 19th July 2010 16:15permalink.

  29. How nice of your sharing! I have been looking for it! classified |ad|select comfort beds

    jessie 21st July 2010 08:19permalink.

  30. Also the backslash is required.

    Rolex watches 22nd July 2010 07:35permalink.

  31. This was the first place that told me the answer.

    r4 ds 22nd July 2010 07:36permalink.

  32. i m glad i found ur blog.Not everyone can provide information with proper flow. Good post. I am going to save the URL and will definitely visit again. Keep it up.coursework writing | research writing

    essay help 22nd July 2010 23:52permalink.

  33. Your blog is very informative.This is obviously one great post.i keep on reading articles from here.thanks for sharing..thesis help | assignment help

    dissertation help 22nd July 2010 23:53permalink.

  34. Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case

    Health World 25th July 2010 08:21permalink.

  35. Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.

    Micro Trend Security 25th July 2010 12:22permalink.

  36. Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.

    Micro Trend Security 25th July 2010 12:23permalink.

  37. I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored to their needs.

    Fashion Blog 26th July 2010 12:47permalink.

  38. Your blog is very informative.This is obviously one great post.i keep on reading articles from here.thanks for sharing.

    Replica Watches 26th July 2010 17:47permalink.

  39. I am following your blog regularly and got great information. I really like the tips you have given.

    philadelphia security systems 28th July 2010 07:53permalink.

Line breaks are preserved; URLs will be converted in to links.

Enter your own, valid XHTML. Allowed tags are: a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

23rd May 2009

You are reading "Dinky pocketbooks: the command-line reference edition" written by Natalie Downe on the 23rd of May 2009 at 5:01 pm.

Next: Styling buttons to look like links

Previous: Dinky pocketbooks with WebKit transforms