zoukankan      html  css  js  c++  java
  • 2020-2021-1 20209321《Linux内核原理与分析》第一周作业

    Linux基本命令总结

    1. sudo adduser lilei 在文件夹shiyanlou下新建一个用户lilei,lilei和shiyanlou 都在home这个目录下,ls /home 发现home下有shiyanlou和lilei

    2. su -l lilei 切换到lilei的这个登录用户

    3. who am i 显示的是当前操作用户的用户名

    4. whoami 显示的是当前登录用户的用户名

    5. groups shiyanlou 找到shiyanlou这个用户属于哪个用户组

    6. sudo apt-get update,
      sudo apt-get install xxx

    7. sudo deluser lilei --remove-home 删除用户,使用--remove-home参数在删除用户的时候会一并将该用户的工作目录一并删除,如果不使用那么系统会自动在/home目录为该用户保留工作目录

    8. ls 显示除了当前目录和上一级目录之外的所有非隐藏文件

    9. ls -l 显示非隐藏文件的详细信息(文件权限,所有者,所属用户组等)

    10. ls -a 显示除了当前目录和上一级目录之外的所有文件,包括隐藏文件

    11. ls -al 显示除了当前目录和上一级目录之外的所有文件包括隐藏文件的详细信息(文件权限,所有者,所属用户组等)

    12. ls -asSh 显示出所有文件以及文件的大小

    13. pwd 获取当前路径

    14. cd /home/lilei(su lilei) 切换到lilei这个用户,但是不切换环境变量

    15. su -lilei 切换到新的用户环境

    16. touch iphone11 新建iphone这个文件

    17. sudo chown shiyanlou iphone11 cd /home/lilei后,将iphone11文件所有者改为shiyanlou

    18. adduser和useradd的区别
      useradd只创建用户,不会创建用户密码和工作目录,创建完了需要使用passwd 去设置新用户的密码;adduser在创建用户的同时,会创建工作目录和密码(提示你设置),做这一系列的操作。

    19. cd .. 进入上一级目录

    20. cd ~ 进入你的home目录

    21. cd - 上一次所在目录

    22. cd /usr/local/bin 以绝对路径进入到/usr/local/bin目录

    23. cd ../../usr/local/bin 以相对路径进入到/usr/local/bin目录

    24. 创建文件时需要先cd ~ 切换到用户的主目录,然后touch 文件名

    25. 新建目录:
      mkdir mydir(空目录)
      mkdir -p father/son/grandson

    26. cp test father/son/grandson复制文件

    27. 将father复制到family目录

    • cd /home/shiyanlou
    • mkdir family
    • cp -r father family
    1. 强制删除test文件
    • cd /home/shiyanlou
    • rm -r test
    1. 强制删除family目录
    • cd /home/shiyanlou
    • rm -rf family
    1. 将文件file1移动到Documents目录
    • mkdir Documents
    • touch file1
    • mv file1 Documents
    1. 重命名文件
      mv file1 myfile 将文件file1命名为myfile

    2. 使用cat命令查看passwd文件内容

    • cd /home/shiyanlou
    • cp /etc/passwd passwd
    • cat -n passwd
    1. 使用more命令阅读passwd文件内容

      more passwd 打开后默认只显示一屏内容,终端底部显示当前阅读的进度

    2. 使用tail命令查看文件的头几行(默认前10行)和尾几行,可以查看最新增加的用户
      tail -n 1 /etc/passwd(参数-n后面紧跟行数)

    3. 使用file命令查看文件类型
      file /bin/ls

    4. cd /home/shiyanlou

    • declare tmp 新建变量
    • tmp=shiyanlou 为变量赋值
    • echo $tmp 读取变量的值
    1. 创建脚本文件
    • cd /home/shiyanlou
    • touch hello_shell.sh
    • gedit hello_shell.sh
    1. 为脚本文件添加可执行权限
      chmod 755 hello_shell.sh

    2. 执行脚本文件

    • cd /home/shiyanlou
    • ./hello_shell.sh
    1. 创建一个C程序
    • cd /home/shiyanlou
    • gedit hello_world.c
      保存后使用gcc生成可执行文件
    • gcc -o hello_world hello_world.c(gcc生成二进制文件默认具有可执行文件,不需要修改)
    1. 添加自定义路径到"PATH"环境变量
    • 使用cat /etc/shells命令查看当前系统安装的shell
    • 将命令添加到.zshrc中
      echo "PATH=$PATH:/home/shiyanlou/mybin" >> .zshrc
    1. unset (环境变量名)删除环境变量
    2. cd /home/shiyanlou
    • source .zshrc 让环境变量立即生效
    1. 打包文件夹,并查看了打包后文件的大小和类型
    • cd /home/shiyanlou
    • zip -r -q -o shiyanlou.zip /home/shiyanlou/Desktop
    • du -h shiyanlou.zip
    • file shiyanlou.zip
    1. unzip shiyanlou.zip
      将shiyanlou.zip解压到当前目录

    2. tar

    • 打包:cd /home/shiyanlou

      tar -P -cf shiyanlou.tar /home/shiyanlou/Desktop

    • 解包:mkdir tardir
      tar -xf shiyanlou.tar -C tardir

    1. 只查看一级目录信息
      du -h -d 0 ~

      只查看二级目录信息
      du -h -d 1 ~

  • 相关阅读:
    nhibernate的不支持
    iis7部署mvc2
    如何获取一张表的字段名
    HttpHandler与HttpModule
    json中含有HTML标签
    hql实现select new Type(column) from table
    数据库优化工具及如何进行优化
    ios MJExtension 数据解析转换
    阻止表中出现重复项——SQL UNIQUE 约束
    java IO 之 流的总结篇(图)
  • 原文地址:https://www.cnblogs.com/traceurli/p/13798885.html
Copyright © 2011-2022 走看看