1. echo command
echo (option) (variable)
Options: -e: translational activation character
Use -e
option, if the character appears in the string, then be treated specially, will not it as normal text output:
- \ A warning sound;
- \ B before deleting a character;
- \ C Finally, do not add line breaks;
- \ F new line but the cursor still remain in the original position;
- \ N wrap and move the cursor to the first line;
- \ R cursor to the beginning of the line, but do not wrap;
- \ T Insert Tab;
- \ V and \ f the same;
- \\ inserted into the \ character;
- \ Nnn insert nnn (octal) ASCII character represented;
Printed color text:
Letter color:
echo -e "\e[1;31mThis is red text\e[0m" This is red text
\e[1;31m
Set the color to red\e[0m
The color set back again
Color code: Reset = 0, 30 = black, red = 31, green = 32, 33 = yellow, blue = 34, 35 = magenta, cyan = 36, 37 = white
Background color :
echo -e "\e[1;42mGreed Background\e[0m" Greed Background
Color code: Reset = 0, 40 = black, red = 41, green = 42, 43 = yellow, blue = 44, 45 = magenta, cyan = 46, 47 = white
Flashing text:
echo -e "\033[37;31;5mMySQL Server Stop...\033[39;49;0m"
There are other numerical parameters of the red numbers: 0 Close all attributes, a set of high brightness (in bold), underline 4, 5 flashes, reverse display 7, 8 blanking
2. date command
date (option) (parameters)
Options:
-d <string>: date and time display string referred to. Before and after the string must be enclosed in double quotes; -s <string>: to set the date and time according to the character string. Before and after the string must be enclosed in double quotes; -u: GMT display;
parameters :
% H hour, 24-hour (00 ~ 23 is)
% the I hour, 12-hour (01 ~ 12 is)
% K hour, 24-hour (0 ~ 23 is)
% L-hour, 12-hour clock (. 1 ~ 12 is)
% M min (00 ~ 59)
% P AM or exhibit the PM
% R & lt time display, 12-hour (HH: mm: SS % P)
% S from January 1, 1970 to present experience seconds 00:00:00
% S show seconds (00 ~ 59)
% T display time, 24-hour (HH: mm: SS)
% X-display time format (% H:% M:% S)
% the Z time zone, date field (CST)
% a week short (the Sun ~ Sat)
% a week's full name (the Sunday ~ Saturday)
% H,% B month abbreviation (Jan ~ On Dec)
% B monthly full name (January ~ December)
% C date and time (Tue Nov 20 14:12:58 2012)
% d day of the month (01 ~ 31 is)
% X,% D date (mm / dd / YY)
% j day of the year (001 ~ 366)
% m month (01 ~ 12)
% w day of (0 for Sunday) a week
% W the first few weeks of the year (00 to 53, Monday is the first day)
% y last two digits of year (1999 99)
Walk, conversion, output operation delay
Addition and subtraction operations
date +% Y% m% d // day before the date display date -d "+1 day" +% Y% m% d // day before the date display date -d "-1 day" +% Y% m @% d day after the date display date -d "-1 month" +% Y% m% d // display the date on January date -d "+1 month" +% Y% m% d // display the date of the next month date -d "-1 year" +% Y% m% d // display the date one year before the date -d "+1 year" +% Y% m% d // display year date
set time
date -s // set the current time, only root privileges to set up, the other can only view the date -s 20120523 // set to 20,120,523, which will set the specific time to empty 00:00:00 DATE -s 01:01:01 // set a specific time and date will not do to change date -s "01:01:01 2012-05-23" // this will set the all-time date -s "01:01:01 20120523" // this sets all time date -s "2012-05-23 01:01:01" // this will set the all-time date -s "20120523 01:01:01" // this will set the all-time
Note: set the system here time, under normal circumstances with the system hardware time [time] hwclock different
synchronization time required to install ntpdate, synchronous command: ntpdate, you can also write timing task is completed
3. reboot command
reboot (option)
-d: not write record file data / var / tmp / wtmp on reboot. This parameter has a "-n" effect parameter; -f: forced reboot, do not call shutdown instruction function; -i: before rebooting, close all the network interfaces; -n: not before checking whether a reboot is not completed program; - w : do only testing the system does not actually reboot, reboot will only write wtmp record data files in / var / log directory.
reboot // reboot. reboot -w // to be a reboot of the simulation (only the record does not really reboot
4. poweroff command
poweroff (option)
-n: Do not shut down the operating system when performing sync operation;
- W : not really shut down the operating system, only in the log file "/ var / log / wtmp" in;
-d: a closed operating system, the operation is not written to a log file "/ var / log / wtmp" added to the corresponding record;
-f: forcibly shut down the operating system;
-i: Close all network interfaces before closing the operating system;
-H: shut down the operating system before the system hardware is provided to all standby mode.
5. wget command
Too much trouble, do not want to write
6. ps command
-a: display program executed in all terminals, in addition to the steps of the process leader. a: Display all procedures under the existing terminals, including other users of the program.
-A: Show all programs. -c: display CLS and PRI fields. c: When listing the program, each program displays the name of the real command and does not contain marked path, options or resident services. -C <command name>: Specifies the name of the execution of the instruction, and lists the status of the program instructions. -d: show all programs, but the program leader of stage work is not included. -e: this option is specified the same effect and the "A" option. e: when the program lists, for each display environment variables used by the program. -f: display UID, PPIP, C and STIME field. f: Displays the tree with ASCII characters, expressing the relationship between programs. -g <Group Name>: the effect of this option and specify "-G" the same options, can also use the name of the job when the leader of the stage to specify. g: Display all procedures under the existing terminals, including the program leader of the group. -G <Group ID>: status of belonging to the group are listed in a program, you may also be used to specify the name of the group. h: do not display the title bar. -H: displays a tree structure showing the relationship between programs. -j or j: the use of job control format display program status. or -l l: using the detailed status display program format. L: list information field. -m or m: Display all the threads. n: with numbers to represent USER and WCHAN field. -N: display all programs other than the program in addition to the terminal under the instruction execution ps. -p <program identification code>: Specifies the program identification code, and lists the status of the program. p <program identification code>: This option effect and designated "-p" r: lists only the current program being executed in the terminal. -s <stage job>: Specifies the program identification code phase of the job, and lists the membership status of the phase of the job program. s: program using the program status signal format. S: When listing procedures, including the interrupted routine information. -t <terminal ID>: Specifies the terminal number, and lists the status of belonging to the terminal program. t <terminal number>: same effect and specify this option "-t" option, only a slight difference in the list of formats. -T: displays all the programs under the current terminal. -u <user ID>: the same effect and specify this option "-U" option. u: user-based format to display program status. -U <user ID>: status lists belonging to the user program, can also be used to specify the name of the user. U <user name>: lists the status of belonging to the user program. v: virtual memory format display program status. -V or V: Display version information. - W or w: using wide format display program status. x: Show all programs, the terminal is not to be distinguished. X: using the old Linux i386 landed format display program status. -y: with the option "-l" When in use, do not show F (flag) field, and RSS fields to replace ADDR field. - <program identification code>: this option is specified, and the same effect of the "p" option. --cols <number of characters per row>: Sets the maximum number of characters per column. --columns < --cumulative: the same effect and specify this option "S" option. --deselect: effects and specify this option "-N" the same options. --forest: the effect of this option and specify "f" of the same options. --headers: Repeat display the title bar. - Help : online help. - info : displays troubleshooting information. --lines <shows the number of columns>: setting display screen is the number of columns. --no-headers: the effect of this option and specify "h" the same options, only a slight difference in the list of formats. --group <Group Name>: same effect and specify this option "-G" option. --Group <Group ID>: the same effect and this option designated "-G" option. --pid <program identification code>: the same effect and this option designated "-p" option. --rows <shows the number of columns>: the same effect and this option designated "--lines" option. --sid <stage operation>: This option is the same effect and designated the "-s" option. --tty <terminal number>: same effect and specify this option "-t" option. --user <username>: same effect and specify this option "-U" option. --User <user ID>: the same effect and specify this option "-U" option. --version: This option's effect and specify "
The results of this command may be very long. For ease of viewing, and the pipe may be combined to use less command.
$ ps -ax | less
2. The user filtering process
In the case of the need for specific user processes, we can use the -u parameter. For example, we want to see users 'pungki' process, you can use the following command:
$ Ps -u pungki
7. top command
-b: in batch mode; -c: display the full rule command; -d: Screen refresh interval; the -I: ignore the failure process; -s: privacy mode; -S: Cumulative mode; -i <time> : set the interval; -u <user name>: Specifies the user name; -p <process ID>: Specifies the process; -n <number>: the number of times to cycle through
the interactive command:
h: Help screen is displayed, the command is given a brief summary of some description; k: terminate a process; i: Ignore idle and zombie process, which is a switch-type command; q: exit the program; r: re-arrange the priority of a process ; S: switching to the accumulation mode; S: change the delay time between two refreshes (in s), if there is a decimal, it is converted into ms. Input 0 value, the system will continue to refresh, the default value is 5S; F or F: add or remove items from the currently displayed; O or O: changing the order of the displayed items; L: switching display the average load and start time information; m: toggle display of memory information; T: switch the display process and CPU state information; C: switching the display name and full command line command; M: sorted according to the size of the memory-resident; P: using the percentage of sorted according to size CPU; T: The time / total time for sorting; W : write current settings ~ / .toprc file.
8. pidof command
9. The kill command
-a: When dealing with the current process, the process does not limit the number of command names and corresponding relationship; -l <message number>: If left <message number> option, the -l option will list the names of all of the information; -p: Specifies the kill command to print only the process ID related processes, without sending any signal; -s <message name or number>: Specifies the information to be sent; -u: Specifies the user.
-ef PS | grep vim
root 3268 2884 0 16:21 PTS / 1 00:00:00 vim install .log
root 3370 2822 0 16:21 PTS / 0 00:00:00 grep vim
the kill 3268
the kill 3268
-bash: the kill : (3268) - do not have that process
10. killall command
-e: a long name for an exact match; the -l: Ignore different capitalization; -p: process group to kill the process belongs; -i: Interactive kill the process, kill the process before need to be acknowledged; the -l: Print a list of all known signal; -q: if no processes were killed. Not output any information; -r: Use regular expression matching process name to kill; -s: instead of using the default specified process ID signal "SIGTERM"; -u: kill the specified user process.
Kill all processes with the same name
killall we