Linux 常见文件系统命令 tmux操作 vim命令

Linux常见文件系统命令

目录说明

  • / 是根目录
  • ~/ 是家目录,家目录是指 进入系统后用户后所在目录,一般为/home/用户名
  • . 是当前目录
  • .. 是上层目录
  • 绝对路径是指从 根路径下 开始的路径
  • 相对路径是指相对于 当前路径 的路径

常用文件系统命令

  1. man 命令 或者 命令 --help 查看命令的帮助文档,man代表 “manual”(手册)的缩写

  2. ls [路径] 查看路径下的内容,list的缩写,常用的参数:

    • -h : 以人类可读的格式显示文件大小,例如使用KM等单位表示。human
    • -a:显示所有文件和目录,包括以.开头的隐藏文件。all
    • -l:以长格式显示文件和目录的详细信息,包括文件权限、所有者、大小、修改日期等。long

    可以复合使用,如ls -lh

  3. cd [路径] 进入路径,change directory,路径可以是相对路径绝对路径根目录家目录

  4. pwd 查看当前路径

  5. rm [文件或者文件夹]: 删除目录或者文件,remove的缩写,常见参数:

    • -r:递归删除目录及其内容。recursive
    • -f:强制删除,无需确认。rm /* -rf 删库跑路。force
    • -i:交互模式。在删除前会询问用户是否确认删除操作,用户需要手动确认。interactive
  6. cp [路径1] [路径2] 将路径1下的内容拷贝到路径2,copy的缩写,复制时可以进行重命名,常见参数:

    • -r:递归复制目录及其内容。当要复制的源文件是目录时使用。
  7. mv [路径1] [路径2] 将路径1下的内容移动到路径2,move的缩写,兼具重命名的功能。

  8. mkdir [目录名] 创建文件夹,make directory 的简写,可以具有多个目录,常用参数:

    • -p:递归创建目录。parentsmkdir a/b/c -p 表示a目录不存在时,将a作为父目录创建。
  9. touch [文件名称] 创建文件。

  10. cat [文件名称] 在终端显示文件内容。

  11. ctrl c 终止当前行命令,跳转到下一行

  12. ctrl u 清除当前行命令。

tmux 使用

tmux原本的使用前缀键是ctrl + b 并且不支持一些鼠标操作,以下的操作是修改配置文件.tmux.conf之后的操作命令。配置文件在文章末尾,将其放在家目录下即可

tmux的作用:

  1. 分屏
  2. 防止终端挂掉,数据丢失。

tmux 操作命令

  1. tmux 打开一个tmux session,一个window,一个pane。
  2. ctrl + a,再按% 左右分屏,右边多出一个pane
  3. ctrl + a,再按" 上下分屏,下边多出一个pane
  4. ctrl + d 关闭当前鼠标聚焦的pane
  5. ctrl + a,再按z 当前鼠标聚焦的pane全屏,再按一次取消全屏,目的是有时需要全屏复制一些内容
  6. ctrl + a,再按d 挂起当前的tmux,挂起表示还在后台运行
  7. tmux a 打开挂起的tmux
  8. shift + 鼠标 选中内容,ctrl INSERT 复制选中内容,shift INSERT 粘贴刚才选中的内容。
  9. ctrl + a 再按s 查看当前tmux中的所有session,上下键可以上下选择,左右键可以折叠和展开。

vim命令

vim的三种模式

  1. 普通模式:可以执行各种编辑操作,如移动光标复制粘贴文本删除查找等。按下 Esc 键可以从其他模式返回到普通模式。
  2. 插入模式:按下i进入插入模式,可以进行输入。
  3. 命令行模式:在普通模式下,按下 : 键进入命令行模式。在命令行模式下,你可以输入各种 Vim 命令来执行特定的操作,如保存文件搜索替换设置选项等。按下回车键执行命令后,会返回到普通模式。

配置文件在文章末尾,.vimrc 复制到家目录下。

常见操作命令

  1. i 进入插入模式
  2. ESC 推出插入模式进入 普通模式
  3. : set paste 进入粘贴模式,复制进来的代码保持原有代码的缩进格式,再进行插入时没有缩进。
  4. set nopaste 退出粘贴模式
  5. /word 查找光标后面的的所有word,查找到 的位置会全部高亮
  6. :noh 取消高亮,主要是为了查找到的位置会高亮,插入时影响观察
  7. ?word 查找光标前的的所有word,查找到的位置会全部高亮
  8. n 按照查找的方向光标顺序跳转,N 按照查找的方向光标逆序跳转
  9. gg 跳转到首行
  10. G 跳转到最后一行
  11. nG 跳转到第n行
  12. n 空格 光标跳转到n个空格之后
  13. 0 跳转到当前行首,$ 跳转到当前行末
  14. v 选中内容
  15. y 复制选中的内容 yy复制当前行
  16. p 粘贴复制的内容
  17. d 删除选中的内容 dd 删除当前行
  18. :n1,n2s/word1/word2/g 将n1行和n2行之间的所有word1替换为word2,如果没有g,将n1行和n2行之间每一行的第一个word1替换为word2
  19. u 撤销上一步操作,ctrl u 恢复上一步的撤销操作。

配置文件

tmux配置文件

set-option -g status-keys vi                                                                                                                                                        
setw -g mode-keys vi

setw -g monitor-activity on

# setw -g c0-change-trigger 10
# setw -g c0-change-interval 100

# setw -g c0-change-interval 50
# setw -g c0-change-trigger  75


set-window-option -g automatic-rename on
set-option -g set-titles on
set -g history-limit 100000

#set-window-option -g utf8 on

# set command prefix
set-option -g prefix C-a 
unbind-key C-b 
bind-key C-a send-prefix

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

bind < resize-pane -L 7
bind > resize-pane -R 7
bind - resize-pane -D 7
bind + resize-pane -U 7


bind-key -n M-l next-window
bind-key -n M-h previous-window                                                                                                                                                               

set -g status-interval 1
# status bar
set -g status-bg black
set -g status-fg blue


#set -g status-utf8 on
set -g status-justify centre
set -g status-bg default
set -g status-left " #[fg=green]#S@#H #[default]"
set -g status-left-length 20


# mouse support
# for tmux 2.1
# set -g mouse-utf8 on
set -g mouse on
#
# for previous version
#set -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on


#set -g status-right-length 25
set -g status-right "#[fg=green]%H:%M:%S #[fg=magenta]%a %m-%d #[default]"

# fix for tmux 1.9
bind '"' split-window -vc "#{pane_current_path}"
bind '%' split-window -hc "#{pane_current_path}"
bind 'c' new-window -c "#{pane_current_path}"

# run-shell "powerline-daemon -q"

# vim: ft=conf

vim 配置文件

" An example for a vimrc file.
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file
endif
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching
"==========================================================================
"My Setting-sunshanlu
"==========================================================================
vmap <leader>y :w! /tmp/vitmp<CR>
nmap <leader>p :r! cat /tmp/vitmp<CR>

"语法高亮
syntax enable
syntax on
"显示行号
set nu

"修改默认注释颜色
"hi Comment ctermfg=DarkCyan
"允许退格键删除
"set backspace=2
"启用鼠标
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"按C语言格式缩进
set cindent
set autoindent
set smartindent
set shiftwidth=4

" 允许在有未保存的修改时切换缓冲区
"set hidden

" 设置无备份文件
set writebackup
set nobackup

"显示括号匹配
set showmatch
"括号匹配显示时间为1(单位是十分之一秒)
set matchtime=5
"显示当前的行号列号:
set ruler
"在状态栏显示正在输入的命令
set showcmd

set foldmethod=syntax
"默认情况下不折叠
set foldlevel=100
" 开启状态栏信息
set laststatus=2
" 命令行的高度,默认为1,这里设为2
set cmdheight=2


" 显示Tab符,使用一高亮竖线代替
set list
"set listchars=tab:\|\ ,
set listchars=tab:>-,trail:-


"侦测文件类型
filetype on
"载入文件类型插件
filetype plugin on
"为特定文件类型载入相关缩进文件
filetype indent on
" 启用自动补全
filetype plugin indent on 


"设置编码自动识别, 中文引号显示
filetype on "打开文件类型检测
"set fileencodings=euc-cn,ucs-bom,utf-8,cp936,gb2312,gb18030,gbk,big5,euc-jp,euc-kr,latin1
set fileencodings=utf-8,gb2312,gbk,gb18030
"这个用能很给劲,不管encoding是什么编码,都能将文本显示汉字
"set termencoding=gb2312
set termencoding=utf-8
"新建文件使用的编码
set fileencoding=utf-8
"set fileencoding=gb2312
"用于显示的编码,仅仅是显示
set encoding=utf-8
"set encoding=utf-8
"set encoding=euc-cn
"set encoding=gbk
"set encoding=gb2312
"set ambiwidth=double
set fileformat=unix


"设置高亮搜索
set hlsearch
"在搜索时,输入的词句的逐字符高亮
set incsearch

" 着色模式
set t_Co=256
"colorscheme wombat256mod
"colorscheme gardener
"colorscheme elflord
colorscheme desert
"colorscheme evening
"colorscheme darkblue
"colorscheme torte
"colorscheme default

" 字体 && 字号
set guifont=Monaco:h10
"set guifont=Consolas:h10

" :LoadTemplate       根据文件后缀自动加载模板
"let g:template_path='/home/ruchee/.vim/template/'

" :AuthorInfoDetect   自动添加作者、时间等信息,本质是NERD_commenter && authorinfo的结合
""let g:vimrc_author='sunshanlu'
""let g:vimrc_email='sunshanlu@baidu.com'
""let g:vimrc_homepage='http://www.sunshanlu.com'
"
"
" Ctrl + E            一步加载语法模板和作者、时间信息
""map <c-e> <ESC>:AuthorInfoDetect<CR><ESC>Gi
""imap <c-e> <ESC>:AuthorInfoDetect<CR><ESC>Gi
""vmap <c-e> <ESC>:AuthorInfoDetect<CR><ESC>Gi



" ======= 引号 && 括号自动匹配 ======= "
"
":inoremap ( ()<ESC>i

":inoremap ) <c-r>=ClosePair(')')<CR>
"
":inoremap { {}<ESC>i
"
":inoremap } <c-r>=ClosePair('}')<CR>
"
":inoremap [ []<ESC>i
"
":inoremap ] <c-r>=ClosePair(']')<CR>
"
":inoremap < <><ESC>i
"
":inoremap > <c-r>=ClosePair('>')<CR>
"
"":inoremap " ""<ESC>i
"
":inoremap ' ''<ESC>i
"
":inoremap ` ``<ESC>i
"
":inoremap * **<ESC>i

" 每行超过80个的字符用下划线标示
""au BufRead,BufNewFile *.s,*.asm,*.h,*.c,*.cpp,*.java,*.cs,*.lisp,*.el,*.erl,*.tex,*.sh,*.lua,*.pl,*.php,*.tpl,*.py,*.rb,*.erb,*.vim,*.js,*.jade,*.coffee,*.css,*.xml,*.html,*.shtml,*.xhtml Underlined /.\%81v/
"
"
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 80 characters.
  autocmd FileType text setlocal textwidth=80

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

  augroup END

else

  set autoindent		" always set autoindenting on

endif " has("autocmd")

" 增加鼠标行高亮
set cursorline
hi CursorLine  cterm=NONE   ctermbg=darkred ctermfg=white

" 设置tab是四个空格
set ts=4
set expandtab

" 主要给Tlist使用
let Tlist_Exit_OnlyWindow = 1
let Tlist_Auto_Open = 1
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我定亲手擦亮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值