Linux常见基础命令1
ls
用法: ls [选项] [文件名]
功能: 对于目录可以列出目录下的所有文件,对于文件列出文件名及其详细信息。
常用选项详解:
ls -a :
-a, --all
do not ignore entries starting with .
**列出所有文件,包括隐藏文件**
**例子**
[liu@localhost 进度条]$ ls -a
. .. a.out JDT.c .Makefile.swp
ls -l :
-l use a long listing format
**列出文件的详细信息**
**例子**
[liu@localhost 进度条]$ ls -l
total 640
-rwxr-xr-x. 1 root root 647712 Aug 15 04:22 a.out
-rw-rw-r--. 1 liu liu 411 Aug 15 04:17 JDT.c
/ 权限信息 所属组 所属者 大小 最后一次修改时间 文件名
pwd
直接使用 pwd
功能 : 打印当前所在目录
pwd - print name of current/working directory
cd
语法 : cd [目录名]
功能 : 切换工作目录,将当前工作目录改变到指定的目录底下
**例子**
cd .. : 返回上一级
cd : 返回家目录
cd - : 返回最近一次所在的目录
touch
语法 : touch [选项] [文件名]
功能 : touch一个不存在的文件时,创建该文件,touch一个存在的文件时,刷新该文件的时间属性
Update the access and modification times of each FILE to the current time.
A FILE argument that does not exist is created empty, unless -c or -h is supplied.
A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output.
Mandatory arguments to long options are mandatory for short options too.
**例子**
当文件不存在时 :
[liu@localhost boke]$ ls
[liu@localhost boke]$
[liu@localhost boke]$ touch boke
[liu@localhost boke]$ ls
boke
创建新的文件
当文件存在时 :
[liu@localhost Vim]$ ls -l test.c
-rw-rw-r--. 1 liu liu 48 Aug 15 01:45 test
[liu@localhost Vim]$ touch test.c
[liu@localhost Vim]$ ls -l
-rw-rw-r--. 1 liu liu 48 Aug 15 09:36 test.c
该文件的时间属性被刷新
mkdir
语法 : mkdir [选项] 目录名
功能 : 创建一个新的目录
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
mkdir -p name1/name2/name3
**例子**
**递归创建**
[liu@localhost boke]$ mkdir -p t1/t2/t3
[liu@localhost boke]$ ls
t1
[liu@localhost boke]$ tree
.
└── t1
└── t2
└── t3
rmdir
语法 : rmdir [选项] [目录名]
功能 :删除空目录
Remove the DIRECTORY(ies), if they are empty.
--ignore-fail-on-non-empty
ignore each failure that is solely because a directory
is non-empty