Linux system study concluded with commonly used commands

Introduction linux operating system

1.1 Introduction
Linux is a free to use and free dissemination of Unix-like operating system, it is based on POSIX and Unix multi-user, multi-tasking, multi-threading and multi-CPU support for the operating system. It can run major Unix tools, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux has inherited the Unix design idea to the network as the core, is a stable performance multi-user network operating system.
1.2 Linux History
Linux was originally developed by University of Helsinki student Linus Torvalds is not satisfied because of his MINIX operating system used in teaching, so that at the end of 1990 due to personal hobby designed the LINUX system kernel. Later released on Finland's largest FTP server, users can download for free, so more and more of it around the program, Linux itself has grown up, after Linux in less than three years, it would be a perfect function, stable and reliable operating system.

1.3 Linux version
Linux version is divided into two types:
kernel version: kernel version is the version number of the kernel team under the leadership of Linus in the development and maintenance of the system kernel
release: release of some organizations and companies according to their different release

File system

Directory file and document classification

Directory , also known folder that contains all the files
directory create a rule:
1, size 256
2, can not contain special characters
3, see the name EENOW
path : is the location of files and directories to reflect the
[absolute position]: Files location: windos: drive: folders, files .avi
Linux: / Home / master files / 0530 / day1 / a
[relative] position: the current directory location for the 0520./day01/a
. \ c ... \ 01hk \ bil.txt
file, everything is a file in the computer
to distinguish in the windows file can be distinguished by extension; in Linux, can be color-coded, and can be distinguished by file filename command
system _LINUX directory structure and function of
Linux system, all files and directories are organized in a tree structure with a root node inverted began.
The top level of the file system is the root of the beginning, with / represents the root directory.
Under the root directory can be either a directory or a file, and each directory and subdirectories can contain files. And so forth can constitute a large file system.

System startup must:
/boot: Kernel files are stored for use when starting Linux, including connected files and image files.
/etc: Store all system configuration files and subdirectories needed list, change the file directory may cause the system will not boot.
/lib: Store Basic code base (such as c ++ library), where its role is similar to Windows DLL files. Almost all applications need to use these shared libraries.
/sys: This is a core linux2.6 great changes. The directory of a file system sysfs 2.6 kernel emerging installation. sysfs file system integrates information on the following three kinds of file systems: for proc file system processes information for devfs file system devices and file systems for devpts pseudo terminal. The file system is a visual reflection of kernel device tree. When a kernel object is created, the corresponding kernel object files and directories are created subsystem.

Instruction set:

Instruction combined Features
/bin Store the most frequently used programs and instruction
/sbin Only a system administrator can use the procedures and instructions.

External File Management:

External File Management Features
/dev Device (device) abbreviation, Linux is stored in an external device. Note: In the Linux way to access devices and access files are the same.
/media Other windows of device class, such as a U disk, CD-ROM and the like, the device will identify the linux together under this directory.
/ mnt Temporary mount another file system, we can drive mount / mnt /, and then enter the directory you can view the contents of the CD-ROM drive.

Temporary Files:

Temporary Files Features
/run Information since a temporary file system, storage system startup. When the system is restarted, the files in this directory should be deleted or cleared. If there is / var / run directory on your system, it should point to run
/lost+found Under normal circumstances is empty, the system illegal shutdown, some files stored here.
/tmp This directory is used to store temporary files.

Account

Account Features
/root The user's home directory system administrator.
/home User's home directory to the user account named
/usr Many applications and user files are placed in this directory, similar to the program files directory under windows
/usr/bin The application system used by the user instruction.
/usr/sbin More advanced management programs and system daemons use of super user
/usr/src: Kernel source code to place the default directory.

During operation use:

/where Storing frequently modified data, such as program run log file (/ var / log directory)
/proc Managing memory space! Virtual directory, the system memory map, we can directly access the directory to obtain system information. Contents of this directory on the hard disk but not in memory, we can also modify some files inside to do the changes directly.
/opt The default is empty, we can install additional software on the inside
/bin The default is empty, we can install additional software on the inside.
/boot - Here are some of the core is stored in files that are used when you start Linux, including some connection files and image files
/dev dev is the Device (device) abbreviation is stored in the directory Linux external device, the access device in the manner of Linux and accessed files are the same.
/etc This directory is used to store configuration files and subdirectories all system management needs.
/home: The user's home directory, in Linux, each user has its own directory, the directory name is based on the general user account named.
/lib This directory is stocked with a basic system dynamic link shared libraries, its role is similar to Windows in the DLL file. Almost all applications need to use these shared libraries.
/media linux system will automatically identify some devices, such as U disk, CD-ROM, etc., when the identification, linux identified device will mount this directory.
/ Mnt: The system provides this directory is to enable users to temporarily mount other file systems, we can drive mounted on / mnt /, then enter the directory you can view the contents of the CD-ROM drive
/opt: This is for the host to install additional software placed in the directory. For example, you install a ORACLE database you can put this directory. The default is empty.
/proc This directory is a virtual directory, which is the system memory map, we can get system information directly access this directory through. Contents of this directory on your hard disk but not in memory, we can also directly modify certain files inside, such as the ping command can be shielded by the command of the host, so that others can not ping your machine:
/root The catalog for the system administrator, also known as super user's home directory permissions persons.
/sbin s is the Super User's meaning here is stored in the system management program used by system administrators.
/sbin s is the Super User's meaning here is stored in the system management program used by system administrators.
/selinux This directory is Redhat / CentOS specific directory, Selinux is a security mechanism, similar to the windows firewall, but this mechanism is more complex, this directory is stored selinux related documents.
/srv The directory to store some data to be extracted after the service started.
/sys 这是linux2.6内核的一个很大的变化。该目录下安装了2.6内核中新出现的一个文件系统 sysfs 。sysfs文件系统集成了下面3种文件系统的信息:针对进程信息的proc文件系统、针对设备的devfs文件系统以及针对伪终端的devpts文件系统。该文件系统是内核设备树的一个直观反映。当一个内核对象被创建的时候,对应的文件和目录也在内核对象子系统中被创建。
/tmp 这个目录是用来存放一些临时文件的。
/usr 这是一个非常重要的目录,用户的很多应用程序和文件都放在这个目录下,类似于windows下的program files目录。
/usr/bin 系统用户使用的应用程序。
/usr/sbin 超级用户使用的比较高级的管理程序和系统守护程序。
/usr/src 内核源代码默认的放置目录。
/var 这个目录中存放着在不断扩充着的东西,我们习惯将那些经常被修改的目录放在这个目录下。包括各种日志文件。
/run 是一个临时文件系统,存储系统启动以来的信息。当系统重启时,这个目录下的文件应该被删掉或清除。如果你的系统上有/var/run 目录,应该让它指向 run。

文件分类
通常,LINUX文件系统中常用的文件类型有5中:普通文件、目录文件、设备文件、管道文件和链接文件

文件权限

读【r】
写【w】
执行【e】
在这里插入图片描述
第一个字母代表文件的类型:“d” 代表文件夹;“-”代表普通文件;“c”代表硬件字符设备;“b”代表硬件块设备;“s”代表管道文件;“l”:代表软链接文件
后9个字母分贝代表三组权限:文件所有者、用户者、其他用户拥有的权

常用命令格式和快捷键

linux命令:
格式:命令 选项 参数
查看帮助文档
快捷键
常用命令

查看文件命令和重定向

ls【查看文件】
LINUX文件或者目录名称最长可以有256个字符,“.”代表当前目录;“…”代表上一级目录,以“.”开头的文件为隐藏文件,需要用-a参数才能显示。
格式:
ls -a: 查看所有文件包含隐藏文件
ls -l:以列表形式查看文件,不包含隐藏文件
ls -lh:一列表形式查看文件,不包含隐藏文件,按照1024倍显示{ KB,MB,GB}
ls- all:以列表形式查看文件,包含隐藏文件,快捷方式【11】
在这里插入图片描述
通配符:
【*】匹配任意多个字符 a *:l一个以上,256以下
【?】匹配任意一个字符 a?:两个字符
【[a-z]】:区间法,匹配a~z字符,只能确定一个字符
【[abcdef]】:穷举法,匹配abcdef中所有字符,只能确定一个字符

输出重定向 >
LINUX允许将命令执行结果重定向到一个文件,本应该显示在终端上出的内容保存到指定文件中
> 输出重定向会覆盖原来的内容
>>输出重定向则会追加到文件的尾部

分屏显示:more

查看内容时,在信息过长无法一屏显示时,会出现快速滚屏,使得用户无法看清楚屏幕上的内容,此时可以使用more命令,每次只显示一页,按下空格键可以显示另外一页,按下q键退出显示,按下h键可以获取帮助。
管道:一个命令的输出可以作为另外一个命令的输入

清屏:clear

clear**clear作为清除终端上的显示(类似于DOS的cls清屏功能),也可以使用快捷键:ctrl+l

切换工作目录cd

cd命令可以帮助用户切换工作命令LINUX所有目录和文件名大小写敏感,cd后面可以跟相对路径,也可以跟绝对路径。如果省略目录,则默认到当前用户的主目录
切换工作目录:【cd】
格式:
cd:切换到用户主目录
cd~:切换到当前用户主目录
cd…:切换到上级目录/
cd.:切换到当前目录
cd-:切换到上一级目录

显示当前路径:pwd

使用pwd命令可以显示当前的工作目录,该命令很简单,直接输入pwd即可,后面不带参数

创建目录(mkdir)和删除目录(rmdir)

创建目录

通过mkdir命令可以创建一个新的木,参数-p可递归创建目录;需注意的是新创建的目录的名称不能与现有目录中已有的目录或文件重名,并且目录创建者必须对当前目录具有写权限
mdlkir:目录名 -p递归创建

删除目录rmdir

rmdir 目录名目录一定是空的

删除文件rm

可通过rm删除文件或者目录,使用rm命令需小心,因为文件删除后疘恢复,未了防止误删。可以在rm命令后使用-i参数以逐个确认要删除的文件。

参数 含义
-i 以进行交互式执行
-f 强制删除,忽略不存在的文件,无需提示
-r 递归的删除目录下的内容,删除文件夹是必须加此参数

建立链接文件lh

在这里插入图片描述
硬链接文件占磁盘空间,但是删除源文件不会影响链接文件
软链接文件不占磁盘空间,但是删除源文件会影响链接文件

查看或者合并文件内容cat

文本搜索grep

Linux系统中grep命令是一种强大的文本搜索工具,grep允许文本文件进行模式查找,如果找到匹配模式,grep打印包含的所有行
grep‘文件搜索’ 文件名
在grep命令中输入字符串参数时,最好引号或者双引号括qiL来
常用选项说明:
-n 显示行号及匹配
-v 反选【显示不包含匹配文本的所有行】
-i 忽略大小写
通配符:
【^a】以a起始的字符搜索文件
【a$】以a结尾的字符搜索文件
【.】匹配任意一个非换行的字符
【*】匹配任意字符(大于0 的整数)

文件搜索

查找文件find

find 目录 参数 文件名(可以使用通配符)
fiind命令功能十分强大,通常用来
在这里插入图片描述

拷贝文件cp

cp命令的功能时将给出的文件或目录副职到另外一个文件或者目录中,相当于dos命令下的copy命令

选项 含义
-a 该选项通常在复制命令时使用,它保留连接、文件属性,并递归的赋值目录,简单而言,保持文件原有属性
-f 删除已经存在的目标文件而不提示
-i 交互式复制,在覆盖目标之前将给出提示让用户确认
-r 若给出的文件是目录文件,则cp将递归复制到该目录下所有子目录和文件,目标文件必须为一个目录名
-v 显示拷贝进度

cp vim configure/ code/ -vir 把文件夹 vim configure拷贝到code 目录里

移动文件mv

获取文件类型file

归档管理tar

tar -cvf 归档文件名.tar 文件1 文件2
解归档:tar-xvf 归档文件名.tar 路径
常用参数:

参数 含义
-c 生成档案文件,创建打包文件
-v 列出归档解档的详细过程,显示进度
-t 列出档案中包含的文件
-f 指定档案名称,f后面一定是.tar文件,所以必须放选项最后面
-x 揭开档案文件

归档压缩gzip

压缩:gzip 归档文件名.tar 生成了一个文件 归档文件名.tar.gz 文件大小小于归档文件大小
解压缩:gzip-d 归档文件名.tar.gz 生成了一个文件 归档文件名.tar
一步归档压缩:tar -czvf 文件名.tar.gz 文件1文件2 目录1目录2
一步解归档压缩:tar -czvf 文件名.tar.gz 路径
解压到指定目录:+-C

文件压缩解压bzip2

tar与zip2命令结合舒勇实现文件打包、压缩。tar只负责打包但是不压缩,用bzip2压缩tar打包后的文件,使其扩展名一般用:xxxx.tar.bzp2,在tar命令中增加一个选项(-J)可以调用bizp2
实现一个先打包后压缩的过程:
压缩用法:tar cjvf压缩包包名 文件…(tarjcvf bk.tar.bz2*.c)
解压用法:tar xjvf 压缩包包名(tar jxvfbk.tar.bz2

文件压缩解压zip、unzip

通过zip压缩文件的目标文件不需要指定扩展名,默认扩展名为zip.
压缩文件:zip[-r]目标文件(没有扩展名)源文件
解压缩文件:unzip-d 解压后目录文件 压缩文件

查看命令位置which

发布了28 篇原创文章 · 获赞 5 · 访问量 3714

Guess you like

Origin blog.csdn.net/qq_42711899/article/details/104775500
Recommended