测试工程师常用Linux命令(1)

Linux中的路径

命令实例 作用 重要性
/

表示根目录,是绝对路径

./ 表示当前路径,是相对路径
../ 表示上一级目录,是相对路径
/root root用户的主目录
/home/username 存放普通用户的个人配置文件
/bin 存放Linux的常用命令
/boot 存放系统启动时要用到的命令
/dev 存放Linux系统中使用的外部设备
/etc 存放系统管理时用到的配置文件和子目录
/sbin 存放管理员的系统管理程序
/lib 存放系统动态链共享库
/lost+found 系统运行时异常产生的错误,会将遗失的片段放在这里
/mnt 可临时将别的外部设备挂接在此项目下
/proc 存在系统内存中的信息
/user 用户的应用程序和文件都存放在这个目录下
/tmp 存放临时文件的目录

 

Linux文件操作

 

功能项 命令实例 作用 重要性
文件创建 vi /opt/work/hello.txt 在目录下创建文件hello.txt并进入vi编辑器界面
  touch /opt/learn/test  在目录/opt/work下创建空白文件test  高
   cat>/opt/learn/catfile  

创建文件catile并在屏幕上输入内容,最后按ctrl+D
退出

 高
 文件查看  vi /etc/passwd  在vi编辑器中输出文本内容  高
   cat /etc/ passwd  在屏幕上输出文本内容  高
   more /etc/ passwd  分屏输出文本内容  高
   less /etc/ passwd  分屏输出文本内容并按需加载文件(适用于大文件的查看)  高
   head -n 10  只输出文件的头10行  高
   tail -n 20  /etc/passwd  只输出文件末尾的20行  高
  strings /bin/ls   查看二进制文件中的可打印字符  高
  文件操作 cp hello.txt /opt/test 把文件hello.txt复制到文件夹/opt/test下  高
   cp hello.txt /opt/test/hello.cp  把文件hello.txt复制到文件夹/opt/test下并重命名成hello.cp  高
   mv hello.txt /opt/test  将文件hello.txt剪切到文件夹/opt/test下  高
   mv hello.txt /opt/test/hello.txt 将文件hello.txt剪切到文件夹/opt/test下并重新命名hello.txt
   mv hello.txt hello2.txt  重命名  高
   rm /opt/test/hello.cp  删除文件  高
  rm -f /opt/test/hello.txt 强制删除文件,不会有提示信息
  du -sk hello.txt 查看文件hello.txt的大小(以k为单位)
链接 ln -s hello.txt shello 为hello.txt文件创建一个名为shello的软链接(类似与快捷方式)
  ln -s hello.txt dhello 为hello.txt文件创建一个名为dhello的硬链接,硬链接表示所有文件中更改任意一个,其他文件的所有属性会跟着变化,如大小,更新时间,权限等

--------未完待续--------

posted @ 2020-07-21 21:36  luffy_best  阅读(267)  评论(0)    收藏  举报