Linux
Just like Windows XP, Windows 7, Windows 8, and Mac OS X, Linux is an operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply – the operating system manages the communication between your software and your hardware. Without the operating system (often referred to as the “OS”), the software wouldn’t function.
- Index Struct
root@iZuf60ahcky4k4nfv470juZ:/# ls /
bin boot dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
dir | desc |
---|---|
bin | 存放着最经常使用的命令 |
boot | 启动Linux时使用的一些核心文件,包括一些连接文件以及镜像文件 |
dev | Linux的外部设备 |
etc | 系统管理所需要的配置文件和子目录 |
home | 用户的主目录 |
lib | 系统最基本的动态连接共享库 |
lost+found | 当系统非法关机后,这里就存放了一些文件 |
media | linux系统会自动识别一些设备,例如U盘、光驱等,linux会把识别的设备挂载到这个目录下 |
mnt | 让用户临时挂载别的文件系统 |
opt | 额外安装软件所摆放的目录 |
proc | 虚拟目录,是系统内存的映射,可通过直接访问这个目录获取系统信息 |
root | 超级权限者的用户主目录 |
run | |
sbin | 统管理员使用的系统管理程序 |
srv | 一些服务启动之后需要提取的数据 |
tmp | 存放一些临时文件的 |
usr | 存放用户的应用程序和文件 |
var | 存放着在不断扩充着的东西,习惯将经常被修改的目录放在这个目录下。包括各种日志文件 |
Linux Command
File Manage
- cat
cat命令用于把档案串连接后传到基本输出(萤幕或加 > fileName 到另一个档案)
-n 或 --number 由 1 开始对所有输出的行数编号
-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号
-s 或 --squeeze-blank 当遇到有连续两行以上的空白行,就代换为一行的空白行
-v 或 --show-nonprinting
>
redirect, >>
append
redirect file cat_original.txt
content with number-line into file cat_back.txt
:
cat -n cat_original.txt > cat_backup.txt
clear cat_original.txt
content :
cat /dev/null > cat_original.txt
- chmod
houbinbindeMacBook-Pro:linux houbinbin$ chmod
usage: chmod [-fhv] [-R [-H | -L | -P]] [-a | +a | =a [i][# [ n]]] mode|entry file ...
chmod [-fhv] [-R [-H | -L | -P]] [-E | -C | -N | -i | -I] file ...
mode param desc:
[ugoa...][[+-=][rwxX]...][,...]
u 表示该文件的拥有者,g 表示与该文件的拥有者属于同一个群体(group)者,o 表示其他以外的人,a 表示这三者皆是
+ 表示增加权限、- 表示取消权限、= 表示唯一设定权限
r 表示可读取,w 表示可写入,x 表示可执行,X 表示只有当该文件是个子目录或者该文件已经被设定过为可执行
- cmp
Compare diff between two files.
- diff
Compare diff between two files.
"|"表示前后2个文件内容有不同
"<"表示后面文件比前面文件少了1行内容
">"表示后面文件比前面文件多了1行内容
demo
houbinbindeMacBook-Pro:linux houbinbin$ diff cat_original.txt cat_backup.txt
4a5
> 5
- file
get the file info
houbinbindeMacBook-Pro:linux houbinbin$ file cat_original.txt
cat_original.txt: ASCII text
- find
Linux find命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时, 不设置任何参数,则find命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示