Bash Tutorial
A brief overview of Bash, on your way to becoming a Linux expert. When a computer boots up, a kernel (MacOS, Windows, Linux) is started. This kernel provides a shell that allows user to interact with a most basic set of commands. Typically, the casual user will not interact with the shell as a Desktop User Interface is started by the computer boot up process. To activate a shell directly, users will run a “terminal” through the Desktop. VS Code provides ability to activate “terminal” while in the IDE.
Custom Variables
I set up bash shell dependency variables for this page.
Hack: I changed the variables for my own project.
%%script bash
# Dependency Variables, set to match your project directories
cat <<EOF > /tmp/variables.sh
export project_dir=$HOME/vscode # change vscode to different name to test git clone
export project=\$project_dir/drewtwo # change teacher to name of project from git clone
export project_repo="https://github.com/drewreed2005/drewtwo.git" # change to project of choice
EOF
%%script bash
# Extract saved variables
source /tmp/variables.sh
# Access the variables
echo "Project dir: $project_dir"
echo "Project: $project"
echo "Repo: $project_repo"
Project dir: /Users/mister_dew/vscode
Project: /Users/mister_dew/vscode/drewtwo
Repo: https://github.com/drewreed2005/drewtwo.git
Setup Project
I pulled code from GitHub to your machine. This script didn’t need to create a project directory and add “project” from GitHub to the vscode directory, since there is conditional logic to make sure that clone only happen if it does not exist.
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Using conditional statement to create a project directory and project"
cd ~ # start in home directory
# Conditional block to make a project directory
if [ ! -d $project_dir ]
then
echo "Directory $project_dir does not exists... makinng directory $project_dir"
mkdir -p $project_dir
fi
echo "Directory $project_dir exists."
# Conditional block to git clone a project from project_repo
if [ ! -d $project ]
then
echo "Directory $project does not exists... cloning $project_repo"
cd $project_dir
git clone $project_repo
cd ~
fi
echo "Directory $project exists."
Using conditional statement to create a project directory and project
Directory /Users/mister_dew/vscode exists.
Directory /Users/mister_dew/vscode/drewtwo exists.
Look at files Github project
All computers contain files and directories. The clone brought more files from cloud to your machine. Review the bash shell script observe the commands that show and interact with files and directories.
- “ls” lists computer files in Unix and Unix-like operating systems
- “cd” offers way to navigate and change working directory
- “pwd” print working directory
- “echo” used to display line of text/string that are passed as an argument
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Navigate to project, then navigate to area wwhere files were cloned"
cd $project
pwd
echo ""
echo "list top level or root of files with project pulled from github"
ls
Navigate to project, then navigate to area wwhere files were cloned
/Users/mister_dew/vscode/drewtwo
list top level or root of files with project pulled from github
Gemfile
Gemfile.lock
LICENSE
Makefile
README.md
_config.yml
[34m_data[m[m
[34m_includes[m[m
[34m_layouts[m[m
[34m_notebooks[m[m
[34m_posts[m[m
[34m_site[m[m
[31mactivate.sh[m[m
csa.md
csp.md
csse.md
[34mimages[m[m
index.md
indexBlogs.md
[34mscripts[m[m
Look at file list with hidden and long attributes
I just ran the thing below.
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Navigate to project, then navigate to area wwhere files were cloned"
cd $project
pwd
echo ""
echo "list all files in long format"
ls -al # all files -a (hidden) in -l long listing
Navigate to project, then navigate to area wwhere files were cloned
/Users/mister_dew/vscode/drewtwo
list all files in long format
total 128
drwxr-xr-x 26 mister_dew staff 832 Aug 22 08:39 [34m.[m[m
drwxr-xr-x@ 31 mister_dew staff 992 Aug 22 08:48 [34m..[m[m
drwxr-xr-x 15 mister_dew staff 480 Aug 22 08:36 [34m.git[m[m
drwxr-xr-x 3 mister_dew staff 96 Aug 17 09:15 [34m.github[m[m
-rw-r--r-- 1 mister_dew staff 104 Aug 17 09:15 .gitignore
-rw-r--r-- 1 mister_dew staff 6 Aug 19 20:49 .ruby-version
-rw-r--r-- 1 mister_dew staff 143 Aug 19 16:11 Gemfile
-rw-r--r-- 1 mister_dew staff 7335 Aug 19 20:50 Gemfile.lock
-rw-r--r-- 1 mister_dew staff 1081 Aug 17 09:15 LICENSE
-rw-r--r-- 1 mister_dew staff 3154 Aug 19 21:41 Makefile
-rw-r--r-- 1 mister_dew staff 5798 Aug 17 09:15 README.md
-rw-r--r-- 1 mister_dew staff 451 Aug 17 09:15 _config.yml
drwxr-xr-x 6 mister_dew staff 192 Aug 17 09:15 [34m_data[m[m
drwxr-xr-x 9 mister_dew staff 288 Aug 17 09:15 [34m_includes[m[m
drwxr-xr-x 6 mister_dew staff 192 Aug 17 09:15 [34m_layouts[m[m
drwxr-xr-x 6 mister_dew staff 192 Aug 22 08:56 [34m_notebooks[m[m
drwxr-xr-x 10 mister_dew staff 320 Aug 22 08:56 [34m_posts[m[m
drwxr-xr-x 17 mister_dew staff 544 Aug 22 08:56 [34m_site[m[m
-rwxr-xr-x 1 mister_dew staff 1291 Aug 17 09:15 [31mactivate.sh[m[m
-rw-r--r-- 1 mister_dew staff 92 Aug 17 09:15 csa.md
-rw-r--r-- 1 mister_dew staff 98 Aug 17 09:15 csp.md
-rw-r--r-- 1 mister_dew staff 108 Aug 17 09:15 csse.md
drwxr-xr-x 7 mister_dew staff 224 Aug 17 09:15 [34mimages[m[m
-rw-r--r-- 1 mister_dew staff 788 Aug 17 09:15 index.md
-rw-r--r-- 1 mister_dew staff 53 Aug 17 09:15 indexBlogs.md
drwxr-xr-x 4 mister_dew staff 128 Aug 17 22:19 [34mscripts[m[m
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Look for posts"
export posts=$project/_posts # _posts inside project
cd $posts # this should exist per fastpages
pwd # present working directory
ls -l # list posts
Look for posts
/Users/mister_dew/vscode/drewtwo/_posts
total 128
-rw-r--r-- 1 mister_dew staff 1812 Aug 17 09:15 2023-08-15-Tools_Sprint.md
-rw-r--r-- 1 mister_dew staff 4397 Aug 17 09:15 2023-08-16-Tools_Equipment.md
-rw-r--r-- 1 mister_dew staff 22661 Aug 22 09:05 2023-08-16-linux_shell_IPYNB_2_.md
-rw-r--r-- 1 mister_dew staff 3752 Aug 22 08:39 2023-08-17-AP-pseudo-vs-python_IPYNB_2_.md
-rw-r--r-- 1 mister_dew staff 4991 Aug 22 00:21 2023-08-20-Pixel_Canvas.md
-rw-r--r-- 1 mister_dew staff 468 Aug 17 09:15 2023-08-21-GitHub_Pages.md
-rw-r--r-- 1 mister_dew staff 211 Aug 22 09:02 2023-08-21-Reflections_on_Tools_IPYNB_2_.md
-rw-r--r-- 1 mister_dew staff 6059 Aug 22 08:39 2023-08-21-VSCode-GitHub_Pages_IPYNB_2_.md
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Look for notebooks"
export notebooks=$project/_notebooks # _notebooks is inside project
cd $notebooks # this should exist per fastpages
pwd # present working directory
ls -l # list notebooks
Look for notebooks
/Users/mister_dew/vscode/drewtwo/_notebooks
total 112
-rw-r--r-- 1 mister_dew staff 31961 Aug 22 09:04 2023-08-16-linux_shell.ipynb
-rw-r--r-- 1 mister_dew staff 5415 Aug 17 09:15 2023-08-17-AP-pseudo-vs-python.ipynb
-rw-r--r-- 1 mister_dew staff 561 Aug 22 09:02 2023-08-21-Reflections_on_Tools.ipynb
-rw-r--r-- 1 mister_dew staff 8615 Aug 17 09:15 2023-08-21-VSCode-GitHub_Pages.ipynb
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Look for images in notebooks, print working directory, list files"
cd $notebooks/images # this should exist per fastpages
pwd
ls -l
Look for images in notebooks, print working directory, list files
bash: line 6: cd: /images: No such file or directory
/Users/mister_dew/vscode/drewtwo/_notebooks
total 112
-rw-r--r-- 1 mister_dew staff 31096 Aug 22 09:10 2023-08-16-linux_shell.ipynb
-rw-r--r-- 1 mister_dew staff 5415 Aug 17 09:15 2023-08-17-AP-pseudo-vs-python.ipynb
-rw-r--r-- 1 mister_dew staff 966 Aug 22 09:10 2023-08-21-Reflections_on_Tools.ipynb
-rw-r--r-- 1 mister_dew staff 8615 Aug 17 09:15 2023-08-21-VSCode-GitHub_Pages.ipynb
drwxr-xr-x 3 mister_dew staff 96 Aug 22 09:09 [34mimages[m[m
Look inside a Markdown File
“cat” reads data from the file and gives its content as output
%%script bash
# Extract saved variables
source /tmp/variables.sh
echo "Navigate to project, then navigate to area wwhere files were cloned"
cd $project
echo "show the contents of README.md"
echo ""
cat README.md # show contents of file, in this case markdown
echo ""
echo "end of README.md"
Navigate to project, then navigate to area wwhere files were cloned
show the contents of README.md
## Blog site using GitHub Pages and Jekyll
> This site is intended for Students. This is to record plans, complete hacks, and do work for your learnings.
- This can be customized to support computer science as you work through pathway (JavaScript, Python/Flask, Java/Spring)
- All tangible artifact work is in a _posts or in a _notebooks.
- Front matter (aka meta data) in ipynb and md files is used to organize information according to week and column in running web site.
## GitHub Pages
All `GitHub Pages` websites are managed on GitHub infrastructure. GitHub uses `Jekyll` to tranform your content into static websites and blogs. Each time we change files in GitHub it initiates a GitHub Action that rebuilds and publishes the site with Jekyll.
- GitHub Pages is powered by: [Jekyll](https://jekyllrb.com/).
- Publised teacher website: [nighthawkcoders.github.io/teacher](https://nighthawkcoders.github.io/teacher/)
## Preparing a Preview Site
In all development, it is recommended to test your code before deployment. The GitHub Pages development process is optimized by testing your development on your local machine, prior to files on GitHub
Development Cycle. For GitHub pages, the tooling described below will create a development cycle `make-code-save-preview`. In the development cycle, it is a requirement to preview work locally, prior to doing a VSCode `commit` to git.
Deployment Cycle. In the deplopyment cycle, `sync-github-action-review`, it is a requirement to complete the development cycle prior to doing a VSCode `sync`. The sync triggers github repository update. The action starts the jekyll build to publish the website. Any step can have errors and will require you to do a review.
### WSL and/or Ubuntu installation requirements
- The result of these step is Ubuntu tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/ubuntu/)
- Run scripts in scripts directory of teacher repo: setup_ubuntu.sh and activate.sh. Or, follow commands below.
```bash
## WSL/Ubuntu commands
# sudo apt install, installs packages for Ubuntu
echo "=== Ugrade Packages ==="
sudo apt update
sudo apt upgrade -y
#
echo "=== Install Ruby ==="
sudo apt install -y ruby-full build-essential zlib1g-dev
#
echo "=== Install Python ==="
sudo apt-get install -y python3 python3-pip python-is-python3
#
echo "=== Install Jupyter Notebook ==="
sudo apt-get install -y jupyter-notebook
# bash commands, install user requirements.
echo "=== GitHub pages build tools ==="
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
echo "=== Gem install starting, thinking... ==="
gem install jekyll bundler
head -30 ./teacher/scripts/activate.sh
echo "=== !!!Start a new Terminal!!! ==="
```
### MacOs installation requirements
- Ihe result of these step are MacOS tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/macos/). Run scripts in scripts directory of teacher repo: setup_macos.sh and activate_macos.sh. Or, follow commands below.
```bash
# MacOS commands
# brew install, installs packages for MacOS
echo "=== Ugrade Packages ==="
brew update
brew upgrade
#
echo "=== Install Ruby ==="
brew install chruby ruby-install xz
ruby-install ruby 3.1.3
#
echo "=== Install Python ==="
brew install python
#
echo "=== Install Jupyter Notebook ==="
brew install jupyter
# bash commands, install user requirements.
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"
echo '# Install Ruby Gems to ~/gems' >> ~/.zshrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.zshrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.zshrc
echo "=== Gem install starting, thinking... ==="
gem install jekyll bundler
head -30 ./teacher/scripts/activate.sh
echo "=== !!!Start a new Terminal!!! ==="
```
### Preview
- The result of these step is server running on: http://0.0.0.0:4100/teacher/. Regeneration messages will run in terminal on any save. Press the Enter or Return key in the terminal at any time to enter commands.
- Complete installation
```bash
bundle install
```
- Run Server. This requires running terminal commands `make`, `make stop`, `make clean`, or `make convert` to manage the running server. Logging of details will appear in terminal. A `Makefile` has been created in project to support commands and start processes.
- Start preview server in terminal
```bash
cd ~/vscode/teacher # my project location, adapt as necessary
make
```
- Terminal output of shows server address. Cmd or Ctl click http location to open preview server in browser. Example Server address message...
```
Server address: http://0.0.0.0:4100/teacher/
```
- Save on ipynb or md activiates "regeneration". Refresh browser to see updates. Example terminal message...
```
Regenerating: 1 file(s) changed at 2023-07-31 06:54:32
_notebooks/2024-01-04-cockpit-setup.ipynb
```
- Terminal message are generated from background processes. Click return or enter to obtain prompt and use terminal as needed for other tasks. Alway return to root of project `cd ~/vscode/teacher` for all "make" actions.
- Stop preview server, but leave constructed files in project for your review.
```bash
make stop
```
- Stop server and "clean" constructed files, best choice when renaming files to eliminate potential duplicates in constructed files.
```bash
make clean
```
- Test notebook conversions, best choice to see if IPYNB conversion is acting up.
```bash
make convert
```
end of README.md
Env, Git and GitHub
Env(ironment) is used to capture things like path to Code or Home directory. Git and GitHub is NOT Only used to exchange code between individuals, it is often used to exchange code through servers, in our case deployment for Website. All tools we use have a behind the scenes hav relationship with the system they run on (MacOS, Windows, Linus) or a relationship with servers which they are connected to (ie GitHub). There is an “env” command in bash. There are environment files and setting files (.git/config) for Git. They both use a key/value concept.
- “env” show setting for your shell
- “git clone” sets up a director of files
- “cd $project” allows user to move inside that directory of files
- “.git” is a hidden directory that is used by git to establish relationship between machine and the git server on GitHub.
%%script bash
# This command has no dependencies
echo "Show the shell environment variables, key on left of equal value on right"
echo ""
env
Show the shell environment variables, key on left of equal value on right
VSCODE_CLI=1
VSCODE_CRASH_REPORTER_PROCESS_TYPE=extensionHost
TERM_PROGRAM=Apple_Terminal
TERM=xterm-color
SHELL=/bin/bash
CLICOLOR=1
TMPDIR=/var/folders/8g/ys6yf8855vj976vktrkvj_gh0000gn/T/
CONDA_SHLVL=1
PYTHONUNBUFFERED=1
TERM_PROGRAM_VERSION=445
CONDA_PROMPT_MODIFIER=(base)
ORIGINAL_XDG_CURRENT_DESKTOP=undefined
MallocNanoZone=0
PYDEVD_USE_FRAME_EVAL=NO
TERM_SESSION_ID=C3AEDDE2-A177-42D3-AE3D-5E967DFE3A70
PYTHONIOENCODING=utf-8
USER=mister_dew
COMMAND_MODE=unix2003
CONDA_EXE=/Users/mister_dew/opt/anaconda3/bin/conda
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.vJrRfmrsXU/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PAGER=cat
ELECTRON_RUN_AS_NODE=1
VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcess
_CE_CONDA=
CONDA_ROOT=/Users/mister_dew/opt/anaconda3
PATH=/Users/mister_dew/opt/anaconda3/bin:/Users/mister_dew/opt/anaconda3/bin:/Users/mister_dew/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
LaunchInstanceID=86B557C0-5DE9-4532-AFB3-475629FD897E
__CFBundleIdentifier=com.microsoft.VSCode
CONDA_PREFIX=/Users/mister_dew/opt/anaconda3
PWD=/Users/mister_dew/vscode/drewtwo/_notebooks
VSCODE_HANDLES_UNCAUGHT_ERRORS=true
ELECTRON_NO_ATTACH_CONSOLE=1
MPLBACKEND=module://matplotlib_inline.backend_inline
LANG=en_US.UTF-8
XPC_FLAGS=0x0
FORCE_COLOR=1
_CE_M=
XPC_SERVICE_NAME=0
SHLVL=5
HOME=/Users/mister_dew
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=1
VSCODE_NLS_CONFIG={"locale":"en-us","osLocale":"en","availableLanguages":{},"_languagePackSupport":true}
PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING=1
LOGNAME=mister_dew
CONDA_PYTHON_EXE=/Users/mister_dew/opt/anaconda3/bin/python
VSCODE_IPC_HOOK=/Users/mister_dew/Library/Application Support/Code/1.81-main.sock
VSCODE_CODE_CACHE_PATH=/Users/mister_dew/Library/Application Support/Code/CachedData/6c3e3dba23e8fadc360aed75ce363ba185c49794
CLICOLOR_FORCE=1
CONDA_DEFAULT_ENV=base
VSCODE_PID=3484
DISPLAY=/private/tmp/com.apple.launchd.dyzVEHJNca/org.macosforge.xquartz:0
GIT_PAGER=cat
VSCODE_L10N_BUNDLE_LOCATION=
VSCODE_CWD=/Users/mister_dew/vscode
SECURITYSESSIONID=186a3
_=/usr/bin/env
%%script bash
# Extract saved variables
source /tmp/variables.sh
cd $project
echo ""
echo "show the secrets of .git"
cd .git
ls -l
echo ""
echo "look at config file"
cat config
show the secrets of .git
total 64
-rw-r--r-- 1 mister_dew staff 42 Aug 22 08:36 COMMIT_EDITMSG
-rw-r--r-- 1 mister_dew staff 99 Aug 22 08:36 FETCH_HEAD
-rw-r--r-- 1 mister_dew staff 21 Aug 17 09:15 HEAD
-rw-r--r-- 1 mister_dew staff 41 Aug 22 08:36 ORIG_HEAD
-rw-r--r-- 1 mister_dew staff 309 Aug 17 09:15 config
-rw-r--r-- 1 mister_dew staff 73 Aug 17 09:15 description
drwxr-xr-x 15 mister_dew staff 480 Aug 17 09:15 [34mhooks[m[m
-rw-r--r-- 1 mister_dew staff 4026 Aug 22 08:36 index
drwxr-xr-x 3 mister_dew staff 96 Aug 17 09:15 [34minfo[m[m
drwxr-xr-x 4 mister_dew staff 128 Aug 17 09:15 [34mlogs[m[m
drwxr-xr-x 21 mister_dew staff 672 Aug 22 08:36 [34mobjects[m[m
-rw-r--r-- 1 mister_dew staff 112 Aug 17 09:15 packed-refs
drwxr-xr-x 5 mister_dew staff 160 Aug 17 09:15 [34mrefs[m[m
look at config file
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/drewreed2005/drewtwo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main
Student Request - Make a file in Bash
This example was requested by a student (Jun Lim, CSA). The request was to make jupyer file using bash, I adapted the request to markdown. This type of thought will have great extrapolation to coding and possibilities of using List, Arrays, or APIs to build user interfaces. JavaScript is a language where building HTML is very common.
To get more interesting output from terminal, this will require using something like mdless (https://github.com/ttscoff/mdless). This enables see markdown in rendered format.
- On Desktop Install PKG from MacPorts
- In Terminal on MacOS
- Install ncurses
gem install mdless
Output of the example is much nicer in “jupyter”
%%script bash
# This example has error in VSCode, it run best on Jupyter
cd /tmp
file="sample.md"
if [ -f "$file" ]; then
rm $file
fi
tee -a $file >/dev/null <<EOF
# Show Generated Markdown
This introductory paragraph and this line and the title above are generated using tee with the standard input (<<) redirection operator.
- This bulleted element is still part of the tee body.
EOF
echo "- This bulleted element and lines below are generated using echo with standard output (>>) redirection operator." >> $file
echo "- The list definition, as is, is using space to seperate lines. Thus the use of commas and hyphens in output." >> $file
actions=("ls,list-directory" "cd,change-directory" "pwd,present-working-directory" "if-then-fi,test-condition" "env,bash-environment-variables" "cat,view-file-contents" "tee,write-to-output" "echo,display-content-of-string" "echo_text_>\$file,write-content-to-file" "echo_text_>>\$file,append-content-to-file")
for action in ${actions[@]}; do # for loop is very similar to other language, though [@], semi-colon, do are new
action=${action//-/ } # convert dash to space
action=${action//,/: } # convert comma to colon
action=${action//_text_/ \"sample text\" } # convert _text_ to sample text, note escape character \ to avoid "" having meaning
echo " - ${action//-/ }" >> $file # echo is redirected to file with >>
done
echo ""
echo "File listing and status"
ls -l $file # list file
wc $file # show words
mdless $file # this requires installation, but renders markown from terminal
rm $file # clean up termporary file
File listing and status
-rw-r--r-- 1 mister_dew wheel 809 Aug 22 09:33 sample.md
15 132 809 sample.md
bash: line 30: mdless: command not found
Hacks
- Come up with your own student view of this procedure to show your tools are installed.
I created a bash script that will check where various important tools are installed and show their versions.
%%script bash
# checking github info
echo "WHO ARE YOU (according to GitHub)?";
git config --global --get user.name;
echo "WHERE CAN YOU BE REACHED?";
git config --global --get user.email;
echo;
# checking homebrew info
echo "WHERE IS HOMEBREW?";
which brew;
echo "WHICH VERSION(S) OF HOMEBREW?";
brew -v;
echo;
# checking ruby info
eval "$(rbenv init -)"
echo "WHERE IS RUBY?";
which ruby;
echo "WHICH VERSION OF RUBY?";
ruby -v;
echo;
# checking rbenv info
echo "WHERE IS RBENV?";
which rbenv;
echo "WHICH VERSION OF RBENV?";
rbenv -v;
echo;
# checking python info
echo "WHERE IS PYTHON?";
which python;
echo "WHICH VERSION OF PYTHON?"
python3 --version
echo;
# checking jupyter
echo "WHERE IS JUPYTER?";
which jupyter;
echo "LET'S SEE SOME VERSIONS...";
jupyter --version;
echo "LET'S SEE SOME PACKAGES..."
jupyter kernelspec list;
echo;
# checking for bundler
echo "WHERE IS BUNDLER?";
which bundler;
echo "WHICH VERSION OF BUNDLER?";
bundle -v;
echo
# checking java
echo "WHERE IS JAVA?";
which java;
echo "WHICH VERSION OF JAVA?";
java -version;
WHO ARE YOU (according to GitHub)?
Drew Reed
WHERE CAN YOU BE REACHED?
drewdafox@gmail.com
WHERE IS HOMEBREW?
/usr/local/bin/brew
WHICH VERSION(S) OF HOMEBREW?
Homebrew 4.1.5-55-g3cd7290
Homebrew/homebrew-core (git revision f1cc1840f65; last commit 2023-08-17)
Homebrew/homebrew-cask (git revision 1a4702d1d4; last commit 2023-08-17)
WHERE IS RUBY?
/Users/mister_dew/.rbenv/shims/ruby
WHICH VERSION OF RUBY?
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin21]
WHERE IS RBENV?
/usr/local/bin/rbenv
WHICH VERSION OF RBENV?
rbenv 1.2.0
WHERE IS PYTHON?
/Users/mister_dew/opt/anaconda3/bin/python
WHICH VERSION OF PYTHON?
Python 3.9.12
WHERE IS JUPYTER?
/Users/mister_dew/opt/anaconda3/bin/jupyter
LET'S SEE SOME VERSIONS...
Selected Jupyter core packages...
IPython : 8.7.0
ipykernel : 6.19.2
ipywidgets : 7.6.5
jupyter_client : 6.1.12
jupyter_core : 5.1.1
jupyter_server : 1.13.5
jupyterlab : 3.3.2
nbclient : 0.5.13
nbconvert : 6.4.4
nbformat : 5.7.0
notebook : 6.4.8
qtconsole : 5.3.2
traitlets : 5.7.1
LET'S SEE SOME PACKAGES...
Available kernels:
bash /Users/mister_dew/Library/Jupyter/kernels/bash
java /Users/mister_dew/Library/Jupyter/kernels/java
javascript /Users/mister_dew/Library/Jupyter/kernels/javascript
python3 /Users/mister_dew/opt/anaconda3/share/jupyter/kernels/python3
WHERE IS BUNDLER?
/Users/mister_dew/.rbenv/shims/bundler
WHICH VERSION OF BUNDLER?
Bundler version 2.4.19
- Name and create notes on some Linux commands you will use frequently.
Frequently-used commands:
Directory and file commands
- mkdir [directory name]: make a new directory
- touch [file name]: make a new file
- rm [file/directory]: delete a file/directory
- mv [original location] [new location]: move a file/directory
- cp [original location] [new location]: copy a file/directory to another file/directory
Listing and searching files
- ls: lists files and directories in the current directory
- ls -l: lists files and directories in long format (includes permissions, owner)
- ls -a: lists all files and directories, including hidden ones
- find [directory] -name [file name]: Search for files within a directory
- grep [search term] [file name]: Search for text within a file
Others
- cat [file]: shows the contents of a given file
- ps: lists running processes
- kill [process ID]: kill a running process
- echo $[variable name]: display the value of an environment variable
- export [variable name]=[value]: set an environment variable to a given value
There are many more, but these are some that I’ve used before.
- Is there anything we use to verify tools we install? Review versions checks.
There are tons, and I showed them in the shell that checks for everything.
- Is there anything we could verify with Anaconda? or WSL?
There’s plenty. I’ll show some Anaconda possibilities below.
%%script bash
# using conda list
# conda list lets you varify certain package installation (see examples in output)
echo "PYTHON CONTENTS";
conda list python;
echo;
echo "NumPY CONTENTS";
conda list NumPy;
echo;
# you can also create isolated Python environments and get info on them
echo "ANACONDA ENVIRONMENTS";
conda info --envs;
# conda activate [environment name] would activate a new environment
# update packages in the format below:
# conda update [package_name]
PYTHON CONTENTS
# packages in environment at /Users/mister_dew/opt/anaconda3:
#
# Name Version Build Channel
ipython 8.7.0 py39hecd8cb5_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
msgpack-python 1.0.3 py39haf03e11_0
python 3.9.12 hdfd78df_0
python-dateutil 2.8.2 pyhd3eb1b0_0
python-fastjsonschema 2.16.2 py39hecd8cb5_0
python-libarchive-c 2.9 pyhd3eb1b0_1
python-lsp-black 1.0.0 pyhd3eb1b0_0
python-lsp-jsonrpc 1.0.0 pyhd3eb1b0_0
python-lsp-server 1.2.4 pyhd3eb1b0_0
python-slugify 5.0.2 pyhd3eb1b0_0
python-snappy 0.6.1 py39hcec6c5f_0
python-vlc 3.0.16120 pypi_0 pypi
python.app 3 py39hca72f7f_0
NumPY CONTENTS
# packages in environment at /Users/mister_dew/opt/anaconda3:
#
# Name Version Build Channel
numpy 1.21.5 py39h2e5f0a9_3
numpy-base 1.21.5 py39h3b1a694_3
numpydoc 1.2 pyhd3eb1b0_0
ANACONDA ENVIRONMENTS
# conda environments:
#
base * /Users/mister_dew/opt/anaconda3
- How would you update a repository? Could you do that in script above?
I can do it in the script below.
%%script bash
# navigate to the repo
cd /path/to/repo
# use git fetch command to retrieve updates from the remote repository
git fetch origin #(or replace "origin" with the remote repo's name)
# you can then review the changes with git log
git log
# pull changes
git pull origin main #main is an example; it can be another branch