Shutdown and restart commands
Shutdown
#-H shutdown,-r restart;-C to cancel the previous shutdown command;-now immediately shut down the machine
Halt
Poweroff
Init 0
Restart
Reboot
Init 6
------------------------------------------------------------------------------------------------
File processing commands
mkdir Directory
#-P Parent directory does not exist in case of Mister into parent directory
CP original file or directory destination file
#-R copy directory;-p reserved file attributes;
ln Original File Destination file
MV Original File destination directory
#功能描述: Moving files, renaming files
Cat FileName
#-N Displays line numbers
TAC FileName
#反向列示文件内容
Less fileName
#分页显示文件的内容 (can page UP)
Head FileName
#显示文件前面几行
#-n Specifies the number of rows
Tail FileName
#显示文件的后面几行
#-n Specifies the number of rows;-f dynamically displays the end of the file
WC FileName
#统计文本文档的行数, number of words, characters, WC (word count)
#-C Statistics bytes;-l counts the number of rows;-m counts characters and cannot be used in conjunction with-C; A word is defined as a string separated by a blank, a jump, or a newline character.
------------------------------------------------------------------------------------------------
File Search Command
Find [Search Range] [match condition]
Example: Find/home/jxn-name man search for a file or directory named man starting from a specified directory
grep [Specify string] FileName
#在文件中搜寻字串匹配的行并输出,-I is not case-sensitive, and-V excludes the specified string (reverse lookup);--color=auto search keywords are displayed in color
Whereis command
#搜索命令所在目录及帮助文档路径
which command
#搜索命令所在目录及别名信息
Locate FileName
#在文件资料库中查找文件
------------------------------------------------------------------------------------------------
Configuration file
/etc/profile: System Global Environment settings and startup programs
/ETC/BASHRC: System-defined functions and command aliases
/ETC/INPUTRC: Settings related to keyboard and input
/$HOME/.bash_profile: User's environment setting and startup program
/$HOME/.BASHRC: User-defined functions and command aliases
/$HOME/.bash_history: The History of the shell command executed by the user
/$HOME/.bash_logout: Executes the file when the user logs off
------------------------------------------------------------------------------------------------
Account System Files
/etc/password
#用户信息文件, the root user has a UID of 0
/etc/shadow
#用户密码文件
/etc/group
#组信息文件
/etc/gshadow
#组密码文件
------------------------------------------------------------------------------------------------
User and Group Management commands
Useradd UserName
#添加用户,-p password;-d home directory name;-g group name;-s shell path;-U set UID number
Usermod UserName
#修改用户信息,-p new password;-g new group name;-l new login name;-d home directory name;-U new UID number
Userdel UserName
#删除用户,-R deletes the user's home directory while deleting the user
passwd UserName
#修改密码,--stdin the data as the user's password through the pipe character;-d delete the account password;
Groupadd GroupName
#添加新组, the GID of the-G setting group
Groupmod GroupName
#修改组信息,-N Change the name of the group account;-G new GID
Groupdel GroupName
#删除组
W.H.O.
#查看登录用户的信息
W
#查看登录用户的详细信息
ID UserName
#查看用户的UID, GID
Groups username
#显示用户所属组
Su UserName
#切换用户,-Indicates that the user's environment variable is switched at the same time;-C uses only that user to execute a command without switching user identities
Chage UserName
#修改用户密码状态
chmod fileName
#修改操作权限, the group user, o other user, a all user of the group of Master, G owner;
#+ permissions,-minus permissions, = Plus permissions to delete the original permissions, R (4), W (2), X (1) Read, write, execute permissions
Example: chmod u+x fileName
Chown Owner[:group] File or directory
#更改文件的属主或属主所在的组,-R processes all files under the specified directory and directory;
Example: Change directory: Chown-r jxn:student/tmp/src change file: Chown jxn Test.java
Chgrp
#修改文件或目录所属群组 (Note: The owner cannot be modified)
Chgrp-r groupname/tmp/all the subdirectories and files in the TMP directory are all set to GroupName
Umask
#显示, setting default permissions for files
#-S Displays the new file default permissions in rwx form
------------------------------------------------------------------------------------------------
File System Management
Mount [-t file system] device file name mount point
#挂载命令
#ext2 Linux currently used in the file system; Msdos MS-DOS fat, is fat16;vfat u disk and windows98 commonly used FAT32; NFS Network File system
ISO9660 CD-ROM standard file system
DF Mount point
#查看文件系统磁盘空间的使用情况,-a displays all file system information;-H uses the display capacity of KB, MB, GB and so on;-T displays the file system type,-K,-M in KB, MB display capacity
Du directory or file name
#显示指定的文件或目录已使用的磁盘空间的总量,-a displays the disk footprint of each sub-file;-S statistics total usage, not subdirectories and sub-files,-H Ibid
Fdisk-l
#查看硬盘列表
Fdisk/dev/sdb
#使用fdisk命令分区
#fdisk交互指令说明
Command description
A to set the bootable tag
b Edit BSD Disk label
C Set DOS operating system compatibility tag
D Delete a partition
L Displays the known file system type. 82 for Linux swap partitions, 83 for Linux partitions
M Display Help Menu
N New Partition
o Create a blank DOS partition table
P Show Partition list
Q Do not save exit
s new Blank Sun disk label
T change the system ID of a partition
U Change Display recording Unit
V Verify partition Table
W Save exit
X additional features (experts only)
Mkfs-t EXT4/DEV/SDB1
#格式化分区
Fsch Partition Device file name
#修复文件系统
------------------------------------------------------------------------------------------------
System administration Commands
Stat
#显示文件的相关信息, more detailed than the LS command display
W.H.O.
#显示在线登录用户
WhoAmI
#显示用户自己的身份
Hostname
#显示主机名称
Uname
#显示系统信息
Top
#系统监视器 (equivalent to Task Manager under Windows), showing the most resource-intensive processes in the current system
Ps
#显示瞬间的进程状态
Kill
#杀死进程
Free
#显示当前内存和交换空间的使用情况
------------------------------------------------------------------------------------------------
Network commands
Ping IP Address
#测试网络连通性,-c specifies the number of times to send
Ifconfig NIC name IP address
#查看和设置网络接口 (NIC) information, Ifconfig (interface Configure)
Last
#列出目前与过去登入系统的用户信息
Netstat
#显示网络相关信息,-t TCP protocol;-u UDP protocol;-L listener;-R Route;-N Displays IP address and port number
Setup
#配置网络
Mail UserName
#查看发送电子邮件
Write UserName
#给用户发信息, save end with Ctrl+d
Wall message
#发广播信息, Wall (that is, write all)
------------------------------------------------------------------------------------------------
Help commands
Man command or configuration file
Help command
------------------------------------------------------------------------------------------------
Bash common shortcut keys
CTRL + C forces the current command to terminate.
Ctrl+l clear screen, equivalent to the clear command.
Ctrl+u the command before the cursor is deleted or clipped.
Ctrl+y Paste the contents of Ctrl+u or ctrl+k cut.
Ctrl+r Search in the history command, after pressing CTRL+R, the search interface will appear, as long as the search content is entered, it will be searched from the history command.
Ctrl+d exit the current terminal.
------------------------------------------------------------------------------------------------
Linux basic commands