Difference between revisions of "Unix cheatsheet"
From CoolWiki
Jump to navigationJump to searchm |
m |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Here is a quick list of common unix commands. These will work from a terminal window on Linux or Mac, or from a terminal window once you have cygwin installed on Windows. (see [[Windows hints, tips, and tricks]].) | Here is a quick list of common unix commands. These will work from a terminal window on Linux or Mac, or from a terminal window once you have cygwin installed on Windows. (see [[Windows hints, tips, and tricks]].) | ||
− | * Changing directories (folders) | + | * Changing directories (folders) from the root partition (absolute file structure). Note that the cd command is asking the computer to go to a location with a leading slash. What this means is "go from the root of the system." See also next item. |
cd /path/to/directory | cd /path/to/directory | ||
+ | |||
+ | * Changing directories (folders) from your current partition (relative file structure). Note that the cd command is asking the computer to go to a location withOUT a leading slash. What this means is "go from where I am now." See also previous item. | ||
+ | cd relative/path/to/directory | ||
+ | |||
+ | * Figuring out where you are currently (pwd = Print Working Directory) | ||
+ | pwd | ||
* Getting a directory listing | * Getting a directory listing | ||
ls | ls | ||
+ | |||
+ | * Getting a directory listing where the computer will add "/" to directories (folders) and "*" to executable programs, and leave plain text files unadorned: | ||
+ | ls -F | ||
* Getting a directory listing of just one kind of file extension | * Getting a directory listing of just one kind of file extension | ||
Line 13: | Line 22: | ||
ls *fits > listoffiles.txt | ls *fits > listoffiles.txt | ||
− | * Unzipping the files from | + | * Examining the contents of a file (works best on text files, but will also attempt it without complaint on binary files -- be careful!) ... To scroll down and see more of the file, hit the space bar; to quit out, hit "q". |
+ | more listoffiles.txt | ||
+ | |||
+ | |||
+ | * Unzipping the files from SHA -- the "\" is important!! | ||
unzip \*.zip | unzip \*.zip | ||
Line 22: | Line 35: | ||
tar -xf foo.tar | tar -xf foo.tar | ||
− | * Uncompressing a compressed tar file (may not work on older systems) | + | * Uncompressing a compressed tar file (may not work on older systems) -- e.g., doing the previous two steps in just one step. |
tar -xzf foo.tar.gz | tar -xzf foo.tar.gz | ||
+ | |||
+ | |||
+ | =Useful links= | ||
+ | There are lots of other unix cheatsheets on the web, such as [http://www.sap-basis-abap.com/unix/unix-commands-cheat-sheet.htm this one]. Google to find more. |
Latest revision as of 19:10, 13 May 2011
Here is a quick list of common unix commands. These will work from a terminal window on Linux or Mac, or from a terminal window once you have cygwin installed on Windows. (see Windows hints, tips, and tricks.)
- Changing directories (folders) from the root partition (absolute file structure). Note that the cd command is asking the computer to go to a location with a leading slash. What this means is "go from the root of the system." See also next item.
cd /path/to/directory
- Changing directories (folders) from your current partition (relative file structure). Note that the cd command is asking the computer to go to a location withOUT a leading slash. What this means is "go from where I am now." See also previous item.
cd relative/path/to/directory
- Figuring out where you are currently (pwd = Print Working Directory)
pwd
- Getting a directory listing
ls
- Getting a directory listing where the computer will add "/" to directories (folders) and "*" to executable programs, and leave plain text files unadorned:
ls -F
- Getting a directory listing of just one kind of file extension
ls *txt
- Getting a directory listing in a plain text file
ls *fits > listoffiles.txt
- Examining the contents of a file (works best on text files, but will also attempt it without complaint on binary files -- be careful!) ... To scroll down and see more of the file, hit the space bar; to quit out, hit "q".
more listoffiles.txt
- Unzipping the files from SHA -- the "\" is important!!
unzip \*.zip
- Unzipping files with a *gz extension
gunzip *.gz
- Uncompressing a tar file -- tar = Tape ARchive
tar -xf foo.tar
- Uncompressing a compressed tar file (may not work on older systems) -- e.g., doing the previous two steps in just one step.
tar -xzf foo.tar.gz
Useful links
There are lots of other unix cheatsheets on the web, such as this one. Google to find more.