Linux common command introduction

xiaoxiao2021-03-06  20

Talking to Linux or a daunting, because Linux's 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 an essential to learn Linux. The link is also the Getting Started Basis 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 lookup related commands and system call formats based on your keywords: Apropos Keyword

Example: Find commands and system calls related to FTP

$ APROPOS 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 Using (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 performed, 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 the 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 Modify 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 Writings X Execution Permissions

The following command demonstrates how to make all users to read and write file files.

$ chmod a rw file

Chown change file owner format: chown [-r] [- c] [User Name] [Group Name] file or directory name

Option Description:

The -c file 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 Edit the current user's crontab file, or create a crontab file when a crontab file does not exist. 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) To execute the command

Among them, the value of the week is 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

Below is an example of a crontab file, edit it with a crontab -e command.

Shell = / bin / bash

Path = / usr / bin: / bin: / usr / sbin: / sbin

Mailto = Bugboy

HOME = / home / bugboy

30 23 * * 0-4 Halt -P

The front four lines define environment variables, and the last line is the execution command, you can define multiple commands to perform. If your crontab file has been edited correctly, you will get information about "crontab: installing new crontab" after saving exit. Related documents:

/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 The file system listed 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 10. Format: fdisk -l [-u] [device ...]

11. 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] [Match Expression]

There are several types of matching expressions:

-name filename Find files for the specified 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 .bak and delete them.

$ FIND. -NAME "* .bak" -exec rm {} /;

Note: Here * .bak must be caused by single quotes or double quotes, or you can write Cheng /*.BAK.

HEAD output file content front partial format: Head [option] [file] ......

Option Description:

-n output the front N row of the 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 pages forward, C-P, C-N move forward by C-V (Page-up), C-B (Page-Up). 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 establishes 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 the directory, see the files and file name formats in the current directory: LS [option]

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 page Display file content format: More [option] file name

Option Description:

N is started from the Nth row / STR from the place where the STR string is displayed.

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 is commonly used with CodePage, IoCharset (for Chinese codepage = 936, IOCHARSET = GB2312) -loop Mount ISO file

For example, mount / dev / hda5 to / mnt / wind directory and directory support Chinese, commands 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 target file or folder

Option Description:

-b For the source file for backup -f file, it is enforced to overwrite the file. -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 file is .ogg format format: OGGENC file name

Compress * .wav file to * .ogg format

$ OGGENC * .WAV

Under the same conditions, 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 the disk you use: quota [-g] [- u] [- v] [- p] User Name or Group Name Option Description:

-g Displays privileges that the user is located. -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 to change the file

The following command demonstrates the rear rm of all files to RMVB

$ rename .rm .rmvb *

The following command changes 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 Package

Option Description:

--Version gets the 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 deleting a package, 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 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

Convert file1.wav into a file1.voc file, and reduce the sampling frequency from 10,000 Hz to 5000 Hz

$ SOX -R 10000 file1.wav -r 5000 file1.voc

Reduce file noise, let files pass low-pass filters $ SOX file1.wav file1.voc lowp 2200

Note: SOX does not support for some file formats that are not licensed.

Su change the ID of the current user. Some format behind the TAIL output file content: Tail [Options] File Name

Option Description:

-n shows only the N rows 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 CPU usage, modify process run priority format: TOP option

Option Description:

-d delay Specifies the number of seconds that refreshes. -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 you want: Type Command

Example: Find the path where the ls command is

$ TYPS

Umount Uninstall System Format: Umount Disk or Partition Device File (can also be loaded)

UserAdd adds users or updates the default information format for newly created users: useradd options

Option Description:

-c Comment Description New User Account, usually a full name of the user. -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 useers -g wheel, student -s / bin / sh -c "yan dingcheng" bugboy

Each option is similar to the UseRadd command when modifying user accounts with usermod.

Userdel deletes user account format: Userdel UserName

Option Description:

-r Delete an account and deleted along 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 the bugboy user: #find / -user bugboy -exec rm {} /;

WHATIS ​​View basic features of the man page and commands you can use: $ What TOP

Whereis positioning executables, source code files, helping files in the file system: whereis [-bmsu] [BMS directory name -f] file name

Option Description:

-b positioning 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 format 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. Reboot restarts the command, don't say more.

Halt shutdown command, don't say more.

转载请注明原文地址:https://www.9cbs.com/read-42627.html

New Post(0)