Overview

Linux

The function of Linux directories:

Root directory (/)
The highest level directory from which all other directories stem, and only the root user has write permission.

/bin directory – User binary files
Contains binary executable files for commonly used Linux commands.

/sbin directory – System binary files
Contains commands typically used by system administrators for maintenance.

/etc – Configuration files
Contains all configuration files required by programs, including startup and shutdown shell scripts for individual programs.

/dev – Device files
Contains device files, including terminal devices, USB or any device connected to the system, such as network cards.

/proc – Process information files
This is a virtual file system that contains information about running processes.

/usr – User programs
Contains binary files, library files, documentation, and source code for secondary programs.

/usr/bin contains binary files for user programs. If you cannot find user binary files in /bin, check the /usr/bin directory.
/usr/sbin contains binary files for system administrators. If you cannot find system binary files in /sbin, check the /usr/sbin directory.
/usr/lib contains libraries used by /usr/bin and /usr/sbin.
/usr/local contains user programs installed from source.

/home – HOME directory
Contains personal profiles for all users. Linux is a multi-user system, so this directory is used to save user information.

/boot – Boot loader
Contains files related to the boot loader.

/lib – System libraries
Contains library files that support binary files located in /lib and /sbin.

/opt – Optional additional applications
A directory for installing additional software on the host, previously placed in the /usr/local directory.

/mnt /media – Mount directories
Default mount points for CDs, typically mounted at /mnt/cdrom, but not necessarily. You can choose any location for mounting.

/root – Administrator’s home directory.

Linux Command

shutdown

sync
shutdown
-k 并非真正关机,只向所有人显示警告信息。
如:shutdown -k +5
-r 重启。默认延迟一分钟
如:shutdown -r +3 “shutdown in 3 minutes”
-h 关机。默认延迟一分钟
如:shutdown -h 12:00/shutdown -h now
-f 重启时跳过磁盘检测。
-F 重启时强制磁盘检测。
-c 取消shutdown

system info

uname

-s 输出内核名称
-n 输出网络节点上的主机名
-r 输出内核发行号
-v 输出内核版本
-m 输出主机的硬件架构名称
-p 输出处理器类型或”unknown”
-i 输出硬件平台或”unknown”
-o 输出操作系统名称
-a 以如下次序输出所有信息。其中若-p和-i的结果不可知则省略

date

file and directory

查看当前目录下有哪些文件
-a 列出目录下的所有文件,包括以 . 开头的隐含文件。
-A 显示除 “.”和“..”外的所有文件。
-B 不输出以 “~”结尾的备份文件。
-c 与lt一起使用,显示并按照修改时间(ctime)排序,与l一起使用,显示修改时间,按名称排序。
-d 将目录象文件一样显示,而不是显示其下的文件。
-f 对输出的文件不排序,使用此选项后aU选项生效,lst选项失效
-F 在每个文件名后附上一个字符以说明该文件的类型,“*”表示可执行的普通文件;“/”表示目录;“@”表示符号链接;“|”表示FIFOs;“=”表示套接字(sockets)。
-g 类似l但是不显示所有者
-h 与l一起,以易于阅读的格式输出文件大小(例如 1K 234M 2G)
-i 输出文件的i节点的索引信息。
-k 以k字节的形式表示文件的大小。–si类似k但是以1000为进制而非1024
-l 列出文件的详细信息。
-L 遇到链接文件是,显示原文件的信息,而非链接信息
-m 横向输出文件名,并以“,”作分格符。
-n 类似l,但是用数字的 UID,GID 代替名称。
-o 显示文件的除组信息外的详细信息。
-p 目录后面加上/标识
-q 用?代替不可输出的字符。
-r 对目录反向排序。
-s 在每个文件名后输出该文件的大小。
-t 以修改时间排序。
-u 与lt一起使用,以访问时间(atime)排序;与l一起使用显示访问时间,按照名称排序
-x 按列输出,横向排序。
-Q 把输出的文件名用双引号括起来。
-R 列出所有子目录下的文件。
-S 以文件大小排序。
-X 以文件的扩展名(最后一个 . 后的字符)排序。
-1 一行只输出一个文件。
–color=no 不显示彩色文件名
–help 在标准输出上显示帮助信息。
–version 在标准输出上输出版本信息并退出。

mkdir

-m 设置权限模式(类似chmod)
-p 需要时创建目标目录的上层目录,但即使这些目录已存在也不当作错误处理
-v 每次创建新目录都显示信息
-Z 将每个创建的目录的SELinux 安全环境设置为CTX

touch 建立文件

-a 只更改访问时间
-c 不创建任何文件
-m 只更改修改时间
-r 使用指定文件的时间属性替代当前时间
-t 使用[[CC]YY]MMDDhhmm[.ss] 格式的时间替代当前时间

cat 查看文件内容

-A 等价于-vET
-b 对非空输出行编号
-e 等价于-vE
-E 在每行结束处显示$
-n 对输出的所有行编号
-s 不输出多行空行
-t 与-vT等价
-T 将跳格字符(tab)显示为 ^I
-v 使用^和M

rm 删除文件或目录

-f 强制删除。忽略不存在的文件,不提示确认
-i 在删除前需要确认
-I 超过三个文件或者递归删除前要求确认。比-i提示内容更少
-d 删除空目录
-r 递归删除目录及其内容

cp 拷贝

-i 覆盖前询问(使前面的 -n 选项失效)
-n 不要覆盖已存在的文件(使前面的 -i 选项失效)
-R, -r, –recursive 递归复制目录及其子目录内的所有内容
-s 只创建符号链接而不复制文件
-f 强制,将目标文件无法打开则将其移除并重试

mv 移动/改名

-f 覆盖前不询问
-i 覆盖前询问
-n 不覆盖已存在文件
#如果您指定了-i、-f、-n 中的多个,仅最后一个生效。

ln

语法:
ln 源文件路径 链接位置路径

常用命令选项:

-s 创建软连接

-f 强制执行

-i 交互模式,文件存在则提示用户是否覆盖

-n 把符号链接视为一般目录,显示为一般文件

-v 显示详细的处理过程