Linux Commands
Commands to demonstrate my understanding of Linux.
Before we get started I wanted to highlight the purpose of this notebook. I wanted to explictly test my skills on Linux commands. I decided to make a bash script that checks if my personal computer has all the required installations for the CSA course.
GREEN=”\033[32m” RED=”\033[31m” YELLOW=”\033[33m” NC=”\033[0m”
check_command() command_name=$1 version_flag=$2 package_name=$3
echo -e "${YELLOW}Checking for $package_name...${NC}"
if command -v "$command_name" &> /dev/null
then
version=$($command_name $version_flag)
echo -e "${GREEN}$package_name is installed: ${version}${NC}"
else
echo -e "${RED}$package_name is not installed.${NC}"
echo -e "${YELLOW}To install $package_name, please run:${NC}"
case "$command_name" in
jupyter)
echo " pip install jupyterlab"
;;
python)
echo " sudo apt install python3 (for Linux)"
echo " brew install python3 (for Mac)"
;;
java)
echo " sudo apt install default-jdk (for Linux)"
echo " brew install java (for Mac)"
;;
*)
echo " Use your package manager to install $package_name."
;;
esac
fi
echo ""
check_command “python3” “–version” “Python”
check_command “jupyter” “–version” “Jupyter”
check_jupyter_kernels() if command -v jupyter &> /dev/null then echo -e “${YELLOW}Checking Jupyter kernels…${NC}” kernels=$(jupyter kernelspec list 2>/dev/null) if [ -n “$kernels” ]; then echo -e “${GREEN}Jupyter kernels installed:${NC}” echo “$kernels” else echo -e “${RED}No Jupyter kernels installed.${NC}” fi fi check_jupyter_kernels check_command “java” “-version” “Java” check_command “pip3” “–version” “Pip” check_command “node” “–version” “Node.js (for Jupyter extensions)” echo -e “${GREEN}System check completed.${NC}” Here is the result in the terminal with the Bash script.
It clearly shows my understanding of linux commands and helps people to see what they are missing for the course:
In Addition to all of the above I also made a bash script that helps MacOS users install their java kernel if they have both Java and Jupyter already installed (Default if attended CSP)
This Script helped a lot of people who were struggling before. «comment
Help
Objective of this exercise is to test setup environment …
plus, start a Web Server
The hash # is a comment or action …
# is a comment symbol in a .sh file
The dollar $ represent a terminal command …
$ is not part of command
Start a terminal for commands
$ mdkir vscode cd vscode git clone https://github.com/nighthawkcoders/teacher_portfolio.git cd ~/vscode/teacher_portfolio/scripts ./activate_ubuntu.sh
Run the head command, leave this terminal open …
the head command shows remaining instructions …
find this spot and continue on
head -34 ~/vscode/teacher_portfolio/scripts/activate_ubuntu.sh
Start a new terminal …
the “new” terminal is the command terminal …
the “original” terminal shows commands …
type commands in “new” terminal
cd ~/vscode/teacher_portfolio pip install -r requirements.txt bundle install make
End
The build execution is complete …
Ctl-Click on “link” in terminal …
observe web site in the opened browser
comment
echo “The Point of this script is to install a Java kernel for your Jupyter Notebooks”
brew install jbangdev/tap/jbang
jbang install-kernel@jupyter-java jupyter kernelspec list