SlideShare a Scribd company logo
Sol Genomics Network
Introduction to
UNIX command-line
Boyce Thompson Institute
March 17, 2015
Lukas Mueller & Noe Fernandez
Sol Genomics Network
• Terminal file system navigation
• Wildcards, shortcuts and special characters
• File permissions
• Compression UNIX commands
• Networking UNIX commands
• Basic NGS file formats
• Text files manipulation commands
• Command-line pipelines
• Introduction to bash scripts
Class Content
Sol Genomics Network
What is a virtual machine?
Sol Genomics Network
What is a terminal?
Sol Genomics Network
Origins of Linux.The UNIX operating system
Sol Genomics Network
Why use command-line?
• Most software for biological data analysis is used through
UNIX command-line terminal
• Most of the servers for biological data analysis use Linux as
operative system
• Data analysis on calculation servers are much faster since we
can use more CPUs and RAM than in a PC (e.g.: Boyce servers
has 64 cores and 1TB RAM)
• Large NGS data files can not be opened or loaded in most of
GUI-based software and web sites
• Compression commands are useful, since NGS large data files
usually are stored and shared as compressed files
Sol Genomics Network
Text handling commandsText handling commands
command > file saves STDOUT in a file
command >> file appends STDOUT in a file
cat file concatenate and print files
cat file1 file2 > file3 merges files 1 and 2 into file3
cat *fasta > all.fasta
concatenates all fasta files in
the current directory
head file prints first lines from a file
head -n 5 file prints first five lines from a file
tail file prints last lines from a file
tail -n 5 file prints last five lines from a file
less file view a file
less -N file includes line numbers
less -S file wraps long lines
grep ‘pattern’ file Prints lines matching a pattern
grep -c ‘pattern’ file counts lines matching a pattern
cut -f 1,3 file
retrieves data from selected
columns in a tab-delimited file
sort file sorts lines from a file
sort -u file sorts and return unique lines
uniq -c file filters adjacent repeated lines
wc file counts lines, words and bytes
paste file1 file2
concatenates the lines of input
files
paste -d “,”
concatenates the lines of input
files by commas
sed transforms text
File system CommandsFile system Commands
ls lists directories and files
ls -a lists all files including hidden files
ls -lh formatted list including more data
ls -t lists sorted by date
pwd returns path to working directory
cd dir changes directory
cd .. goes to parent directory
cd / goes to root directory
cd goes to home directory
touch file_name creates en empty file
cp file file_copy copy a file
cp -r copy files contained in directories
rm file deletes a file
rm -r dir deletes a directory and its files
mv file1 file2 moves or renames a file
mkdir dir_name creates a directory
rmdir dir_name deletes a directory
locate file_name searches a file
man command shows commands manual
top shows process activity
df -h shows disk space info
Networking CommandsNetworking Commands
wget URL download a file from an URL
ssh user@server connects to a server
scp copy files between computers
apt-get install installs applications in linux
Compression commandsCompression commands
gzip/zip compress a file
gunzip/unzip decompress a file
tar -cvf groups files
tar -xvf ungroups files
tar -zcvf groups and gzip files
tar -zxvf gunzip and ungroups files
UNIX Command-Line Cheat Sheet
BTI-SGN Bioinformatics Course 2014
•File system commands
File system navigation
http://www.slideshare.net/NoFernndezPozo/unix-command-sheet2014
https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf
Download the cheat sheet from:
Sol Genomics Network
File system navigation
File Browser Terminal
=
Sol Genomics Network
Home and Root directories
/bin, /lib, /usr code and code libraries
/var logs and other data
/home user directories
/tmp temporary files
/etc configuration information
/proc special file system in Linux
/home/bioinfo
/home/noe
/home/noe/Desktop
Root directory
Home directory
Sol Genomics Network
Anatomy of a UNIX command
grep -c -A 3 --ignore-case file.txt
command
Simple option flag
(short form)
option (long form)option with
argument
argument
man grep
print grep manual
Sol Genomics Network
ls, cd and pwd to navigate the file system
• where am I? pwd
• how to change current directory cd
• what files and directories are in my current directory? ls
pwd
return current work directory
Sol Genomics Network
ls
list directories and files in current directory
ls lists directories and files
ls -a
list all directories and files, including hidden files
ls -l -h -t
time sorted
ls -lhS
size sorted
ls -l -h
list in long format
human readable
Sol Genomics Network
ls lists directories and files
r readable
w writable
x executable or searchable
- not rwx
d Directory
- Regular file
d rwx r-x r-x
user
group
other
owner user
permissions
owner group
date File namesizelinks #
Sol Genomics Network
Use up and down
arrows to navigate
the command
history
Wildcards, history and some shortcuts
ls *txt
ls P*s list files starting with P and ending with s,
e.g.: Pictures, Photos, Programs ...
list all txt files in current directory
ctrl-c stop process
ctrl-a go to begin of line
ctrl-e go to end of line
ctrl-r search in command history
Sol Genomics Network
Escaping special characters
Tip: file names in lower
case and with underscores
instead of spaces
! @ $ ^ & * ~ ? . | / [ ] < >  ` " ;# ( )
Use tab key to
autocomplete names
ls my folder list a folder containing a space
ls my_folder list a folder
Sol Genomics Network
Use tab key to
autocomplete names
cd changes directory
cd Desktop
changes directory to Desktop
cd ..
goes to parent directory
cd goes to home directory
cd / goes to root directory
cd - goes to previous directory
Sol Genomics Network
Absolute and relative paths
ls /home/user/Desktop
list files in Desktop using an absolute path
ls Desktop/
list files in Documents using a relative path (from your home: /home/bioinfo)
ls ~/Desktop
list files in Desktop using your home as a reference
Sol Genomics Network
Absolute and relative paths
ls /home/bioinfo/Desktop
ls ~/Desktop
Absolute paths do not depend on where you are
~/ is equivalent to /home/bioinfo/
Sol Genomics Network
Absolute and relative paths
ls ../Documents
cd Desktop/
goes to Desktop from when you are in your home (/home/bioinfo)
list files from Documents when you are in Desktop
Sol Genomics Network
Create, copy, move and delete files
touch tmp_file.txt
creates an empty file called tmp_file.txt
cp tmp_file.txt file_copy.txt
copies tmp_file.txt in file_copy.txt
rm file.txt deletes file.txt
mv file1.txt file2.txt moves or rename a file
Tip: file names in lower
case and with underscores
instead of spaces
Sol Genomics Network
Locate a file
locate unix_class_file_samples.zip
Locate the path for the file unix_class_file_samples.zip
locate unix_class
Locate the path for all the files containing unix_class
Sol Genomics Network
Create, copy and delete directories
mkdir dir_name
creates an empty directory called dir_name
rmdir dir_name
deletes dir_name directory if it is empty
cp -r dir_name dir_copy
copy dir_name and its files in a new folder
rm -r dir_name delete dir_name and its files
Sol Genomics Network
wc file counts lines, words and bytes
paste file1 file2
concatenates the lines of input
files
paste -d “,”
concatenates the lines of input
files by commas
sed transforms text
locate file_name searches a file
man command shows commands manual
top shows process activity
df -h shows disk space info
Networking CommandsNetworking Commands
wget URL download a file from an URL
ssh user@server connects to a server
scp copy files between computers
apt-get install installs applications in linux
Compression commandsCompression commands
gzip/zip compress a file
gunzip/unzip decompress a file
tar -cvf groups files
tar -xvf ungroups files
tar -zcvf groups and gzip files
tar -zxvf gunzip and ungroups files
Text handling commandsText handling commands
command > file saves STDOUT in a file
command >> file appends STDOUT in a file
cat file concatenate and print files
cat file1 file2 > file3 merges files 1 and 2 into file3
cat *fasta > all.fasta
concatenates all fasta files in
the current directory
head file prints first lines from a file
head -n 5 file prints first five lines from a file
tail file prints last lines from a file
tail -n 5 file prints last five lines from a file
less file view a file
less -N file includes line numbers
less -S file wraps long lines
grep ‘pattern’ file Prints lines matching a pattern
grep -c ‘pattern’ file counts lines matching a pattern
cut -f 1,3 file
retrieves data from selected
columns in a tab-delimited file
sort file sorts lines from a file
sort -u file sorts and return unique lines
uniq -c file filters adjacent repeated lines
wc file counts lines, words and bytes
paste file1 file2
concatenates the lines of input
files
paste -d “,”
concatenates the lines of input
files by commas
sed transforms text
File system CommandsFile system Commands
ls lists directories and files
ls -a lists all files including hidden files
ls -lh formatted list including more data
ls -t lists sorted by date
pwd returns path to working directory
cd dir changes directory
cd .. goes to parent directory
cd / goes to root directory
cd goes to home directory
touch file_name creates en empty file
cp file file_copy copy a file
cp -r copy files contained in directories
rm file deletes a file
rm -r dir deletes a directory and its files
mv file1 file2 moves or renames a file
mkdir dir_name creates a directory
rmdir dir_name deletes a directory
locate file_name searches a file
man command shows commands manual
top shows process activity
df -h shows disk space info
Networking CommandsNetworking Commands
wget URL download a file from an URL
ssh user@server connects to a server
scp copy files between computers
apt-get install installs applications in linux
Compression commandsCompression commands
gzip/zip compress a file
gunzip/unzip decompress a file
tar -cvf groups files
tar -xvf ungroups files
tar -zcvf groups and gzip files
tar -zxvf gunzip and ungroups files
UNIX Command-Line Cheat Sheet
BTI-SGN Bioinformatics Course 2014
Compression commands
tar -zcvf file.tar.gz f1 f2
groups and compress files
tar -zxvf file.tar.gz
decompress and ungroup a tar.gz file files, directories or wildcards
Sol Genomics Network
Compression commands
gzip f1.txt
gunzip file.gz
unzip file.zip decompress file.zip
zip file.zip f1 f2
compress files f1 and f2 in file.zip
compress file f1.txt in f1.txt.gz
decompress file.gz
Sol Genomics Network
Text handling commandsText handling commands
command > file saves STDOUT in a file
command >> file appends STDOUT in a file
cat file concatenate and print files
cat file1 file2 > file3 merges files 1 and 2 into file3
cat *fasta > all.fasta
concatenates all fasta files in
the current directory
head file prints first lines from a file
head -n 5 file prints first five lines from a file
tail file prints last lines from a file
tail -n 5 file prints last five lines from a file
less file view a file
less -N file includes line numbers
less -S file wraps long lines
grep ‘pattern’ file Prints lines matching a pattern
grep -c ‘pattern’ file counts lines matching a pattern
cut -f 1,3 file
retrieves data from selected
columns in a tab-delimited file
sort file sorts lines from a file
sort -u file sorts and return unique lines
uniq -c file filters adjacent repeated lines
wc file counts lines, words and bytes
paste file1 file2
concatenates the lines of input
files
paste -d “,”
concatenates the lines of input
files by commas
sed transforms text
File system CommandsFile system Commands
ls lists directories and files
ls -a lists all files including hidden files
ls -lh formatted list including more data
ls -t lists sorted by date
pwd returns path to working directory
cd dir changes directory
cd .. goes to parent directory
cd / goes to root directory
cd goes to home directory
touch file_name creates en empty file
cp file file_copy copy a file
cp -r copy files contained in directories
rm file deletes a file
rm -r dir deletes a directory and its files
mv file1 file2 moves or renames a file
mkdir dir_name creates a directory
rmdir dir_name deletes a directory
locate file_name searches a file
man command shows commands manual
top shows process activity
df -h shows disk space info
Networking CommandsNetworking Commands
wget URL download a file from an URL
ssh user@server connects to a server
scp copy files between computers
apt-get install installs applications in linux
Compression commandsCompression commands
gzip/zip compress a file
gunzip/unzip decompress a file
tar -cvf groups files
tar -xvf ungroups files
tar -zcvf groups and gzip files
tar -zxvf gunzip and ungroups files
UNIX Command-Line Cheat Sheet
BTI-SGN Bioinformatics Course 2014
•Networking commands
Networking Commands
Sol Genomics Network
scp noe@boyce.sgn.cornell.edu:/home/noe/file.txt .
copy file.txt from your home in the server to the current directory in your computer
Networking Commands
wget http://btiplantbioinfocourse.files.wordpress.com/2014/01/unix_command_sheet_2014.pdf
downloads the UNIX command line cheat sheet PDF file
ssh user_name@server_adress
connects your terminal to your account in a server
Tip: use the command pwd to get the path for cp and scp
Sol Genomics Network
scp file.txt noe@boyce.sgn.cornell.edu:
copy file.txt from the current directory in my computer to my home in the server
Networking Commands
ssh noe@boyce.sgn.cornell.edu
connects my terminal to my account Boyce, the BTI server
scp -r dir/ noe@boyce.sgn.cornell.edu:
copy the folder dir and all its files and subdirectories to my home in the server
Sol Genomics Network
Useful commands in the server
top
display and update sorted information about processes
df -h shows disk space information
Sol Genomics Network
q quit
u user (top -u user)
M sort by memory usage
Top displays and update sorted information about processes
Sol Genomics Network
Commands to install software
sudo apt-get install pbzip2
installs pbzip2 in your computer
call the command with super user permissions
aptitude search blast
sudo aptitude install blast2
Sol Genomics Network
1. Go to your Desktop directory using the command cd
2. Use the command touch to create a file called:
Do not Use “special characters” in file names!.txt
3. Use the command rm to delete that file
4. Use the command mkdir to create a folder called unix_data in your desktop
5. Copy the file unix_class_file_samples.zip from your folder Data, in your home, to the
folder unix_data, in your desktop
6. Uncompress the file unix_class_file_samples.zip in /home/bioinfo/Desktop/unix_data
7. Use the command rm with the option -r to remove the _MACOSX folder
8. Use the command wget to download the “UNIX command line cheat sheet” PDF from:
https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf
Exercises

More Related Content

PDF
SGN Introduction to UNIX Command-line 2015 part 2
PDF
Unix Command Line Productivity Tips
PPTX
Know the UNIX Commands
PDF
Introduction to UNIX Command-Lines with examples
PDF
Unix command line concepts
PDF
Bozorgmeh os lab
PDF
50 most frequently used unix linux commands (with examples)
PDF
Os lab manual
SGN Introduction to UNIX Command-line 2015 part 2
Unix Command Line Productivity Tips
Know the UNIX Commands
Introduction to UNIX Command-Lines with examples
Unix command line concepts
Bozorgmeh os lab
50 most frequently used unix linux commands (with examples)
Os lab manual

What's hot (20)

PDF
Basic linux commands
PPTX
Linux command for beginners
PPTX
Unix slideshare
DOCX
Linux final exam
PDF
Operating system lab manual
PPT
Unix(introduction)
PPTX
Unix OS & Commands
DOC
Unix Basics For Testers
PPT
Linux basic commands
PPT
Basic Linux day 2
PDF
Unix practical file
PPT
101 3.4 use streams, pipes and redirects
PPTX
Piping into-php
PDF
Basic linux commands
PPT
Linux commands
PDF
Basic unix commands_1
PPT
101 4.1 create partitions and filesystems
ODP
Linux commands
PDF
One Page Linux Manual
PPT
101 3.2 process text streams using filters
Basic linux commands
Linux command for beginners
Unix slideshare
Linux final exam
Operating system lab manual
Unix(introduction)
Unix OS & Commands
Unix Basics For Testers
Linux basic commands
Basic Linux day 2
Unix practical file
101 3.4 use streams, pipes and redirects
Piping into-php
Basic linux commands
Linux commands
Basic unix commands_1
101 4.1 create partitions and filesystems
Linux commands
One Page Linux Manual
101 3.2 process text streams using filters
Ad

Similar to SGN Introduction to UNIX Command-line 2015 part 1 (20)

PDF
Unix Command-Line Cheat Sheet BTI2014
PPTX
Introduction to linux2
PPTX
Linux System commands Essentialsand Basics.pptx
PPTX
OS-Module 2 Linux Programming Important topics
PPT
Linux presentation
PPTX
Basic Linux Commands with syntax and functions
PPTX
Basic Linux Commands and implementation with Examples
PPTX
linux chapter 5.pptx lesson About introduction to linux
PPT
Linux ppt
PDF
Lecture1 2 intro-unix
PDF
Linux Command Line - By Ranjan Raja
PDF
Linux file commands and shell scripts
PPT
PDF
Comenzi unix
PPTX
Introduction to linux day1
PDF
Quick guide of the most common linux commands
PPT
managing-the-linux-file-system_suse_.ppt
PPT
managing-the-linux-file-system________________________
PPTX
PPTX
2. UNIX OS System Architecture easy.pptx
Unix Command-Line Cheat Sheet BTI2014
Introduction to linux2
Linux System commands Essentialsand Basics.pptx
OS-Module 2 Linux Programming Important topics
Linux presentation
Basic Linux Commands with syntax and functions
Basic Linux Commands and implementation with Examples
linux chapter 5.pptx lesson About introduction to linux
Linux ppt
Lecture1 2 intro-unix
Linux Command Line - By Ranjan Raja
Linux file commands and shell scripts
Comenzi unix
Introduction to linux day1
Quick guide of the most common linux commands
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system________________________
2. UNIX OS System Architecture easy.pptx
Ad

More from solgenomics (20)

PDF
Sl4.0 and ITAG4.0
PDF
Cassavabase-PhenoApps demo ISTRC 2018
PDF
Cassavabase-PhenoApp sample tracking
PDF
breeding informatics solutions at SGN
PDF
Musabase PAG 2018
PDF
Cassavabase workshop ibadan March17
PDF
Improvements in the Tomato Reference Genome (SL3.0) and Annotation (ITAG3.0)
PPT
SolGS Hyderabad conference 2016
PPTX
Musa base phenotyping workflow demo
PPT
SolGS workshop 2016
PPTX
Cassavabase workshop IITA oct2016
PDF
Sql cheat sheet
PDF
Introduction to SQL
PPTX
YamBase phenotyping workflow demo
PPTX
Introduction to YamBase
PDF
Cassavabase general presentation PAG 2016
PDF
Cassavabase SolGS presentation PAG 2016
PDF
Cassavabase SolGS poster PAG 2016
PDF
1 introduction to cassavabase
PDF
2 Cassavabase workshop: search menu
Sl4.0 and ITAG4.0
Cassavabase-PhenoApps demo ISTRC 2018
Cassavabase-PhenoApp sample tracking
breeding informatics solutions at SGN
Musabase PAG 2018
Cassavabase workshop ibadan March17
Improvements in the Tomato Reference Genome (SL3.0) and Annotation (ITAG3.0)
SolGS Hyderabad conference 2016
Musa base phenotyping workflow demo
SolGS workshop 2016
Cassavabase workshop IITA oct2016
Sql cheat sheet
Introduction to SQL
YamBase phenotyping workflow demo
Introduction to YamBase
Cassavabase general presentation PAG 2016
Cassavabase SolGS presentation PAG 2016
Cassavabase SolGS poster PAG 2016
1 introduction to cassavabase
2 Cassavabase workshop: search menu

Recently uploaded (20)

PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
Placing the Near-Earth Object Impact Probability in Context
PDF
HPLC-PPT.docx high performance liquid chromatography
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPTX
Cell Membrane: Structure, Composition & Functions
PDF
. Radiology Case Scenariosssssssssssssss
PPT
POSITIONING IN OPERATION THEATRE ROOM.ppt
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PPTX
Derivatives of integument scales, beaks, horns,.pptx
PPTX
Classification Systems_TAXONOMY_SCIENCE8.pptx
PPTX
BIOMOLECULES PPT........................
PPTX
microscope-Lecturecjchchchchcuvuvhc.pptx
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PDF
Sciences of Europe No 170 (2025)
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
Placing the Near-Earth Object Impact Probability in Context
HPLC-PPT.docx high performance liquid chromatography
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
Cell Membrane: Structure, Composition & Functions
. Radiology Case Scenariosssssssssssssss
POSITIONING IN OPERATION THEATRE ROOM.ppt
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
Phytochemical Investigation of Miliusa longipes.pdf
Derivatives of integument scales, beaks, horns,.pptx
Classification Systems_TAXONOMY_SCIENCE8.pptx
BIOMOLECULES PPT........................
microscope-Lecturecjchchchchcuvuvhc.pptx
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
Sciences of Europe No 170 (2025)
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5

SGN Introduction to UNIX Command-line 2015 part 1

  • 1. Sol Genomics Network Introduction to UNIX command-line Boyce Thompson Institute March 17, 2015 Lukas Mueller & Noe Fernandez
  • 2. Sol Genomics Network • Terminal file system navigation • Wildcards, shortcuts and special characters • File permissions • Compression UNIX commands • Networking UNIX commands • Basic NGS file formats • Text files manipulation commands • Command-line pipelines • Introduction to bash scripts Class Content
  • 3. Sol Genomics Network What is a virtual machine?
  • 4. Sol Genomics Network What is a terminal?
  • 5. Sol Genomics Network Origins of Linux.The UNIX operating system
  • 6. Sol Genomics Network Why use command-line? • Most software for biological data analysis is used through UNIX command-line terminal • Most of the servers for biological data analysis use Linux as operative system • Data analysis on calculation servers are much faster since we can use more CPUs and RAM than in a PC (e.g.: Boyce servers has 64 cores and 1TB RAM) • Large NGS data files can not be opened or loaded in most of GUI-based software and web sites • Compression commands are useful, since NGS large data files usually are stored and shared as compressed files
  • 7. Sol Genomics Network Text handling commandsText handling commands command > file saves STDOUT in a file command >> file appends STDOUT in a file cat file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta concatenates all fasta files in the current directory head file prints first lines from a file head -n 5 file prints first five lines from a file tail file prints last lines from a file tail -n 5 file prints last five lines from a file less file view a file less -N file includes line numbers less -S file wraps long lines grep ‘pattern’ file Prints lines matching a pattern grep -c ‘pattern’ file counts lines matching a pattern cut -f 1,3 file retrieves data from selected columns in a tab-delimited file sort file sorts lines from a file sort -u file sorts and return unique lines uniq -c file filters adjacent repeated lines wc file counts lines, words and bytes paste file1 file2 concatenates the lines of input files paste -d “,” concatenates the lines of input files by commas sed transforms text File system CommandsFile system Commands ls lists directories and files ls -a lists all files including hidden files ls -lh formatted list including more data ls -t lists sorted by date pwd returns path to working directory cd dir changes directory cd .. goes to parent directory cd / goes to root directory cd goes to home directory touch file_name creates en empty file cp file file_copy copy a file cp -r copy files contained in directories rm file deletes a file rm -r dir deletes a directory and its files mv file1 file2 moves or renames a file mkdir dir_name creates a directory rmdir dir_name deletes a directory locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Networking CommandsNetworking Commands wget URL download a file from an URL ssh user@server connects to a server scp copy files between computers apt-get install installs applications in linux Compression commandsCompression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files UNIX Command-Line Cheat Sheet BTI-SGN Bioinformatics Course 2014 •File system commands File system navigation http://www.slideshare.net/NoFernndezPozo/unix-command-sheet2014 https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf Download the cheat sheet from:
  • 8. Sol Genomics Network File system navigation File Browser Terminal =
  • 9. Sol Genomics Network Home and Root directories /bin, /lib, /usr code and code libraries /var logs and other data /home user directories /tmp temporary files /etc configuration information /proc special file system in Linux /home/bioinfo /home/noe /home/noe/Desktop Root directory Home directory
  • 10. Sol Genomics Network Anatomy of a UNIX command grep -c -A 3 --ignore-case file.txt command Simple option flag (short form) option (long form)option with argument argument man grep print grep manual
  • 11. Sol Genomics Network ls, cd and pwd to navigate the file system • where am I? pwd • how to change current directory cd • what files and directories are in my current directory? ls pwd return current work directory
  • 12. Sol Genomics Network ls list directories and files in current directory ls lists directories and files ls -a list all directories and files, including hidden files ls -l -h -t time sorted ls -lhS size sorted ls -l -h list in long format human readable
  • 13. Sol Genomics Network ls lists directories and files r readable w writable x executable or searchable - not rwx d Directory - Regular file d rwx r-x r-x user group other owner user permissions owner group date File namesizelinks #
  • 14. Sol Genomics Network Use up and down arrows to navigate the command history Wildcards, history and some shortcuts ls *txt ls P*s list files starting with P and ending with s, e.g.: Pictures, Photos, Programs ... list all txt files in current directory ctrl-c stop process ctrl-a go to begin of line ctrl-e go to end of line ctrl-r search in command history
  • 15. Sol Genomics Network Escaping special characters Tip: file names in lower case and with underscores instead of spaces ! @ $ ^ & * ~ ? . | / [ ] < > ` " ;# ( ) Use tab key to autocomplete names ls my folder list a folder containing a space ls my_folder list a folder
  • 16. Sol Genomics Network Use tab key to autocomplete names cd changes directory cd Desktop changes directory to Desktop cd .. goes to parent directory cd goes to home directory cd / goes to root directory cd - goes to previous directory
  • 17. Sol Genomics Network Absolute and relative paths ls /home/user/Desktop list files in Desktop using an absolute path ls Desktop/ list files in Documents using a relative path (from your home: /home/bioinfo) ls ~/Desktop list files in Desktop using your home as a reference
  • 18. Sol Genomics Network Absolute and relative paths ls /home/bioinfo/Desktop ls ~/Desktop Absolute paths do not depend on where you are ~/ is equivalent to /home/bioinfo/
  • 19. Sol Genomics Network Absolute and relative paths ls ../Documents cd Desktop/ goes to Desktop from when you are in your home (/home/bioinfo) list files from Documents when you are in Desktop
  • 20. Sol Genomics Network Create, copy, move and delete files touch tmp_file.txt creates an empty file called tmp_file.txt cp tmp_file.txt file_copy.txt copies tmp_file.txt in file_copy.txt rm file.txt deletes file.txt mv file1.txt file2.txt moves or rename a file Tip: file names in lower case and with underscores instead of spaces
  • 21. Sol Genomics Network Locate a file locate unix_class_file_samples.zip Locate the path for the file unix_class_file_samples.zip locate unix_class Locate the path for all the files containing unix_class
  • 22. Sol Genomics Network Create, copy and delete directories mkdir dir_name creates an empty directory called dir_name rmdir dir_name deletes dir_name directory if it is empty cp -r dir_name dir_copy copy dir_name and its files in a new folder rm -r dir_name delete dir_name and its files
  • 23. Sol Genomics Network wc file counts lines, words and bytes paste file1 file2 concatenates the lines of input files paste -d “,” concatenates the lines of input files by commas sed transforms text locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Networking CommandsNetworking Commands wget URL download a file from an URL ssh user@server connects to a server scp copy files between computers apt-get install installs applications in linux Compression commandsCompression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files Text handling commandsText handling commands command > file saves STDOUT in a file command >> file appends STDOUT in a file cat file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta concatenates all fasta files in the current directory head file prints first lines from a file head -n 5 file prints first five lines from a file tail file prints last lines from a file tail -n 5 file prints last five lines from a file less file view a file less -N file includes line numbers less -S file wraps long lines grep ‘pattern’ file Prints lines matching a pattern grep -c ‘pattern’ file counts lines matching a pattern cut -f 1,3 file retrieves data from selected columns in a tab-delimited file sort file sorts lines from a file sort -u file sorts and return unique lines uniq -c file filters adjacent repeated lines wc file counts lines, words and bytes paste file1 file2 concatenates the lines of input files paste -d “,” concatenates the lines of input files by commas sed transforms text File system CommandsFile system Commands ls lists directories and files ls -a lists all files including hidden files ls -lh formatted list including more data ls -t lists sorted by date pwd returns path to working directory cd dir changes directory cd .. goes to parent directory cd / goes to root directory cd goes to home directory touch file_name creates en empty file cp file file_copy copy a file cp -r copy files contained in directories rm file deletes a file rm -r dir deletes a directory and its files mv file1 file2 moves or renames a file mkdir dir_name creates a directory rmdir dir_name deletes a directory locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Networking CommandsNetworking Commands wget URL download a file from an URL ssh user@server connects to a server scp copy files between computers apt-get install installs applications in linux Compression commandsCompression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files UNIX Command-Line Cheat Sheet BTI-SGN Bioinformatics Course 2014 Compression commands tar -zcvf file.tar.gz f1 f2 groups and compress files tar -zxvf file.tar.gz decompress and ungroup a tar.gz file files, directories or wildcards
  • 24. Sol Genomics Network Compression commands gzip f1.txt gunzip file.gz unzip file.zip decompress file.zip zip file.zip f1 f2 compress files f1 and f2 in file.zip compress file f1.txt in f1.txt.gz decompress file.gz
  • 25. Sol Genomics Network Text handling commandsText handling commands command > file saves STDOUT in a file command >> file appends STDOUT in a file cat file concatenate and print files cat file1 file2 > file3 merges files 1 and 2 into file3 cat *fasta > all.fasta concatenates all fasta files in the current directory head file prints first lines from a file head -n 5 file prints first five lines from a file tail file prints last lines from a file tail -n 5 file prints last five lines from a file less file view a file less -N file includes line numbers less -S file wraps long lines grep ‘pattern’ file Prints lines matching a pattern grep -c ‘pattern’ file counts lines matching a pattern cut -f 1,3 file retrieves data from selected columns in a tab-delimited file sort file sorts lines from a file sort -u file sorts and return unique lines uniq -c file filters adjacent repeated lines wc file counts lines, words and bytes paste file1 file2 concatenates the lines of input files paste -d “,” concatenates the lines of input files by commas sed transforms text File system CommandsFile system Commands ls lists directories and files ls -a lists all files including hidden files ls -lh formatted list including more data ls -t lists sorted by date pwd returns path to working directory cd dir changes directory cd .. goes to parent directory cd / goes to root directory cd goes to home directory touch file_name creates en empty file cp file file_copy copy a file cp -r copy files contained in directories rm file deletes a file rm -r dir deletes a directory and its files mv file1 file2 moves or renames a file mkdir dir_name creates a directory rmdir dir_name deletes a directory locate file_name searches a file man command shows commands manual top shows process activity df -h shows disk space info Networking CommandsNetworking Commands wget URL download a file from an URL ssh user@server connects to a server scp copy files between computers apt-get install installs applications in linux Compression commandsCompression commands gzip/zip compress a file gunzip/unzip decompress a file tar -cvf groups files tar -xvf ungroups files tar -zcvf groups and gzip files tar -zxvf gunzip and ungroups files UNIX Command-Line Cheat Sheet BTI-SGN Bioinformatics Course 2014 •Networking commands Networking Commands
  • 26. Sol Genomics Network scp [email protected]:/home/noe/file.txt . copy file.txt from your home in the server to the current directory in your computer Networking Commands wget http://btiplantbioinfocourse.files.wordpress.com/2014/01/unix_command_sheet_2014.pdf downloads the UNIX command line cheat sheet PDF file ssh user_name@server_adress connects your terminal to your account in a server Tip: use the command pwd to get the path for cp and scp
  • 27. Sol Genomics Network scp file.txt [email protected]: copy file.txt from the current directory in my computer to my home in the server Networking Commands ssh [email protected] connects my terminal to my account Boyce, the BTI server scp -r dir/ [email protected]: copy the folder dir and all its files and subdirectories to my home in the server
  • 28. Sol Genomics Network Useful commands in the server top display and update sorted information about processes df -h shows disk space information
  • 29. Sol Genomics Network q quit u user (top -u user) M sort by memory usage Top displays and update sorted information about processes
  • 30. Sol Genomics Network Commands to install software sudo apt-get install pbzip2 installs pbzip2 in your computer call the command with super user permissions aptitude search blast sudo aptitude install blast2
  • 31. Sol Genomics Network 1. Go to your Desktop directory using the command cd 2. Use the command touch to create a file called: Do not Use “special characters” in file names!.txt 3. Use the command rm to delete that file 4. Use the command mkdir to create a folder called unix_data in your desktop 5. Copy the file unix_class_file_samples.zip from your folder Data, in your home, to the folder unix_data, in your desktop 6. Uncompress the file unix_class_file_samples.zip in /home/bioinfo/Desktop/unix_data 7. Use the command rm with the option -r to remove the _MACOSX folder 8. Use the command wget to download the “UNIX command line cheat sheet” PDF from: https://btiplantbioinfocourse.files.wordpress.com/2014/02/unix_command_sheet_2014.pdf Exercises