(1) shell的使用

<1>检查系统当前运行的shell版本:

[root@lab root]# echo $SHELL

<2>从当前shell下切换到csh:

[root@lab root]# csh

退出csh,回到bash:

[root@lab root]# exit

<3>在系统的根目录下寻找文件

文件名第一个字符为任意字符,后面是asswd的文件:

[root@lab root]# find / -name "?asswd"

列出/etc目录下的所有以.conf结尾的文件:

[root@lab root]# ls /etc/*.conf

列出/etc 目录下的特定文件。此文件文件名第一个字符为“S”“s”“H”“h”中之一,

后面的字符为“osts”:

[root@lab root]# ls /etc/[HhSs]osts

<4>创建ls –a的别名lsa:

[root@lab root]# alias lsa='ls -a'

比较两个命令的输出结果:

[root@lab root]# ls -a

[root@lab root]# lsa

取消别名ls –a的别名lsa:

[root@lab root]# unalias lsa

比较两个命令的输出结果:

[root@lab root]# ls -a

[root@lab root]# lsa

<5>命令替换

[root@lab tmp]# echo `pwd`

<6>输入重定向cat从/root/ anaconda-ks.cfg文件中获取输入并显示文件内容:

[root@lab root]# cat</root/ anaconda-ks.cfg

<7>输出重定向

建立my.out文件

[root@ lab root]# touch my.out

将ls命令的输出写入my.out文件中

[root@lab root]# ls –l /root >/root/my.out

查看my.out文件内容。可以发现和直接使用ls命令在屏幕上的输出一致:

[root@lab root]# cat /root/my.out

追加输出重定向:

[root@lab root]# cat /root/my.out

[root@lab root]# cat /root/ anaconda-ks.cfg

[root@lab root]# cat /root/anaconda-ks.cfg >>/root/my.out

[root@lab root]# cat /root/my.out

删除my.out文件:

[root@ lab root]# rm -f /root/my.out

<8>管道的使用:

[root@ lab root]# rpm -qa | grep kudzu

(2) 文件和目录操作命令

使用cd命令,进入/tmp目录:

[root@lab root]# cd /tmp/ 

使用pwd命令查看当前路径:

[root@lab tmp]# pwd  

使用mkdir命令建立一个目录linuxtest

[root@lab tmp]# mkdir linuxtest 

使用ls命令查看/tmp目录中是否出现了linuxtest目录

[root@lab tmp]# ls  

进入linuxtest目录

[root@lab tmp]# cd linuxtest/ 

查看此目录中是否有文件

[root@lab linuxtest]# ls

使用find命令在根目录下查找以”passwd”开头的所有文件

[root@lab linuxtest]# find / -name "passwd*"

使用cp命令将/etc/passwd文件复制到当前目录中

[root@lab linuxtest]# cp /etc/passwd .

列出当前目录下文件的详细信息,特别注意passwd的权限和用户,用户组

[root@lab linuxtest]# ls -l

改变passwd文件的权限属性为777,也就是rwxrwxrwx

[root@lab linuxtest]# chmod 777 passwd

改变passwd的用户所有者为nobody

[root@lab linuxtest]# chown nobody passwd

改变passwd文件的组所有为nobody

[root@lab linuxtest]# chgrp nobody passwd

使用ll命令列出文件的详细信息,注意再次观察passwd文件的权限,用户和用户组

[root@lab linuxtest]# ll

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

[root@lab linuxtest]# cat passwd

使用grep命令在passwd文件中寻找nobody字串

[root@lab linuxtest]# grep nobody /tmp/linuxtest/passwd

使用wc命令对passwd进行统计

[root@lab linuxtest]# wc passwd

使用mkdir命令建立一个目录student

[root@lab linuxtest]# mkdir student 

使用mv命令将passwd文件从/tmp/linuxtest/目录移动到/tmp/linuxtest/student目录

[root@lab linuxtest]# mv /tmp/linuxtest/passwd /tmp/linuxtest/student

进入/tmp/linuxtest/student目录

[root@lab linuxtest]# cd student

列出目录中文件,注意是否有passwd

[root@lab student]# ls

使用rm命令强制删除passwd文件

[root@lab student]# rm -f passwd

回到/tmp/ linuxtest目录

[root@lab student]# cd ..

使用rmdir命令删除目录student

[root@lab linuxtest]# rmdir student

回到/tmp目录

[root@lab linuxtest]# cd ..

使用rm命令删除目录linuxtest

[root@lab tmp]# rm-fr linuxtest

Linux命令—文件目录的更多相关文章

  1. linux命令--文件目录操作命令

    一.命令的基本格式 1.命令提示符 [root@love2 ~]# []:这是提示符的分隔符号,没有特殊含义. root:显示的是当前的登录用户. @:分隔符号,没有特殊含义.love2:当前系统的主 ...

  2. linux命令_文件目录操作命令

    # linux命令--文件和目录操作命令 pwd "print working directory" 打印工作目录的绝对路径 范例: 在bash命令行显示当前用户的完整路径 系统B ...

  3. 第2章 新手必须掌握的Linux命令

      第2章 新手必须掌握的Linux命令 章节简述: 本章节讲述系统内核.Bash解释器的关系与作用,教给读者如何正确的执行Linux命令以及常见排错方法. 经验丰富的运维人员可以恰当的组合命令与参数 ...

  4. Linux学习心得之 linux命令

    作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 前言 本篇博客是对 每日一linux命令(http://www.cnblogs.com/pe ...

  5. 每天一个linux命令目录

    出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html 开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每 ...

  6. 工作中常用的Linux命令:find命令

    本文链接:http://www.cnblogs.com/MartinChentf/p/6056571.html (转载请注明出处) 1.命令格式 find [-H] [-L] [-P] [-D deb ...

  7. LINUX命令总结 -------来自 水滴娃娃 的CSDN

    LINUX命令总结 标签: LINUX命令总结 2014-01-27 15:54 41039人阅读 评论(1) 收藏 举报  分类: linux(1)  版权声明:本文为博主原创文章,未经博主允许不得 ...

  8. 工作中常用的Linux命令:目录

    工作两三年,每天都和Linux打交道,但每每使用Linux命令的时候却会像提笔忘字般不知如何使用,常常查手册或到网上找资料.此系列文章主要是为了方便自己在使用命令时随时可查阅.鄙人才疏学浅,文中若有任 ...

  9. Linux命令自己总结

    对于每一个Linux学习者来说,了解Linux文件系统的目录结构,是学好Linux的至关重要的一步.,深入了解linux文件目录结构的标准和每个目录的详细功能,对于我们用好linux系统只管重要,下面 ...

随机推荐

  1. [SCOI2009]windy数

    题目描述 windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道, 在A和B之间,包括A和B,总共有多少个windy数? 输入输出格式 输 ...

  2. bzoj 4919: [Lydsy六月月赛]大根堆

    Description 给定一棵n个节点的有根树,编号依次为1到n,其中1号点为根节点.每个点有一个权值v_i. 你需要将这棵树转化成一个大根堆.确切地说,你需要选择尽可能多的节点,满足大根堆的性质: ...

  3. hdu1698 线段树区间更新

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  4. A Problem-Solving FlowChart || 如何解决编程问题

    This is from book Cracking the coding interview, Gayle Laakmann Mcdowell. The flowchart can be used ...

  5. 开源小工具 - swagger API访问代码生成器(js/typescript)

    现在流行前后端分离,后端通常会使用swagger生成api文档,提供给前端的同事来调用,一般前端是查看这个文档,根据文档说明编写调用代码.其实,swagger已经提供了足够多的描述信息,我们可以基于s ...

  6. day0203 XML 学习笔记

    day02, 03 1. xml语言和作用 2. xml语法详解 2.1 xml 语法声明 2.1.1 encoding 属性 2.1.2 standalone 属性 2.2 xml 元素(Eleme ...

  7. VueJs(3)---V-指令

    VueJs(3)---V-指令(1) 一.语法 v- 指令是带有v-的特殊属性 v-if 条件渲染 v-show v-else (必须在v-if/v-else-if/v-show指令后) v-else ...

  8. python实现编写windows服务

    使用python编写windows服务 最近测试服务器上经常发生磁盘空间不足,每次手动清除比较麻烦,所以写个windows服务定时清理下.中间也遇到过几个坑,一起记录下来. 1.python实现win ...

  9. url重定向或者重写

    有四种方式:1.urlMappings,返回200状态码 <system.web> <urlMappings > <add url="~/others.aspx ...

  10. c++ 深入理解数组

    阅读前提:你得知道啥是数组. 本文需要弄清楚的问题如下: 1,数组作为函数参数,传入的是值,还是地址? 2,数组作为函数参数,数组的长度能否确定? 解决如下 1,数组作为函数参数,传入的是地址.因为数 ...