Common Command Line Commands

This page will present some linux tricks to make your work easier.

In the Beginning There Was the Command Line...
Open command line (Terminal)

Navigating around:

man (MANual) man followed by command will bring up help and options available
help List of available commands
pwd (Print Working Directory) Find out file path of directory you are in
ls (LiSt) List all files and directories are in current directory
ls -l Files and info
cd (Change Directory) Move around in folder tree
cd
cd .. Up one level
~/ Shortcut for root directory
^ SHIFT C (control shift c) Copy command
SHIFT INSERT (shift insert) Paste command
TAB key Finish typing directory or file that you started
UP key Displays previously entered command (you can scroll through history)
mkdir (MaKeDIRectory) Make new directories
locate Find file path of file
which Find file path of program
cp (CoPy) Copy files
mv (MoVe) Move file to another place
rm (ReMove) Delete specified file
cat (conCATenate) String files together
nano Text editor at command line
less Allows you to page through file
head Displays lines at beginning of file
tail Displays lines at end of file
> Output result to file (will write over if exists)
>> Output result to file (adds to end of file)
command | command Directs results from one command to another
command & Executes command and returns command prompt (very useful on oscar)
jobs Lists all running commands (use with command &)
history Bring up all typed commands
wc (WordCount) Count characters, lines ...
wc -l Just lines
chmod u+x <file> (CHange file MODe) Makes a text file executable
echo Displays line of text (used with $PATH or to figure out when programs are called)
grep Search for text in files and returns line
^C (control C) Stops current command
clear Clears command window
exit Close terminal window


Logging on to Oscar:

ssh (SecureSHell) Secure remote login tool
ssh -Y Able to display images, HUGE for R
ssh user@ssh.ccv.brown.edu Login to CCV
ssh oscar Login to Oscar
scp (Ssh CoPy) Transfer files to/from Oscar
scp <file> user@ssh.ccv.brown.edu:/gpfs/home/user/filepath Copy to Oscar
scp <file> user@128.148.83.196:/home/user/filepath Copy from Oscar
Can also do remote to remote computer but I'm not sure how...
logout Close connection
xclock Displays clock, test if ssh -Y worked (very helpful for R)
/gpfs/home/user Root directory for your stuff
/gpfs/runtime Root directory for all programs, including ABySS, Velvet, BLAST, Casava, etc.
/gpfs/runtime/bin Root directory for python, R, perl, etc.


Python:

RTFM (Casey's Book)


R:

dir() ls equilivent
getwd() pwd equilivent
setwd("filepath") cd equilivent
?command man equilivent
??text searchable man (may not work on Oscar)
q() exit equilivent
read.table Why you are using R
dim(data) Returns dimensions of data
summary(data) Gives statistics on data
max(data[x,y]) Returns max value for x and y in data

Comments