GNU/Linux (Ubuntu) Setup Log
Web & CLI Trade-off
Data preparation and visualization with Jupyter, train or deploy models with IPython/ssh.
ssh etc Win
My combo: xshell + xftp + xming
Hint:
Set: Xshell 键盘选择 Meta按键 为 Right Alt以避免按键冲突,尤其是nano
xshell-会话-属性-ssh-隧道/Tunnel-Xforward开启,设置localhost:21, 端口和xLaunch运行结果一致。
可能后续会改为xmanager,形成完整的套件(已下载安装包)
简单解释下:x11-forward可以转发服务器中选定应用的GUI, 又不像rdp那样实时转发流量。非常极致。
cmd + xming
install xming (listening port 0.0 by default, can use XLaunch to redirect).
Run cmd and use set DISPLAY=localhost:0.0
to set display output, then use ssh -Y <username>@<server IP>
to redirect cmd display output to xming.
System Cmd
1 2 3 |
who # 查看当前登录用户 uname -a #查看系统信息,64位 ufw #ubuntu firewall, su required |
wget download dropbox file
tips: in DOS, use wget.exe
and curl.exe
-
Add
?dl=1
after the download page link. {StackExchange-Ref}
It will create a temp file and wget-log in current directory. -
Only Buisness URL ending with
?dl=0
works -
Trying to know how wget can download into folder instead of single file.
Download folder as zip then unzip it1curl -L https://www.dropbox.com/sh/igoku2mqsjqsmx1/AAAeF57DR2ou_nZGC4JPoQKfa?dl=1 > download.zip -
currently it works by saving the file to my dropbox to create a file-specified share link for wget.
(can use -c for continuous partial downloading) -
Now it works with only the link part without
?dl=0
behind.
tips:
1 |
man wget |
to read manuscripts, h
for help. ‘/$KEY_WORD$’ for search
wget download dropbox file in series
Put dropbox share link in txt file, without ?dl=0
1 |
wget --input-file/-i $url_list.txt |
{Trying}
unzip
1 |
unzip -q -d %extdir% |
-q for quiet mode, and -d for extract directory
For zip file over 4GB generated by win10, fix them first with
1 |
zip -FF foo.zip --out fixed.zip |
-FF for fixing, –out for output zip file name
awk
A powerful text editor (almost a programming language)
1 |
awk -F '[_.]' 'NR==,1, NR==6 {print $0, $2,$3, $NF}' test.txt |
The structure is 'Condition {Command}'
$NF is number of field, last column number
$NR is the number of row-F
set the field separator and [-.]
set both _
and .
as separator.
other usages are:
-v OFS=','
set output field separator!~/^$/
regexp exclude empty lines, another quick way to replace is sed {link}
Note that: use single quotation mark ''
for scripts part, for code,
[]
for list, $
for magic variables.
Can use together with uniq
and sort
for quick examination of file list.
sed
Never use -i
and -n
together, will overwrite with empty file.
And do not use substitute s////
with print //p
安装deb文件
进入.deb的对应路径,.deb后缀是由debian发行的linux版本的安装包,.rpm是redhat系列,还有.tar.gz是压缩包,解压后配置添加环境变量运行。
关于dpkg 和 apt
dpkg是底层本地包管理器,apt记录依赖关系进行更加自动化的获取和安装
https://zhuanlan.zhihu.com/p/201060276
是用于重新编译软件的,他会自动寻找Makefile路径中的文件,此外可以通过-f指定其他路径
GNU、gcc、make?
GNU 是 GNU is not Unix的递归缩写,是一个发起为了避免Unix垄断的项目
Linux其实只是kernel, 全称应为 GNU|Linux
gcc是compiler, compile scripts into binary executable files.
make is a batch run tool for gcc.
combo: find| xargs grep
重点描述 xargs的作用,他是作为一个过滤器,简单理解就是把find的stdout转换为stdin传递给下一命令。
Text editor: nano
该服务器没装vim,只有nano
nano官方documentation – shortcut:
https://www.nano-editor.org/dist/latest/cheatsheet.html
常用:ctrl
+w
搜索
alt+w下一个,alt+q上一个
Bkgrd running: screen
后台运行进程,nohup 的升级版:screen
基本就是新建一个后台静默线程:
详细解说:https://blog.csdn.net/euzmin/article/details/105090217
主要命令
- 创建 screen -S %Session%Name
- 展示 screen -ls [match]
- 内部 ctrl+a后输入?,访问说明
- ctrl+a d 退出当前窗口。
基本上常用的就只有上述4个补充功能
- 翻页查看,ctrl+a esc进入复制模式,ctrl+d Page down, ctrl+u Page up
- 进入activate状态的screen, screen -D -r YOUR_SCREEN
IPython
ipython的多行输入:ctrl+o
conda
conda env quick deploy 快速配置环境
1 2 3 |
conda env create -f environment.yml # 导出环境配置到environment.yml,可以改为自定义文件名 # 注意修改 name 和 prefix (prefix中最好是包含name结尾的路径) conda env create -f environment.yml # 导入配置创建环境 |
conda migrate
If you have installed the conda using default settings but now decide to move it to a new drive with more space. Instead of the prevalent uninstall & reinstall, try my process below. Leave a comment if you find it helpful. ;D
1) move the miniconda3 folder to the destination.
2) Override the export
using declare
as well as the .bashrc
2.1) Input export
in shell, the first 2 lines should show the old path of conda
2.2) Override the old paths with declare -x
as shown.
2.3) Replace the old dir in ~/.bashrc
The conda should work as before now. Have fun!