My blog - Shortcut command

  1. VS code
  2. OUTLOOK
  3. Python3
  4. Anaconda
  5. Linux
    1. find
    2. grep
    3. To see
    4. write to file
    5. chmod command
    6. delete or add something on file
    7. Unzip command
    8. cp command
    9. mv command
    10. For internet
  6. Git
    1. alias
  7. Para

It's never the umbrella that can get out of the rainy season, but the one who is not afraid of the wind and rain.

能走出雨季的从来不是雨伞,而是不惧风雨的自己。

Updated time: 09/23 2024.

VS code

Shift whole left: shift + Tab
           Right: Tab

Batch annotation: Ctrl + K + C
          Cancel: Ctrl + K + U

COMMAND: Ctrl + Shift + P

OUTLOOK

Emoij: Windows + Dot

Python3

python3 -m venv /path/name
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

1、添加源
比如添加清华源https://pypi.tuna.tsinghua.edu.cn/simple:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
如果set多次,似乎只能保存最后一次set的镜像源。

2、删除源
pip config unset global.index-url

3、查看现在用的哪个源
pip config list

Anaconda

conda activate ...
conda env list
conda list -e > requirement.txt
conda create -n ... python=3.11
conda env remove -n ...

1、添加源
比如清华源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
2、删除源
conda config --remove-key channels
3、查看现在用的是哪些源
conda config --show channels
也可以使用
conda config --show-sources

Linux

find

% find
% delete all files despite of 'relax.bash'
find . -type f ! -name 'relax.bash' -exec rm -f {} +
find . -type f ! \( -name 'POSCAR' -o -name 'INCAR' \) -print
find . -type f ! \( -name 'POSCAR' -o -name 'INCAR' -o -name 'POTCAR' \) -exec rm -f {} +

grep

% grep
% what line up and after around the line contained 'format'
grep -A 6 -B 6 'format' file
% grep energy
grep  without OUTCAR | tail -n 1
grep '  without' OUTCAR | tail -n 1  # 本人常用的是这个
grep sigma OUTCAR | tail -n 1

To see

% to see
diff file1 file2
more sub.vasp
cat sub.vasp
% to see the line number
cat -n filename.txt
% tail
tail -f slurm.txt

write to file

%create a file
cat > file.txt
Ctrl + D
% write content
echo ' ' >  file.txt
         >>              % append

chmod command

% for run script
chmod u+x sub.vasp

delete or add something on file

% delete specified line of the file
sed -i '10, 20d' filename.txt

% cat command
a = '$(cat POSCAR)'
echo '$a'

% add file to another file
sed -i 'N r tmp_file' filename.txt
% N - line

% delete file
rm -f /../../*.log

% delete directory
rm -rf /root/log/game

Unzip command

unzip .../*.zip
tar -zxvf .../*.tar.gz

cp command

% transfer the entirely directory
cp  -r /home/downloads/phpcms_v9_UTF8/install_package/ /opt/lampp/htdocs/

mv command

% move directory
mv ../../  ../

For internet

# all up
ip addr
# restart network
sudo systemctl restart networking
# if down, set up
sudo ip link set ens33 up
sudo dhclient ens33

Git

# 配置Git用户信息
git config --global user.name "Your Name"  # 设置全局用户名
git config --global user.email "youremail@example.com"  # 设置全局邮箱地址
# SSH to cennected between git and github

# 初始化一个新的Git仓库
git init  # 在当前目录初始化新的Git仓库

# 克隆一个现有的仓库 # http / SSH (recommended)
git clone https://github.com/username/repository.git  # 克隆远程仓库到本地
git clone git@github.com:ShengLin1001/hetbuilder.git

# 查看状态
git status  # 查看当前工作目录和暂存区的状态

# 添加和提交更改
git add .  # 将所有修改和新文件添加到暂存区
git commit -m "Commit message"  # 提交暂存区到仓库区

# 推送更改到远程仓库
git push origin main  # 将本地的更改推送到远程仓库的main分支

# 更新你的本地仓库
git pull origin main  # 从远程仓库的main分支拉取最新更改并合并到本地

# 分支操作
git branch branchname  # 创建一个新分支
git checkout branchname  # 切换到指定分支
git merge branchname  # 将指定分支合并到当前分支

# 查看提交历史
git log  # 查看提交历史记录

alias

# see alias
git config --get-regexp alias

# 设置 'co' 为 'checkout' 的别名 git co branch-name
git config --global alias.co checkout

# 设置 'br' 为 'branch' 的别名
git config --global alias.br branch

# 设置 'ci' 为 'commit' 的别名
git config --global alias.ci commit

# 设置 'st' 为 'status' 的别名
git config --global alias.st status

# 设置 'lg' 为更美观的日志输出格式
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

# 设置 'unstage' 作为撤销暂存的别名
git config --global alias.unstage 'reset HEAD --'

# 设置 'last' 为查看最后一次提交的别名
git config --global alias.last 'log -1 HEAD'

# git ac ""
git config --global alias.ac '!git add -A && git commit -m'

# push and pull on main
git config --global alias.push 'push origin main'
git config --global alias.pull 'pull origin main'

Para

papp_cloud 是一个登录超算的命令行工具,具备ssh,scp,rsync, sftp, sshfs 等基础功能。

o 支持的操作系统

  - Linux x86_64/i686
  - Darwin x86_64

Flags:
  -h, --help     Show context-sensitive help (also try --help-long and --help-man).
  -V, --version  Show application version.
  -D, --debug    Enable debug mode.
  -s, --select   select a vpn link route.

Commands:
  help [<command>...]
    Show help.

  ssh [<flags>] <destination> [<command>...]
    Ssh is a sub command for logging into a remote machine and for executing commands on a remote machine.

    example:

      1. 使用paratera帐号登录广州超算(IPv4)

      $ papp_cloud ssh paratera@gz                                                   

      2. 使用paratera帐号登录广州超算(IPv6)

      $ papp_cloud ssh -6 paratera@gz                                                   


  sshfs [<flags>] <source ... target>...
    SSHFS - filesystem client based on SSH.

    example:


       1.挂载广州超算目录/home/paratera到本地挂载点/localdir

       $ papp_cloud sshfs paratera@gz:/home/paratera /localdir

  scp [<flags>] <source ... target>...
    Scp copies files between hosts on a network.

    example:

      o Upload

      1. 使用paratera帐号上传file1,file2文件到广州超算的paratera用户家目录(IPv4)

      $ papp_cloud scp file1 file2 paratera@gz:/home/paratera           

      2. 使用paratera帐号上传file1,file2文件到广州超算的paratera用户家目录(IPv6)

      $ papp_cloud scp -6 file1 file2 paratera@gz:/home/paratera           

      o Download

      1. 使用paratera帐号下载广州超算paratera用户家目录下的file1 文件到本地的/data
      目录(IPv4)

      $ papp_cloud scp paratera@gz:/home/paratera/file1 /data           

      2. 使用paratera帐号下载广州超算paratera用户家目录下的file1 文件到本地的/data
      目录(IPv6)

      $ papp_cloud scp -6 paratera@gz:/home/paratera/file1 /data           


  sftp [<flags>] <destination>...
    Sftp is a file transfer program, similar to ftp.

    example:

      1. 使用paratera帐号登录广州超算(IPv4)

      $ papp_cloud sftp paratera@gz                           

      2. 使用paratera帐号登录广州超算(IPv6)

      $ papp_cloud sftp -6 paratera@gz                           


  rsync [<flags>] <source ... target>...

    Rsync copies files either to or from a remote host, or locally on the current host (it does not support copying files between two remote hosts

    example:

      o Upload

      1. 使用paratera帐号同步file1,file2文件到广州超算的paratera用户家目录(IPv4)

      $ papp_cloud rsync file1 file2 paratera@gz:/home/paratera         

      2. 使用paratera帐号同步file1,file2文件到广州超算的paratera用户家目录(IPv6)

      $ papp_cloud rsync -6 file1 file2 paratera@gz:/home/paratera         

      o Download

      1. 使用paratera帐号下载广州超算paratera用户家目录下的file1 文件到本地的/data
      目录(IPv4)

      $ papp_cloud rsync paratera@gz:/home/paratera/file1 /data         

      2. 使用paratera帐号下载广州超算paratera用户家目录下的file1 文件到本地的/data
      目录(IPv6)

      $ papp_cloud rsync -6 paratera@gz:/home/paratera/file1 /data         

  login --user=USER --[no-]password
    Login paratera cloud service.

    example:

      $ papp_cloud login -u user@paratera.com -p

  logout
    Logout paratera cloud service.

    example:

      $ papp_cloud logout

  lsc
    list super computer centers.

  accounts
    list super computer center accounts
papp_cloud ssh scg6928@zc-m6

Please indicate the source when reprinting. Please verify the citation sources in the article and point out any errors or unclear expressions.