# this is comment
ls
ls -al
touch hello.txt
touch --help
man touch
echo hello world
echo "hello world"
MY_TEXT="ABC"
echo $MY_TEXT
cat hello.txt
cp hello.txt hello2.txt
mv hello.txt hello1.txt
rm hello*.txt
mkdir abc
cd abc
cd /
cd ~
cd
cd ..
cd .
cd -
rmdir abc
clear
history
exit
echo "hello world" > hello.txt
echo "hi world" >> hello.txt
echo "hello world" > /dev/null
ls 1> out.txt 2> error.txt
ls -z 1> out.txt 2> error.txt
cat hello.txt|head
whereis python3
which python3
grep search_text -rniH .
find . |grep hello
find . |less
less hello.txt
head hello.txt
tail hello.txt
tail -f log.txt
ps aux
ps aux |grep python
top
htop
pstree
tail -f log.txt &
jobs
fg
bg
kill -9 12345
nohup a_long_remote_script.sh &
ping google.com
wget http://google.com
wget https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv
ifconfig
ssh example_account@example.com
scp hello.txt example_account@example.com:/home/example_account/
scp demo@test.rebex.net:/readme.txt ./
env
FOO=BAR a_script.sh
source venv/bin/activate
. venv/bin/activate
ln -s target_file link_file_to_create
nano hello.txt
#!/bin/bash
TALKING_TO=WORLD
echo "Hello $TALKING_TO! ($FOO, $1, $2)"
Run with a environment variable
chmod +x hello.sh
FOO=BAR ./hello.sh
#!/bin/bash
is called a shebang line. By that the operating system decide the interpreter to run.- For a python script it can be like
#!/usr/bin/env python3
to be more portable across different systems.
python3 -m venv venv
. venv/bin/activate
pip install numpy
pip install -U pip
pip freeze
pip freeze > requirements.txt
pip install -r requirements.txt
python hello.py
deactivate
code .
(pyenv)
# install pyenv with the guide from https://realpython.com/intro-to-pyenv/
pyenv versions
pyenv install --list
pyenv install 3.8.12
pyenv global
pyenv global 3.8.12
pyenv local
pyenv local 3.8.12
# update the python version list if you don't see the latest versions
cd ~/.pyenv && git pull && cd -
git clone git@github.com:hotohoto/ml_course.git
cd ml_course
git fetch
git log origin/master
git reset --hard origin/master
- soft link
- ln -s target_file link_file_name
- return code or error code
$?
- 0: success
- non-zero: fail
- &&
- ||
- watch
watch ps aux
- find and execute
- awk
- nano or vim
- apt or brew
- arguments for bash script
- if statement
- for statement
- telnet to check if a port is open
- ssh-add
- ssl 🔑 gen for git configuration
IO devices
- 0: /dev/stdin
- 1: /dev/stdout
- 2: /dev/stderr
- /dev/null