UNIX Commands: Difference between revisions

From Genecats
Jump to navigationJump to search
(added sym link section)
(→‎Resources: Hiram paper shared.)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Shorthand Key:==
==Shorthand Key:==
  file name fl nm
  file name flnm
  database name dbnm
  database name dbnm
  table name tbl nm
  table name tblnm


==Common Unix Commands==
==Common Unix Commands==
  pwd present working directory
  pwd present working directory
  ls list directories/files
  ls list directories/files
  ls –ltr lists directories/files without a “.” in front
  ls –ltr lists directories/files without a “.” in front
  ls –ltra lists directories/files with a “.” In front
  ls –ltra lists directories/files with a “.” In front
  ls -1 lists directories/files with one entry on each line
  ls -1 lists directories/files with one entry on each line
Line 13: Line 13:
  ls –L1 flnm* shows names & sym links & lists them one/line that start with “flnm”
  ls –L1 flnm* shows names & sym links & lists them one/line that start with “flnm”
  !$ last argument on previous line (space to end)
  !$ last argument on previous line (space to end)
  hgsql db nm         gets us in mysql database
  hgsql dbnm         gets us in mysql database
  Ctrl + c cancels command in progress
  Ctrl + c cancels command in progress
  h history
  h history
Line 23: Line 23:
  egrep extended grep
  egrep extended grep
  -v remove this
  -v remove this
  rm fl nm remove file
  rm flnm remove file
  diff flnm1 flnm2 shows differences between two files
  diff flnm1 flnm2 shows differences between two files
  cp fl nm copy file
  cp flnm copy file
  mv fl nm move copy file
  mv flnm move copy file
  mv fl nm new fl nm         rename file from fl nm to new fl nm
  mv flnm1 flnm2         rename file from flnm1 to flnm2 (overwriting flnm2 if it already existed)
  ^ beginning of a line or begins with
  ^ beginning of a line or begins with
  \ escapes a character (insert char. don’t execute its comnd)
  \ escapes a character (insert char. don’t execute its comnd)
Line 33: Line 33:
  df name of machine
  df name of machine
  command | more         give the first few records & give one more line when "enter" is clicked
  command | more         give the first few records & give one more line when "enter" is clicked
  > fl nm put in file
  > flnm         put in file
  J takes next line and prints it to the screen
  J takes next line and prints it to the screen
  :. , $ from here to the end of the line
  :. , $ from here to the end of the line
  ~ toggles between the last two places
  ~ toggles between the last two places
  ssh machine         open shell on that machine (ex  ssh hgwdev)
  ssh machine         open shell on that machine (ex  ssh hgwdev)
  cat fl nm print this file to the screen (rather than vi)
  cat flnm print this file to the screen (rather than vi)
  cat fl nm | grep “criteria” print only the criteria of the file to the screen
  cat flnm | grep “criteria” print only the criteria of the file to the screen
  head fl nm first 10 lines of file in window
  head flnm first 10 lines of file in window
  tail fl nm last 10 lines of file in window
  tail flnm last 10 lines of file in window
  history shows you every command typed in session
  history shows you every command typed in session
  !# displays that line number in command line (ex. !20)
  !# displays that line number in command line (ex. !20)
  sudo mypush db tbl hgwbeta push a table to hgwbeta (from dev)
  sudo mypush db tbl hgwbeta push a table to hgwbeta (from dev)
Line 54: Line 54:
  bg background (must do ctrl+z first)
  bg background (must do ctrl+z first)
  fg foreground
  fg foreground
top display processes currently running in real time (default sort is by highest CPU usage)
uptime displays how long the system has been up (without reboot) and recent overall CPU usage
man cmd1 show the manual page for the command cmd1 (this is for unix commands, not programs we write)
   
   
  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')
  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')
Line 69: Line 72:


*Use a Sym Link:
*Use a Sym Link:
  cd ~/ sym link name
  cd ~/sym link name
   
   
  ex.
  ex.
  cd ~/ trackDb
  cd ~/trackDb




[[Category:Browser QA]]
[[Category:Browser QA Training]]
==Resources==
*Unix Tutorial: http://www.ee.surrey.ac.uk/Teaching/Unix/
* Parts I and II of this tutorial: http://korflab.ucdavis.edu/Unix_and_Perl/current.html
* This free PDF download about the Linux Command line, http://linuxcommand.org/tlcl.php,  has more in-depth information where chapters 1–7, 9, 11, 18, 19, 20, and maybe 24–33 have been recommended.
* Recommended paper on [https://people.eecs.berkeley.edu/~brewer/cs262/unix.pdf The UNIX Time-Sharing System]
[[Category:Browser QA]]
[[Category:Browser QA]]
[[Category:Browser QA Training]]
[[Category:Browser QA Training]]

Latest revision as of 18:23, 11 September 2018

Shorthand Key:

file name		flnm
database name		dbnm
table name		tblnm

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 dbnm		        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 flnm				remove file
diff flnm1 flnm2		shows differences between two files
cp flnm				copy file
mv flnm				move copy file
mv flnm1 flnm2		        rename file from flnm1 to flnm2 (overwriting flnm2 if it already existed)
^				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
> flnm			        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 flnm			print this file to the screen (rather than vi)
cat flnm | grep “criteria”	print only the criteria of the file to the screen
head flnm			first 10 lines of file in window
tail flnm			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
top				display processes currently running in real time (default sort is by highest CPU usage)
uptime				displays how long the system has been up (without reboot) and recent overall CPU usage
man cmd1			show the manual page for the command cmd1 (this is for unix commands, not programs we write)

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)


Sym Link

  • Make a Sym Link:
ln –s location sym link name

ex.
ln –s kent/src/hg/makeDb/trackDb trackDb
  • Use a Sym Link:
cd ~/sym link name

ex.
cd ~/trackDb

Resources