Linux and basic toolkit

  • The “operating system” of the UPPMAX and most of the other clusters is Linux.

Questions

  • What is Linux?

  • How to use the command line?

Objectives

  • We’ll briefly get an overview of Linux

    • How the command line works

    • Some text editors

    • Things to be aware of

Instructor note

  • Approx timing: 10:10-10:40

  • Theory and type-along

Tip

  • TAB complete:

    • Whenever you’re writing a path or filename on the bash prompt, you can strike the ‘tab’ key to ask Bash to complete what you’re writing.

    • Get in the habit of this — it will save you many hours!

These commands are useful in the command line when something is stuck or a program is limiting you to do further work.

  • ctrl-C interupts a program or a command that is “stuck”

  • ctrl-Z pauses a program, can be continues in background (bg) or foreground (fg)

  • ctrl-D quits some programs

Warning

  • There is no undo for:

    • copy (cp),

    • move (mv), and

    • remove (rm).

  • Beware of overwriting files and deleting the wrong ones.

Note

  • Tip: make “rm” ask if you really want to erase:

    • Within a session: Type in the command prompt

      alias rm='rm -i'
      
    • Override asking with

      rm –f <>
      
    • Edit file .bashrc in home directory by adding the alias line for this to start everytime.

  • This will also work for mv and cp!

Note

  • If you do destroy your data, email UPPMAX support, we may be able to help.

Keypoints

  • Linux Operating system is a UNIX-like and UNIX compatible Operating system.

  • Typical command: $ program word1 word2 word3 […]

  • Example of file editors

    • terminal

      • nano

      • vim

      • emacs

    • graphical:

      • gedit

  • Tips

    • use Tab completion

    • capitalization and spaces matters

    • no undo:s for copying, moving and removing

      • Solution: alias rm='rm -i'

Basic toolkit

Objectives

  • Let’s dig into the most important BASH commands

  • We’ll do a type-along session

Instructor note

  • Approx timing: 10:40-11.30

  • Type-alongs

We will cover these commands

Read files and change file properties

  1. cat  print content on screen

  2. head  print first part

  3. tail  print last part

  4. less  browse content

  5. tar  compress or extract file

  6. chmod  change file permissions

  7. man  info about a command

chmod — Hands-on

  • In your locally created linux_tutorial directory, find important files and old saved data that you wouldn’t want to lose (imagine).

    • Directories: important_results/, old_project/

    • File: last_years_data

  • Use chmod to remove write permission from those files and directories (use the -R flag (not -r) to also do the files in the directories).

    • Take a moment to play around with chmod and explore the effects of permissions on files and directories.

More about BASH command line and scripts on Tuesday and Wednesday!

  • https://www.uppmax.uu.se/support/courses-and-workshops/uppmax-introductory-course/