FHS:文件层次标准
操作系统自身运行使用的
/bin: 存放可执行的二进制程序,管理员和普通用户都可以使用
/sbin:管理员才能执行的命令
运行正常功能的程序存放位置
/usr/bin
/usr/sbin
用来存放第三方软件的程序
/usr/local/bin
/usr/local/sbin
/boot: 系统启动相关的文件,如内核、initrd,以及grub(bootloader)
/dev: 设备文件
设备文件:
块设备:随机访问,数据块(硬盘)
字符设备:线性访问,按字符为单位(键盘/鼠标/显示器)
设备号:主设备号(major)和次设备号(minor)
/etc:配置文件
/home:用户的家目录,每一个用户的家目录通常默认为/home/USERNAME
/root:管理员的家目录;
/lib:库文件
静态库, .a
动态库, .dll, .so (shared object)(内存中加载共同使用,节省内存空间)
/lib/modules:内核模块文件
/media:挂载点目录,移动设备
/mnt:挂载点目录,额外的临时文件系统
/opt:可选目录,第三方程序的安装目录
/proc:伪文件系统,内核映射文件
/sys:伪文件系统,跟硬件设备相关的属性映射文件
/tmp:临时文件, /var/tmp
/var:可变化的文件
/bin: 可执行文件, 用户命令
/sbin:管理命
目录管理
ls
cd
pwd
mkdir:创建空目录
NAME
mkdir - make directories
SYNOPSIS
mkdir [OPTION]... DIRECTORY...
[rhel@localhost ~]$ mkdir x/y
mkdir: cannot create directory `x/y‘: No such file or directory
[rhel@localhost ~]$ mkdir x
[rhel@localhost ~]$ ll
total 36
drwxr-xr-x. 4 rhel rhel 4096 Jun 25 2015 Desktop
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Documents
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Downloads
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Music
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Pictures
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Public
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Templates
drwxr-xr-x. 2 rhel rhel 4096 Jun 21 2015 Videos
drwxrwxr-x. 2 rhel rhel 4096 Nov 19 18:53 x
[rhel@localhost ~]$ mkdir x/y
[rhel@localhost ~]$ mkdir x/y/z
[rhel@localhost ~]$ ll x/y
total 4
drwxrwxr-x. 2 rhel rhel 4096 Nov 19 18:53 z
-p, --parents(直接创建父目录)
no error if existing, make parent directories as needed
-v: verbose(输出创建目录信息)
print a message for each created directory
[root@localhost ~]# mkdir -pv /m/n/q
mkdir: created directory `/m‘
mkdir: created directory `/m/n‘
mkdir: created directory `/m/n/q‘
{}:花括号展开
/mnt/test/x/m,y
mkdir -pv /mnt/test/x/m /mnt/test/y
mkdir -pv /mnt/test/{x/m,y}
rmdir:删除空目录
NAME
rmdir - remove empty directories
SYNOPSIS
rmdir [OPTION]... DIRECTORY...
[root@localhost /]# rm /x/y/z
rm: cannot remove `/x/y/z‘: Is a directory
[root@localhost /]# rmdir /x/y/z
[root@localhost /]#
-p, --parents(删除空目录及其父目录)
remove DIRECTORY and its ancestors; e.g., ‘rmdir -p a/b/c’ is similar to ‘rmdir a/b/c
a/b a’
touch:改变时间戳,可用于创建文件
NAME
touch - change file timestamps
SYNOPSIS
touch [OPTION]... FILE...
-c, --no-create(只修改文件时间戳)
do not create any files
-t STAMP(时间格式)
use [[CC]YY]MMDDhhmm[.ss] instead of current time
-a change only the access time(访问时间)
[root@localhost /]# stat a
File: `a‘
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 14674 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-19 19:40:06.997714999 -0800
Modify: 2016-11-19 19:40:06.997714999 -0800
Change: 2016-11-19 19:40:06.997714999 -0800
[root@localhost /]# touch -a a 20170212
[root@localhost /]# stat a
File: `a‘
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 14674 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-19 19:44:10.414717913 -0800
Modify: 2016-11-19 19:40:06.997714999 -0800
Change: 2016-11-19 19:44:10.414717913 -0800
-m change only the modification time(修改时间)
[root@localhost /]# touch -m a 20170212
[root@localhost /]# stat a
File: `a‘
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 14674 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-19 19:44:10.414717913 -0800
Modify: 2016-11-19 19:44:46.502716778 -0800
Change: 2016-11-19 19:44:46.502716778 -0800
stat:查看文件状态
NAME
stat - display file or file system status
SYNOPSIS
stat [OPTION]... FILE...
[root@localhost /]# stat a
File: `a‘
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 14674 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2016-11-19 19:35:12.727718345 -0800
Modify: 2016-11-19 19:35:12.727718345 -0800
Change: 2016-11-19 19:35:12.727718345 -0800
nano 文本编辑器(只编辑文本,不会处理字符)
NAME
nano - Nano’s ANOther editor, an enhanced free Pico clone
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell
^:为ctrl键
[root@localhost /]# file hello
hello: ASCII text
[root@localhost /]# cat hello
this is a test file
rm:删除文件
NAME
rm - remove files or directories
SYNOPSIS
rm [OPTION]... FILE...
-i prompt before every removal(删除前,提示)
[root@localhost /]# type rm
rm is aliased to `rm -i‘
[root@localhost /]# rm hello
rm: remove regular file `hello‘? y^H^[[3~^[[3~
-f, --force(强制删除,没有提示)
ignore nonexistent files, never prompt
[root@localhost /]# rm a
rm: remove regular empty file `a‘? n
[root@localhost /]#
[root@localhost /]# rm -f a
[root@localhost /]# ll
total 106
-rw-r--r--. 1 root root 0 Nov 19 19:44 20170212
dr-xr-xr-x. 2 root root 4096 Nov 19 18:31 bin
dr-xr-xr-x. 5 root root 1024 Jun 21 2015 boot
drwxr-xr-x. 18 root root 3860 Nov 19 17:54 dev
drwxr-xr-x. 103 root root 12288 Nov 19 18:31 etc
drwxr-xr-x. 3 root root 4096 Jun 21 2015 home
-r, -R, --recursive(递归删除目录及其子目录)
remove directories and their contents recursively
[root@localhost /]# rm -rf /x
linux常用命令-FHS,mkdir,rmdir,touch,stat,nano,rm
原文:http://f1yinsky.blog.51cto.com/12568071/1897034