zoukankan      html  css  js  c++  java
  • 实验三 Linux系统用户管理及VIM配置

    实验三 Linux系统用户管理及VIM配置

    项目 
    这个作业属于哪个课程 Linux系统与应用
    这个作业的要求在哪里 作业要求
    学号-姓名 17041526-钟大胜
    作业学习目标 1. 学习Linux系统用户管理 2.学习vim使用及配置

    简答:Linux系统为什么应避免使用root用户登录

         因为任何人只要知道了root的密码,就都可以通过su命令来登录为root用户--这无疑为系统带来了安全隐患,尤其是对服务器来说。而且root用户权力大,这导致自己误操作的破坏性就大。

    1)如何在与用户有关的三个文件中查看当前用户的信息?

    cat /etc/passwd | grep zds #查看用户配置文件

    请简要描述这三个文件?

          (1)/etc/passwd :用户信息文件

         (2)/ect/group :用户组文件

          (3)/ect/shadow :密码文件

    2)用id命令查看当前用户相关信息

    请简要描述输出结果?

       uid=1000(zds) #(zds)用户id

       gid=1000(zds) #(zds)组id

       组=1000(zds),10(wheel)#(zds)组名称

       uid=0(root) #(root)用户id

       gid=0(root) #(root)组id

       组=0(root) #(root)组名称

    3)创建两个账号,一个账号为test,另外一个账号以大写E开头加上你自己学号尾数4位,两个账号分别设置密码及管理员权限,账号设置完成后,切换账号简单查看信息后,删除test账号,保留另一账号,以备后续操作。

    a)创建账号

    b) 设置密码

    c)设置权限

    请简要描述用户组的概念?

       答:在linux中的每个用户必须属于一个组,不能独立于组外。在linux中每个文件有所有者,所有组,其他组的概念。所有者:一般为文件的创建者。所在组:当某个用户创建了一个文件后,这个文件的所在组就是该用户的所在组。除开文件的所有者和所有组的用户外,系统的其他用户都是文件的其他组。

    d)切换账号

    e)删除账号test

    VIM简单配置

    a)切换到保留的新创建账号

    b)在用户主目录创建一个VIM配置文件.vimrc

    c)打开并向文件中添加以下内容

    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: zds") 
    
            call append(line(".")+2, "# mail: 228256123@qq.com ") 
    
            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: zds") 
    
            call append(line(".")+2, "    > Mail: 228256123@qq.com ") 
    
            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)创建并打开一个以.c结尾的文件,如vim helloworld.c

    新建的文件应显示如下

  • 相关阅读:
    构建之法阅读笔记01
    最长英语单词链
    第十五周学习总结
    寻找“水王”
    Happy Necklace HDU
    Bi-shoe and Phi-shoe LightOJ
    The Embarrassed Cryptographer POJ
    Big Number HDU
    矩阵乘法模板C/C++
    Baby Step,Giant Step算法模板
  • 原文地址:https://www.cnblogs.com/zds1526/p/12539680.html
Copyright © 2011-2022 走看看