Useful Terminal Commands
From Liki
A list of useful *nix terminal commands and their functions:
Contents |
[edit] Getting help
In almost all cases, typing
$ <command> --help
or
$ man <command>
will give help on the specifics for a particular command. If those fail, look on the liki, [Google] it, or ask somebody.
[edit] Directory Commands
commands for editing the directory structure:
| command | action |
|---|---|
| ls | list directory contents |
| mkdir | make a directory |
| rmdir | remove an empty directory |
| rm | remove a file |
| mv | move a file |
| cp | copy a file |
Warning rm, mv, and cp are potentially destructive (whoops, there goes my research directory... etc.). To avoid doing something you'll regret later, it's wise to place something like
alias rm='rm -iv' alias cp='cp -iv' alias mv='mv -iv'
in your ~/.bashrc file (try nano ~/.bashrc). This makes the commands interactive by default and prints messages showing what files are being moved, deleted, etc.
[edit] Viewing and Editing Files
| command | action |
|---|---|
| cat | print a file to the terminal |
| less | allow scrolling through large program output (paginate) |
| nano | simple text editor. Helpful shortcuts are listed at the bottom of the screen. |
| emacs | complicated text editor. The shortcuts are in your head, but you can write your own. |
| vi | another complicated text editor. Whatever works for you. |
[edit] Searching Commands
| command | action |
|---|---|
| find | search for a file (slow, but lots of features). |
| locate | search for a file in a pre-compiled index (fast). |
| grep | search a file (or stdin) for matching regular expressions. |
[edit] Currently Uncategorized
| command | action |
|---|---|
| pwd | print working directory. |
| ssh | Secure SHell. Log in to remote computers. |
| scp | Secure CoPy. Copy files to/from remote computers. |
| paste | merge files by row paste,join, sort article |
| join | intelligently merge files by row paste,join,sort article |
| sort | sort files by row paste,join,sort article |
| uniq | remove duplicate lines |
| cut | select particular columns from a file |
| awk | record editor for flat-text databases, general text processing. |
| sed | stream editor, search-replace, etc. |
| find | search for files |
| lsof | list open files |
| ps | show current processes |

