UNIX Commands

From Genecats
Revision as of 22:57, 28 March 2011 by Vanessa (talk | contribs) (Adding categories)
Jump to navigationJump to search

Shorthand Key:

file name		fl nm
database name		dbnm
table name		tbl nm

Common Unix Commands

pwd				present working directory
ls				list directories/files
ls –ltr			lists directories/files without a “.” in front
ls –ltra			lists directories/files with a “.” In front
ls -1				lists directories/files with one entry on each line
ls –L				shows just sym link names, not destination
ls –L1 flnm*			shows names & sym links & lists them one/line that start with “flnm”
!$				last argument on previous line (space to end)
hgsql db nm		        gets us in mysql database
Ctrl + c			cancels command in progress
h				history
cp				copy
mkdir				make directory
cd -				back to the last place you were
cd				takes all the way to the top no mater where you are
grep				search/find
egrep				extended grep
-v				remove this
rm fl nm			remove file
diff flnm1 flnm2		shows differences between two files
cp fl nm			copy file
mv fl nm			move copy file
mv fl nm new fl nm	        rename file from fl nm to new fl nm
^				beginning of a line or begins with
\				escapes a character (insert char. don’t execute its comnd)
|				pipe to
df				name of machine
command | more		        give the first few records & give one more line when "enter" is clicked
> fl nm			put in file
J				takes next line and prints it to the screen
:. , $				from here to the end of the line
~				toggles between the last two places
ssh machine		        open shell on that machine (ex  ssh hgwdev)
cat fl nm			print this file to the screen (rather than vi)
cat fl nm | grep “criteria”	print only the criteria of the file to the screen
head fl nm			first 10 lines of file in window
tail fl nm			last 10 lines of file in window
history			shows you every command typed in session
!#				displays that line number in command line (ex. !20)
sudo mypush db tbl hgwbeta	push a table to hgwbeta (from dev)
diff flnm1 flnm2		difference between two files

cat flnm | awk -F\. '{ print $1 }'	makes deliminator a "." and prints the first column (before the ".")

ls -1 | wc -l 			number of flies in a directory
ps				processes running in terminal, -e for everything, -ef for everything full, | grep katrina for just my stuff
ctrl+z				halts a job
bg				background (must do ctrl+z first)
fg				foreground

samtools view -x <file> <pos> | grep <QNAME> | sed 's/\t/\n/g'		prints bam records in a region with particular QNAME vertically with the FLAG field in hex (made alias: sv = 'samtools view -x')

To view processes: http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/
kill processId		to force quit a command that you can't "ctrl + c" out of (must open another window and view processes first)