linux命令讲解.docx

上传人:b****5 文档编号:28038844 上传时间:2023-07-07 格式:DOCX 页数:64 大小:32.30KB
下载 相关 举报
linux命令讲解.docx_第1页
第1页 / 共64页
linux命令讲解.docx_第2页
第2页 / 共64页
linux命令讲解.docx_第3页
第3页 / 共64页
linux命令讲解.docx_第4页
第4页 / 共64页
linux命令讲解.docx_第5页
第5页 / 共64页
点击查看更多>>
下载资源
资源描述

linux命令讲解.docx

《linux命令讲解.docx》由会员分享,可在线阅读,更多相关《linux命令讲解.docx(64页珍藏版)》请在冰豆网上搜索。

linux命令讲解.docx

linux命令讲解

[root@localhostzhl]#cp/etc/passwd/etc/group/home/zhl拷贝两个文件到/home/zhl

cp:

是否覆盖“/home/zhl/passwd”?

y

cp:

是否覆盖“/home/zhl/group”?

y

[root@localhostzhl]#cp/etc/passwd/home/zhl拷贝一个文件到/home/zhl

===========================================================================

[root@localhostzhl]#rm-rf/home/zhl/passwd选项-rf表示删除其下子目录不询问

[root@localhostzhl]#rm/home/zhl/group有询问

rm:

是否删除一般文件“/home/zhl/group”?

y

===========================================================================

[root@localhostzhl]#ls

Desktopfile1file3file4file6filemlMyDocuments

[root@localhostzhl]#mvfile1file3

mv:

是否覆盖“file3”?

y

[root@localhostzhl]#ls

Desktopfile3file4file6filemlMyDocuments

[root@localhostzhl]#mvfile3file7

[root@localhostzhl]#ls

Desktopfile4file6file7filemlMyDocuments

[root@localhostzhl]#mv-ffile7file4选项f表示不询问直接覆盖

[root@localhostzhl]#ls

Desktopfile4file6filemlMyDocuments

============================================

cat功能:

1显示文件

2创建文件

3连接文件

[root@localhost~]#cat>file1创建文件

abc

大家好

今天天气不错

[root@localhost~]#catfile1显示文件

abc

大家好

今天天气不错

[root@localhost~]#catfile1>>file2文件file1内容追加到file2后面

[root@localhost~]#catfile2

abc

大家好

今天天气不错

[root@localhost~]#catfile1>>file2

[root@localhost~]#catfile2

abc

大家好

今天天气不错

abc

大家好

今天天气不错

[root@localhost~]#

=================================================================================

[root@localhostzhl]#ls-l/etc|less

[root@localhostzhl]#ls-l/etc|more命令ls-l/etc显示太长,利用分屏显示命令more或less管道符号

===================================================================================

[root@localhostzhl]#headfile1

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

sync:

x:

5:

0:

sync:

/sbin:

/bin/sync

shutdown:

x:

6:

0:

shutdown:

/sbin:

/sbin/shutdown

halt:

x:

7:

0:

halt:

/sbin:

/sbin/halt

mail:

x:

8:

12:

mail:

/var/spool/mail:

/sbin/nologin

news:

x:

9:

13:

news:

/etc/news:

显示file1的前20个字符

[root@localhostzhl]#head-c20file1

root:

x:

0:

0:

root:

/roo[root@localhostzhl]#

==================================================================================

azd[root@localhostzhl]#tail-c3file2显示最后3个英文字母

azd[root@localhostzhl]#tail-3file2显示最后3行

==================================================================================

[root@localhostzhl]#wcpasswdgroup

35521559passwd

4747621group

82992180总计

[root@localhostzhl]#

==================================================================================

touch命令:

新建文件

[root@localhostzhl]#touchabc

[root@localhostzhl]#ls

abcDesktopfile1file2file4file6filemlgroupMyDocumentspasswd

[root@localhostzhl]#ls-l

总计17

-rw-r--r--1rootroot004-1815:

25abc

drwxr-xr-x2zhlzhl102404-0808:

27Desktop

-rw-r--r--1rootroot467704-1814:

54file1

-rw-r--r--1rootroot35504-1815:

19file2

-rw-r--r--1rootroot404-0909:

45file4

-rw-r--r--1rootroot1604-0909:

57file6

-rw-r--r--1rootroot341904-1815:

21fileml

-rw-r--r--1rootroot62104-1814:

44group

drwxr-xr-x5zhlzhl102404-0808:

27MyDocuments

-rw-r--r--1rootroot155904-1814:

44passwd

-------------------------------------------------

touch命令:

当前目录所有文件修改时间标签为当前系统时间

[root@localhostzhl]#touch*

[root@localhostzhl]#ls-l

总计17

-rw-r--r--1rootroot004-1815:

26abc

drwxr-xr-x2zhlzhl102404-1815:

26Desktop

-rw-r--r--1rootroot467704-1815:

26file1

-rw-r--r--1rootroot35504-1815:

26file2

-rw-r--r--1rootroot404-1815:

26file4

-rw-r--r--1rootroot1604-1815:

26file6

-rw-r--r--1rootroot341904-1815:

26fileml

-rw-r--r--1rootroot62104-1815:

26group

drwxr-xr-x5zhlzhl102404-1815:

26MyDocuments

-rw-r--r--1rootroot155904-1815:

26passwd

-----------------------------------------------------

touch命令:

文件时间修改为当前系统时间

[root@localhostzhl]#touch-d20090812abc

[root@localhostzhl]#ls-l

总计17

-rw-r--r--1rootroot02009-08-12abc

drwxr-xr-x2zhlzhl102404-1815:

26Desktop

-rw-r--r--1rootroot467704-1815:

26file1

-rw-r--r--1rootroot35504-1815:

26file2

-rw-r--r--1rootroot404-1815:

26file4

-rw-r--r--1rootroot1604-1815:

26file6

-rw-r--r--1rootroot341904-1815:

26fileml

-rw-r--r--1rootroot62104-1815:

26group

drwxr-xr-x5zhlzhl102404-1815:

26MyDocuments

-rw-r--r--1rootroot155904-1815:

26passwd

[root@localhostzhl]#

==================================================================================

按照文件名称查找

[root@localhostzhl]#find/-namehosts

/etc/avahi/hosts

/etc/hosts

/mnt/sda1/WINDOWS/system32/drivers/etc/hosts

[root@localhostzhl]#find/ect-name"h*"-print

find:

/ect:

没有那个文件或目录

[root@localhostzhl]#find.-name"f*"-print

./fileml

./Desktop/firefox.desktop

./file4

./file1

./file6

./file2

[root@localhostzhl]#

查找输入某个用户的文件

[root@localhostzhl]#find/-userzhl

---------------------------------------------------------------------------------

[root@localhostzhl]#find.-userzhl-execcat'{}'\;|more在当前目录下查找用户zhl的文件并执行cat命令

[root@localhostzhl]#find.-name"f*"-execcat'{}'\;在当前目录下查找文件名为f开头的文件并执行cat命令显示文件

[root@localhostzhl]#

---------------------------------------------------------------------------------

find.-typef-execfile’{}’\;

Runs‘file’oneveryfileinorbelowthecurrentdirectory.Noticethatthebracesareenclosedinsinglequotemarkstoprotectthemfrom

interpretationasshellscriptpunctuation.Thesemicolonissimilarlyprotectedbytheuseofabackslash,though’;’couldhavebeenused

inthatcasealso.

---------------------------------------------------------------------------------

[root@localhostzhl]#find.-size-10-execfile'{}'\;在当前目录寻找长度小于10个字节的文件显示文件类型

[root@localhostzhl]#find.-size-10-execls'{}'\;

[root@localhostzhl]#find.-size-10-execls-l'{}'\;注意find后空格.查找范围后空格-size选项后空格-10参数取值后空格-exec选项后空格ls-l'{}'后有空格\;

---------------------------------------------------------------------------------

-------------------------------------------------------------------------------locte命令:

1、建立文件名数据库利用命令updatedb

[root@localhost~]#updatedb

updatedb:

src/updatedb.c:

595:

scan_cwd:

断言“name_size>1”失败。

已放弃

问题原因:

“name_size>1”失败。

数据库文件大小太长,大于最高限。

[root@localhost~]#updatedb-v

可以看到建立文件名数据库时扫描到的文件路径,

发现是“/sys/module/nousb/parameters/目录里的一个文件导致updatedb退出,这个文件在列表里如下所示:

ls/sys/module/nousb/parameters/-lah

总计0

drwxr-xr-x2rootroot02008-04-24

drwxr-xr-x2rootroot02008-04-24.

drwxr-xr-x3rootroot02008-04-24..

就是第一个文件,什么也没显示的。

修改了一下它的配置文件,修改updatedb.conf,把包含这个文件的目录放到PRUNEPATHS里,不让updatedab扫描这个目录,然后重新执行updatedb这个命令。

另外,/dev中的文件很多,是ntfs文件系统的文件,修改updatedb.conf,把包含这个/dev目录放到PRUNEPATHS里,不让updatedab扫描这个目录,然后重新执行updatedb这个命令。

[root@localhost~]#vi/etc/updatedb.conf

修改后的/etc/updatedb.conf配置文件:

[root@localhost~]#cat/etc/updatedb.conf

PRUNEFS="autoafsiso9660sfsudf"

PRUNEPATHS="/sys/dev"

重新执行updatedb不再提示错误:

[root@localhost~]#updatedb

[root@localhost~]#

[root@localhost~]#

2、利用命令locate,在文件名数据库中查找file1文件

[root@localhost~]#locatefile1

/home/file1

/home/zepc/file1

/home/zhl/file1

/root/file1

/usr/openoffice.org2.4/program/libucpfile1.so

/usr/openoffice.org2.4/program/libucpfile1.so.1.1

[root@localhost~]#--

==================================================================================

grep命令:

功能:

在指定文件中寻找符合条件的字符。

[root@localhostzhl]#cat>d

abc

abc

&&[root@localhostzhl]#catabd

在文件d中,寻找包含ab的行

[root@localhostzhl]#cat>mode

ab

-f文件名:

在指定文件中寻找包含文件名内容的行

&&[root@localhostzhl]#grep-fmoded

abc

abc

在文件d中,寻找包含mode文件内容的行

&&和&&命令效果是相同的。

==================================================================================

tr命令:

功能:

字符替代。

[root@localhostzhl]#tr-saA

apple

Apple

------------------------------------------------

去掉ab:

[root@localhostzhl]#tr-dab

apple

pple

bed

ed

------------------------------------------------

文件ls.txt中的多个空格用一个空格替代:

[root@localhostzhl]#ls-l>ls.txt

[root@localhostzhl]#catls.txt

总计22

-rw-r--r--1rootroot02009-09-08abc

-rw-r--r--1rootroot804-2020:

47d

drwxr-xr-x2zhlzhl102404-1909:

23Desktop

-rw-r--r--1rootroot4304-1909:

32file1

-rw-r--r--1rootroot155904-1909:

23file2

-rw-r--r--1zhlzhl467704-1909:

23file3

-rw-r--r--1rootroot404-1909:

23file4

-rw-r--r--1rootroot1604-1909:

23file6

-rw-r--r--1rootroot771304-1909:

57fileml

-rw-r--r--1rootroot004-2020:

51ls2.txt

-rw-r--r--1rootroot004-2020:

51ls.txt

-rw-r--r--1rootroot304-2020:

48mode

drwxr-xr-x5zhlzhl102404-1909:

23MyDocuments

输入重定向符号<

[root@localhostzhl]#tr-s""

总计22

-rw-r--r--1rootroot02009-09-08abc

-rw-r--r--1rootroot804-2020:

47d

drwxr-xr-x2zhlzhl102404-1909:

23Desktop

-rw-r--r--1rootroot4304-1909:

32file1

-rw-r--r--1rootroot155904-1909:

23file2

-rw-r--r--1zhlzhl467704-1909:

23file3

-rw-r--r--1rootroot404-1909:

23file4

-rw-r--r--1rootroot1604-1909:

23file6

-rw-r--r--1rootroot771304-1909:

57fileml

-rw-r--r--1rootroot004-2020:

51ls2.txt

-rw-r--r--1rootroot004-2020:

51ls.txt

-rw-r--r--1rootroot304-2020:

48mode

drwxr-xr-x5zhlzhl102404-1909:

23MyDocuments

命令的输出结果输出重定向到ls2.txt

[root@localhostzhl]#tr-s""ls2.txt

[root@localhostzhl]#catls2.txt

总计22

-rw-r--r--1rootroot02009-09-08abc

-rw-r--r--1rootroot804-2020:

47d

drwxr-xr-x2zhlzhl102404-1909:

23Desktop

-rw-r--r--1rootroot4304-1909:

32file1

-rw-r--r--1rootroot155904-1909:

23file2

-rw-r--r--1zhlzhl467704-1909:

23file3

-rw-r--r--1rootroot404-1909:

23file4

-rw-r--r--1rootroot1604-1909:

23file6

-rw-r--r--1rootroot771304-1909:

57fi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1