Tianhappy
Linux common command introduces that there are too many people who talk about Linux commands, because Linux command is too much, and each command has a lot of options, but the Linux command is the most important tool in the Linux system. Learning Linux command is a must An indispensable link is also the foundation of Linux. So before introducing the other aspects of Linux, let's introduce Linux's common commands, I hope that this brief introduction is helpful to you understand the Linux command.
Before introducing all commands, let's introduce Linux's online help man. Under Linux, when you want to find a command, you can pass the command of the command from the MAN command name. Because each Linux has a Man document, we only introduce the learning options for commands when introducing the command. If you want to see a detailed instructions for the command, please see MAN yourself. Below is the content of each section of the Man: 1 user command. 2 system call. 3 library function. 4 Special documents (equipment and network interfaces). 5 file format. 6 games and demonstrations. 7 System environment, form and macro. 8 System management and related commands.
Apropos Find related commands and system call formats based on your keyword: Apropos Keyword Example: Find commands and system calls related to FTP
$ APOPOS FTP Note: Similar commands have man -k. Man -k is actually executing Apropos
AT executes the specified command format at a specific time: AT [-v] [- Q Queue] [- F File] [- M] TIME Option Description: -v Displays the standard error output. -f can use this option to specify a file in a file. For example, a shell file. -q Specifies the queue name, default is C. -m is executed to send a message to the user. Time specifies the time to start execution. The time format is: hh: mm, date format: mm / dd / yy or mm.dd.yy or mmddyy. The following example demonstrates an AT command at 21:34 March 11, 2004.
$ AT 21:34 03/11/04 After performing this command, you will get a WARNING: Commands Will Be Executed useing (in Order) a) $ shell b) login shell c) / bin / sh. Then "AT>" prompt appears. At this point you can enter the command you want to execute, press Ctrl D after the end. You can drink tea, and the system will automatically perform it after the time.
Related profiles: /etc/at.allow If this file exists, only the users listed in this file use AT.
/etc/at.deny If this file exists, users listed by this file cannot use AT services. When this file is empty, any user can use AT, which is the default configuration.
When running the AT command, check if the /etc/at.allow file exists. If there is no existence, check whether the /etc/at.deny file exists. No matter whether these two files do not exist, both the root user executes the AT command.
Related Commands: ATQ: Lists the tasks to be executed, except for the root user, each user's task will be listed.
ATRM: Remove the AT task by the Taskboard.
BATCH: The command is executed when the system load is allowed. For example, when the load is less than 0.8 or a specified value, the ATRUN is guided.
CAT View file content, read data from the keyboard, merge file, etc.: CAT [-b] [- a] [- e] [- t] [- n] [- s] [- v] file name option Description: -b does not display blank lines in the file. -A is equivalent to -V -E -T (-vet). -E Plus "$" characters at each row of files. -T Displays the TAB key in the file "^ i". -n displays the line number in front of each line of the file. -s Displays a plurality of spaces in multiple spaces. -v displays all characters other than Tab and Enter. The following command demonstrates how to display the line number in the File file $ CAT-N File
CHMOD modification file permission format: chmod option file or directory name option Description: u File Owner G File All Group O Other User Add Permissions - Cancel Permissions = Assignment Permissions A All User R Read Permission W Write Permissions X Execution Permissions The command demonstrates how to make all users to read and write file files.
$ chmod a rw filechown change file owner format: Chown [-r] [- c] [User Name] [Group Name] File or Directory Name Option Description: The description is displayed when the host changes. -R / r changes the files under the directory and the owner of all files in their subdirectory. The following command demonstrates how to change the files in the DIR directory and the owner of the files in its subdirectory for Bugboy
$ Chown -R Bugboy Dir
CP Copy File Format: CP Option Source File Name Target File Name Option Description: -r Copy the entire directory. -f deletes the target file that exists. -i gives a prompt using -F to delete files. The following command demonstrates how to copy the file file to the current user's root directory
$ CP file ~ /
CRONTAB Develop Plan Tasks CRONTAB Enables users to perform certain programs at the specified time, which is copied by cron, creating lists, deleting crontab files to manage user privileges and plans.
Command format: crontab [-u username] [-l] [-e] [-r] option Description: -e Edits the current user's crontab file, or when a crontab file does not exist, create a crontab file. Edit and save the file by the current user's crontab installation. -l lists the current crontab file content. -r Deletes the current user's crontab file. -u UserName Specifies the username. CRONTAB file format:
The crontab file has six domains, with spaces between each domain or Tab, all five domains are integers or *, the format is as follows (the range is the value range):
Minute (0-59) hours (0-23) Day (1-31) Month (1-12) Week (0-6) The command to be executed is in the week value 0 refers to the sun, and the other value is pushed. The front five domains, each domain can be used to represent all legal values, or list a list of legal values, and the values are used by "," separated, or "-" can represent a range. The following command demonstrates all the week and 23:30 in the evening of Thursday night.
30 23 * * 0-4 Halt -P
The following example shows the core files under Monday to Friday 3:15 every week.
15 3 * * 1-5 Find $ home -name core 2> / dev / null | xargs RM -F The following is an example of a crontab file, edit it with a crontab -e command.
Shell = / bin / bashpath = / usr / bin: / bin: / usr / sbin: / sbinmailto = bugboyHome = / home / bugboy30 23 * * 0-4 HALT -P front four lines define environment variables, the last line is executed Command, you can define that you want to perform multiple commands. If your crontab file has been edited correctly, you will get information about "crontab: installing new crontab" after saving exit.
Related files: /etc/cron.d/cron.Allow If this file exists, the username contained in the file can use crontab.
/etc/cron.d/cron.deny If this file exists, the user contained in the file cannot use crontab.
You can edit these two files yourself, pay attention to each user name.
DF View Disk Remaining Space Format: DF [-T] [- X] [- K] [- P] [- A] [- M] [FileName] option Description: -t Output Type Column File System in FSTYPE . -x only output type is not listed in FSTYPE. -k display space in K unit. -m display space in m. -a outputs a file system with a space of 0. FILENAME Specifies the size of the file to view. FDISK / SFDisk View Hard Disk Partition Information Format: FDisk -l [-u] [Device ...] fdisk -s partition
Option Description: -u Lists the size of the sector when the partition table is used instead of the cylindrical size. -l lists the partition tables for a given device. If there is no given device, the partition tables of the device in / PROC / PARTIONS are listed. -s Partition gives the size of the Partition partition (in blocks). FILE Identification File Type Format: File File Name Find Find File Format: Find [Path] [Matching Expression] Where a matching expression is shown in: -Name FileName Find a file that specifies the name. -user username finds a file that specifies the username. -group grpname finds a file that specifies a level. -print displays the results of the lookup. -size n Find a file with N-block, a piece equal to 512 bytes. Symbol " n" indicates a file that looks large to N block; the symbol "NC" indicates that the file is displayed as n characters, and the same symbol " nc" is also available. -inum n Find files of index node (i-node) N. -time n Finds the files accessed before. " N" means a file that is accessed more than N days; "- n" means no more than N days before being accessed. -mtime n is similar to atime, but checks the time that the file content is modified. -ctime n is similar to atime, but checks the time when the file index node is changed. -Perm Mode finds files that match the given permissions, you must give access to access in an octave. -newer file finds a new file than the specified file, that is, the final modification is closer to now. -EXEC Command performs Command commands for matching files, and Command includes file names with a large bracket. Command must end with a backslash and a segment. -OK Command When performing Command, request user confirmation. Others are the same as -EXEC. Example: Find all the files ending with .bek, and remove them $ FIND. -NAME "* .bak" -exec rm {} /; Note: Here * .bak must use single quotes or double quotes Or you can write it into /*.bak.
Head output file content front partial format: head [option] [file] ...... Option Description: The first N row of the output file, the default output 10 lines. -c Specifies the size of the output file, in Byte. Kill Termination Process Format: Kill [-s | P] [- A] PID Option Description: -s Indicates the signal sent to the process. For example -9 (forced termination), the TERM signal is transmitted by default. -p Displays the ID of the process, no signal. -a terminates all processes. 0 Send a signal to all processes in the current process group. -1 sends a signal to all processes greater than 1. Less interactive display file content format: LESS file name description: You can turn forward forward by C-V (Page-down), C-B (Page-Up), and C-P, C-N move forward. This command can be exited by the Q key by the q key. LN creates a link format between files: ln [-b] [- d] [- f] [- f] [- i] [- n] [- s] [- v] source file directory file or directory option description : -B Establish a backup for the deleted file. -d allows root users to build hard links. -F is the same as B. -f forcibly delete the target file. -i gives a prompt when deleting a file. -n This symbol link is replaced when the target file is a symbolic link of the directory. The -s uses a symbolic link instead of hard link (establish a symbolic link). -v outputs the file name of the linked file. Ls is used to browse directories, see files and file name formats in the current directory: LS [Options] option Description: -a Displays all files (including hidden files). -l Displays the details of the file. -k The file size is displayed in K. -Color Displays the file type with different colors when the file is displayed. -d will display the root directory as a file. MORE 1 Page Display File Content Format: More [Options] File Name Option Description: N Start the display / STR from the nth row to start displayed by a place containing the STR string. Mount Loading File System Format: Mount Disk or Partition Device File Load Point Options Option Description: -T File System Type (FAT32 is vfat) -O Option Common option with CodePage, IoCharset (for Chinese codepage = 936, iocharset = GB2312 ) -loop Mounts an example, use an example, mount / dev / hda5 to / mnt / wind directory and directory support Chinese, command as follows:
#mount -t vfat / dev / hda5 / mnt / wind -o codepage = 936, ocharset = GB2312
MV rename file or mobile file format: mv [-b] [- f] [- i] [- u] [- v] source file destination file or folder option description: -b For the source file for backup -f file Mandatory to override your documents when renamed. -i coverage files give a tip. -U target file is not overwritten when the source file is new. -v mobile files give the corresponding prompt. Oggenc compressed music files for .ogg format format: OGGENC file name * .wav file compressed to * .ogg format
Under the same condition of $ OGGENC * .WAV, OGG will get better music than MP3.
PS View Process Status Format: PS [Options] Option Description: -e / a lists all processes. -u Select a valid user ID. -p Select the process under the specified terminal. -C Select the specified file name. -f lists all details. -L is displayed in length format. -j is displayed in JOB format. -x Select the process without the control terminal. Quota Displays the usage of the disk, the general user can view the permission format of yourself using the disk: quota [-g] [- u] [- v] [- p] User Name or Group Name Option: -g Display User Group Disk permissions. -u Displays the user's own permissions to use the disk. -p The display information is simple. Rename Batch Modify File Name Format: Rename from To File ... Option Description: from source character. TO target character. File The following command below demonstrates the following command to RMVB $ RENAME.RM .rmvb * below the next command to change the uppercase of all file names to lowercase
$ RENAME 'TR / A-Z / A-Z /' * RPM Redhat Package Management Tool Format: RPM [Options] File Name | Software Packet Name Option Description: - Version gets version information of the RPM program. -VV gets detailed help information. -v prints lengthy information, often with the -i option, and obtain the installation progress. -i installation package. -U Upgrade package, install it if there is no old version of the package. -F update package when there is an old package. --force equivalent to - RepalcePkgs, - Repalcefiles, - OldPackage. --Nodigest does not verify the independence of the package. --Nosignature does not verify the package or header signature. --Nodeps does not check the installation path of the package. - NeldPackage replaces the old package with a new software. --Prefix Path Specifies the installation path of the package. --Relocate OldPath = NewPath reinstalls the package that is originally installed under "OldPath" to "NewPath". --ReplaceFiles Install package, even if they replace other files. --ReplacePKGS Replace the same name package that has been installed. -e | --rase software package name Delete package. - AlLmatches Delete all the versions of the package. -q query the installed package. -a Select all packages. -H When you unlock the package, print 50 tags, usually used with the IV option. Special note: When the package is deleted, the name of the package is not equal to the file name when the installation is installed. Usually an RPM package is made of a software package name version number issue number release platform after it. For example, there is a file name is bugboy-1.01-1.i386.rpm, then its package name is bugboy, version number is 1.0.1, the issued number is 1, the release platform is Intel 386.
RM Delete file or directory format: RM [-d] [- i] [- r] [- v] [- f] file name or directory name option Description: -d After using this option, RM is generally imaginary as unlink. -i deletes each file to a user prompt. -r Deletes the entire directory, including files and subdirectories. -v Delete each file to give a prompt. -f is forcibly deleted and does not give a prompt. SOX Conversion Audio File Format: SOX [Option] From [Option] TO Option Description: -t file format. -r sampling frequency. Example: Convert file1.wav to file1.au file
$ SOX file1.wav file1.au converts file1.wav into a file1.voc file, and drop the sampling frequency from 10,000 Hz to 5000 Hz
$ SOX -R 10000 file1.wav -r 5000 file1.voc reduces file noise, letting files pass low-pass filters
$ SOX file1.wav file1.voc LOWP 2200 Note: SOX does not support for some file formats without licensed authorized
Su change the ID of the current user. Some formats behind the TAIL Output File Content: Tail [Options] File Name Option Description: -n Displays only the N row behind. -f is too displays that are often used to track message files. TAR decompression or compressed file format: TAR [option] file [file 1 ...] Directory [Directory 1 ...] Option Description: -a Add a TAR file to a archive. -c Generates a new archive file. --delete is removed from the archive. -r Add files to a archive end. -l lists a archived content. -u Only add some new files in some archives to the archive. -x Unpack file from the archive. -v detailed list information of the processed file. -z uses GZIP to process files. -remove-file deletes them after extracting the file. -Z uses Compress to process files. Note: You must include one or more of A C D R T ux in the option.
Top View the usage rate of the CPU, modify the process Run priority format: TOP Options Option Description: -d delay Specifies the number of seconds of the refresh. -p PID View the CPU usage of the specified PID. By default, the process is sorted by the CPU usage, and can be sorted by PID (N), time limit (a), the resident memory usage (M), time (T), and CPU usage (P).
TYPE View a path format where the command is: Type Command Example: Find the path where the ls command is located
$ TYPE LSUMOUNT Uninstall System Format: Umount Disk or Partition Device File (or Load Point) UserAdd Add User or Update New Create User's Default Information Format: UseRADD Options Option Description: -c Comment Description New User Account, usually The user is full name. -d home_dir Sets the user home directory, the default value is the user's login name and placed in the / home directory. -D to create the default information set for the new account after creating a new account. -e eXpire_date Sets the account expiration date with the MM / DD / YYYY format. -f inactivity set the password failure time, the value is 0, and the account is immediately invalid after the password is expired, and the option fails to -1. -g Set basic group. -k skel_dir Set the framework directory, which contains the user's initial configuration file, and the files in this directory are copied to the user's home directory when creating a user. -m automatically creates user home directories and copy files under the framework directory (default / etc / skel) to the user's home directory. -M does not create user home directories. -r Allows the system account to create a new account using the user ID. -S shell Specifies the user's login shell. -u user_id Sets the user ID. Example: #useradd -m -g users -g wheel, student -s / bin / sh -c "yan dingcheng" Bugboy example When modifying user accounts with usermod, each option is similar to the useerAdd command.
Userdel deletes user account format: Userdel username option Description: -r Deletes an account to delete together with an account primary directory. Note: Deleting User Account When the user file in the user's home directory is not deleted, the administrator must search for these files with a FIND command search. Below this command deletes all the files of bugboy users: #find / -user bugboy -exec rm {} /; Whatis View the basic features of the man page and commands you can use: $ whatis topwhereis Locate executable file, source code file Help files in the location format in the file system: whereis [-bmsu] [BMS directory name -f] file name option Description: -b Located executable. -m positioning help file. -S positioning source code file. -u Search the default path to remove the executable file, source code file, other files other than the help file. -B Specifies the path to search executable. -M Specifies the path to the search help file. -S Specifies the path to search the source code file. w View login users and what they are doing: w [-hsfv] [user] option Description: -H does not print information head. -s uses a short format display information. -f prints the source of users. -V Displays version information. WHO View the current user's convenient format: WHO [-i] [- u] [- m] option Description: -i Displays the user's activity. -u is the same as -i. -m Displays the user's own situation.