Linux (RedHat) Basic Learning-file addressing and management

Source: Internet
Author: User
Tags create directory

1. System structure
                                                    Linux系统目录结构

/:根目录,linux系统中最高层目录。在根目录下的目录叫二级目录/bin:放置系统的必备二进制可执行文件(程序),例如;cat,cp,ls,su,kill,rm,tar等/sbin:系统管理员专用的系统管理的二进制可执行文件存放目录,例如:reboot,rmmod,ifconfig等/boot:启动分区。引导程序(启动linux的核心文件)、内核等村反复目录/sys:内核参数调整。记录核心系统硬件信息/dev:挂载设备文件目录。所有的硬件设备及周边均放置在这个目录下。访问该目录下某个文件相当于访问某个设备。/lib:32位库文件。系统使用的函数库的目录。程序在执行过程中需要调用一些额外的参数时就需要函数库的协助。/lib64:64文库文件/media:挂载的媒体设备目录/mnt:其他临时设备的挂载点/run:系统运行时产生的文件。重启系统后重新生成对应目录数据/opt:第三方软件安装位置/proc:系统信息(虚拟文件系统,通常是内存中的映射)/etc:系统配置文件目录/home:默认普通用户家目录/root:超级用户家目录(系统管理员主目录)/var:存放系统执行中经常改变的文件/srv:系统数据目录(服务启动后需要访问的数据目录)

for a more detailed catalogue, refer to: Linux Directory format and interpretation

2. File addressing

1. The path is divided into

绝对路径:文件所在系统的真实位置,在系统的任何位置都可以使用通常以"/"开头相对路径:相对当前所在系统位置的一个文件名称的简写,他通常会自动添加"pwd"的值在名称前

2. Related commands

pwd                          print work directory 显示当前所在系统位置的路径touch /mnt/file        用绝对路径的方式在/mnt/中建立file文件rm -fr /mnt/file         用绝对路径的方式删除/mnt/中的file文件mv hello /mnt         把当前的hello文件移动到/mnt目录中mv /mnt/hello .       用绝对路径的表示方式把/mnt中的hello文件移动到当前位置,“.”表示当前所在目录

3. Switch working directory (CD)

cd 目标目录          切换到目录cd ..                        进入当前目录的上层目录cd -                         进入当前目录之前所在目录cd ~                        返回当前用户家目录

4. Display of the file (LS)

ls -a          显示所有文件包括以点开头的隐藏文件ls -R         递归显示目录中的所有内容ls -l           显示文件详细信息ls -i           显示文件idls -ld         显示目录详细信息
3. Simple understanding of File management

1.touch: Create a new blank file, modify the file timestamp

touch 文件名       新建空白文件touch -t [[CC]YY]MMDDhhmm[.ss] filename                                修改时间戳stat 文件名          查看文件时间戳

access:被访问的时间modify:文件中内容被修改的时间change:文件被修改的时间

2. New directory: mkdir directory name

mkdir -m 目录名           新建目录同时指定权限


, the default is to create a directory when its permissions and create directory permissions when it is created.

mkdir  -p  目录名          第归构建目录(当上级目录不存在时自动创建上级目录)

3. Delete Files: rm-f file

    -f 是force的缩写,表示强制删除不提示

4. Delete directory: rm-f-R directory (RM-FR directory)

    -r 表示递归,就是目录本身和里面的所有内容

5. View the contents of the file:

1.cat  显示文件的标准输出    cat file          内容显示到当前命令行中    cat -b file      输出表追行号,不忽略空行    cat -n file      输出表追行号,忽略空行

2.head与tail    head filename                显示一个文件的前几行,默认前10行    head -n  5  filename      查看文件内容前五行    tail filename                    显示一个文件后几行,默认后10行    tail -n 5 filename            显示文件的最后5行

tail -f filename                     监控文件后10行内容

3.less:分页浏览文件    当文件过长时使用    less filename

进入浏览模式后:    /关键字          搜索关键字    q                     退出    v                      编辑模式

6.WC Statistics File capacity information

wc -l filename           统计行数wc -w filename         字数wc -c filename          字节数wc -m filename         字符数

7. Writing files: echo content > FileName

直接向文件写入内容,是覆盖原内容的写入(>改成>>表示文件末尾追加内容)

Vim FileName: Enter file browse mode

按"i"键 进入插入模式开始编写字符编写结束后按"ESC"键 退出插入模式按":wq" 保存退出,文件编写完成

8. Copy: CP

cp  目标文件  目标位置cp -r 目标目录   目标位置

9. Mobile: MV

The file/directory location must change before and after the move or the file/directory is renamed

    mv file   目录    mv dir    目录    mv 目录/*  .     把目录中的所有内容移动到当前所在系统位置 "."代表当前所在系统目录    使用mv为文件改名:            mv filename newname       ---------> 用mv命令重命名文件爱,必须保持文件的所在目录不变

Linux (RedHat) Basic Learning-file addressing and management

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.