# Linux shell crash course ## Part 1: why shell? - is it too old? - script stuff - copy and paste explinations from others or stackoverflow - Faster, once you get used to it - Easy to program interfaces (as opposed to GUIs) - We can't teach you shell, but we can show you some examples and you can explore yourselfves later. - work with others! ## Part 2: crash course https://scicomp.aalto.fi/scicomp/shell/ - General principles - type in, see output - command + options + arguments - cp -i file1.txt file2.txt - Success = quiet - Files - Files represented by names - Directories separated by / - Editing files - Do you need to via shell? Sometimes - nano - C-x then y to exit - less - Some keystrokes to do things: q - Listing, moving, copying - ls , ls -l, ls -a, ls -la (=ls -l -a) - mv - cp - warning: both of these will overwrite file with no warnings! - rm, rm - - mkdir - Directories - working directory - pwd - cd - / and ~ - Manual pages - man (same keystrokes as less) - --help or -h - example: how to make `rm` ask before removing a file? - History and tab completion - up arrow - TAB - - Variables - Environment and shell variables - ABCD=value to set - $ or ${} syntax to retrieve - WORK=/home/rkdarst/project - echo $WORK - cd $WORK ## Part 3: what's next? - ssh - Use it for something (otherwise no purpose...) - Operate on remote computer - Connect things together - Unix philosophy: many small connected tools - grep | wc - scripting - You could say the whole point is to *do it many times* - conditionals, loops - if, then, else, for, case, etc - math - x=5, $((1 + $x)) - If you go too far, maybe shell isn't the right thing for you - coustomization via .bashrc - Other resources - - Linux shell scripting, focused on science: https://scicomp.aalto.fi/training/linux-shell-tutorial/