• linux测试


    1 简述看到的文件权限都代表什么意思
    文件类型 所有者,组,其他人
    2 说说主组与其他组有什么区别
    主组建立文件显示组,其他权限一样
    3 如何创建一用户,创建一个组,如何将一个用户加入一个组

    useradd 选项 用户名
    groupadd 选项 用户组
    usermod -a -G groupname username

    4 如何更改一个文件的权限,将一个文件改为所有者可读可写可执行,其他人可读
    chmod 774 文件名
    5 如何创建一个目录,如何将一个目录复制到另一个目录里去
    cp -r
    6 如何查看一个文件的内容,并显示行号
    set nu
    7 如何进入到一个文件中并查询某个单词,如何在文件中直接跳转到指定行
    ?或/ 数字加G
    8 如何查看所有进程,如何查看指定进程
    ps aux | grep XXX
    9 如何查看一个进程的父进程

    pstree -Aup

    10 什么样的进程是僵尸进程,产生原因?如何处理?
    文件属性为z,强制删除某些文件或者中断某个进程的残留,先删除父进程
    11 如何结束一个服务(常规方法与非常规方法)?
    killall -15 -9
    12 如何杀死一个进程?
    kill
    13 如何查看你系统中最占用cpu的程序,将他们按照从多到少排序?
    top P
    14 如何在linux中执行一个定时计划任务
    crontab
    15 管理员如何修改一个用户的账号密码?
    passwd username
    16 与用户及组相关的文件有哪些?
    etc/group etc/shdow etc/ passwd
    17 使用pycharm远程链接linux,编写正确的代码报错的原因是什么?
    因为windows换行有特殊符号

    18 写出shell脚本中的比较符号用字母的表示,比如 等于是eq

    19 使用shell完成一个计算器小程序,要求得到结果后可以继续进行下一次计算
    版本一

    #!/bin/sh
    read -p '请输入第一个数:' num1
    echo "1 +"
    echo "2 -"
    echo "3 *"
    echo "4 \"
    
    read -p '请输入运算符号序号:' fu
    read -p '请输入第二个数:' num2
    
    if [ $fu == 1 ]
    then
    echo `expr $num1 + $num2`
    fi
    if [ $fu == 2 ]
    then
    echo `expr $num1 - $num2`
    fi
    if [ $fu == 3 ]
    then
    echo `expr $num1 * $num2`
    fi
    if [ $fu == 4 ]
    then
    echo `expr $num1 / $num2`
    fi
    
     
    
    版本二
    
    #!/bin/bash
    read -p "请输入第一个数:" num1
    read -p "请输入运算符:" fuhao
    read -p "请输入第二个数:" num2
    if [ "$fuhao" == "+" ]
    then
    echo $num1 + $num2=$(($num1+num2))
    elif [ "$fuhao" == "-" ]
    then
    echo $num1 - $num2=$(($num1-num2))
    elif [ "$fuhao" == "*" ]
    then
    echo $num1 * $num2=$(($num1*num2))
    else [ "$fuhao" == "/" ]
    echo $num1 / $num2=$(($num1/num2))
    fi
    
    版本三:实现得到结果后可以继续进行下一次计算
    #!/bin/bash
    results=1
    while true
    do
    echo $results
    if [ $[results] -eq 1 ]
    then
    read -p "请输入第一个数:" results
    fi
    
    read -p "请输入运算符:" fuhao
    read -p "请输入第二个数:" num2
    if [ "$fuhao" == "+" ]
    then
    echo $results + $num2=$(($results+num2))
    results=$(($results+num2))
    elif [ "$fuhao" == "-" ]
    then
    echo $results - $num2=$(($results-num2))
    results=$(($results-num2))
    
    elif [ "$fuhao" == "*" ]
    then
    echo $results * $num2=$(($results*num2))
    results=$(($results*num2))
    else [ "$fuhao" == "/" ]
    echo $results / $num2=$(($results/num2))
    results=$(($results/num2))
    
    fi
    
    echo "输入exit退出当次计算输入任意值继续运算"
    read -p "请输入:" aaa
    if [ "$aaa" = "exit" ]
    then
    results=1
    fi
    
    done
    

    20 将计算器放到函数中,调用函数开启计算器。

    hello(){
    
    read -p "请输入第一个数:" num1
    read -p "请输入运算符:" fuhao
    read -p "请输入第二个数:" num2
    if [ "$fuhao" == "+" ]
    then
    echo $num1 + $num2=$(($num1+num2))
    elif [ "$fuhao" == "-" ]
    then
    echo $num1 - $num2=$(($num1-num2))
    elif [ "$fuhao" == "*" ]
    then
    echo $num1 * $num2=$(($num1*num2))
    else [ "$fuhao" == "/" ]
    echo $num1 / $num2=$(($num1/num2))
    fi
    
    }
    
    hello
    
  • 相关阅读:
    HDU1312 ZOJ2165 Red and Black
    HDU1312 ZOJ2165 Red and Black
    HDU1181 变形课【DFS】
    codevs1017 乘积最大
    codevs1220 数字三角形
    codevs1169 传纸条
    codevs1219 骑士游历
    codevs1010 过河卒
    codevs1166 矩阵取数游戏
    codevs1154 能量项链
  • 原文地址:https://www.cnblogs.com/HK769405/p/13967460.html
Copyright © 2020-2023  润新知