ls [选项] [文件目录]
-a 列出所有包括隐藏文件
-l 显示详细信息
-d 目录详细属性(查看目录信息而不是目录下的文件)
-h 人性化显示文件大小
-i 显示iNode
ls-l(别名ll)
[root@MiWiFi-R1CM ~]# ls -l
总用量 44
-rw-------. 1 root root 1208 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 25906 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7690 3月 10 18:39 install.log.syslog
第一位为:"-"代表是普通文件
“d”代表是一个目录
“l”软连接(快捷方式)
还有四种不常用文件:块设备文件,字符设备文件,套接字文件,管道文件
--------------------------------------
每三位字符一组:
第一组权限(也就是rw):是文件所有者 的权限
第二组:所属组
第三组:其他人
除了rw权限还有x权限:执行
-----------------------------------
“1”代表引用计数
-------------------------
第一个root代表文件所有者
----------------------
第二个root位置代表文件所有者所属的用户组
------------------------
数字代表文件大小 加上-h可以显示为常用格式
ls -lh
总用量 44K
-rw-------. 1 root root 1.2K 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 26K 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7.6K 3月 10 18:39 install.log.syslog
------------------
文件名以“.”开头的是隐藏文件。
------------------------
下面查看指定目录:
[root@MiWiFi-R1CM ~]# ls -l /etc/
总用量 1756
drwxr-xr-x. 3 root root 4096 3月 10 18:36 abrt
drwxr-xr-x. 4 root root 4096 3月 10 18:39 acpi
-rw-r--r--. 1 root root 16 3月 10 18:40 adjtime
-rw-r--r--. 1 root root 1512 1月 12 2010 aliases
-rw-r--r--. 1 root root 12288 3月 10 18:41 aliases.db
drwxr-xr-x. 2 root root 4096 3月 10 18:39 alsa
drwxr-xr-x. 2 root root 4096 3月 10 18:39 alternatives
-rw-r--r--. 1 root root 541 7月 19 2011 anacrontab
-rw-r--r--. 1 root root 148 5月 15 2009 asound.conf
-rw-r--r--. 1 root root 1 1月 30 2012 at.deny
drwxr-x---. 3 root root 4096 3月 10 18:39 audisp
drwxr-x---. 2 root root 4096 3月 10 18:39 audit
-rw-------. 1 root root 232 6月 22 2012 autofs_ldap_auth.conf
-rw-r--r--. 1 root root 658 6月 22 2012 auto.master
-rw-r--r--. 1 root root 524 6月 22 2012 auto.misc
-rwxr-xr-x. 1 root root 1260 6月 22 2012 auto.net
-rwxr-xr-x. 1 root root 687 6月 22 2012 auto.smb
drwxr-xr-x. 4 root root 4096 3月 10 18:37 avahi
drwxr-xr-x. 2 root root 4096 3月 10 18:39 bash_completion.d
-rw-r--r--. 1 root root 2681 6月 22 2012 bashrc
............
------------------------------------------------
<hr>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2.创建目录(make directories)
总用量的意思是:占用了多少kb
mkdir -p [目录名]
-p:递归创建(一次创建多级目录用)
[root@MiWiFi-R1CM ~]# mkdir jiangshang
[root@MiWiFi-R1CM ~]# ls -l
总用量 48
-rw-------. 1 root root 1208 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 25906 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7690 3月 10 18:39 install.log.syslog
drwxr-xr-x. 2 root root 4096 3月 11 00:04 jiangshang
[root@MiWiFi-R1CM ~]# mkdir -p luanzhong/aoming/jiangshang
[root@MiWiFi-R1CM ~]# ls -l
总用量 52
-rw-------. 1 root root 1208 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 25906 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7690 3月 10 18:39 install.log.syslog
drwxr-xr-x. 2 root root 4096 3月 11 00:04 jiangshang
drwxr-xr-x. 3 root root 4096 3月 11 00:05 luanzhong
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3.切换目录(change directories)
cd [目录] [-|.|..|~]
-:上次目录
.:当前
..:上级
~:家
cd:同上
注:pwd可查看当前路径(print workspace directories)
相对路径是从当前目录为起点,绝对路径是/root为起点,不要以为是输个文件名能自动查找。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4、删除空白目录和强制删除目录(remove empty directories)
rmdir [目录名]
rm -rf[文件和目录]
-r 删除目录(注:如果该目录下有文件无法删除)
-f 强制(可以删除所有的,谨慎操作)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
5、复制命令(copy)
cp [选项] [原文件或者目录] [目标目录]
-r 复制目录
-p 连带文件属性复制
-d 若是链接文件,则复制链接文件属性
-a 相当 -pdr
改名复制示例,一定不要在复制文件的时候写上不存在的文件夹,那叫改名:
[root@MiWiFi-R1CM ~]# mkdir jiangshang
[root@MiWiFi-R1CM ~]# ls
anaconda-ks.cfg install.log install.log.syslog jiangshang
[root@MiWiFi-R1CM ~]# cp -p install.log jiangshang/copyinstall.log
[root@MiWiFi-R1CM ~]# ls
anaconda-ks.cfg install.log install.log.syslog jiangshang
[root@MiWiFi-R1CM ~]# cd jiangshang
[root@MiWiFi-R1CM jiangshang]# ls
copyinstall.log
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6.剪切(move)
mv [原文件或者目录名] [目标目录]
改名示例:
[root@MiWiFi-R1CM ~]# ll
总用量 48
-rw-------. 1 root root 1208 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 25906 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7690 3月 10 18:39 install.log.syslog
drwxr-xr-x. 3 root root 4096 3月 11 01:07 jiangshang
[root@MiWiFi-R1CM ~]# mv jiangshang jiangshang_name
[root@MiWiFi-R1CM ~]# ll
总用量 48
-rw-------. 1 root root 1208 3月 10 18:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 25906 3月 10 18:40 install.log
-rw-r--r--. 1 root root 7690 3月 10 18:39 install.log.syslog
drwxr-xr-x. 3 root root 4096 3月 11 01:07 jiangshang_name
[root@MiWiFi-R1CM ~]#