Linux Command Cheat sheet

Software Installation

mit-scheme

For learning sicp, first, to solve compile dependencies, you need to install these packages:

sudo apt-get install debhelper m4 autotools-dev libssl-dev libmhash-dev libmcrypt-dev 
libgdbm-dev libpq-dev libncurses5-dev libx11-dev libxt-dev libdb-dev 
libltdl-dev 
View Code

then follow the instruction

Tmux

setw -g c0-change-trigger 100
setw -g c0-change-interval 250

bind-key c new-window -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"
bind-key '"' split-window -c "#{pane_current_path}"
~/.tmux.conf

Error shooting

locale error

locale -a
apt-get install locales
sudo dpkg-reconfigure locales 
View Code

 References

 

Vim

A recommanded vimrc for ics course(the statusline is awesome!)

setlocal noswapfile " 不要生成swap文件
set bufhidden=hide " 当buffer被丢弃的时候隐藏它
colorscheme evening " 设定配色方案
set number " 显示行号
set cursorline " 突出显示当前行
set ruler " 打开状态栏标尺
set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
set tabstop=4 " 设定 tab 长度为 4
set nobackup " 覆盖文件时不备份
set autochdir " 自动切换当前目录为当前文件所在的目录
set backupcopy=yes " 设置备份时的行为为覆盖
set hlsearch " 搜索时高亮显示被找到的文本
set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码
set matchtime=2 " 短暂跳转到匹配括号的时间
set magic " 设置魔术
set smartindent " 开启新行时使用智能自动缩进
set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符
set cmdheight=1 " 设定命令行的行数为 1
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ Ln\ %l,\ Col\ %c/%L%) " 设置在状态行显示的信息
set foldenable " 开始折叠
set foldmethod=syntax " 设置语法折叠
set foldcolumn=0 " 设置折叠区域的宽度
setlocal foldlevel=1 " 设置折叠层数为 1
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠
View Code

 

Docker

on debian, follow the instruction on the official website.

And there is a domestic mirror for docker resources :curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://51c782a9.m.daocloud.io

A typical configuration file of docker

 # setting base image
FROM debian

 # new a directory for sshd to run
RUN mkdir -p /var/run/sshd

 # installing ssh server
RUN apt-get update
RUN apt-get install -y openssh-server

 # installing sudo
RUN apt-get install -y sudo

 # make ssh services use IPv4 to let X11 forwarding work correctly
RUN echo AddressFamily inet >> /etc/ssh/sshd_config

 # defining user account imformation
ARG username=ics
ARG userpasswd=ics

 # adding user
RUN useradd -ms /bin/bash $username && (echo $username:$userpasswd | chpasswd)

 # adding user to sudo group
RUN adduser $username sudo

 # setting running application
CMD /usr/sbin/sshd -D

Then, to trigger this configuration, type

docker build -t ics-image .
docker images

# create a vm using certain image
docker create --name=ics-vm -p 20022:22 ics-image
docker start ics-vm
ssh -p 20022 ics@127.0.0.1
# see the configuration file (Dockerfile), it specifies the username and passwd of the super user of the image
exit
docker stop ics-vm

notice, you have to run these commands under root.

User Manage

Add user

groupadd rt
useradd -g rt -d /home/hzf -s /bin/bash -m hzf

# add sudo privilege

su
vi /etc/sudoers
# add 'hzf (ALL)... like the line that describes root'

 Short Cuts

  • ctrl-w delete a word before
  • ctrl-u delete the whole line
  • ctrl-r redo

References

https://learncodethehardway.org/unix/bash_cheat_sheet.pdf

 

 

posted @ 2017-09-08 19:01  ichneumon  阅读(172)  评论(0编辑  收藏  举报