【移动应用开发技术】RHEL6中文件基本操作命令有哪些_第1页
【移动应用开发技术】RHEL6中文件基本操作命令有哪些_第2页
【移动应用开发技术】RHEL6中文件基本操作命令有哪些_第3页
【移动应用开发技术】RHEL6中文件基本操作命令有哪些_第4页
【移动应用开发技术】RHEL6中文件基本操作命令有哪些_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【移动应用开发技术】RHEL6中文件基本操作命令有哪些

ls--显示指定目录下内容/upload/information/20200311/45/197857.jpg/upload/information/20200311/45/197859.jpg/upload/information/20200311/45/197861.jpg[root@localhost

~]#

ls

-ld

/home

drwxr-xr-x.

4

root

root

4096

9月

22

10:41

/home

[root@localhost

~]#

ls

-d

/home

/home

[root@localhost

~]#[root@localhost

~]#

ls

-h

/home

justin

lost+found

[root@localhost

~]#

ls

-lh

/home

总用量

20K

drwx.

27

justin

justin

4.0K

9月

22

13:19

justin

drwx.

2

root

root

16K

9月

18

15:30

lost+found

[root@localhost

~]#[root@localhost

~]#

ls

-lR

/home

/home:

总用量

20

drwx.

27

justin

justin

4096

9月

22

13:19

justin

drwx.

2

root

root

16384

9月

18

15:30

lost+found

/home/justin:

总用量

32

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

公共的

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

模板

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

视频

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

图片

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

文档

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

下载

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

音乐

drwxr-xr-x.

2

justin

justin

4096

9月

22

10:49

桌面

/home/justin/公共的:

总用量

0

/home/justin/模板:

总用量

0

/home/justin/视频:

总用量

0

/home/justin/图片:

总用量

0

/home/justin/文档:

总用量

0

/home/justin/下载:

总用量

0

/home/justin/音乐:

总用量

0

/home/justin/桌面:

总用量

0

/home/lost+found:

总用量

0

[root@localhost

~]#[root@localhost

~]#

ls

-l

/home

总用量

20

drwx.

27

justin

justin

4096

9月

22

13:19

justin

drwx.

2

root

root

16384

9月

18

15:30

lost+found

-rw-r--r--.

1

root

root

0

9月

22

15:21

t

[root@localhost

~]#

ls

-lt

/home

总用量

20

-rw-r--r--.

1

root

root

0

9月

22

15:21

t

drwx.

27

justin

justin

4096

9月

22

13:19

justin

drwx.

2

root

root

16384

9月

18

15:30

lost+found

[root@localhost

~]#gssapi_mech.conf

popt.d

xml

gtk-2.0

portreserve

yp.conf

hal

postfix

yum

host.conf

ppp

yum.conf

hosts

prelink.cache

yum.repos.d

hosts.allow

prelink.conf

hosts.deny

prelink.conf.d

[root@localhost

etc]#

ll

-d

/etc/po*.d

drwxr-xr-x.

2

root

root

4096

1月

11

2010

/etc/popt.d

[root@localhost

etc]#

ll

-d

/etc/po?.d

ls:

无法访问/etc/po?.d:

没有那个文件或目录

[root@localhost

etc]#du显示文件或目录大小[root@localhost

src]#

du

-h

nagios-3.5.0.tar.gz

1.8M

nagios-3.5.0.tar.gz

[root@localhost

src]#

du

nagios-3.5.0.tar.gz

1748

nagios-3.5.0.tar.gz

[root@localhost

src]#[root@localhost

local]#

du

-b

src/nagios-3.5.0.tar.gz

1789376

src/nagios-3.5.0.tar.gz

[root@localhost

local]#[root@localhost

local]#

du

-sh

src/

41M

src/

[root@localhost

local]#df显示档案系统的状况;主要用来了解系统中已经挂载的各个文件系统的磁盘使用情况[root@localhost

~]#

df

-Th

文件系统

类型

容量

已用

可用

已用%%

挂载点

/dev/sda2ext4

9.9G

2.6G

6.9G

28%

/

tmpfs

tmpfs

504M

112K

504M

1%

/dev/shm

/dev/sda1ext4

194M

27M

158M

15%

/boot

/dev/sda5ext4

7.7G

147M

7.2G

2%

/home

/dev/sr0iso9660

2.9G

2.9G

0

100%

/media/RHEL_6.3

i386

Disc

1

[root@localhost

~]#file查看文件类型[root@localhost

home]#

file

justin/

justin/:

directory

[root@localhost

home]#

file

justin1

justin1:

empty

[root@localhost

~]#

file

install.log

install.log:

UTF-8

Unicode

text文件内容查看cat显示文件内容[root@localhost

log]#

cat

/var/log/messagesmore分页显示文件内容[root@localhost

log]#

more

-5s

/var/log/messages

Sep

22

10:36:06

localhost

kernel:

imklog

5.8.10,

log

source

=

/proc/kmsg

started.

Sep

22

10:36:06

localhost

rsyslogd:

[origin

software="rsyslogd"

swVersion="5.8.10"

x-pid

="1323"

x-info=""]

start

Sep

22

10:36:06

localhost

kernel:

Initializing

cgroup

subsys

cpuset

Sep

22

10:36:06

localhost

kernel:

Initializing

cgroup

subsys

cpu

--More--(0%)less分页显示文件内容head查看文件开头部分的内容[root@localhost

~]#

head

-5

/etc/passwd

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

[root@localhost

~]#tail查看文件末尾部分的内容[root@localhost

~]#

tail

-5

/etc/passwd

nfsnobody:x:65534:65534:Anonymous

NFS

User:/var/lib/nfs:/sbin/nologin

abrt:x:173:173::/etc/abrt:/sbin/nologin

sshd:x:74:74:Privilege-separated

SSH:/var/empty/sshd:/sbin/nologin

tcpdump:x:72:72::/:/sbin/nologin

justin:x:500:500:justin_peng:/home/justin:/bin/bash

[root@localhost

~]#paste用于合并文件的列,将多行合并为一行[root@localhost

~]#

cat

>

1.txt

<<

EOF

>

1

>

11

>

111

>

EOF

[root@localhost

~]#

cat

>

2.txt

<<

eof

>

2

>

22

>

222

>

eof

[root@localhost

~]#

cat

>

3.txt

<<

eof

>

3

>

33

>

333

>

eof

[root@localhost

~]#

paste

1.txt

2.txt

3.txt

1 2 3

11 22 33

111 222 333

[root@localhost

~]#[root@localhost

~]#

cat

>

test.txt

<<

EOF

>

001

>

002

>

003

>

004

>

005

>

006

>

007

>

EOF

[root@localhost

~]#

paste

-d

"

"

-s

<

test.txt

001

002

003

004

005

006

007

[root@localhost

~]#

cat

test.txt

001

002

003

004

005

006

007

[root@localhost

~]#

cat

test.txt

|

paste

-d

"

"

-s

>>

test1.txt

[root@localhost

~]#

cat

test1.txt

001

002

003

004

005

006

007

[root@localhost

~]#创建文件(夹)命令touch改变档案的时间记录,档案不存在则创建一个空文件,通常用来创建一个文件[root@localhost

home]#

touch

file1

file2

[root@localhost

home]#

ls

file1

file2

justin

lost+found

t

[root@localhost

home]#[root@justin

touch]#

touch

file{1..5}

[root@justin

touch]#

ls

file1

file2

file3

file4

file5

[root@justin

touch]#

touch

file{6...9}

[root@justin

touch]#

ls

file1

file2

file3

file4

file5

file{6...9}

[root@Zabbix

zabbix]#

mkdir

dir{1..5}

[root@Zabbix

zabbix]#

ls

dir1

dir3

dir5

file10

file12

file14

file16

file18

file2

file3

file5

file7

file9

dir2

dir4

file1

file11

file13

file15

file17

file19

file20

file4

file6

file8

[root@Zabbix

zabbix]#

touch

dir{1..5}/file{1..20}

[root@Zabbix

zabbix]#

ls

dir1

dir3

dir5

file10

file12

file14

file16

file18

file2

file3

file5

file7

file9

dir2

dir4

file1

file11

file13

file15

file17

file19

file20

file4

file6

file8

[root@Zabbix

zabbix]#[root@localhost

touch]#

date

Sat

Jan

14

10:54:16

CST

2017

[root@localhost

touch]#

touch

test1.txt

[root@localhost

touch]#

touch

-t

201610141053

test2.txt

[root@localhost

touch]#

ll

total

0

-rw-r--r--

1

root

root

0

Jan

14

10:54

test1.txt

-rw-r--r--

1

root

root

0

Oct

14

10:53

test2.txt

[root@localhost

touch]#

touch

-r

test1.txt

test2.txt

[root@localhost

touch]#

ll

total

0

-rw-r--r--

1

root

root

0

Jan

14

10:54

test1.txt

-rw-r--r--

1

root

root

0

Jan

14

10:54

test2.txt

[root@localhost

touch]#mkdirMakeDirectory创建新的目录[root@localhost

home]#

ls

justin

lost+found

t

[root@localhost

home]#

mkdir

dir1

[root@localhost

home]#

mkdir

dir2/dir

mkdir:

无法创建目录"dir2/dir":

没有那个文件或目录

[root@localhost

home]#

mkdir

-p

dir2/dir

[root@localhost

home]#[root@localhost

home]#

ls

justin

lost+found

t

[root@localhost

home]#

mkdir

-p

{dir1,dir2/{dir3,dir4}}

[root@localhost

home]#

ls

dir1

dir2

justin

lost+found

t

[root@localhost

home]#

ls

dir2

dir3

dir4

[root@localhost

home]#删除文件(夹)命令rmdir删除空目录(若目录非空删除中会报错)[root@localhost

home]#

mkdir

-p

{dir1,dir2/dir3}

[root@localhost

home]#

ls

dir1

dir2

justin

lost+found

t

[root@localhost

home]#

rmdir

dir1

[root@localhost

home]#

rmdir

dir2

rmdir:

删除

"dir2"

失败:

目录非空

[root@localhost

home]#

rmdir

-p

dir2/dir3/

[root@localhost

home]#

ls

justin

lost+found

t

[root@localhost

home]#rm删除档案或目录[root@localhost

home]#

mkdir

-p

dir1/dir2

[root@localhost

home]#

rm

-r

dir1/

rm:是否进入目录"dir1"?

y

rm:是否删除目录

"dir1/dir2"?y

rm:是否删除目录

"dir1"?y

[root@localhost

home]#[root@APP

rm]#

ls

sda

SDa

sdaa

SDaa

sdaaa

sdaaaa

SDaaaa

sdaab

sdaz

[root@APP

rm]#

ls

|grep

-v

SD|xargs

rm

-f

[root@APP

rm]#

ls

SDa

SDaa

SDaaaa

[root@APP

rm]#[root@APP

rm]#

touch

sda

SDa

sdaa

SDaa

sdaaa

sdaaaa

SDaaaa

sdaab

sdaz

[root@APP

rm]#

rm

-f

!(SD*)

-bash:

!:

event

not

found

[root@APP

rm]#

shopt

-s

extglob

[root@APP

rm]#

rm

-rf

!(SD)

[root@APP

rm]#

ls

SDa

SDaa

SDaaaa

[root@APP

rm]#

rm

-f

!(a|b)

#保留a和b[root@mail

cur]#

rm

-rf

*

-bash:

/bin/rm:

Argument

list

too

long

[root@mail

new]#

ll

|wc

-l

221993

[root@mail

cur]#

ls

|

xargs

-n

10

rm

-fr

ls

[root@mail

new]#

ll

|wc

-l

1

[root@mail

new]#root@localhost

node_api]#

ls

-i

403627443

config

16073267

-g

[root@localhost

node_api]#

find

./

-inum

16073267

-exec

rm

{}

\;

[root@localhost

node_api]#

ls

config

[root@localhost

node_api]#[root@localhost

rename]#

ls

111222

111.sh

111.txt

222.txt

333.txt

[root@localhost

rename]#

rename

111

aaa

*

将所有的文件(夹)中的111替换成aaa

[root@localhost

rename]#

ls

222.txt

333.txt

aaa222

aaa.sh

aaa.txt

[root@localhost

rename]#

rename

'.txt'

'.sh'

*

将所有的以.txt的后缀替换成.sh

[root@localhost

rename]#

ls

222.sh

333.sh

aaa222

aaa.sh

[root@localhost

rename]#

rename

\.sh

''

*

去掉所有的.sh后缀

[root@localhost

rename]#

ls

222

333

aaa

aaa222

[root@localhost

rename]#[root@localhost

~]#

dd

if=/dev/zero

of=test

bs=1M

count=1024

[root@localhost

~]#

du

-sh

test

1.1G test

[root@localhost

~]#

>

test

[root@localhost

~]#

du

-sh

test

0 test

[root@loca

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论