Linux基础二

linux命令分类

内部命令:属于shell解释器

外部命令:独立于shell解释器

检查命令类型

type:检查命令字的类型

[root@localhost ~]# type ls

ls 是 `ls --color=auto' 的别名

————————————————————————

 类型             含义

builtin       shell内建立的命令

file          磁盘文件,外部命令

alias         命令别名

keyword       保留的关键字

function      shell函数

not found     未找到,无法识别

——————————————————————————

man xxx 查看详细帮助

按g 滚动到开头

按G 滚动到末尾

大写N向上跳转匹配

小写n向下跳转

输入 / -x 查找-x的这个选项

——————————————————————————

ls 

格式:ls -[选项] [目录或者文件名]

-l:以长格式显示

-A:显示隐藏目录。其他与-a相同

-d:显示目录本身而不是内容

-h:提供易读的容量单位

-R:递归显示内容

——————————————————————————

alias:创建自己的命令

alias xx=‘ls -lhd’

unalias xx 删除自己创建的命令xx

——————————————————————————

du

格式:du -[选项] [目录或文件]

常用命令选项:

-a:统计所有文件,而不是仅统计目录

-s:只统计给个参数所占的总空间大小

-h:提供易读的容量单位(K M等)

[root@localhost 桌面]# du -sh /boot/ /etc/pki/

116M    /boot/

1.5M    /etc/pki

———————————————————————————

mkdir:创建文件夹

格式:mkdir [文件名] [/路径/] 目录名

-p:连续创建目录

[root@localhost 桌面]# mkdir /root/hydra

———————————————————————————

touch:创建文本文件

格式:touch 文件名

[root@localhost ~]# touch xxx.txt

———————————————————————————

mv:移动/改名(路径不变就是改名)

格式:mv -[选项] 原文件 目标路径

-f:不提示

[root@localhost ~]# touch 1.txt

[root@localhost ~]# mkdir 1

[root@localhost ~]# touch 1.txt

[root@localhost ~]# ls

1      anaconda-ks.cfg  initial-setup-ks.cfg  模板  图片  下载  桌面

1.txt  help.php         公共                  视频  文档  音乐

[root@localhost ~]# mv /root/1.txt /root/1

[root@localhost ~]# ls

1                help.php              公共  视频  文档  音乐

anaconda-ks.cfg  initial-setup-ks.cfg  模板  图片  下载  桌面

————————————————————————————————————

rm:删除

格式:rm -[选项] 文件或目录

常用命令选项:

-r:递归删除整个目录

-f:强制删除,不提示(与-i相对)

[root@localhost ~]# rm -rf xxx.txt

——————————————————————————————————

ln -s 创建连接文件

格式:ln [-s] 源文件 连接文件路径

[root@localhost ~]# cat /etc/redhat-release (源文件)

Red Hat Enterprise Linux Server release 7.2 (Maipo)

[root@localhost ~]# ln -s /etc/redhat-release  /xx(连接源文件路径并创建快捷方式)

[root@localhost ~]# ls /xx

/xx

[root@localhost ~]# ls -l /xx

lrwxrwxrwx. 1 root root 19 5月  17 14:50 /xx -> /etc/redhat-release

[root@localhost ~]# 

————————————————————————————————————————————

cp:复制

格式:cp -[选项] 原文件 目标路径

常用命令选项:

-r:递归复制整个目录

-f:强制覆盖

-p:保持原文件的属性不变

[root@localhost /]# cp -rfp /home/anonymous /boot/

[root@localhost /]# cd /boot/

[root@localhost boot]# ls

anonymous

————————————————————————————————————————————---

原文地址:https://www.cnblogs.com/Hydraxx/p/6906925.html