1. Command Prompt
[email protected] ~]#
Root: User name
localhost: host name
~: Represents the path, which represents the home path of the current user
Home path for Super admin:/root/
home path for normal users:/home/user name/
#: Identity, Super admin
$: Normal user
2. PWD (print working directories): Print the current working directory
Man pwd View Help documentation
pwd [parameter]
-L View logical Path
-P View physical path (valid when viewing hyperlinks folder)
3. LS (list): Displays a list of files and directories
Man ls view Help documentation
Clear Screen: ctrl+l or clear
syntax format: ls [parameter] [file path]
-A: Lists all list information that contains hidden files
-L: Long format display of file information
-H: Display information in a format that people can read (the size of the file is displayed in units)
-R: Recursive presentation of file information
4. mkdir (Make Directories): Common New file Directories
- P: Create a multilevel directory
-V: Displays procedural information for command execution
5. CD (change directory): Switch directory
relative path: Determines the current location by referencing the current path
absolute path: Starting from the root directory/
CD ~: Go to home directory
CD: Go to home directory
CD-: Go to the last directory
CD: Enter the top level directory
CD. : Enter current directory (refresh current directory)
6. RmDir (Remove empty directories): Delete Empty directory
- P: Delete Multilevel directory
-V: Displays procedural information for command execution
7. Touch: Generate an empty file
Create a new file and refresh the file's modified time if the file exists
the name of the stat file: View the file's specific property information
8. RM (remove): Delete Files
RM-RF: Recursive does not prompt for deletion
RM-RF/
RM-RF *
RM-RF.
Shred: Shred (not used)
9. Cat/tac: View the contents of a file
- N: Show line numbers
More : Pagination shows the contents of a file
Less :
Head:
Tail:
11. cp (copy) :文件的复制 语法格式:cp option source dest(文件,目录) cp a.txt b.txt /root/mydir cp -R mydir /root/home cp a.txt /root/c.txt 12. mv(move) :剪切 语法格式:mv option source dest(文件,目录) 重命名: mv a.txt b.txt 剪切: mv a.txt mydir/ 同时操作多个文件: mv a.txt /root/b.txt /root/mydir13. wc(work count ):统计文件中的数据 wc -wcl 文件名称 单词 字符 行数14. echo :字符串的输出 输出数据到控制台 echo "你好" 将数据定向到文本中 echo "你好" > mytest echo "你好" >> mytest 显示命令的执行结果 echo `ls` echo `ls` > mytest15. ln(link) :链接 (windows中的超链接) 语法格式: ln 源文件 目标文件 符号链接: 可以操作文件和目录 创建的是一个路径,相当于windows中的超链接 硬链接:(默认情况) 只能操作文件 相当于创建一个完全一样的副本,类似于实时备份 两个文件完全同步,副本也占用物理空间16. grep(global regular expression and print) :全局规则表达式输出 grep 搜索的字符 文件名称 grep -E 正则表达式 文件的名称
2.1 Description of permissions
文件: 读权限:读取文件的信息 写权限:对文件中的内容进行更改 执行权限:脚本文件 目录: 读权限:读取目录的信息,查看目录中的内容(ls 目录) 写权限:对目录中的内容进行修改(CUD) 执行权限:进行目录的权限 查看文件的权限: ls -l 三种基本的权限: R 读权限 4 W 写权限 2 X 执行权限 1三种用户权限的分类: 属主: user 文件或者文件夹的所有者 属组: group 分组授权,更好的管理权限 其他: other 除了属主和属组之外的用户 十位权限位的说明: 第一位:文件类型 - 普通文件 d 目录 l 链接文件 其余九位: 属主 属组 其他用户 的权限 (RWX)
2.2 change command for permissions
语法格式:chmod (change mode) 读写执行权限 : RWX 修改权限的权限 :文件和目录的所有者、超级管理员 用户的类型 操作的类型 权限类型 chmod u / g / o + /- / = r/w/x 文件、目录 chmod 数字1数字2数字3 文件/目录 chmod ugo+x 文件/目录 chmod u+rwx 文件/目录创建新用户: adduser laowang passwd laowang 设置用户的密码 su laowang 切换用户
2.3 Change of permissions command 2
语法格式:chown 属主:属组 文件/目录名称 chown 属主 文件/目录名称 chown :属组 文件/目录名称
2.4 Change of permissions command 3
语法格式:chgrp 属组
3. Help Commands
man 命令help 命令命令 --help
4. Find Commands
find 查找位置 option 参数 -name 文件名称 -user 用户名 -group 组名称 -type 类型(l , d , f ) -perm 权限(数字:755) -size 大小(+ - 单位:k m g) 例如:find / -name mysqlwhereis 命令的名称 查看命令的命令 例如:whereis ls
5. Piping commands
语法格式:命令2 | 命令2 |
6. Backup and compression
the compression formats commonly used in Linux are:. GZ,. bz2,. Tar, and so on packaging: package multiple files into one file, Size invariant compression: Use some compression algorithm to compress a large file into a small file 6.1 Zip format compression: Zip destination File Source file extract: Unzip original file 6.2. bz2 format compression: bzip2 destination file Source file 2 source file 3 .... For example: Bzip2/root/myfile.txt is packaged by default: myfile.txt.bz2 decompression: bunzip2/root/myfile.txt.bz26.3. gz format compression: gzip target text Piece source file 2 source file 3 .... For example: Bzip2/root/myfile.txt is packaged by default: myfile.txt.gz decompression: gunzip/root/myfile.txt.gz6.4 packaging (Tar focus) Packaging: Tar- CVF destination File Source file 1 source file 2 .... Unpacking: TAR-XVF source file [-C target Location]6.5 Universal notation (emphasis) tar-parameter-C: Package-X: Unpack, unzip-V: Displays the name of the file being processed-f: Keep up with the file names processed by-Z: Processing files using the gzip compression algorithm-J: Processing files using the BZIP2 compression algorithm TAR-CVF packaging TAR-XVF unpacking TAR-ZCVF using gzip to package and compress the text Piece TAR-ZXVF use gzip to unpack and unzip files TAR-JCVF use BZIP2 to package and compress files TAR-JXVF use bzip2 to unpack and extract files
语法格式:shutdown 参数 时间 -r -h -c 例如: shutdown -h now 立即关机 shutdown -r now 立即重启 shutdown -h +6 (定时6分钟关机) shutdown -h 20:55 (设定一个时刻进行关机) ctrl+c 取消上次的命令 shutdown -h +6 & 在后台运行定时的操作 shutdown -c 取消定时操作reboot 重启init 数字: init 0 关机操作 init 3 多用户命令行模式 init 5 多用户图形界面模式 init 6 重启操作
8. Mount Commands
挂载命令:mount -t 文件系统 设备的名称 挂载点 挂载光盘:mount -t iso9660 sr0 /mnt/cdrom 挂载u盘:mount -t vfat /dev/sdb1 (使用虚拟机连接u盘:虚拟机--->可移动设备--->连接U盘)卸载命令:umount 挂载点 或者 设备名称 卸载光盘:umount /dev/cdrom umount /dev/sr0 umount /mnt/cdrom
9. Network Commands
9.1 ping 命令:查看网络的连通性 ping -c 次数 ip地址 ping `cat 文件名称`9.2 ifconfig命令:查看网络设备的信息 ifconfig回车 ifconfig 网卡名称:查看某一个具体的网卡信息 ifconfig 网卡名称 down :关闭网卡 ifconfig 网卡名称 up :激活网卡 修改ip地址:ifconfig 网卡名称 ip地址 netmask 255.255.255.09.3 service 命令:操作服务 service network status service network start/stop/restart
Linux Common commands