The Command Line A terminal is at the end of an electric wire, a shell is the home of a turtle, tty is a strange abbreviation, and a console is a kind of cabinet. - Some person on SO
Learning Resources http://matt.might.net/articles/basic-unix/ http://matt.might.net/articles/settling-into-unix/ https://unix.stackexchange.com/ https://www.udacity.com/course/linux-command-line-basics--ud595
Unix Function over form (as opposed to Windows form over function) In Unix, a word is worth a thousand mouse clicks. More efficiency and quicker (once you get some experience) Can automate many tasks Examples: OS X and Ubuntu
Logging in with Git Bash Username: your email address Everything before @ All lowercase ssh <username>@grok Password It will ask you for a password. Initially this will be: HELLO_CLASS It will then prompt you to change your password You first must type HELLO_CLASS again Then your new password twice
SSH Keys Setup SSH Keys ssh-keygen t rsa ssh-copy-id <username>@grok <blank passphrase> Note: you will only have access to Grok for once semester, but you can get access for other classes if you request it Access Grok from off campus using the MSU VPN https://experts.missouristate.edu/display/kb/vpn
Copying Files rsync is my preferred command But scp is available with Git-Bash scp local_file aclark@grok:~/ scp aclark@grok:~/remote_file.
Basic Commands cd : change to a different directory (.,..,../..) ls : list files and directories in the current working directory pwd : print the current working directory cat : easy way to print a file (does quite a bit more though) less : read through a longer file (press q to quit) vim : pretty powerful command-line text editor (or nano or emacs) man : a command for accessing the manual of different commands grep : search for text inside files (ripgrep is better) find : search for files by name (fd is better) ssh : secure shell to remotely control a different computer
Basic Commands Every file and directory has: An owner, A group, and A set of permissions chmod chown chgrp : change file modes (permissions) : change the owner of a file : change the group of a file
Pipes, Redirection, and Flags/Options Most commands take input from STDIN Most commands write output to STDOUT Most commands write errors to STDERR Input and output act as if you were interacting with a Python program You can redirect STDIN and STDOUT using < and > You can use a pipe to direct one programs STDOUT to another s STDIN Many commands take flags to change the output ls -lah
Glob Matching You can use a * to match any number of unknown characters (*.py) You can use a? To match exactly one unknown character (*.c??) You can use [ ] to match a set of characters (*.c[px][px])
Environment Variables and PATH Run env to see all environment variables Available to all programs run in the shell PATH is a list of directories in which the shell will look for programs
Terminals and Consoles (or Konsole) tty: teletype, dating back to the late 1800s Interfacing with computers (a terminal or a physical console) These are terms for things you use to interact with a computer Examples: iterm, iterm2, konsole, xterm, etc. Now, when you hear terminal it is an emulated input/output device It is more or less just a GUI (or a windowed program) that acts like the old physical terminals/consoles
Shell A shell is the software that a user interacts with It interprets user commands and starts/runs/monitors other programs Examples: bash, fish, zsh Users can also write scripts in a language provided by the shell
Terminal or Shell? Terminal Handles key and turns them into control sequences Scroll-back history Acts on display commands Shell Handles control sequences Command history, tabcompletion, etc. Sets display info (color, text, etc.) Manages the prompt
Options on Windows 1. PuTTY: is a free implementation of SSH and Telnet for Windows and Unix platforms, along with an xterm terminal emulator. 2. Bash on Ubuntu on Windows: enabled by Windows Subsystem for Linux 3. Git for Windows: Git for Windows provides a BASH emulation used to run Git from the command line. It is essentially a Cygwin-derived shell using a terminal called mintty. Our choice out of these three options doesn t matter too much since we are just going to login to Grok. Cygwin: I m not going to consider this as an option, but you are free to try it out.
Options on Windows 1. PuTTY: is a free implementation of SSH and Telnet for Windows and Unix platforms, along with an xterm terminal emulator. 2. Bash on Ubuntu on Windows: enabled by Windows Subsystem for Linux 3. Git for Windows: Git for Windows provides a BASH emulation used to run Git from the command line. It is essentially a Cygwin-derived shell using a terminal called mintty. Our choice out of these three options doesn t matter too much since we are just going to login to Grok. Cygwin: I m not going to consider this as an option, but you are free to try it out.
Cygwin vs WSL You can think of Cygwin as a set of libraries that help you port code from POSIX to the Win API The WSL, on the other hand, let s you run ELF binaries directly on windows without porting It does this by effectively translating POSIX system calls to WIN system calls on the fly Wine is the opposite of Cygwin
Cygwin vs WSL You can think of Cygwin as a set of libraries that help you port code from POSIX to the Win API The WSL, on the other hand, let s you run ELF binaries directly on windows without porting It does this by effectively translating POSIX system calls to WIN system calls on the fly Wine is the opposite of Cygwin
For Reference: Customizing Bash on Grok ~/.bash_profile should be super-simple and just load.profile and.bashrc (in that order) ~/.profile ~/.bashrc has the stuff NOT specifically related to bash, such as environment variables (PATH and friends) has anything you'd want at an interactive command line. Command prompt, EDITOR variable, bash aliases for my use A few other notes: Anything that should be available to graphical applications OR to sh (or bash invoked as sh) MUST be in ~/.profile ~/.bashrc should not output anything Anything that should be available only to login shells should go in ~/.profile Ensure that ~/.bash_login does not exist.
https://blog.flowblok.id.au/2013-02/shell-startup-scripts.html