Experiment three: Linux system administration and user configuration VIM

project content
This work belongs courses Course Link
Where this requirement in the job Claim
Student ID - Name 17043114- Li Qiang
Job learning objectives 1. Learning 2. Learning Linux system user management and configuration using vim

A: Linux User Management

Q: Why should avoid using the Linux system root user login?

A: When you log in as root, all programs have the highest authority, can even have the power to destroy the whole system. On the one hand is the fear of misuse root cause huge disaster, one is afraid that he might have malicious software, or the software itself is defective, it will cause great losses.

1) How to view the current user's information in three files related to the user's?


cat / etc / passwd | grep liq # display line containing the root of the / etc / passwd in

Please briefly describe these three files:

1./etc/passwd files: Each user has a corresponding rows, it records the basic attributes of users.

2./etc/group files: / etc / group file is the user group profiles, i.e. all the information of the user group are stored in this file.

3./etc/shadow file: password information is used to store the user's Linux system, also known as "shadow file."

2) view the current user-related information id command


Q: Please briefly describe the output?

A: liq's UID number = 1000, GID number = 1000. User liq members of a group below: amd the GID number = 4, cdrom a GID number = 24, sudo a GID number = 27, dip the GID number = 30, plugdev a GID number = 46, Ipadmin a GID number = 108, sambashare the GID number = 124. root user UID, GID = 0

3) Create two accounts, an account for the test, the other account begins with a capital E add your own student number ending in four and two respectively account password and administrator rights, after account setup is complete, simply switching the account to view information , delete the test account, leaving the other account for subsequent operation

a) creating a user

b) Set Password

c) set permissions

d) switching account


e) deleting the account test

Two: VIM simple configuration

a) Switch to the account reserved

b) VIM create a configuration file in the user's home directory .vimrc

c) Open the file and add the following

set number          "显示行号   

syntax on           "语法高亮

set cursorline      

set ruler           " 显示标尺  

set showcmd         " 输入的命令显示出来,看的清楚些  

set scrolloff=3     " 光标移动到buffer的顶部和底部时保持3行距离  

set novisualbell    " 不要闪烁(不明白)  

set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}   "状态行显示的内容  

set nocompatible               "去除VIM一致性,必须"

set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

set termencoding=utf-8

set encoding=utf-8

set fileencoding=utf-8


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""新文件标题

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"新建.c,.h,.sh,.java文件,自动插入文件头 

autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 

""定义函数SetTitle,自动插入文件头 

func SetTitle() 

    "如果文件类型为.sh文件 

    if &filetype == 'sh' 

        call setline(1,"\#########################################################################") 

        call append(line("."), "\# File Name: ".expand("%")) 

        call append(line(".")+1, "\# Author: liq") 

        call append(line(".")+2, "\# mail: [email protected] ") 

        call append(line(".")+3, "\# Created Time: ".strftime("%c")) 

        call append(line(".")+4, "\#########################################################################") 

        call append(line(".")+5, "\#!/bin/bash") 

        call append(line(".")+6, "") 

    else 

        call setline(1, "/*************************************************************************") 

        call append(line("."), "    > File Name: ".expand("%")) 

        call append(line(".")+1, "    > Author: liq") 

        call append(line(".")+2, "    > Mail: [email protected]") 

        call append(line(".")+3, "    > Created Time: ".strftime("%c")) 

        call append(line(".")+4, " ************************************************************************/") 

        call append(line(".")+5, "")

    endif

    if &filetype == 'cpp'

        call append(line(".")+6, "#include<iostream>")

        call append(line(".")+7, "using namespace std;")

        call append(line(".")+8, "")

    endif

    if &filetype == 'c'

        call append(line(".")+6, "#include<stdio.h>")

        call append(line(".")+7, "")

    endif

    "新建文件后,自动定位到文件末尾

    autocmd BufNewFile * normal G

endfunc 

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent      " 自动缩进

set cindent

set tabstop=4        " Tab键的宽度

set softtabstop=4       " 统一缩进为4

set shiftwidth=4

set noexpandtab         " 不要用空格代替制表符

set smarttab            " 在行和段开始处使用制表符

set showmatch

set history=1000        " 历史记录数

set nobackup            "禁止生成临时文件

set noswapfile

set ignorecase          "搜索忽略大小写

set hlsearch            "搜索逐字符高亮

set incsearch

set gdefault            "行内替换

set langmenu=zh_CN.UTF-8        "语言设置

set helplang=cn

set laststatus=2                " 总是显示状态行

filetype on                     " 侦测文件类型

filetype plugin on          " 载入文件类型插件

filetype indent on          " 为特定文件类型载入相关缩进文件

set iskeyword+=_,$,@,%,#,-      " 带有如下符号的单词不要被换行分割

set linespace=0         " 字符间插入的像素行数目

set wildmenu        " 增强模式中的命令行自动完成操作

set backspace=2     " 使回格键(backspace)正常处理indent, eol, start等

set whichwrap+=<,>,h,l      " 允许backspace和光标键跨越行边界

set mouse=a     " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)

set selection=exclusive

set selectmode=mouse,key

"自动补全

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

function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction

set completeopt=longest,menu    "打开文件类型检测, 加了这句才可以用智能补全

d) Create and open a file that ends in .c

Guess you like

Origin www.cnblogs.com/liqi2/p/12519410.html