A Practical cheat sheet
Command | Description | Usage example |
---|---|---|
echo | Print out a string to screen | Echo 'Hello World' |
man | Look at the manual page of a command | man man |
clear | Clear the screen | clear |
<tab> | Complete a path or command | <tab> |
cd | Change directory | cd /directory/path/ |
pwd | Print Working Directory | pwd |
ls | List the contents of a directory | ls /directory/path/ |
mkdir | Make a directory | mkdir /directory/path/new_directory/ |
cp | Copy content to another path | cp /directory/path/file.txt /directory/path/new_directory/ |
mv | Move content to a new path | mv /directory/path/file.txt /directory/path/new_directory/ |
rm | Delete content | rm /directory/path/file.txt |
cat | Print contents of a file to screen | cat /directory/path/file.txt |
head | Print out the first n lines of a file to screen | head -n 10 /directory/path/file.txt |
tail | Print the last n lines of a file to screen | tail -n 12 /directory/path/file.txt |
less | Read a file one page at a time | less /directory/path/file.txt |
wc | Print out line, word and byte count | wc /directory/path/file.txt |
grep | Search for lines that contain a specific pattern | grep "pattern" /directory/path/file.txt |
vim | Text editor | vim /directory/path/file.txt |
B Windows terminals
If you are on a windows you may need to download a terminal program to ssh
to a linux cluster. Thankfully Macs come with an in built terminal. Below are a few suggestions of windows terminals:
C ssh
The ssh
(Secure Shell Protocol) command is used to login into cluster and other machines. For more information on this please see the following online tutorial: https://opensource.com/article/20/9/ssh
D File transferring
When working with a remote cluster you will most likely want to transfer files from your computer to the cluster and vice versa.
For transferring on windows machine I would suggest WinSCP.
For transferring on Macs I would suggest FileZIlla
E Mamba
E.1 Mamba installation
Once you start using bioinformatic tools you will notice that a lot of installing is required. I would highly suggest using Mamba for this purpose.
Mamba is a reimplementation of conda. It is a great tool for installing bioinformatic packages including R packages.
Mamba github: https://github.com/mamba-org/mamba
The best way to use Mamba is to install Miniforge. It has both Conda and Mamba commands.
Miniforge installation: https://github.com/conda-forge/miniforge
Mamba guide: https://mamba.readthedocs.io/en/latest/user_guide/mamba.html
F vim
To enter the vim
text editor you can use the command vim
. The command is: vim file.txt
.
vim
can be run with a previous file name which you can then edit or a new file name in which case you will create a new file.
Once you are in the vim
editor there are two main modes:
- Command mode: This is the starting mode of
vim
. It can be used to enter commands but not for typing. - Insert mode: This mode can be used to insert characters into the text. Pasting only works properly in insert mode. You will know you are in insert mode as at the bottom of the screen will be “-- INSERT --”.
- To enter insert mode press i
- To escape Insert mode press esc
Below are a subset of commands you can use in the command mode of vim.
- :q - Quit vim. Will fail if there are any unsaved changes
- :w - Save the file
- :wq - Save and quit
- :x - Save and quit
- :q! - Quit and throw away unsaved changes
- :saveas file - Save file as. File name can be changed
- :w file - Save file as. File name can be changed
- arrow keys - Navigate the text. (works in insert mode too)
- ^ - Jump to the start of a line
- $ - Jump to the end of a line
- /pattern - Search for pattern
- n - Repeat search in same direction
- N - Repeat search in reverse direction
- dd - Delete the current line
- i - Enter insert mode
- 1G - Go to the first line in the file. Number can be changed
- G - Go to the last line of the file