Linux Common commands

Source: Internet
Author: User
Tags parent directory readable switches touch command

There are several ways to get help with the use of commands:
1.man: (for Linux internal commands)
Man Nine chapters:
1. User command Help documentation (commands that all users can execute)
2. System calls
3. Library call (C library Call)
4. (Special call) equipment and special files
5. Configuration file format
6. Game-related Help information
7. Miscellaneous
8. System Administrator Class commands
9. Kernel history-related help information
Some of the fields that are commonly seen in each man Handbook:
Name: A simple description of the program names and related functions
Synopsis: Syntax format used by commands
DESCRIPTION: Detailed description information of the program
Options: A detailed description of the use of the option and the meaning of the option
AUTHOR: Information for program authors
EXAMPLES: Example of using a command program
REPORTING BUGS: The way in which bugs are reported in the program, usually e-mail
See ALSO: Additional reference content
File: Other documentation related to the program, such as configuration files, readme documents, etc.
The meaning of some special symbols that may appear in the Help information:
[]: You can omit to write, or you can choose to use
{}: A vertical bar "|" is generally included in curly braces, which means that you must select from all projects and only one use: "|" With or with the intention
<&gt: What must be written
... : Can have more content
Ways to differentiate between internal and external commands:
# Type Commend
Internal command if the word "inline" or "Buildin" appears in the Find results
The rest of the results are external commands
Help for internal commands is obtained without using the man manual, while using the assist command
# Help Buildin_command
2. Get help with the Whereis command
You can view the program's binaries, source code files, and where the help manuals are located
3.whatis
You can get the description of the manual page of the command that is matched to
4.which
You can show how the aliases of the commands are defined and the path to the binary files of the commands
5.info command
Infocommand
Get the online Help documentation for the command
6. There are many programs that have their own help documentation
/usr/share/doc/app_name-version/
README: Information about the program
Install: Installation information for the program
Changes: Information about the course of the program's version change
LICENSE: The type of license that the program follows
Gpl
Lgpl
Bsd
Apache
MIT
7. Search Engine
Google
Search tips for MySQL filetype:pdf
MySQL site:51cto.com
8. Documentation information in the relevant site site
Wiki
FAQs
9. Official documents provided by the official site of the issuer of the program
10. Reference books:
O ' Reiley
Wrox
Electronic Industry Publishing House
Simple commands for the System Management class:
Logout: In Linux It's just a sign-out.
Exit
Logout
Ctrll+d
Reboot (reboot): Shuts down all processes running in memory, shuts down the system kernel, re-powers all computer parts processes, loads the kernel, launches the application, prints the login prompt
Reboot
Shutdown-r-T #|now|time (recommended)
#: A number that represents a relative time, that is, a reboot after # minutes
Now: Reboot immediately, equivalent to-t 0;
time:12:00
Init 6
Shut down the system: shuts down all processes running in memory, shuts down the system core, and loses power to all computer components
Halt
Poweroff
Init 0
shutdown-h {#|now|time} (recommended)
The philosophical thought of Linux
1. All Documents
Linux abstracts almost all of its data and resources into files, including sockets used by hardware network communication devices and pipelines.
File: A set of streaming data in a storage device with boundaries
2. Composed of a large number of single-function small programs, can achieve complex tasks
Single function: Each small program only do one thing, only to achieve a function, and to do the best
Complex tasks: You can combine multiple small programs as perfectly as possible based on business logic or business type, enabling multiple small programs to complement each other to maximize functionality
3. Try to avoid direct interaction with users
In the programmatic, systematic, platform, automated operation and maintenance space, people are extremely error-prone a link; try to avoid direct interaction with the user can be as far as possible to ensure the accuracy of the results and
Process efficiency, easy to implement automation tasks in a programmatic manner;
4. Save the program's configuration information using a plain text file
You can use the Text Programming tool to analyze the error cause of a program without having to rely on a binary file when the program is in error or does not perform smoothly

File system:
The file is divided into two parts:
Metadata: Describing the properties of a file
Data: The contents of a file
Hierarchical addressing methods:
In the file system, file access is based on the file name reference, by name
In the file system, there are a number of rules for filenames
1. File name cannot contain "/" characters
"/" means the root file system; The so-called root filesystem, which is the original starting point for Linux files;
"/" indicates the delimiter for the path
2. The file name cannot be longer than 255 characters
3. In the same location, the file name cannot be reused;
4. File names are strictly case sensitive
The file system uses the concept of a path to identify the location of the file, and the so-called path is a collection of hierarchy of directories that must go through when locating a file's location.

How paths are described in the file system:
Absolute path: The path where everything starts with the "/" Search

Relative path: Everything starts with the "Current working directory" to find the path;
“.” : Represents the current working directory
“..” : Represents the parent directory of the current working directory (top level directory)
So it can also be said that everything with "." or ".." The path to start looking for is called relative strength, and the "." is used. Represents the current working directory, it can be omitted.
How do I select a path? Select absolute path or relative path?
If the destination file and the current directory are not on the way to find the file, use the absolute path;
On the way: the current working directory is included in the absolute path
Home directory:
The default current working directory for each user who logs on to the system, and also the starting directory for each user, as well as "home directory"
Any one of these paths is actually made up of two parts:
The base name of the file:
BaseName
Directory name of the file:
DirName
FHS: Hierarchical standard for file systems
Bin:binary, common operations commands that all users (including ordinary users) can perform
Boot (start, boot, boot): Boot the operating system to boot the static files, including: Boot program, Linux kernel, INITRAMFS, etc.;
Dev:device, Equipment
Block devices: Block device, random access, refers to a device that enables data storage
Character devices: Character device, sequential access (linear access), refers to the ability to achieve data transmission and data processing functions of equipment;
Etc:exsternal Text Configure, storing the configuration files of each application in the host;
Home: The root of the default home directory for ordinary users;
Lib,lib64:library, the directory where the application shared library is stored, the module of the kernel
Media: mount point for removable devices;
MNT: Mount point of the temporary file system;
Opt:optional, optional, previously this directory is a very popular third-party application installation directory

Root:root User's home directory
Run: Save the PID file for some process; now obsolete
Sbin:super binary, which holds commands for system management classes that the Superuser root can execute
SRV: Data that holds services provided by the system

Tmp:temporary, temp file directory, the system automatically cleans up files in this directory that have not been accessed over 30 every 30 days
The second root of the usr:usual system Root,linux systems is now primarily used to install third-party applications;
/usr/local: Third, mainly used to compile the source code for the installation of third-party applications;
/USR/SRC: The source code of the third party application;
var:variable, variables, storing changeable data, database class files
A pseudo file system in which the data stored in the memory is mapped by the operating system file
Proc:process, Process
Sys:system
File type: the
To differentiate file types by color:
Black or White: plain text files, regular file;
Green: Executable file, command;
Yellow: Device files, including block devices and character devices;
Red: Package files, including: packages, compressed packages, archive packages, etc.;
Dark blue: Catalog file
Cyan Blue (Turquoise): Symbolic link file, equivalent to a shortcut in Windows system;
Purple (Pink): Socket file;
Brown: Pipe file;
Differentiate file types according to the tag of the file type:
-: Normal file
B: Block device files
C: Character device file:
d: catalog files;
L: Symbolic Link file:
P: Pipeline File
S: Socket file
The exact file type is differentiated:
File command
#file/path/to/somefile
Common ways to use commands:
1.echo:display a line of text
Common options:
-N: No Line break
-e: Use the \ Guided escape sequence to take effect;
\ n: Line break
\ t: Horizontal tab
2.cd
Change the shell working directory
Switch working directory
cd[-l|[ -P[-E]] [dir]
Cd/path/to/somedir: Switch The working directory to the directory represented by the parameter;
CD: Switch The working directory to the home directory of the currently logged-in user, equivalent to CD ~;
CD-: Switches the working directory to the last working directory before;
The shell provides two variables;
Pwd
Oldpwd
Note that the method of getting the value of the variable in the shell, the variable name is strictly case-sensitive;
Echo ${var_name}
CD ~username: Switches the working directory to the specified user's home directory;
3.pwd
Print the name of the current working directory
Print the name of the current working directory
4.ls
Ls-list Directory Contents
Note: The contents of the directory are file names;
ls [OPTION] ... [FILE] ...
In the Linux file system, all with "." Files that are the starting character of a file name are hidden files
Common options:
-a,--all: Displays all files, including hidden files;
-a,--almost-all: Display except "." and ".." All files, including hidden files
--color[=when]: Display query results in different colors
-d,--directory: Displays the directory itself, not the file name in the directory
-h,--human-
Readable: Displays a more readable format when displaying file sizes: Typically used with the-l option
-L: Display detailed properties of a file using a long column table
-RW-------. 1 root root 1458 December anaconda-ks.cfg
-: Indicates file type
RW-------: Permission bit settings for files
.: Indicates whether the file has special attributes or extended properties
1: Indicates the number of times the file has been hard connected
Root: The owner of the file
Root: The genus Group of the file
1458: Indicates the size of the file, in bytes when the-H option is not used;
December 23 2016: One of the timestamp of the file, indicating the last modified time
Anaconda-ks.cfg: File name

For device files:
~]# ls-l/dev/sr0
BRW-RW----. 1 root cdrom 11,0 September 10:50/dev/sr0
11,0:major,minor
Major: The main device number that identifies the device type, and then determines what driver needs to be loaded
Minor: Secondary device number to identify different devices in the same device type

The device number is represented by default with a 8-bit binary, so the default device number range is 0-255

-r,--reverse: Reverse output result
-r,--recursive: Recursive display, if there is a subdirectory in the target directory, then recursively display the contents of the subdirectory, one at a time recursively down
-z,--context: Display the SELinux security context label for a file

5.mkdir
Mkdir-make directories, creating a new directory
mkdir [OPTION] ... DIRECTION ...
-P,--Parents: When creating a directory, if its parent directory does not exist, it is created first;
-v,--verbose: Display a message for each directory created
6.rm
Rm-remove Files or directories

RM [OPTION] ... FILE ...
-F,--force: violence, forced deletion;
-R,-R,--recursive: recursively deletes the contents of directories and directories;
7.touch
Touch-change file timestamps The timestamp of the modified files.
-C,--no-create does not create any files
-A: Modify only the file's access timestamp
-M: Only times the modified timestamp of the file
-T Decimtime
Here the time values are formatted as MMDDHHMM[[CC]YY][.SS] from left to right for the month, date, hour, minute, optional century and year, as well as optional seconds. Touch
The time stamp for the specified file is modified with this set of values. Note that this format is not the same as the format specified by the POSIX standard.
Additionally, if the-C option is not specified, the touch command can create a file that is specified as a parameter and does not exist
8.stat
Stat-display file or file system status, showing the state of the files or filesystem;
Format: stat [OPTION] ... FILE ...
Common options:
-C,--format=format: Displays the specified state property of the file in the specified format;
9.nano-nano ' s another editor, an enhanced free Pico clone
Nano [OPTIONS] [[[+line,column] FILE] ...
^: caret, indicating the CTRL key on the keyboard
^+o: Saving document content
^+x: Exit the edit screen
10.cat-con;catenate files and print on the standard output connection file and output
Format: Cat [OPTION] ... [FILE] ...
Common options:
-B,--number-nonblank: Number output for non-blank lines;
-N,--number: number output for all lines;
-S,--squeeze-blank: merge contiguous blank lines;
-E,--show-ends: Displayed at the end of the line in $ characters;
Tac-concatenate and print files in reverse
Format: TAC [OPTION] ... [FILE] ...
Note: The cat or TAC command, if no parameters are given, all of the content needs to be done through standard input (typed from the keyboard), and can then be exited with "^+c" or "^+d";
11.head-output the beginning of the first part of the files output file
Format: Head [OPTION] ... [FILE] ...
Common options:
-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;
-N,--lines=[-]k: Displays the content of the corresponding length in the behavior unit;
can be used-#K方式替换-n #K;
Note: If you do not use any of the options, the first 10 lines of the specified file contents are displayed by default, and if there are less than 10 lines in the file, all content is displayed;


Tail-output the end portion of the last part of the files output file
Format:.. /src/tail [OPTION] ... [FILE] ...
Common options:-C,--bytes=n output last N bytes

-F,--follow[={name|descriptor}]
When the file grows, output the data that is added later; -F,--follow and--follow=descriptor all mean the same thing.

-N,--lines=n outputs the last n rows instead of the default last 10 rows

13.more
More-file perusal filter for CRT Viewing page displays the contents of the document
Format: More [options] file [...]

Interactive editing methods:
You can use "/" to search for filters based on subsequent string combinations;
You can use "n" to find the next match;
Use "Q" to exit more mode;
Using Enter, you can turn down one line;
Using space, you can turn down one page;

14.less
Less-opposite of more
Format: less [options] file [...]
Interactive editing methods:
You can use the "/" or "?" Search filtering based on subsequent string combinations;
The next occurrence can be found using "n" or "n";
Use "Q" to exit more mode;
Using Enter, you can turn down one line;
Using space, you can turn down one page;

Date and time-related commands:
15.date
Operating system time, abbreviated system time, time recorded using software mode clock
date-printf or set the system date and time
Format:
Date [OPTION] ... [+format]
Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]
Common options:
-S,--set =string: Set the system time to the specified time
Two types of formats:
1) MMDDHHMM[[CC]YY][.SS]
2) "Ccyy-mm-dd HH:mm:ss" or "Ccyy/mm/dd HH:mm:ss"
FORMAT

%F: Represents the full date format, i.e.: YY-MM-DD
%T: Indicates the complete time-division-seconds format, and: HH:MM:SS
%Y: Represents the full year
%m: Indicates the month
%d: Represents the date
%H: Indicates hours
%M: Indicates minutes
%s: Indicates seconds
%s: Time stamp, from 1970-01-01 00:00:00 to the current system time the number of seconds experienced;
Note: January 1, 1970 as the Unix of the same;
This timestamp is represented by a 32-bit binary, so the maximum range of its representation is 0~4294967295;
16.clock/hwclock
Hwclock-query or set the hardware clock (RTC)
Format:
Hwclock [function] [option ...]
Common options:
-S,--hctosys: Set the system time according to the hardware clock;
-W,--SYSTOHC: Sets the hardware clock according to the system time; (not recommended)
17.cal
With shutdown, restart, logout related commands
Shutdown: half,poweroff,shutdown-h time,init 0:;
Restart: reboot,shutdown-r Time,init 6;
deregistration: exit,logout,^+d;
18.cp
cp-copy Files and directories
Format: CP [OPTION] ... [-T] SOURCE DEST: Single source copy
CP [OPTION] ... SOURCE ... DIRECTORY: Multi-source replication


Attention:
1) The CP command must be connected to at least two parameters
2) The last parameter, usually the target of this copy
3) If the target given at the time of copying is the directory, copy and rename the file directly to the specified directory, preserving the original file name, and if the target is a non-directory file when copying a non-directory file.

Common options:
-r,-r,--recursive: Recursive copy of directory file:
-d Same as--no-dereference--preserve=links
When the copied source file is a symbolic link file, the-D option preserves the symbolic link file as the source file is copied, and the file referred to by the symbolic link file is not copied
19.mv
MV-Move (rename) file
Format:
MV [Options] ... Source File Destination File
MV [Options] ... Source file ... Directory
Common options:
-F,--force: Never prompt before overwriting
-N,--no-clobber: When you move a file, the source file does not move if it has the same name as the file in the target location



This article is from the "Little Children" blog, please make sure to keep this source http://yigechenlin.blog.51cto.com/13306169/1974387

Linux Common commands

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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