linux常用命令-02-文件管理

touch:

创建文件或者更新文件修改时间

[root@leitingyan ~]# touch 1.txt
[root@leitingyan ~]# 

在这里插入图片描述

[root@leitingyan ~]# touch 1.txt
[root@leitingyan ~]# touch a.txt b.txt c.avi

在这里插入图片描述

cp:

复制文件或文件夹

//复制文件到指定目标
[root@leitingyan ~]# cp a.txt /root/Public/
[root@leitingyan ~]# 

在这里插入图片描述
(2)如果复制的是文件夹,则需要添加参数 -r

[root@leitingyan ~]# cp -r Public Desktop/

在这里插入图片描述
(3) 如果赋值过程中有同名的文件则可以使用 -f进行强制覆盖
在linux中为什么加了-f但是没有效果
取消别名: \命令

mv:

(1)移动文件夹或文件

[root@leitingyan ~]# mv 1.txt Music/
[root@leitingyan ~]# mv Public Music/

在这里插入图片描述
(2)改名字

[root@leitingyan ~]# mv a.txt b.bcb
[root@leitingyan ~]# ls
anaconda-ks.cfg  b.txt  Desktop    Downloads    install.log.syslog  Pictures   Videos
b.bcb            c.avi  Documents  install.log  Music               Templates
[root@leitingyan ~]# 

rm:

删除文件或者文件夹
(1)删除文件

[root@leitingyan ~]# rm b.txt
rm: remove regular empty file `b.txt'? Y

(2) 删除文件夹

[root@leitingyan ~]# rm -r Music/
rm: descend into directory `Music'? y
rm: remove regular empty file `Music/1.txt'? Y
rm: descend into directory `Music/Public'? Y
rm: remove regular empty file `Music/Public/a.txt'? Y
rm: remove directory `Music/Public'? Y
rm: remove directory `Music'? Y
[root@leitingyan ~]# ls
anaconda-ks.cfg  c.avi    Documents  install.log         Pictures   Videos
b.bcb            Desktop  Downloads  install.log.syslog  Templates
[root@leitingyan ~]#  

(3)关掉提示警告:文件

[root@leitingyan ~]# rm -f c.avi
[root@leitingyan ~]# ^C
[root@leitingyan ~]# ls
anaconda-ks.cfg  Desktop    Downloads    install.log.syslog  Pictures   Videos
b.bcb            Documents  install.log  Music               Templates
[root@leitingyan ~]# 

(4) 删除文件夹时关掉提示

[root@leitingyan ~]# rm -rf Music/
[root@leitingyan ~]# ls
anaconda-ks.cfg  b.bcb  Desktop  Documents  Downloads  install.log  install.log.syslog  Pictures  Templates  Videos
[root@leitingyan ~]# 

cat:

查看文件内容
在这里插入图片描述

more:

也是查看,查看一大部分

[root@leitingyan ~]# more anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$UhaJsq1A.IxwFwZN$joqiwlFqQz0PzvYKjYCKMfawvd4PgyQJikvXjUPhZguknzXoe7CVtPOu3vE7j041Ae.m4BOvlF1.Ppt
h9oMyE/
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --all --drives=sda

#part /boot --fstype=ext4 --size=500
#part pv.008002 --grow --size=1

#volgroup vg_leitingyan --pesize=4096 pv.008002
#logvol / --fstype=ext4 --name=lv_root --vgname=vg_leitingyan --grow --size=1024 --maxsize=51200
#logvol swap --name=lv_swap --vgname=vg_leitingyan --grow --size=2048 --maxsize=2048


%packages
@base
@client-mgmt-tools
@core
@debugging
@basic-desktop
@desktop-debugging

less:

查看文件内容的一小部分

head:

从文件头开始查看

[root@leitingyan ~]# head  anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
cdrom
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$UhaJsq1A.IxwFwZN$joqiwlFqQz0PzvYKjYCKMfawvd4PgyQJikvXjUPhZguknzXoe7CVtPOu3vE7j041Ae.m4BOvlF1.Ppth9oMyE/
firewall --service=ssh

tail:

从文件的尾开始查看

[root@leitingyan ~]# tail  anaconda-ks.cfg
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
perl-DBD-SQLite
%end[root@leitingyan ~]# 

grep:

筛选的意思

%end[root@leitingyan ~]# cat  anaconda-ks.cfg | grep file
# Kickstart file automatically generated by anaconda.
@network-file-system-client
[root@leitingyan ~]# 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值