#+title: Lesson 05 | Command line Environment
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+OPTIONS: H:6
* Links
#+attr_html: :class links
- [[../toc.org][TOC | Missing Semester]]
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]]
- [[https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbVVJc2RzZ25nMmlrVW5zVGRsTS1fX2ladmRPQXxBQ3Jtc0ttWjQ5Ujcyd19TekNncTZGNEp1eDc3RWhzTzhvMW9oSTFoUl9JbGt1Mi0yU3FLc00wVUx1UXNJdFQxTjBjMWphdUZxNnU1WUYzTmFqd3RRemNLUDBJMlZkV3B0SnB4RVhpaUhvWWtnc1RISW1WVzdYWQ&q=https%3A%2F%2Fmissing.csail.mit.edu%2F2020%2Fcommand-line%2F&v=e8BO_dYxk5c][class notes]]
- Curr: https://youtu.be/e8BO_dYxk5c?si=7tmshQsaihcvs-aP&t=2018
*** timestamps
:PROPERTIES:
:CUSTOM_ID: timestamp
:END:
#+attr_html: :class playlist
+ [[https://youtu.be/e8BO_dYxk5c?si=A-imhHunQCtp_-Oz][00:00 - introduction]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=138s][02:18 - Job Control]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=227s][03:47 - Signal Interrupts]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=360s][06:00 - Python Program]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=672s][11:12 - The Kill Command]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=881s][14:41 - Terminal Multiplexer]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=1112s][18:32 - The Key Bindings]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=1536s][25:00 - Dot Files]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=1799s][29:59 - Context Based Configuration File]] *current*
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2004s][33:24 - Terminal Emulator]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2196s][36:36 - Aliases]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2286s][38:06 - Common Folder Structure]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2344s][39:04 - Symlinks]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2552s][42:32 - ssh]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=2715s][45:15 - ssh keys]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=3057s][50:57 - ssh config]]
+ [[https://www.youtube.com/watch?v=e8BO_dYxk5c&t=3231s][53:51 - changing the prefix]]
* notes
** topics
- job control
- terminal multiplexers
- dot files / how to configure
- work with remote machines
** job control
*** sleep
- puts process to sleep for a specified amount of time
- exit by typing Ctrl-C
*** Ctrl-C
- sends SIGINT - signal interrupt
- man signal will show the list of signals
** signals
- SIGQUIT :: signal sent when we want to quit
- SIGTERM :: similar to quit but not in term
- SIGHUP :: when we have processes running but still want to close
*** pausing
- SIGSTOP :: pause execution of program
- SIGCONT :: continue program
*** python library
- use import signal
#+BEGIN_SRC python
import signal
def handler(signum, frame):
printf("signal received")
signal.signal(signal.SIGINT, handler)
#+END_SRC
- the above would catch a Ctrl-C and run it through handler
- you use this by catching a Ctrl-C and running any saves or cleanup before exiting
** nohup and jobs
- allows for a process to continue livign when the terminal is killed
*** example
- sleep put the process to sleep
- '&' puts the process in the background
- wont take over the process
#+BEGIN_SRC bash
nohup sleep 2000 & python somprog.py
#+END_SRC
*** jobs
- ~jobs~
will show the suspended and running processes in background
- how to restart a suspended process
- type 'jobs' to see what there is in this terminal
- the find the jobs number, ie [1] or [2]
- use the 'bg' command
#+BEGIN_SRC bash
bg %1
#+END_src
** kill command
- allows you to send any kind of signal to a job
- e.g. "stop" will suspend but not close the job
*** some commands
- HUP :: Hang Up
- STOP :: suspend
- KILL :: kill it no matter what
** Terminal Multiplexer
*** overview
- tmux
- lets you create workspaces that you can work in
- rearrange the environment
- have different settings
*** core concepts
- hierarchy
- sessions
- windows
- panes
** dot files
*** alias
- remap a source series of characters to a longer series
- alias takes a single argument, ie, do not use spaces
- to show what an alias refers to pass the alias to the alias command
- e.g.
#+begin_src bash
~/somedirectory >>> alias myaliasedcommand
myaliasedcommand='ls -lah'
#+end_src
**** examples
- make an alias "ll" for a list command with flags
#+begin_src bash
alias ll="ls -lah"
#+end_src
- make an alias for git status
#+begin_src bash
alias gs="git status"
#+end_src
- alias to prompt for an override
#+begin_src bash
alias mv="mv -i"
#+end_src
*** text based configuration 'dot files'
- called 'dot files' because they start with a dot
- .bashrc
- must be in the home directory
- PS1
- prompt variable for your prompt
- you can set it in the .bashrc file
- ~PS1=" >> "~
- .vimrc
- vim configuration file
** terminal emulator