Linux tips - shell

uptime … time, how long is the machine running, average loads

top … running processes

wall … send message to all user (works over ssh too). Run: wall --> enter --> write message --> Ctrl-D

dpkg -L package_name … where the package_name is installed

which command_name … where the command_name is run from

Rscript -e 'print("Hello World")' … run R directly from shell

> output.log … output screen into output.log file

head -n 4 reboots.csv | tail -n 3 … pipe ( | ) makes output of first command to be input of the following one (take first 4 lines from file reboots.csv and then take last 3 of those lines)

find /usr -name *fastq … command line file search (look in /usr for files ending fastq)

find . -name "._*" -type f -delete … find and delete files starting "._" recursively in a current folder (".")

find . ! -name "*.txt" -type f … inverse find (all files not ending ".txt")

sudo chmod -R a+rwx /usr/lib/R … yes this basic :-)

wc -l file.txt … how many (l)ines in file.txt

du -sh * … /remember as doosh/, disk usage of files/dirs

df -h … free space on disk

sudo !! … execute last command as root

ls -laFR … list files recursively (with folders contents)

The Shell lecture on Software Carpentry, from Greg Wilson.

Data processing utils from Alexandre Matos Martins.

Useful Unix/Linux One-Liners for Bioinformatics from Stephen D. Turner.

shell history

history … history of shell commands
<Ctrl+R> –> search_term –> <Enter> … search history and execute
<Ctrl+R> –> search_term –> <Right Arrow> … search history and edit command

vim survival commands

<ESC> … get to COMMAND mode
i … get to INSERT mode (for editing)

:w … write (=save) (in COMMAND mode)
:x … save and exit (in COMMAND mode)
:q … quit (it won't let you if changes not saved) (in COMMAND mode)
:q! … quit discarding changes (you will not be prompted if changes not saved) (in COMMAND mode)


I know this is not Linux ... :-)

Feature Branch Workflow to use in projects? Branches for features and pull requests for review?

Work with pull requests

Branching and Merging

GIT branching

## create new branch called "feature_x" and switch to it:
git checkout -b feature_x

## working on a feature x while in its branch ...
## switch back to master (e.g. via RStudio interface)
## and in the shell
##(--no-ff will make git retain branching history):
git merge --no-ff feature_x

GIT fork -> clone -> local -> pull request

# make a fork on bitbucket web
# to make local clone run localy:
git clone
# go to RStudio and maek a new project form the resulting folder
# work on the fork and push to the fork repository on the web
# on the bitbucket repository "Create pull request" when all done.

# in the original repo on the web do the merge
# and in the original repo localy pull from web repo