@linux文件管理
发布时间:2022-10-11 13:53:15 296 相关标签: # ssh# 设备
文件管理
创建文件
[root@string /]# mkdir dir
[root@string /]# ls -l
total 20
drwxr-xr-x 2 root root 6 Mar 5 12:18 dir
- -p : 当上级目录不存在时,自动创建上级目录。一般称之为:递归创建
[root@string ~]# mkdir -p abc/bcd/cde/def
[root@string ~]# tree abc/
[root@string ~]# mkdir -pv one/two/treee/four
# 创建单个文件
[root@string test]# touch 1.txt
[root@string test]# ls
1.txt
# 创建多个文件
[root@string test]# touch 3.txt 2.txt
[root@string test]# ls
1.txt 2.txt 3.txt
# 匹配创建多个文件
[root@string test]# touch {a..z}.txt
[root@string test]# ls
1.txt 3.txt b.txt d.txt f.txt h.txt j.txt l.txt n.txt p.txt r.txt t.txt v.txt x.txt z.txt
2.txt a.txt c.txt e.txt g.txt i.txt k.txt m.txt o.txt q.txt s.txt u.txt w.txt y.txt
[root@string ~]# touch {abc,bcd,fgh}.txt
[root@string ~]# ls
文件查询
[root@string ~]# ls
abc abc.txt {a...c}.txt bcd.txt dir fgh.txt one test
[root@string ~]# ls -a
. abc {a...c}.txt .bash_logout .bashrc .cshrc fgh.txt one .ssh test 系统优化.md
.. abc.txt .bash_history .bash_profile bcd.txt dir
[root@string ~]# ls -l
total 8
drwxr-xr-x 3 root root 17 Mar 5 12:21 abc
-rw-r--r-- 1 root root 0 Mar 5 12:35 abc.txt
-rw-r--r-- 1 root root 0 Mar 5 12:35 {a...c}.txt
-rw-r--r-- 1 root root 0 Mar 5 12:35 bcd.txt
# 说明
- : 普通文件
d : 目录文件
l : 链接文件
s : 套接字文件
c : 设备文件
b : 设备文件
p :
[root@string ~]# ls -lh
total 8.0K
drwxr-xr-x 2 root root 4.0K Mar 5 12:34 test
[root@string ~]# ls -d /etc/sysconfig/
/etc/sysconfig/
[root@string ~]#
[root@string ~]# ls -F /root/
abc/ abc.txt {a...c}.txt bcd.txt dir/ fgh.txt one/ test/ 系统优化.md
[root@string ~]# ls /root/
abc abc.txt {a...c}.txt bcd.txt dir fgh.txt one test 系统优化.md
[root@string ~]# /bin/ls -F /root/
abc/ abc.txt {a...c}.txt bcd.txt dir/ fgh.txt one/ test/ 系统优化.md
[root@string ~]#
[root@string ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
- 查看文件开头(head:从头打印文件,默认打印前10行)
[root@string ~]# head /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
[root@string ~]# head -n 2 /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
[root@string ~]# head -c 100 /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IP
- 查看文件结尾(tail 从尾部开始打印文件,默认打印10行)
[root@string ~]# tail /etc/sysconfig/network-scripts/ifcfg-eth0
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=40fd9db3-b150-435d-a610-32285fc596d2
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.15.100
PREFIX=24
GATEWAY=192.168.15.2
DNS1=114.114.114.114
IPV6_PRIVACY=no
[root@string ~]# tail -n 2 /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=114.114.114.114
IPV6_PRIVACY=no
[root@string ~]# tail -c 50 /etc/sysconfig/network-scripts/ifcfg-eth0
192.168.15.2
DNS1=114.114.114.114
IPV6_PRIVACY=no
[root@string ~]# echo "string1" >> abc.txt
文章来源: https://blog.51cto.com/u_15166421/5742225
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报