(1) Name: rpm Takes Snow-1.1.rpm as an example # rpm -ivh snow-1.1.rpm {i: installation, V: Details, H: with # 表示 进 进} # rpm -e snow {delete} # rpm -ivh --force snow-1.1.rpm {Force reload} # rpm -e --Nodeps snow {remove internal relevance check to delete Snow, not recommended} # rpm -UVH snow {upgrade} # rpm -q snow { Query} # rpm -ql snow {Query Snow's file} # rpm -qlc snow {query SNOW document file} # rpm -qld snow {query SNOW configuration file} #RPM -QP SNOW-1.1.rpm {query File, but not query database} # rpm -qa {query all installed software package} # rpm -q / usr / x11r6 / bin / snow {query package owner} #RPM -QR S1-1.1.rpm {query Snow package expect system has the case} # rpm --checksig snow-1.1.rpm {Verify integrity signature} # rpm -v snow {Verify that it is modified after installation}
(2) Name: CAL Use Permissions: All users usage: CAL [-MJY] [MONTH [YEAR]] Description: Display calendar. If there is only one parameter, it represents the year (1-9999), showing the annual calendar. It must be written in the year: `` Cal 89 / will not show the calendar of 1989. Use two parameters, indicating the month and year. If there is no parameter, this month's calendar is displayed. September 3rd on September 1752, the Western calendar, because most countries used a new calendar, 10 days of removal, so the monthly calendar of the month is somewhat different. It was before this. Parameter -M: Displayed on weekdays for weekly first day. -J: Displayed by Kaisa, that is, the number of days from January 1 is displayed. -y: Show this year calendar. Example: CAL: Shows the monthly calendar of this month. [root @ mylinux / root] # Date Tue aug 15 08:00:18 CST 2000 [root @ mylinux / root] # Cal August 2000 Su Mo Tu We TH fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root @ mylinux / root] # CAL 2001: Show AD 2001 calendar.
[root @ mylinux / root] # CAL 2001 2001 January February March Su Mo Tu We TH fr SU Mo Tu We TH fr SU Mo Tu We TH fr sa 1 2 3 4 5 6 1 2 3 1 2 3 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 14 15 16 14 16 17 11 12 13 14 15 16 17 21 22 23 24 25 26 27 18 19 20 21 22 23 24 28 29 29 30 31 25 26 27 2825 26 27 28 29 30 31 April May June Su Mo Tu We TH fr SU Mo Tu We TH fr sa 1 2 3 4 5 6 7 1 2 3 4 5 1 2 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 25 26 27 28 20 21 22 23 24 222 23 29 30 27 28 29 30 31 24 25 26 27 28 29 30 July August September Su Mo Tu We TH fr SA Su Mo Tu WE TH fr Sa 1 2 3 4 5 6 7 1 2 3 4 1 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 15 16 17 18 19 20 21 12 13 14 15 16 14 15 222 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 29 30 31 26 27 28 29 30 31 2 3 24 25 26 27 28 29 30 October November December Su Mo Tu We TH fr SU Mo Tu We TH fr SU Mo Tu We THFR SA 1 2 3 4 5 6 1 2 3 1 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 14 15 16 14 15 16 17 9 10 11 12 13 14 15 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 25 26 27 28 29 30 23 24 25 26 27 28 29 30 31 [root @ mylinux / root] # CAL 5 2001: Show AD 2001 May Calendar. [root @ mylinux / root] # CAL 5 2001 May 2001 Su Mo Tu We TH fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root @ mylinux / root] # Cal -m: The first day of Monday is a weekly way to show this month.
[root @ mylinux / root] # Cal -m August 2000 Mo Tu We TH fr SU 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root @ mylinux / root] # Cal -jy: The number of days from January 1 show this year's calendar. [root @
MYLINUX / ROOT] # Cal -Jy 2000 January February Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat 1 32 33 34 35 36 2 3 4 5 6 7 8 37 38 39 40 41 42 43 9 10 11 12 13 14 15 44 45 617 18 19 20 21 22 51 52 53 54 55 56 57 23 24 25 26 27 28 29 58 59 60 30 31 March April Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri SAT 61 62 67 64 69 70 71 93 94 95 96 97 98 99 72 73 74 75 76 77 78 100 101 102 103 104 105 106 79 80 81 82 83 84 85 107 108 109 110 111 112 113 86 87 88 89 90 91 114 115 116 117 118 119 120 121 May June Sun Mon Tue Wed Thu fri sat 122 123 124 125 128 129 130 131 132 133 134 156 157 158 159 160 161 162 135 136 137 138 165 166 167 168 169 142 143 144 145 146 147 148 174 171 172 173 174 175 176 149 150 151 152 177 178 179 180 181 182 July August Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat 183 214 215 216 217 218 184 185 186 187 188 189 190 219 220 221 222 223 224 2 25 191 192 197 230 231 232 198 29 2002020202202202206 207 208 209 205 206 207 208 209 210 211 240 241 242 243 244 212 213 September October Sun Mon Tue WED THU Fri Sat Sun Mon Tue Wed Thu Fri Sat 245 246 275 276 277 278 279 280 282 251 252 253 282 283 284 255 256 257 258 259 260 289 290 291 292 293 294 295 261 262 263 264 265 266 267 29 29 2922268 269 274 302 272 273 274 303 304 305 November December Sun Mon Tue Wed Thu fri sat 3037 308 309 336 337 310 311 312 313 314 315 316 338 339 343 344 317 318 319 320 321 322 323 345 346 347 348 349 350 351 324 325 326 327 328 329 330 352 353 354 355 356 357
358 331 335 359 364 361 362 363 364 365 366 [root @ mylinux / root] # (3) Name: crontab Usage Permissions: All users use methods: crontab [-u user] filecrontab [-u user] { -l | -r | -e} Description: crontab is used to make the user in a fixed time or a fixed interval execution program, in other words, that is, a similar user's schedule. -u user refers to the schedule that sets the specified user. This premise is that you have to have its permissions (such as root) to specify the schedule of others. If you don't use -u user, it means to set your own schedule. Parameters: -e: Perform a text editor to set a time schedule, the contents of the IP are VI. If you want to use a different text editor, please set the Visual environment variable to specify the use of that text editor. For example, STENV Visual Joe) -r: Deletes the current Time button - List the current schedule meter format as follows: F1 F2 F3 F4 F5 Program where F1 is a minute, F2 represents hours, F3 On the first few days in one month, F4 said the month, F5 represents the first few days in a week. Program represents the program to be executed. When F1 is *, the Program is executed every minute, and the F2 is * indicates that the program is executed per hour, and the remaining classes have been applied to the first time to be AB, which is executed from the first minutes to the third time, F2 is When AB is executed from paragraphs A to B, the remaining classes are pushed to * / n when the f1 is * / N, indicating that each time interval is executed once, and F2 is * / n to execute each time time interval, the remaining classes When F1 is A, B, C, ... is shown in paragraph A, B, C, ... minutes to perform, F2 is A, B, C, ... indicated first, b, c ... In an hour, the remaining class push users can also store all settings first in the file file, and set the time schedule in the way of crontab file. Example: Perhab / bin / ls: 0 7 * * * / bin / ls per hour per hour per hour, per day to 12 o'clock, every 20 minutes per day / usr / bin / backup: 0 6-12 / 3 * 12 * / usr / bin / backup sent a letter to Alex@domain.nam every day from 5:00 in the afternoon on Friday
E: 0 17 * * 1-5 Mail -s "hi"
Alex@domain.nam
E tmp / maildata every day at 0:20, 2:20, 4:20, 4:20 .... Executive Echo "Haha" 20 0-23 / 2 * * Echo "Haha" Note: After executing the time you specified, the system will send you a letter to show you the content executed. If you don't want to receive such a letter, please add> / dev / NULL 2> & 1.
(4) Name: Date Use Permissions: All users use mode: Date [-u] [-d datestr] [-s datestr] [--utc] [--Universal] [--date = datestr] [- Set = datestr] [--help] [--version] [ format] [MMDDHMM [[[CC] YY] YY] [. SS]] Description: Date can be used to display or set the date and time of the system, in display The user can set the format that wants to display, and the format is set to a plus number after the number of marks, where the list of markers are as follows: Time:%: Print% N: Next VIP% T: Jumping% H: Hours (00..23)% i: hour (01..12)% K: Hours (0..23)% L: Hours (1..12)% M: Minutes (00..59)% P: Display local AM or PM% R: Direct display time (12 hours, format is HH: mm: ss [ap] m)% s: from January 1, 1970 00:00 UTC to now Seconds% s: Second (00..61)% T: Direct display time (24-hour system)% x: Parled with% h:% m:% s% z: display time zone date:% A: Week ( Sun..SAT)% A: Sunday..saturday% B: Month (JAN..DEC)% B: Month (January "% C: Direct display date and time% D: Japan (01 ..31)% d: Direct display date (mm / dd / yy)% h: same% b% J: The first few days in the year (001..366)% M: Month (01..12)% U: The first day of the year (00..53) (in the first day of Sunday)% w: The first day of the week (0..6)% w: one year For a few weeks (00..53) (in the case of Monday for a week)% x: Direct display Date (mm / dd / yy)% Y: Year's last two digits (00.99)% Y: Complete Year (0000..9999) If it does not start with the plus sign, it means to set the time, and the time format is MMDDHHMM [[CC] YY] [. SS], where MM is the month, DD is the day, HH is hour, MM for minutes, CC For the first two digits, yy is two digits after the year, SS is the number of seconds: -d datestr: Display time (non-system time) set in DateStr - HELP: Display Assistive message - S DateStr: will The system time is set to date - the time set in DateStr - Show current Greenwich Time --Version: Display version number: Show time jump, then display the current date: DATE % T% N% D display Month and Japanese: Date % B% D Display Date and Setting Time (12:34:56): Date --Date 12:34:56 Note: When you don't want to have meaningless 0 (for example, 1999 / 03/07), you can insert-symbols in the mark, such as Date % - H:% - M:% - S will give down the meaningless 0 in seconds, like the original 08:09:04 It will be 8: 9: 4. In addition, only the permissions (such as ROOT) can set the system time. When you change the system time with the root identity, please write the system time in CMOS in CLOCK -W so that the system time will continue to hold the latest correct value when it is rebooted next time.
(5) Name: SLEEP Usage Permissions: All users use methods: sleep [--help] [--version] Number [SMHD] Description: SLEEP can be used to delay the current action for a period of time parameter: --help: Display Auxiliary message -Version: Display version number Number: Time length, behind can be connected to S, M, H, and D in seconds, m for minute, H is hour, D is the day-to-day number: showing the current time delay 1 minute, Then display time again: Date; SLEEP 1M; DATE
(6) Name: MKDIR function: Create a directory (similar to the MD command under DOS). Syntax: MKDIR [Option] DIRNAME Description: This command creates a directory named by DIRNAME. Users requested to create a directory in the current directory (in the dirName's parent directory) has write permissions, and DirName cannot be a directory or file name in the current directory. Parameters: - m Set access to the new directory. You can also set with a chmod command. - p can be a path name. If some directories in the path do not exist, after adding this option, the system will automatically establish a directory that does not exist, that is, multiple directories can be created once. For example: establishing the / mail directory under Inin and Inin in the current directory, which is continuously built two directories. $ MKDIR - P - M 700 ./ininin/mail/ This command is executed by creating nested directory hierarchical ININ / MAIL in the current directory, and permission is set to only have read, write and execute permissions. (7) Name: RMDIR function: Delete the empty directory. Syntax: RMDIR [Option] DIRNAME Description: DIRNAME represents a directory name. This command deletes one or more subdirectories from a directory. It is important to note that a directory must be empty before being deleted. (Note that the RM - R DIR command can replace RMDIR, but there is a big risk.) You must also have write access to the parent directory when deleting a directory. Parameters: - P Removable Delete Directory DirName, which is also deleted when the child catalog is empty after delete. If the entire path is deleted or reserved for some reason, the system displays the corresponding information on the standard output. For example: $ RMDIR - P / USR / XU / TXT deletes the / usr / xu / txt directory. Change the work directory, display the directory content command (8) Name: CD function: Change the work directory. Syntax: CD [Directory] Description: This command changes the current directory to the directory specified by Directory. If Directory is not specified, return to the user's home directory. In order to change to the specified directory, the user must have execution and read permissions to the specified directory. This command can use wildcards (see Chapter 10 of the wildcard mean). For example: Suppose the user's current directory is: / home / xu, now you need to replace it to the / home / xu / pro directory, $ CD PRO At this point, the user can execute the PWD command to display the work directory. $ PWD / HOME / XU / PRO (9) Name: PWD Function: In the Linux hierarchical directory structure, users can create new directories in any of the authorized directory, or use the CD command to switch from a directory to another. A directory. However, there is no prompt to tell the user which directory is currently in. To know the current directory, you can use the PWD command that displays the entire path name. Syntax: PWD Description: This command shows the absolute path of the current work directory. Example: $ PWD / Home / XU Displayed The path name is / home / XU, each directory name is separated by "/", the root directory is indicated by "/". (10) Name: LS function: LS is an English word List, its functionality is the content listed in the directory. This is one of the most common commands of users, as users need to view the content of a certain directory from time to time. This command is similar to the DIR command under DOS. Syntax: LS [Option] [Directory, or File] For each directory, this command will list all subdirectories and files.
For each file, the LS will output its file name and other information required. By default, the output entries are sorted in alphabetical order. When the directory name or file name is not given, the current directory is displayed. Parameters: - A Displays all subdirectories and files in the specified directory, including hidden files. - a Display all subdirectories and files in the specified directory, including hidden files. But not listed "." And "..". - b Display the non-display character in the file name with an octal escape character. - c Sort by the modification time of the file. - C is divided into multiple columns display. - D If the parameter is a directory, only its name is displayed without displaying each file. Often use together with the L option to get detailed information on the directory. - f is not sorted. This option will make the LTS option to fail and make the AU options are valid. - f Tag "/" after the directory name "/", the executable "*", the symbol link is marked "@", the pipe (or FIFO) after marking "@", pipe (or FIFO), "=" after the SOCKET file. - i Node i node I display file in the first column output. - l Details of the file in a long format. This option is most commonly used. The information listed in each line is: File Type and Permissions Link Document The main file genus file size creates or recently modified time names After the symbolic link file, the displayed file name has "->" and reference file path name. For device files, its File Size field displays the primary, secondary device number, not the file size. The total number of numbers in the directory displays the beginning of the long format list, which contains an indirect block. - L If the specified name is a symbolic link file, the file pointed to by the link is displayed. - m Output by a character flow format, the file is displayed, and the comma is separated. - N The output format is the same as the L option, but only in the output of the file owner and the group group are represented by the corresponding UID number and the GID number, not the actual name. - O is the same as the L option, but does not display the owner information. - p After adding a "/" behind the directory. - q Use "?" Instead of "?" In the file name. - r Displays the output results in an alphanist or first priority order. - R Credit Displays files in each subdirectory of the specified directory. - S gives the number of blocks used in each directory, including indirect blocks. - T is displayed in the modification time (recently priority) instead of by the name. If the file modification is the same, it is in the dictionary order. The modification time depends on whether C or U selection is used. The default time tag is the last revision time. - U shows the time (recently priority) of the last file (recently) instead of being sorted by name. The time tag of -t is to modify to the last time. - X The information of each row is displayed by row. -------------------------------------------------- -------------------------------------------------- - In the information displayed by the ls - l command, the beginning is a string consisting of 10 characters, where the first character represents the file type, which can be one of the following types: - Ordinary file D directory L Sign Link B The 9 characters behind the device file C character device file represents the access rights of the file, divided into 3 groups, 3 digits per group. The first group represents the authority of the file owner, the second group represents the authority of the same group, and the third group represents the permissions of other users. The three characters of each group indicate read, write, and execution permissions for files, respectively. Each permission is as follows: R read W writes X execution. For the directory, it means enters permissions. S When the file is executed, the UID or GID of the file is given the UID (user ID) or GID (group ID) of the process.
T Set the flag bit (stay in memory, not being swapped out). If the file is a directory, the files in this directory can only be deleted by the superuser, directory owner, or file owner. If it is an executable file, after the file is executed, the pointer to its positive segment remains in memory. This will then load the file faster when it is executed again. - No permissions are set. -------------------------------------------------- -------------------------------------------------- - Example 1: List the contents of the current directory. $ LS -F BIN / LIB / VAR / ETC / TMP / INDEX. HTML Example 2: Lists the content of a directory. $ Ls -f / home / xu mai1 / map1e / mm / ptr / telnetd * fd / mbox mount sobsrc. TGZ TMP / Example 3: List all files in a directory (including hidden files). $ 1S -AF / Home / Xu ./. .E1m / .Netscape / Map1E Ptr / ../ .fvwin2rc95 .Term / Mbox Sobsrc. TGZ .xAuthority .kermrc MAI1 / MM / TE1NETD * .BASH-HISTORY .NCFTP / FD / MOUNT TMP / Example 4: List all files in a directory (including hidden files) with long formats. $ 1S -LAF / Home / XR-X L2 root root 1024 NOV 02 22:07 ./ DRWXR-XR-X 15 BBS BBS 1024 JUL 29 07:08 ../ -rw-r - r - 1 yu uses 4343 ju1 29 22:20 .bash-history drwx ------ 2 yu users 1024 May 17 06:36 .e1m / --rw ------ 1 root root 4628 JUN 2 1L : 34 MBOX LRWXRWXRWX 1 ROOT ROOT L4 JU1 29 03:08 Mount -> / MNT DRWXRWXR-X 4 Root Root 1024 JU1 23 03:43 PTR / -RW - R - R- 1 Root Root 483997 JU1 L5 17: 3L Sobsrc. TGZ -RWXR-XR-X L Root Users 60177 JUN 8 01:29 Telnetd * DRWXR-XR-X 2 Root Root 1024 Mar 6 22:32 TMP / Example 5: List all of a directory with a long format The files include hidden files and their I node numbers. And display the file owner and group in the form of UID number and GID. $ 1S -1AINF / Home / Xu Tota1 584 399672 DRWXR-XR-X L2 0 0 L024 NOV 30 22:07 ./333907 DRWXR-XR-X 15 9999 99 L024 JU1 29 07:08 .:/ 39980l -RW-- ----- L 0 0 0 JUN 2 2:09.xauthority 399679 -RW-R - R - 1 505 l00 4343 Jul 29 22:20 .bash-hist0ry 30L763 DRWXR ----- 2 505 100 l024 May 17 06:36 .e1m / ......
There are three different types of users to access files or directories: file owners, group users, other users. Everyone is generally the founder of the file. Owners allow the same group of users to have access to files, and access to other users in the system. In this case, each user in the system can access the file or directory owned by the user. There are three groups of access to each file or directory. Each group is represented by three representations, respectively, write and execute permissions, read, write and execute permissions from the owner's associated group; User read, write, and execute permissions. When the details of the file or directory are displayed with the LS -L command, the leftmost list is the file access. For example: $ ls -l sobsrc. TGZ -RW-R - R - 1 Root Root 483997 JU1 L5 17: 3L Sobsrc. TGZ horizontal line represents empty license. R represents read-only, W is written, and X represents executable. Note that there are 10 locations here. The first character specifies the file type. In the usual sense, a directory is also a file. If the first character is a horizontal line, it is a non-directory file. If D, it is a directory. For example: - rw- r - R - Normal file file main group user Other users are access to file SOBSRC.TGZ, indicating that Sobsrc.tgz is a normal file; Sobsrc.tgz's home owner has read and write permissions; with SOBSRC The .TGZ is the user's user only read the permissions; other users only have read rights. After identifying the access permission of a file, the user can use the chmod command provided by the Linux system to reset different access rights. You can also use the chown command to change the owner of a file or directory. Use the chGRP command to change the user group of a file or directory. These commands are described below. (11) Name: chmod function: chmod command is very important for changing access to files or directories. Users use it to control files or directory access. Syntax: This command has two usage. One is a text setting method containing letters and operator expressions; the other is a digital setting method containing numbers. 1. Text setting method chmod [WHO] [ | - | =] [MODE] file name? Parameter: Operation object WHO, any one of the following or a combination: u Represents "User", That is, the owner of the file or directory. G indicates that "Group) users, that is, all users with the owner of the file owner. O Represents "other (others) users. A Represents "All (all) users. It is the system default value. The operation symbol can be: Add a certain permission. - Cancel a certain permission. = Give a given permissions and cancel all all permissions (if any). Set the permissions represented by MODE available to any combination of the following: r readable. W can be written. X can be executed. X Only the X attribute is added to some users if the user is executable or the target file is a directory. S The owner or group ID of the process is set to the file owner of the file when executed. The user ID bit of the "U S" setting file, "G S" sets the group ID bit. T Save the program's text to the switch. U Have the same authority with the owner of the file. G has the same permissions with users of the owner of the file. O Have the same permissions from other users. File Name: Separate the list of files to change permissions, support wildcard. Multiple permissions can be given in a command line, and there is a comma.
For example: CHMOD G R, O R EXAMPLE makes the group and other users read permissions to file EXAMPLE. 2. Digital Settings We must first understand the meaning of the attribute represented by the number: 0 means no permissions, 1 means executable permissions, 2 indicate that can be written, and then add it. Therefore, the format of the digital attribute should be 3 binary numbers from 0 to 7, and the order is (U) (G) (O). For example, if you want to have two permissions to "read / write", you need to write 4 (read / write) = 6 (read / write). General form of digital setting method is : Chmod [MODE] file name? Example: (1) Text setting method: Example 1: $ chmod a x sort, setting file sort's properties: file owner (u) increase execution permission and file owner Group User (G) Add Permissions Other User (O) Adding Execution Execution 2: $ ChMOD UG W, ox text is the property of setting file text: file owner (u) increase write permissions and file owners Group User (G) Increase Write Permissions Other User (O) Delete Execution Execution Example 3: $ ChMOD U S A.out assumptions Permissions for a.out after CHMOD (you can use the ls - l a.out command) : -Rws - x - x 1 ININ Uses 7192 Nov 4 14:22 A.out and this execution file To use a text file Shiyan1.c, its file access rights are "-rw ------ - "The file is only its owner has read and write permissions. When other users perform A.out this program, his identity is temporarily turned into inin (because the S option is used in the chmod command), so he can read the file (although this file is set) Do not have any permissions for others), this is the function of S. Therefore, in the entire system, in particular the root itself, it is best not to set up this type of file (unless necessary) to ensure the security of the system, avoiding the system to invading the system because of the BUG of some programs. Example 4: $ chmod a-x mm.txt $ chmod -x mm.txt $ chmod ugo-x mm.txt The above three commands are deleted with execution permission of the file mm.txt, which is set for all user.
(2) Digital Setting: Example 1: $ CHMOD 644 mm.txt $ ls -l set file mm.txt properties: -rw-r - r - 1 inin users 1155 NOV 5 11:22 MM.TXT file owner (U) ININ has read, write permissions and file owner's same group users (G) Have read permissions Other (o) Have Read Rights 2: $ ChMOD 750 Wch.txt $ ls -l -rwxr-x --- 1 ISERS 44137 NOV 12 9:22 WCHTXT set the attribute of the WCHTXT this file is: File Master (U) ININ read / writable / executable rights and file main group people ( g) Read / Execute Right Someone (O) No Permissions (12) Name: ChGRP Command Features: Change the group of files or directories. Syntax: Chgrp [Option] Group filename? This command changes the user group to which the specified file belongs. Where Group can be a user group ID, or a group name of the user group in the / etc / group file. The file name is a list of files that are separated by spaces to support wildcards. If the user is not the owner or super user of the file, the group of the file cannot be changed. Parameters: - r Cancellation Change the group of all subdirectories and files under the specified directory. Example 1: $ ChGRP - R Book / Opt / Local / Book Change / Opt / Local / Book / and Groups of All files in its subdirectory are BOOK. (13) Name: chown command function: Change the owner and group of a file or directory. This order is also commonly used. For example, the root user copies its own files to the user XU, in order to allow the user XU to access this file, the root user should set this file to XU, otherwise, the user XU cannot access this file. Syntax: Chown [Option] User or Group file Description: Chown changes the owner of the specified file to the specified user or group. The user can be a username or user ID. The group can be a group name or group ID. The file is a list of files that are separated by spaces to support wildcards. Parameters: - R Cancellation changes the owner of the specified directory and all the subdirectories and files. - v shows the work made by the chown command. Example 1: Change the owner of the file Shiyan.c to Wang. $ Chown Wang Shiyan.C Example 2: Change the owner of all files and subdirectories under the directory / HIS to wang, and the genus is changed to Users. $ Chown - r wang.users / his
(14) Name: CP command function: copy the file or directory to another file or directory, just like the COPY command under DOS, the function is very powerful. Syntax: CP [Option] Source File or Directory Target File or Directory Description: This command copies the specified source file to the target file or copy multiple source files to the target directory. Parameters: - A This option is usually used when copying the directory. It retains links, file properties, and recursively copys the directory, which is equal to the combination of DPR options. - Reserved link when D copy is copied. - f Delete the existing target file without prompting. - The I and F options are reversed, which will give a prompt before the target file is overwritten to require the user to confirm. When the answer y, the target file will be overwritten and is an interactive copy. - P At this point, CP will also copy its modification time and access to the new file in addition to copying the contents of the source file. - R If the source file given is a directory file, the CP will recursively copy all the subdirectory and files in the directory. At this point the target file must be a directory name. - l Does not copy, just link files. It should be noted that in order to prevent the user from using the CP command to use the CP command to destroy another file, such as the user-specified target file name is an existing file name, after copying the file with the CP command, this file will be newly copied. The source file is overwritten, so it is recommended that the user is best to use the I option when using the CP command to copy files. $ CP - I Exam1.c /usr/wang/shiyan1.c This command copies the file exam1.c into the / usr / wang this directory and renamed Shiyan1.c. If you don't want to rename it, you can use the following command: $ cp - r / usr / xu / / usr / liu / 将 / USR / XU directory all files and their subdirectories Copy to the directory / usr / liu. (15) Name: MV command function: Move the file or directory or transfer the file into another directory. This command is like a combination of REN and MOVE under DOS. Syntax: MV [Option] Source File or Directory Target File or Directory Description: Different in the second parameter type in the mv command (Is the target file or target directory), the mv command renames the file or moves to a new one. Directory. When the second parameter type is a file, the mv command completes the file rename. At this time, the source file can only have one (or a source directory name), which rename the source file or directory to a given Target file name. When the second parameter is an existing directory name, the source file or directory parameter can have multiple, the MV command moves the source file specified by each parameter to the target directory. When moving files across file systems, the MV copy, then delete the original file, and the link to the file will also be lost. Parameters: - i interactive operation. If the MV operation will result in overwriting the existing target file, at which point the system is inquiry, requiring the user to answer Y or N, which avoids erroneous overwriting files. - F prohibits interactive operation. When the MV operation is to override an existing target file, the I option will no longer work after specifying this option. If the destination file (not a directory) already exists, the content of the file will be overwritten by the new file. To prevent the user from using the MV command to destroy another file in an inadvertent situation, it is recommended that the user is best to use the I option when using the MV command to move files. It should be noted that MV is different from the results of CP. MV seems to "moving", the number of files is increased, while CP is copied to the file, and the number of files is increased.
Example 1: Move all files in / usr / x to the current directory ("."): $ Mv / usr / xu / *. Example 2: Rename the file wch.txt $ wjz.doc $ mv Wch.txt wjz.doc (16) Name: RM Command Function: Create files in Linux, it is easy to have files at any time at any time and useless. Users can use the RM command to delete it. The functionality of this command is to delete one or more files or directories in a directory, and it can also be deleted with all the files and subdirectories under a directory. For link files, just delete links, the original file remains unchanged. Syntax: RM [Options] File ... If you do not use the RE option, RM does not delete the directory. Parameters: - f ignores files that do not exist, never given a prompt. - R indicates that RM is recursively deleted all directories and subdirectories listed in the parameters. - i interactively deleted. Be careful with the RM command. Because once a file is deleted, it cannot be recovered. For example, when entering the CP, MV or other commands, accidentally entered the RM command, when the user presses the Enter key and recognizes his own mistake, it is too late, the file is no longer. To prevent this happening, you can use the I option in the RM command to confirm each file to be deleted. If the user enters Y, the file will be deleted. If you enter anything else, the file will be retained. In the next example, the user wants to delete the file TEST and EXAMPLE. Each file will then be confirmed. The user finally decides to delete the Example file and retain the TEST file. $ RM - II TEST EXAMPLE REMOVE TEST? N Remove Example? Y
(19) - (19) Name: GREP, FGREP and EGREP This set of commands Search files in specified mode, and notify users to search for strings that match the specified mode and print out all of all containing the string. Text line, the most in front of this text is the file name where the line is located. The grep command can only search for a specified mode at a time; the EGREP command retrieves the extended regular expression (including expression groups and options); the fgrep command retrieves the fixed string, which does not identify the regular expression, is a quick search command. This set of commands is useful in searching for specific themes in the location file. The mode to search for can be considered some keywords that you can use them to search these keywords included. When writing a program, you can use it to find a function, or the relevant phrase. The search function of the grep command is powerful than the FGRep, because the search mode of the grep command can be a regular expression, but FGREP cannot be. See the Shell chapter for regular expressions. Each command in this group command has a set of options that can be used to change its output. For example, you can add a line number on a searched text line, or only the line number of the text line, or output all the text lines that do not match the search mode, or simply output the file name that has been searched for the specified mode, and You can specify whether you write on mode when lookup mode. This group of commands find rows that match the pattern in the specified input file. If you do not specify a file, read it from the standard input. Normally, each matching row is displayed to the standard output. If the file to be found is multiple, add the file name before each row output. Syntax: GREP [Option] [Find Mode] [File Name 1, File Name 2, ...] EGREP [Option] [Find Mode] [File Name 1, File Name 2, ...] FGREP [Option] [Find Mode] [File Name 1, File Name 2, ...] Parameters: - E Each mode is treated as an extension regular expression. - F Each mode is treated as a set of fixed strings (separated from a new row) without as a regular expression. - b Displays the byte offset containing rows in the file in each line of the output. - c shows only the number of matches. - I don't care when comparison. - h When looking up multiple files, indicating that GREP does not to add a file name before the output. - l Displays the file name where the first matching string is located and disabled by the wrap. This file name is not repeated when a matching string is displayed many times in a file. - n The line number in which the matching string is added before the output (the file first line number is 1). - V Only rows that do not contain matching strings are displayed. - x shows only rows of strict matching of the whole line. - e expression specifies the mode of retrieval. The pattern used to prevent the beginning of "-" is interpreted as a command option. - f Expfile Gets the mode to search from the ExpFile file, and a pattern occupies a row. Use the use of the group command to pay attention to the following: Type the search mode after the command, type the file you want to search. Among them, special characters can also be used in the file name list, such as "*", etc. to generate a list of file names. If you want to include a space in the search mode, you can use single quotes to search for the mode to search, indicating that the search is composed of a string containing spaces. Otherwise, the shell will consider the space for the delimiter of the command line parameter, and the grep command will explain the words in the search mode as part of the file name list. In the example below, the grep command search mode "text file" in the file eXample. $ GREP 'TEXT FILE' EXAMPLE users can generate a list of file names that will search with SHELL special characters on the command line.
In the following example, special characters "*" is used to generate a list of file names, which contains all files in the current directory. This command will search for rows that match all files in all files in the current directory. $ GREP DATA * Special characters are very useful when searching for a set of specified files. For example, if you want to search all the specific modes in all C program source files, you can use "* .c" to specify a list of file names. Suppose the user's C program contains some unnecessary steering statements (GOTO statements), want to find these statements, can use the following command to search and display all code rows containing the GOTO statement: $ grep goto * .c user can Type a search mode on the command line, or you can use the -f option to read the mode to search from the specified file. In the file, each search mode occupies a row. This feature is very useful if you are searching for a set of common strings. In the following example, the user wants to search for the string "editor" and "create" in the file exam, put the mode to search in the file mypats, then the grep command reads the mode to search from the file mypats. $ Cat mypats editor create $ grep -f mypats Exam file lookup command (20) Name: find command function: Search files in the directory structure and perform the specified operation. This command provides considerable lookup conditions, which is very powerful. Syntax: Find start directory Search Conditions Operating Instructions: The Find command starts from the specified start directory, recursively searching its individual subdirectories, finds files that meet the search criteria and taking relevant operations. This command is provided with a composite condition that is composed of logical operators NOT, AND, OR. The meaning of logical operators and, or, NOT is: (1) AND: logic, in command, "-a" in command, is the system default option, indicating that only when the conditions given, looking for conditions Complete satisfaction. For example: $ find -name 'tmp'-type c -user 'inin' This command finds all the files that meet all the conditions. (2) OR: Logic or represented by "-o" in the command. The operator indicates that the search is satisfied as long as there is a satisfaction in the conditions given. For example: $ find -name 'tmp' -o -name 'mina *' This command query file name is 'TMP' or all files match 'mina *'. (3) NOT: Logic is not used in the command. The operator represents the file that is not satisfied with the condition. For example: $ find! -Name 'TMP' This command query file name is not all files of 'TMP'. It should be noted that when using a lot of logical options, these options can be enclosed in parentheses. In order to avoid the shell itself cause misunderstandings, it is necessary to add the sense character "//" before the voice number to remove the meaning of parentheses. Example: $ find // (- Name 'TMP' //) Looking for Conditions The following options: First, the n values in the following options can have three input mode, assuming that n is 20, then : 20 indicates that after 20 (21, 22, 23, etc.) -20 indicates 20 previous (19, 18, 17, etc.) 20 indicates that it is just 20 1. Looks with name and file attribute.
- Name 'String' Find all files of the file name match the string of the string, the string can be used in wildcard *, []. - Lname 'String' Find File Name Matches All Symbol Link Files of the String String, and the wildcards available in the string *,?, []. -Gid n Find all files for user groups belonging to the ID number N. -UID N looks out all files of users belonging to the ID number N. -Group 'String' looks into all files that belong to the user group name as the string. -User 'String' looks up all files belonging to the username as a given string. -Empty looks for directory or files of size zero. -Path 'String' Find all files of the path name match the string of the string, wildcards available in the string *,?, []. -Perm Permissions Find files and directories with specified permissions, and privileges may be as 711,644. -Size n [bckw] Find files for specified file size, n, indicating units, defaults B, represents 512 bytes of blocks. -type x Find the file file, X is one of the following characters: b Device file C Character Device file D Directory file P Named pipe (FIFO) F Ordinary file L Symbol Link file (SOMBOLIC LINKS) S socket file - type X is basically the same as -type, but only looks for symbolic link files. 2. Find out time for conditions - Amin N looks for all the files previously visited before. - Atime N looks for all the files previously visited before. - cmin n Find all the files modified by N minutes. - CTIME N looks for all files modified by N days before file status. - Mmin N looks for N minutes before the file content modified all files. - Mtime N looks for all files that have been modified by N days. 3. Executable Operation - Exec Command Name {} Performs the LINUX command to which the eligible file does not ask if the user needs to execute the command. {} Indicates the parameter of the command is the file found; the end of the command must end with "//;". - OK command name {} The Linux command given to the eligible file is different from the EXEC, which will ask if the user needs to execute the command. - LS details all the files found. - The FPRINTF file name writes the file name to the specified file. - Print displays the file name that looks out on the standard output device. - Please refer to the book about C language, please refer to the book about the C language. Example 1: Find all the files starting with main directory and display the contents of these files. $ FIND. - Name 'main *' - Exec More {} //; Example 2: Delete a .out or * .o file that has not been accessed within all weeks in the current directory. $ FIND. // (- Name a.out - o - name '* .o' //) //> - atime 7 - EXEC RM {} //; Description: "." in the command represents the current directory At this time, Find will start from the current directory, and find a file that satisfies the following specified conditions one by one in its subdirectories. / / (And //) indicate parentheses (), "//" is called an escar. The reason why writing is due to the other meaning of the shell, rather than the use of combination conditions here. "- Name a.out" refers to the file you want to find named A.out; "- Name '* .o'" means the file to find all the names to end .o.
These two-name-o represents logic or (or), that is, the lookup name is a.out or name to end files ending with .o, find after the current directory and its subdirectories, then find this file Judgment, see if its final access time is 7 days (condition -Atime 7), if yes, the file is executed command RM (- EXEC RM {} //;). The {} represents the file name that the currently asserting eligible, //; is required by the syntax. The last one of the first rows in the above command is a continuation. When the command is too long and you can't write, you can enter one //, then the system will display a>, indicating that the user continues to enter the command. (21) Name: locate command function: Locate command is used to find files, it is faster than the search speed of the Find command, which requires a database, which is created by a routine work (CRONTAB) program. When we establish this database, you can easily search for the required files. Syntax: Locate related words, for example: lookup related words Issue $ locate Issue / etc / issue /etc/issue.net /usr/man/man5/issue.5 /usr/man/man5/issue.net.5.
(22) Name: TAR effect: TAR can create files for files and directories. With TAR, users can create files for a particular file (backup file), or change files in the file, or add new files to the file. TAR was originally used to create files on tape, and now users can create files on any device, such as floppy disk. With TAR commands, you can pack all a lot of files and directories into a file, which is very useful for backing up files or combining several files into a file for network transmission. TAR on Linux is a GNU version. Syntax: TAR [primary option counseling] file or directory uses this command, the master option must be, it tells Tar to do something, the counseling is auxiliary use, you can choose. Parameters: c Create a new file file. If the user wants to back up a directory or some files, select this option. R Put the file you want to archive to the unlucky of the file file. For example, the user has made a backup file, and there is also a directory or some file forgot backup, then you can use this option to add a directory or file to the backup file. T list the contents of the file file, see which files have been backed up. U Update the file. That is to say, replacing the original backup file with a new file, if you can't find a file in the backup file, append it to the last of the backup file. X Release files from the archive file. Auxiliary Options: b This option is set for the tape drive. Then follow a number, used to explain the size of the block, the system preset value is 20 (20 * 512 bytes). F Use the file or device, this option is usually necessary. K Saves the already existing file. For example, we restore a file, during the restore, encounter the same file, and will not be overwritten. M When restoring the file, set the modification time of all files to now. M Create a multi-volume file to store in several disks. V Detailed report information of TAR processing. If there is no such option, TAR does not report file information. W Each step is required to confirm. Z Use GZIP to compress the / to decompress files, add this option to compress the file file, but must also use this option to decompress when it is restored. Example: Example 1: Take all backup files in the subdirectory in the / home directory, and the backup file is named usr.tar. $ TAR CVF USR.TAR / HOME Example 2: All the subdirectories in the / home include all backup files and compressed, and the backup file is named usr.tar.gz. $ TAR CZVF USR.TAR.GZ / HOME Example 3: Restore the USR.TAR.GZ this backup file and decompressed. $ Tar xzvf usr.tar.gz Example 4: View the contents of the usr.tar backup file and display it on the display in a split screen. $ TAR TVF usr.tar | More To back up files to a specific device, just use the device name as the backup file name. Example 5: Create a backup file in the / dev / fd0 device's floppy disk and copy all the files in the / home directory to the backup file. $ TAR CF / DEV / FD0 / Home To recover files in the device disk, you can use the XF options: $ TAR XF / DEV / FD0 If the user backed up file size exceeds the storage space available in the device, such as floppy disk, you can create one Multi-volume TAR backup files. M Options indicate that TAR command prompts you to use a new storage device, when archiving a floppy drive with M option, the TAR command will remind you to add a new floppy disk when a floppy is full.
This way you can save the TAR file into several disks. $ TAR CMF / DEV / FD0 / Home To restore the files in a few discs, just put the first place in the floppy drive, then enter the tar command with the X and M options. When necessary, you will be reminded to put another floppy disk. $ TAR XMF / DEV / FD0 (23) Name: GZIP role: Reduce file size There are two obvious benefits, one is to reduce storage space, and the second is to reduce the transmission time when transferring files over the network. Gzip is a command to compress and decompress the files in the Linux system, which is convenient and easy to use. Syntax: Gzip [Option] File Name Parameters of Compressed (Decompressed): -c Write the output to the standard output and retains the original file. -D will decompress the compressed file. -L For each compressed file, display the following field: The size of the size of the compressed file is not compressed by the size compression of the specified directory and compresses all files or decompresses the name -R-RC class-R-generated. -T test, check if the compressed file is complete. -V's file name and compression ratio for each compression and decompression file. -Num Adjusts the compressed speed, -1 or -fast represents the fastest compression method (low compression ratio), - 9 or - BEST represents the slowest compression method (high compression ratio). The system default is 6. Suppose a directory / home has file mm.txt, sort.txt, xx.com. Example: Example 1: Complicates each file under the / home to the .gz file. $ CD / Home $ GZIP * $ LS M.TXT.GZ Sort.txt.gz xx.com.gz Example 2: Unzip each compressed file in Example 1 and lists detailed information. $ gzip -dv * mm.txt.gz 43.1% ----- Replaced with mm.txt sort.txt.gz 43.1% ----- Replaced with sort.txt xx.com.gz 43.1% ---- -Replaced with xx.com $ ls mm.txt sort.txt xx.com Example 3: Detailed Display Information of each compressed file in Example 1 does not decompress. $ gzip -l * compressed uncompr. Ratio uncompressed_name 277 445 43.1% mm.txt 278 445 43.1% Sort.txt 277 445 43.1% xx.com $ ls mm.txt.gz sort.txt.gz xx.com.gz Example 4 : Compress a TAR backup file, such as usr.tar, the extension of the compressed file is .TAR.GZ $ Gzip usr.tar $ ls usr.tar.gz (24) Name: UNZIP effect: Compressed under MS Windows How do software WinZip compressed files expand under Linux? You can use the unzip command, which is used to desleviate the compressed file named .zip. Syntax: UNZIP [Option] Compressed file name .zip Parameters: -x File List Decomposing File, but does not include the specified file file. -V View the compressed file directory, but does not decompress. -T test file is damaged, but does not decompress. -D directory solves the compressed file to the specified directory. -Z only shows the annotation of the compressed file. -N does not override existing files. -O covers existing files and does not require user confirmation. -J does not rebuild the directory structure of the document, unfolding all files to the same directory. Example: Example 1: Unpacking the compressed file text.zip in the current directory.
$ UNZIP TEXT.ZIP Example 2: Describe the compressed file text.zip to the specified directory / TMP, if the same file exists, the unzip command does not overwrite the original file. $ Unzip -n text.zip -d / tmp case 3: View the compressed file directory, but does not decompress. $ Unzip -v text.zip (25) Name: The function of zgrep This command is to find a regular expression, the usage, and the GREP command, which only the object is compressed. If the user wants to see if there is a certain sentence in a compressed file, use the zgrep command. (22) Supplementary Name: TAR TAR Xzvf ***. Tar.gz {extract XZ with GZIP, output details V,} tar tzvf ***. Tar.gz {only displayed compressed files, but does not expand} TAR XJVF * **. tar.bz2 {Unfolded file with bzip2 compressed file} TAR CZVF ***. tar.gz / home / boy / * {Pack all the files / home / BOY / lower files into ***. Tar.gz} TAR CMVF / DEV / FD0 ***. tar.gz {split ***. tar.gz to floppy} tar xmvf / dev / fd0 {Split to FLOPPY file, merge to hard disk}
(26) Name: AT Use Permissions: All users use methods: at -v [-q queue] [-f file] [-mldbv] Time Description: AT allows users to specify a certain time to perform a certain time at TIME Or instructions, Time's format is HH: mm in which HH is hour, mm is minutes, or you can specify AM, PM, Midnight, Noon, Teatime (4 pm). If you want to specify the time in more than a day, you can use mmddyy or mm / dd / yy format, where mm is minute, DD is the day, yy refers to the year. In addition, the user can even use a NOW time interval to elastic designation time, where the time interval can be Minutes, Hours, Days, Weeks: In addition, the user can specify Today or Tomorrow to represent today or tomorrow. When the time is specified and press Enter, the AT will enter the conversation mode and ask for input instructions or programs. When you press CTRL D, press Ctrl D to complete all the actions, as for the result of the execution, will be sent back to your account . Putting: -v: Print Publish No. -Q: Use the specified column (Queue) to store, the data of the AT is stored in the so-called queue, and the user can use multiple queue at the same time, and the Queue number is A , B, C ... Z, A, B, ... Z Total 52 - M: Even if the program / instruction is not completed, there is no output result, but also send a letter to the user -f file: read in advance Good command file. Users do not have to use the conversation mode to enter, first write all the specified first to the file once again read -L: List all the specified (the user can also use ATQ directly without AT -L) -D : Delete the specified (the user can use ATRM directly without using AT -D) -V: List all the specified examples that have been completed but have not been removed: 5 pm after three days of execution / bin / ls: AT 5PM 3 days / bin / ls three weeks later 5 pm on 5 pm / bin / ls: at 5pm 2 weeks / bin / ls tomorrow 17:20 execution / bin / date: at 17:20 Tomorrow / bin / date1999 The last day of the last day printed the end of world! At 23:59 12/31/1999 echo the end of world!
(27) Name: PS Use Permissions: All users use mode: PS [options] [--help] Description: Show the dynamic parameters of the instant itinerary: PS is very large, only several commonly used here Parameters and rational introduction Meaning -A list all stroke-W display wide Wid to display more information -au Display more detailed information -Aux Display all stroke Au (x) output format containing other users: user PID % CPU% MEM VSZ RSS TTY Stat Start Time Commanduser: PID: PID% CPU: User CPU Usage% MEM: Used Memory Use VSZ: Occupable Virtual Memory Size RSS: Memory Size TTY: MINOR DEVICE NUMBER OF TTY) Stat: The status of the stroke: D: Uninterruptible stationary (通 □ 缜 b performs I / O action) R: is being executed S: Static state T: Pause to execute z: no existence but temporary unable to eliminate W: Not enough memory paging can be assigned <: high priority stroke N: low priority stroke L: There is a memory paging assignment and lock in memory (instant time) System or AI / O) START: Time Time: Executive Time Command: The instructions performed: pspid Tty Time CMD2791 TTYP0 00:00:00 TCSH3092 TTYP0 00:00:00 PS% PS -APID TTY TIME CMD1 00:00:00 Kflushd3 00:00:00 Kpiod4? 00:00:00 kswapd5? 00:00:00 mdrecoveryd .......% ps -auxuser pid% CPU% Mem vsz RSS TTY Stat Start Time Commandroot 1 0.0 0.7 1096 472? S Sep10 0:03 Init [3] root 2 0.0 0.0 0 0? SW SEP10 0:00 [KFLUSHD] root 3 0.0 0.0 0 0? SW SEP10 0:00 [KPIOD] root 4 0.0 0.0 0 0? SW SEP10 0:00 [kswapd] ........ Linux section Command Introduction (Antai) (28) Name: & & & &&& The command can be used behind any any command, which is used to notify the computer to run a certain command in the background. By placing the job in the background, the user can continue to use the current shell to handle other commands; if the command runs in the front desk, then the user cannot continue to use the current shell before this process. (29) Name: The addUser adduser command is used by root or other permissions to create new users, followed by the addUser command, the account name to be created, for example: addUser flying (30) Name: Alias alias command to Set the alias or alternative name of the command. Generally speaking that an alias is often an abbreviation of the actual command name. For example, the user sets an alias DIR: Alias Dir = LS If only the alias itself is input, the system will display all the current alias. (31) Name: BG BG commands used to force the hang of the process run in the background. For example, when you have already launched a command at the front desk (without using it after this command), you think that this order will run longer, but you still need to use the shell. In this case, the currently running process can be suspended by Ctrl Z. At this point you can make it hang up for a long time, or you can put this process in the background by entering BG. Such a shell can be used to perform other commands. (32) Name: Cat Cat is usually used to scroll through the contents of the file on the screen.
Its format is: CAT