Theorywiki
      • 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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: "commands in terminal (needed for HPC05 cluster)" # date: "2019-02-11" # tag: "how-to" --- Operating the HPC05 cluster requires you to operate a computer by the command line. On Mac or Linux, this programme is called "terminal". On Windows it is called "command prompt". However, the Windows system uses a different coding language to conduct operations. As we are unfamiliar with this format - and all our instructions are written assuming a Linux/Mac-like terminal - we recommend installing one of the following programmes: [WSL Ubuntu](https://www.microsoft.com/store/productId/9NBLGGH4MSV6) [https://www.cygwin.com/](https://www.cygwin.com/) This will provide you with a "Terminal" mimic in a sense in which you can do all the same things as you can on Mac or Linux. ## How to run Python command line When writing a Python code and executing it you probably use some convenient editor that has some kind of auto-completion and user interface allowing you to easily run the script. This is obviously the most pleasant way of doing things. However, when operating the HPC05 cluster you will not be able to see the screen. So how do I know run Python? The answer is to open the command prompt/terminal and 'give the computer the instructions by hand'. When doing the above, you will notice your computer started Python. You can now type as if you would do with any other script. Obviously, typing things in the terminal is not pleasant at all and is therefore not something you will be doing (ever :P). Still, this shows you what the terminal does: You told your computer to start the programme called "Python" ``` python script.py ``` will execute the Python code written in script.py (and is therefore the equivalent of clicking on the "play button" in many graphical interface based interpreters). ## Allowing for command line arguments in Python Say I have simulation that takes in two parameter values that I want to be varying using the cluster's computer power. I first will need to allow my computer to understand that "script.py" takes in these two global input parameters for the code. The following structure in any Python code will allow you to run the script.py via the command line using additional/variable input parameters. ```python import sys def main(argv): parameter1 = float(argv\[1\]) parameter2 = int(argv\[2\]) return if \_\_name\_\_ == "\_\_main\_\_": main(sys.argv) ``` If this code is saved as 'script.py' , it can be run command line using ``` python script.py param1 param2 ``` In combination with the above structure of your Python code, it is equivalent of now running the function called 'main()' (by default), to which the following list will be given as input ``` argv = \['script.py', 'param1' ,'param2'\] ``` Hence, when unpacking the parameters inside your Python code note the following: 1\. The command line is interpreted as a 'string' (text). Hence if I type the value 32, I must tell the Python code to convert it into either a floating point number of integer number (depending on its usage). 2\. Therefore, If my code takes the name of a output file as input, no conversion is needed as a file name should be a string-value anyways. 3\. I started by unpacking value argv\[1\], not 0. The first argument of the argv list by convention will equal the name of the script itself. (argv is the list of input arguments given to the 'python' call on your command line) ## Useful commands on Terminal (Bash) Perhaps the most useful of them al: 'the TAB key' enables autocompletion. To navigate from folder to folder ``` cd Documents/... ``` Navigate one folder up (backwards) ``` cd .. ``` Back to the start/reset to folder I started my Terminal session from ``` cd ``` To see al files present in the folder you are in ``` ls ``` also show 'hidden files' (for instance any file name that starts with a '.' ) ``` ls -a ``` To make a new folder/directory ``` mkdir DirectoryName ``` To make a directory in some different folder ``` mkdir Location/DirectoryName ``` To move a file to a different directory ``` mv MoveThisFile ToThisLocation ``` To copy a file ``` cp NameOfFile CopyIntoThisFolder ``` To operate on all files within a folder: ``` cp Directory/\* CopyIntoThisFolder ``` Or to operate on all .txt files in that folder ``` cp Directory/\*.txt CopyIntoThisFolder ``` To delete (remove) a file (**NOTE: You will not get a warning and anything you delete is also NOT present in your thrash bin.** ) ``` rm file ``` To remove all files in a folder (and its subfolders) add the 'recursive flag' ``` rm -r Directory/\* ``` To remove the file folder itself ``` rmdir Directory ``` 'Oops I made a mistake, please stop this line of command and give me a new empty line' ``` 'CNTRL + C' ``` Clear the screen (move to the top of screen) ``` clear ``` 'What was that previous command I used again? I know it started with a "d" ' ``` 'CNTRL + R' 'Type a 'd' and the latest command starting with this 'd' should appear'. Use another 'CNTRL +R' to view the second to last option and so forth ``` A simple text editor ``` nano filename ``` Using an non-existing file name will create a new (empty file), whereas using this 'nano' to open any existing file allows you to edit it. Quit this programme (it will then ask you to save the file you created/edited) ``` 'CNTRL + Q' ``` Quickly see the content of a file without the need of editing it ``` more filename ```

    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