1.文件管理类型命令
ls:查看目录下文件和目录
cat less more tac tail:查看文本文件内容
cd:切换目录路径
cp:复制命令
mv:改名或类似剪切
rm:删除文件或目录
mkdir:创建文件夹文件
touch:创建文件
2.命令执行后状态返回值
可以用$? 命令查看。其中0表示成功执行,非0表示执行失败。
3.(1)创建/tmp下 a_c a_d b_c b_d
touch /tmp/{a,b}_{c,c}
(2) 创建/tmp/mylinux
[root@localhost zcj]# mkdir -pv /tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scriipts},lib/modles,\lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{lock,log,run}}
mkdir: created directory `/tmp/mylinux’
mkdir: created directory `/tmp/mylinux/bin’
mkdir: created directory `/tmp/mylinux/boot’
mkdir: created directory `/tmp/mylinux/boot/grub’
mkdir: created directory `/tmp/mylinux/dev’
mkdir: created directory `/tmp/mylinux/etc’
mkdir: created directory `/tmp/mylinux/etc/rc.d’
mkdir: created directory `/tmp/mylinux/etc/rc.d/init.d’
mkdir: created directory `/tmp/mylinux/etc/sysconfig’
mkdir: created directory `/tmp/mylinux/etc/sysconfig/network-scriipts’
mkdir: created directory `/tmp/mylinux/lib’
mkdir: created directory `/tmp/mylinux/lib/modles’
mkdir: created directory `/tmp/mylinux/lib64′
mkdir: created directory `/tmp/mylinux/proc’
mkdir: created directory `/tmp/mylinux/sbin’
mkdir: created directory `/tmp/mylinux/sys’
mkdir: created directory `/tmp/mylinux/tmp’
mkdir: created directory `/tmp/mylinux/usr’
mkdir: created directory `/tmp/mylinux/usr/local’
mkdir: created directory `/tmp/mylinux/usr/local/bin’
mkdir: created directory `/tmp/mylinux/usr/local/sbin’
mkdir: created directory `/tmp/mylinux/var’
mkdir: created directory `/tmp/mylinux/var/lock’
mkdir: created directory `/tmp/mylinux/var/log’
mkdir: created directory `/tmp/mylinux/var/run’
[root@localhost zcj]#
4.文件元数据信息,和修改其时间戳
命令 stat 文件名/目录名
[root@localhost zcj]# stat /srun3/db_setup
File: `/srun3/db_setup’
Size: 794 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 920018 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-11-26 02:53:45.061174670 +0800
Modify: 2017-06-02 14:43:36.000000000 +0800
Change: 2017-11-26 02:53:46.225849681 +0800
[root@localhost zcj]#
file 文件名称
size 文件大小 单位K
blocks 所占块的个数
IO blocks 单块的大小
device 设备标识
inode 节点id
links 硬链接数
access 权限
uid 属主信息
gid 属组信息
access 最后一次访问时间
modify 最后一次修改时间
change 最后一次更正时间
可以使用touch修改相应的时间戳
touch -a -t [[CC]YY]MMDDhhmm[.ss]
touch -m -t [[CC]YY]MMDDhhmm[.ss]
如:
[root@localhost zcj]# touch -a -t 1712071207 /srun3/db_setup
[root@localhost zcj]# stat /srun3/db_setup
File: `/srun3/db_setup’
Size: 794 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 920018 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-12-07 12:07:00.000000000 +0800
Modify: 2017-06-02 14:43:36.000000000 +0800
Change: 2017-12-06 19:12:21.001967394 +0800
[root@localhost zcj]#
5.定义命令别名
查看别名:alias
定义别名:[root@localhost zcj]# alias cls=clear
6./var下以l开头 中间至少一个数字。一小写字母结尾的文件或者目录
ls /var |grep “\<l.*[[:digit:]]\+.*[[:lower:]]\>”
7./etc下 数字开头,非数字结尾
ls /etc |grep “\<[[:digit:]].*[^[:digit:]]\>”
8./etc下 非字母开头后面跟一个字母以及任意长度任意字符
ls /etc |grep “\<[^[:alpha:]][[:alpha:]].*”
9 以tfile开头+时间错的文件夹
[root@localhost var]# mkdir -v /tmp/tfile-$(date “+%Y-%m-%d-%H-%M-%S”)
mkdir: created directory `/tmp/tfile-2017-12-07-01-21-33′
10 复制/etc/下p开头非数字结尾的文件或文件夹到/tmp/mytest1
cp -rf /etc/p*[^[:digit:]] /tmp/mytest1
11 复制/etc/下.d结尾的文件或文件夹到/tmp/mytest2
cp -rf /etc/*.d /tmp/mytest2
12 复制/etc/下l或m或n开头,以conf结尾的文件或文件夹到/tmp/mytest3
cp -rf /etc/[l,m,n]*.conf /tmp/mytest3
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/89741