Students
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # MAE_Bioinformatics I. Basic commands August 2023 ###### tags: `MAE`, `basic commands` ---UPDATED June 2021 [TOC] In this webpage, we will just cover very simple commands. ## basic unix commands [cheatsheet!](https://drive.google.com/file/d/10Jvm8IyezDfp0PWnGIXVZTNhpNevToRc/view?usp=sharing) https://drive.google.com/file/d/10Jvm8IyezDfp0PWnGIXVZTNhpNevToRc/view?usp=sharing mv, cp, ls, cd, rm... not familiar? Still not familiar? In the [MAE tutorial](https://jbpc.mbl.edu/unix-tutorial/MAE2020.html#Step_4:_Intro-to-Unix_tutorial) you will find many commands that will be useful in this course. https://jbpc.mbl.edu/unix-tutorial/MAE2020.html#Step_4:_Intro-to-Unix_tutorial Also, you can consult the bioinformatic lab I presentation [here](https://docs.google.com/presentation/d/14LhrA5ODxiwHsLnXhaL9AXO_G5t96mWLHeRwal56t24/edit?usp=sharing) https://docs.google.com/presentation/d/14LhrA5ODxiwHsLnXhaL9AXO_G5t96mWLHeRwal56t24/edit?usp=sharing ## Very brief recap Let's open the terminal and type ``` pwd ``` pwd -> print working directory you can use this command to check where you are! ``` ls ``` what happened? This list all the objects in a folder ls -> list Now type ``` mkdir newfolder ``` and type ``` ls ``` mkdir -> make a directory Now let's navigate to the new directory ``` cd newfolder ``` cd -> change directory did it work? let's check it what would you use to know where are you? ..... **tip** use the tab on your keyboard! this will fill up info for you so you don't have to type us much. if two files share a name, it will stop. type a little more and use the tab again. :) **more tips!** select and use `crt+shift c` to copy the text in the terminal use `crt+shift v` to paste it into the terminal ## how to make a text file in terminal type in terminal ``` cat > fileName.txt ``` now write (or paste) in the terminal ``` There are microbes everywhere. yes, on your keyboard too! :) ``` Press enter and crt +Z Did it work? use `ls` is the file there? Now, is the text in the file? Let's use head to check it. ``` head fileName.txt ``` :) ## now, let's remove the file We use `rm` -> remove to delete files and folder ``` rm fileName.txt ``` did it work? how would you check it? yes, let's use `ls` now, let's remove the folder to navigate back to the previous folder use `cd ..` use `ls` to check the folder objects. Can you see the `newfolder`? to remove a folder we will use ``` rm -fr newfolder ``` The flag `-fr` forces recurrent removal of objects within a folder ( so no need to eliminate all the files inside beforehand) ### listing files before removing (rm) A very useful thing is to use wildcards. For example `*_test.txt will` identify any file finished in `_test.txt` If you want to remove multiple files you can use the wild card `rm *_test.txt` BUT!! Remember that `rm` will remove files **forever**. To check if you have the right list of files replace `rm` with `echo`. It will show you the list of files without removing them. ``` echo *_pass_1.fastq.gz echo *_pass_2.fastq.gz echo *_unpaired_* ``` ### some tutorials This is the MAE-specific Unix tutorial. Always consult here if you have any doubts. https://jbpc.mbl.edu//unix-tutorial/ Others: http://www.ee.surrey.ac.uk/Teaching/Unix/ https://www.doc.ic.ac.uk/~wjk/UnixIntro/ **#this one has exercises** For the project part of the course, you should be familiar with mkdir (creates a directory) cd navigates to a directory ls list the folders or files in a directory rm removes a file rm -rf removes a directory mv moves a file for all these commands, if you have any doubts about how to use them, type the command + -h or --help . This will list the options for usage. You don't need to remember the commands. There are many many tutorials and cheat sheets. I like this [one](https://files.fosswire.com/2007/08/fwunixref.pdf) https://files.fosswire.com/2007/08/fwunixref.pdf ######### not needed################ ## screen This is probably the most important command you will learn today. Read all about the program [here ](https://kb.iu.edu/d/acuy) https://kb.iu.edu/d/acuy #### Creating and naming a screen session ``` screen -S sessionID ``` Screen opens a protected window. This is important because many steps you will be running will run for a **really** long type. Using `screen` the processes won't die if you close the terminal or your computer. You can give any name to a session (the sessionID would be any name you give e.g. qualitycheck) that is meaningful for identifying the screen session. So, if you open several, you can navigate to the desired one because they can be easily identified. #### Deattaching from a screen session Use `crt+a` followed by `d` to detach the terminal, which means to close the terminal screen window and return to the regular terminal **without** ending the process that is running in the screened session. #### Returning to a screen session ``` screen -r ``` If there is just one screen session open, this command will reconnect you to it. If several screen windows are open, there will be a list of select the ones of interest > [eperedo@minnie taxonomy_databases]$ screen -r > There are several suitable screens on: > 59479.tax (Detached) > 65328.database (Attached) > 45734.testscreen.FRot (Detached) > to return to a specific session, use the sessionID listed by `screen -r` ``` screen -r sessionID ``` #### Returning to an attached screen session If a session appears as Attached when the sessions are listed, use `screen -x sessionID` ``` screen -x 65328.database ``` #### Keeping a log of a screen session Most times it is useful to record what you type there are two options. 1. when you create the session use the flag -L (log) ``` screen -L -S test ``` This is a very easy system that will log #ALL# from beginning to end. It will create a log file "output.0" in the folder where you first launched the screen session. **Only one big caveat: If you open another screen in the same folder it will overwrite your file** 2. generate a file to log in to specific parts of the session Once in a screened session type `crt+a` release and press `:` a line of text will appear on the bottom of the terminal Type `logfile NAMEforlog.txt` and press enter (twice) If you want to log something, press `crt+a` followed by `H` in the bottom of the terminal a line saying creating file NAMEforlog.txt will appear, press enter all you type now will be recorded. to stop recording type again `crt+a` followed by `H` Recording will stop **supercool!** if you use `crt+a` followed by `H` it will append (instead of overwrite!) to the log file. To stop, once again `crt+a` followed by `H` #### Finishing a screen session type **exit** to close the screen session. #### How to kill a screen session Sometimes, it happens. Things go wrong. From inside the screen: typing `ctrl+a` followed by `k` ``` screen -X -S sessionID kill ``` kill all screen sessions: ``` screen -ls | grep '(Detached)' | awk 'sys {screen -S $1 -X quit}' ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully