跳到主要内容

4 篇博文 含有标签「shell」

查看所有标签

· 阅读需 1 分钟
大盗天放

How to add commands to $PATH in Linux or Mac?


What is PATH?

PATH is a variable in $ \star$nix system which tells the command path

Option1:Set PATH for your current shell session

export PATH=$PATH:/path/to/your/directory
  • Done

Option2:Change your PATH permanently

  • Edit your .bash_profile(if you ues Bash) or .zshrc( if using zsh)
  • add path at the end of the file
export PATH=$PATH:/path/to/your/directory
OR
export PATH=/path/to/your/directory:$PATH
  • Active your changes
source .bash_profile
OR
source .zshrc

· 阅读需 1 分钟
大盗天放

expect spawn and send

#!/usr/bin/expect -f

#set timeout 20

set sp YourSudoPassword
set passwd UserPassword

# sudo is not always necessary

spawn sudo ssh user@ip

expect "Password:"
send "$sp\r"

expect "some stuff"
send "$passwd\r"
interact
  • spawn: run commands
  • expect: wait for specify pattern
  • send: to send the strings to the process

· 阅读需 1 分钟
大盗天放

If you want to use jupyter on remote server, this blog might be useful.

Step1: Run jupyter without browser on remote server:

jupyter notebook --no-browser --port=8888

Step2: Bind local port to remote server:

ssh -N -f -L localhost:8888:ip:8888 user@ip

Step3: Open browser on you local machine and direct to localhost:8888

To Stop Local Process:

ps aux|grep jupyter

kill pid

· 阅读需 1 分钟
大盗天放

Basic aliases

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status

Git Log

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"