Linux operation and Maintenance command System Management

Source: Internet
Author: User
Tags syslog

syslog command syslog is the default log daemon for Linux systems. The default syslog configuration file is the/etc/syslog.conf file. Programs, daemons, and kernels provide log information for accessing the system. Therefore, any program that wants to generate log information can generate this information to a syslog interface call, which typically accepts information from various functions of the system, each of which includes important levels. /etc/syslog.conf file notifies syslogd How to report information usage based on device and information critical level the creation and writing of log information in/var/log is handled by the Syslog protocol and is performed by the daemon Sylogd. Each standard process can log logs with a syslog. You can use the Logger command to log logs through SYSLOGD.
logger test log linetail -n 1 /var/log/messageMay 28 20:06:34 test root: test log line如果要记录特定的标记(Tag)可以使用:logger -t TAG test log linetail -n 1 /var/log/messageMay 28 20:07:48 test TAG: test log line
The LASTB Command LASTB command is used to display a login list of user errors, which can discover the system's logon exceptions. Executes the LASTB command separately, it reads the file in the/var/log directory named Btmp, and displays the list of users who have logged on to the file with a log-in failure.
####语法lastb [选项] (参数)####选项-a:把从何处登入系统的主机名称或ip地址显示在最后一行;-d:将IP地址转换为主机名称-f<记录文件>:指定记录文件-n<显示列数>或-<显示列数>:设置列出名单的显示列数-R:不显示登入的主机名称或IP地址-x:显示系统关机,重新开机,以及执行等级的改变等信息####参数 - 用户名:显示中的用户的登录列表 - 终端:显示从指定终端的登录列表####实例    lastb | head -10

The sudo command sudo command is used to execute commands in other identities, and the default identity is root. The user who can execute the sudo instruction is set in/etc/sudoers. If an unauthorized user attempts to use sudo, a warning message is sent to the administrator. When using sudo, the user must first enter the password, then have a 5-minute expiration date, and the password must be re-entered after the deadline.
####语法sudo (选项)(参数)####选项-b:在后台执行指令;-h:显示帮助;-H:将HOME环境变量设为新身份的HOME环境变量;-k:结束密码的有效期限,也就是下次再执行sudo时便需要输入密码;。-l:列出目前用户可执行与无法执行的指令;-p:改变询问密码的提示符号;-s<shell>:执行指定的shell;-u<用户>:以指定的用户作为新的身份。若不加上此参数,则预设以root作为新的身份;-v:延长密码有效期限5分钟;-V :显示版本信息####参数指令:需要运行的指令和对应的参数####实例配置sudo需要通过编辑/etc/sudoers文件,而且只有超级用户才可以修改,还必须使用visudo编辑。给普通用使用sudo命令的授权:visudo后得到的格式为:账户名    主机名=(可切换的身份)    可用的指令//比如root账号root        ALL=(ALL)        ALL对于新增的账号就在下面加上test        ALL=(root)        ALL//允许test用sudo命令执行root命令,但是每次切换用户都需要输入密码,使用如下命令避免输入密码:test        ALL=(root)        NOPASSWD:ALL//如果是授权用户在使用%%testgroup        ALL=(root)        ALL
Last command
####语法last (选项)(参数)####选项-a:把从何处登入系统的主机名称或ip地址,显示在最后一行;-d:将IP地址转换成主机名称;-f <记录文件>:指定记录文件。-n <显示列数>或-<显示列数>:设置列出名单的显示列数;-R:不显示登入系统的主机名称或IP地址;-x:显示系统关机,重新开机,以及执行等级的改变等信息。####参数    - 用户名:显示用户登录列表    - 终端:显示从指定终端的登录列表####实例

The Watch Command Watch command executes the given instruction in a periodic fashion, and the command output is displayed in full-screen mode. Watch is a very useful command, basically all Linux distributions with this gadget, like the name, watch can help you monitor the results of a command, save you to manually run over and over again.
####语法watch (选项)(参数)####选项-n:指定指令执行的间隔时间(秒);-d:高亮显示指令输出信息不同之处;-t:不显示标题。####参数指令:需要周期性执行的指令####实例#watch uptime#watch -t uptime#watch -d -n 1 netstat -ntlp#watch -d ‘ls -l | fgrep goface‘     //监测goface的文件#watch -t -differences=cumulative uptime#watch -n 60 from            //监控mail#watch -n 1 "df -i;df"       //监测磁盘inode和block数目变化情况
The pidof file pidof command is used to find the process number ID number of the process with the specified name.
####语法    pidof (选项) (参数)####选项-s:仅返回一个进程号;-c:仅显示具有相同“root”目录的进程;-x:显示由脚本开启的进程;-o:指定不显示的进程ID。####实例

Skill commands the Linux Skill command to send a signal to the executing program, the default message is term (interrupt), the more commonly used messages are HUP, INT, KILL, STOP, CONT, and 0
####语法skill [signal to send] [options] 选择程序的规则
The pgrep Command pgrep command finds a process from the running process queue by name, and displays the process ID that is found.
####语法pgrep (选项)(参数)####选项-o:仅显示找到的最小(起始)进程号;-n:仅显示找到的最大(结束)进程号;-l:显示进程名称;-P:指定父进程号;-g:指定进程组;-t:指定开启进程的终端;-u:指定进程的有效用户ID。####参数进程名称:指定要查找的进程名称,同时也支持类似grep指令中的匹配模式。

The nohup Command nohup command can run the program in a way that ignores the pending signal, and the output information of the program being run will not be displayed to the terminal. The output is appended to the Nohup.out file in the current directory, regardless of whether the output of the Nohup command is redirected to the terminal. If the nohup.out file for the current directory is not writable, the output is redirected to the $home/nohup.out file
####语法nohup (选项) (参数)####选项--help:在线帮助;--version:显示版本信息。####参数程序及选项:要运行的程序及选项。####实例nohup command > myout.file 2>&1 &
The pstree command pstree command displays a tree-like representation of the derivation of the process, showing a more intuitive effect.
####语法pstree (选项)####选项-a:显示每个程序的完整指令,包含路径,参数或是常驻服务的标示;-c:不使用精简标示法;-G:使用VT100终端机的列绘图字符;-h:列出树状图时,特别标明现在执行的程序;-H<程序识别码>:此参数的效果和指定"-h"参数类似,但特别标明指定的程序;-l:采用长列格式显示树状图;-n:用程序识别码排序。预设是以程序名称来排序;-p:显示程序识别码;-u:显示用户名称;-U:使用UTF-8列绘图字符;-V:显示版本信息。####实例pstree -p       //显示当前所有进程的进程号和进程idpstree -a       //显示所有进程的所有详细信息,遇到相同的进程名可以压缩显示。
The PS Command PS command is used to report the process status of the current system. You can break and delete unnecessary programs with the KILL command at any time. The PS command is the most basic and powerful process view command that can be used to determine which processes are running and running, whether the process is complete, if the process is dead, which processes are consuming too much resources, and so on, and most of the information can be obtained by executing the command.
# # # #语法ps (option) # # #选项-A: Shows the program executed under all terminals, except for the stage job leader. A: Displays all programs under the current terminal, including other users ' programs. -A: Displays all programs. -C: Displays the CLS and PRI fields. C: When the program is listed, the actual instruction name of each program is displayed, not the path, option, or resident service. -c< instruction Name: Specifies the name of the execution instruction and lists the status of the program for that instruction. -D: Shows all programs, but does not include the stage job leader program. -E: The effect of this option is the same as specifying the "A" option. E: Displays the environment variables used by each program when the program is listed. -F: Displays Uid,ppip,c and Stime fields. F: Display the tree structure with ASCII characters and express the relationship between the programs. -g< Group name: This option has the same effect as specifying the "-g" option and can be specified using the name of the stage job leader. G: Displays all programs under the current terminal, including the group leader's program. -g< group identification Code;: Lists the status of the programs that belong to the group, or it can be specified using the group name. H: The title column is not displayed. -H: Displays a tree structure that represents the inter-program relationship. -j or J: Displays the status of the program in the form of work control. -L or L: Displays the status of the program in a detailed format. L: Information about the place of the slaughter. -M or M: Displays all threads. N: The user and Wchan fields are represented by numbers. -N: Displays all programs except the program under the PS Command Terminal. -p< program identification Code;: Specify the program identification code and list the status of the program. p< program identification code;: This option has the same effect as specifying the "-P" option, with only a slight difference in the format of the list. R: Lists only the programs that are currently in progress on the current terminal. -s< stage operation;: Specifies the program identification code for the stage job and lists the status of the program that is part of the stage job. S: Show program status in program signal format. S: When listing programs, include interrupted sub-program data. -t< Terminal Number: Specify the terminal number and list the status of the program belonging to the terminal. t< Terminal number: This option has the same effect as specifying the "-t" option, with only a slight difference in the format of the list. -T: Displays all programs under the current terminal. -u< User identification code: This option has the same effect as specifying the "-u" option. U: Displays the status of the program in a user-oriented format. -u< user identification Code;: Lists the status of programs that belong to the user, or you can specify them by using a user name. u< User name: Lists the status of programs that belong to that user. V: Displays program status in virtual memory format. -V or V: Displays the version letterInterest. -W or W: Displays the program status in a wide format. x: Show All Programs, do not differentiate by terminal. X: Displays the status of the program using the old Linux I386 login format. -y: When the Mate option "-l" is used, the F (flag) field is not displayed and the addr field is replaced with the RSS field. -< program identification code;: This option has the same effect as specifying the "p" option. --cols< the number of characters per column;: Sets the maximum number of characters per column. --columns< the number of characters per column;: This option has the same effect as specifying the "--cols" option. --cumulative: The effect of this option is the same as specifying the "S" option. --deselect: The effect of this option is the same as specifying the "-N" option. --forest: The effect of this option is the same as specifying the "f" option. --headers: Displays the title column repeatedly. --help: Online Help. --info: Displays the troubleshooting information. --lines< display column number;: Sets the number of columns in the display screen. --no-headers: This option has the same effect as specifying the "H" option, with only a slight difference in the format of the list. --group< Group name: This option has the same effect as specifying the "-g" option. --group< group identification Code;: This option has the same effect as specifying the "-g" option. --pid< program identification code;: This option has the same effect as specifying the "-P" option. --rows< Displays the number of columns;: This option has the same effect as specifying the "--lines" option. --sid< stage operation;: This option has the same effect as specifying the "-S" option. --tty< terminal number;: This option has the same effect as specifying the "-t" option. --user< user name;: This option has the same effect as specifying the "-u" option. --user< User identification code: This option has the same effect as specifying the "-u" option. --version: This option has the same effect as specifying the "-V" option. --widty< the number of characters per column;: This option has the same effect as specifying the "-cols" option.
The Mount Command mount command is used to load the file system to the specified mount point. The most common use of this command is to mount the CDROM so that we can access the data in the CDROM because you insert the disc into the CDROM, Linux does not mount automatically, and you must manually complete the mount using the Linux mount command.
####语法mount -t 类型 -o 挂接方式 源路径 目标路径####选项-t 详细选项:          光盘或光盘镜像:iso9660          DOS fat16文件系统:msdos          Windows 9x fat32文件系统:vfat          Windows NT ntfs文件系统:ntfs          Mount Windows文件网络共享:smbfs(需内核支持)推荐cifs          UNIX(LINUX) 文件网络共享:nfs    -o 详细选项:         loop :用来把一个文件当成硬盘分区挂接上系统         ro :采用只读方式挂接设备         rw :采用读写方式挂接设备         iocharset :指定访问文件系统所用字符集,例如iocharset=utf8         remount :重新挂载
The KILL command Kill command is used to remove a program or work in execution. Kill to send the specified information to the program. The preset information is sigterm (15), which terminates the specified program. If you still cannot terminate the program, you can use the Sigkill (9) information to try to force the removal of the program. The number of the program or work can be viewed using the PS or job instructions.
# # # #语法kill (options) (Parameters) # # # #选项-A: When processing the current process, the corresponding relationship between the command name and the process number is not restricted;-l < information number;: If the < information number > option is not added, the-l parameter lists all information names;-P: Specify Kill The command prints only the process number of the relevant process without sending any signal;-s < information name or number;: Specify the information to send;-u: Specify the user. # # # #参数进程或作业识别号: Specifies the process or job to be deleted.       # # #所有信号名称列表kill-L 1) SIGHUP 2) SIGINT 3) Sigquit 4) Sigill 5) SIGTRAP 6) SIGABRT 7) Sigbus 8) SIGFPE 9) SIGKILL) SIGUSR1 SIGSEGV) SIGUSR213) sigpipe) SIGALRM 16 ) (SIGSTKFLT17) SIGCHLD) (Sigcont) SIGSTOP) SIGTSTP21) sigttin) Sigttou 24) SIGXCPU25) Sigxfsz () sigvtalrm) sigprof) SIGWINCH29) SIGIO (SIGPWR) sigsys) SIG RTMIN35) (sigrtmin+1) sigrtmin+2) (sigrtmin+3) sigrtmin+439) sigrtmin+5 (sigrtmin+6) sigrtmin+7) SIG rtmin+843) (sigrtmin+9) sigrtmin+10) (sigrtmin+11) sigrtmin+1247) sigrtmin+13) sigrtmin+14 50) SIGRTMAX-1451) SIGRTMAX-13 (SIGRTMAX-12) SIGRTMAX-11) sigrtMAX-1055) SIGRTMAX-9 () SIGRTMAX-8 () SIGRTMAX-7 () SIGRTMAX-659) SIGRTMAX-5) SIGRTMAX-4) SI GRTMAX-263) (SIGRTMAX-1) Sigrtmax
The MKE2FS Command MKE2FS command is used to create a "ETC2/ETC3" file system on a disk partition.
####语法mke2fs(选项)(参数)####选项-b<区块大小>:指定区块大小,单位为字节;-c;检查是否有损坏的区块;-f<不连续区段大小>:指定不连续区段的大小,单位为字节;-F:不管指定的设备为何,强制执行mke2fs;-i<字节>:指定"字节/inode"的比例;-N<inode数>:指定要建立的inode数目;-l<文件>:从指定的文件中,读取文件西中损坏区块的信息;-L<标签>:设置文件系统的标签名称;-m<百分比值>:指定给管理员保留区块的比例,预设为5%;-M:记录最后一次挂入的目录;-q:执行时不显示任何信息;-r:指定要建立的ext2文件系统版本;-R=<区块数>:设置磁盘阵列参数;-S:仅写入superblock与group descriptors,而不更改inode able inode bitmap以及block bitmap;-v:执行时显示详细信息;-V:显示版本信息。####参数        设备文件:指定要创建的文件系统的分区设备文件名;        块数:指定要创建的文件系统的磁盘块数量。
The Useradduseradd command is used for new system users created in Linux
####语法useradd (选项) (参数)####选项-c<备注>:加上备注文字。备注文字会保存在passwd的备注栏位中;-d<登入目录>:指定用户登入时的启始目录;-D:变更预设值;-e<有效期限>:指定帐号的有效期限;-f<缓冲天数>:指定在密码过期后多少天即关闭该帐号;-g<群组>:指定用户所属的群组;-G<群组>:指定用户所属的附加群组;-m:自动建立用户的登入目录;-M:不要自动建立用户的登入目录;-n:取消建立以用户名称为名的群组;-r:建立系统帐号;-s<shell>:指定用户登入后所使用的shell;-u<uid>:指定用户id。####参数用户名:要创建的用户名。
The userdel Command Userdel command is used to delete a given user, as well as files related to the user. Without the option, only the user account will be deleted, not the relevant files.
####语法userdel (选项) (参数)####选项-f:强制删除用户,即使用户当前已登录;-r:删除用户的同时,删除与用户相关的所有文件。####参数用户名:需要删除的用户名
The groupadd Command groupadd command is used to create a new workgroup, and the new workgroup information is added to the system files.
####语法groupadd (选项) (参数)####选项-g:指定新建工作组的id;-r:创建系统工作组,系统工作组的组ID小于500;-K:覆盖配置文件“/ect/login.defs”;-o:允许添加组ID号不唯一的工作组。####参数组名:指定新建工作组的组名。
The usermod Command usermod command is used to modify the user's basic information.
####语法usermod (选项) (参数)####选项-c<备注>:修改用户帐号的备注文字;-d<登入目录>:修改用户登入时的目录;-e<有效期限>:修改帐号的有效期限;-f<缓冲天数>:修改在密码过期后多少天即关闭该帐号;-g<群组>:修改用户所属的群组;-G<群组>;修改用户所属的附加群组;-l<帐号名称>:修改用户帐号名称;-L:锁定用户密码,使密码无效;-s<shell>:修改用户登入后所使用的shell;-u<uid>:修改用户ID;-U:解除密码锁定。####参数登录名:指定要修改信息的用户登录名
The groupdel command groupdel command deletes the specified workgroup, and the system files to be modified by this command include/ect/group and/ect/gshadow.
####语法groupdel (参数)####参数组:要删除的工作组名。
The passwd command passwd command is used to set user authentication information, including user password, password expiration time, and so on.
####语法passwd (选项) (参数)####选项-d:删除密码,仅有系统管理者才能使用;-f:强制执行;-k:设置只有在密码过期失效后,方能更新;-l:锁住密码;-s:列出密码的相关信息,仅有系统管理者才能使用;-u:解开已上锁的帐号。####参数用户名:需要设置密码的用户名

Linux operation and Maintenance command System Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.