Simple commands in Linux

Source: Internet
Author: User

History: Print the commands you've lost
1. Commands entered by the user in the shell are automatically saved to the memory buffer
2. When exiting the shell, the data in memory is flushed to the disk file: ~/.bash_history

Shortcut keys
ESC +.: Gets the last parameter of the previous command
! Sequence Number: The history command for how many numbers are executed
!! : Executes the previous command
A string: A command that matches the beginning of a specified string from the last to come

History options
-C: Empty history command
-A: Append the In-Memory history command to the end of ~/.bash_history
-r: Read History command from ~/.bash_history to memory
-W: Forces all History commands in memory to be saved to ~/.bash_history


Types of variables
Custom variables: Variables defined by the user according to their individual needs
Pre-defined variables: variables generated during system initialization
System Environment Variables:
Example: HOSTNAME Define host name
Path defines the paths that are searched when the command is executed
Local variables
Global variables

Linux Definitions and reference variables

Defining variables
Variable name = value (default is character type)
Requirements for variable names:
* Can be a number, a letter, an underscore, but cannot start with a number
* Variable names are strictly case sensitive
Reference variable
${variable Name}

Note: If the variable is immediately followed by another character, you must use curly braces

History-related environment variables
HISTSIZE Specifies the number of history command bars saved
Histfile save Location (default location: ~/.bash_history)
Histfilesize Specify history file can save up to History command bar number
Histcontrol specifying how historical commands are generated


Linux directory structure
/bin: Store Normal, all users can execute binary program
/sbin: Store administrator to execute binary program
/boot: Storage System boot Process boot file
/dev: This is the directory where the device files are located. Each hardware device in Linux is mapped to a file, and the mapped generated device files are stored here.
/etc: Store most of the configuration files of the system
Example: Nic configuration file:/etc/sysconfig/network-scripts/ifcfg-eth#
Host name profile:/etc/sysconfig/network
DNS configuration file:/etc/resolv.conf
/home: The location of the normal user house directory
/root:root User's home directory
/lib,/lib64: library files are stored in libraries 32 and 64 respectively
/MEDIA,/MNT: For mounting external devices
/proc,/sys These two are pseudo-file system, storage is the hardware information mapping, is not occupy disk space. The directory is empty without booting
/tmp: Temporary files directory, files in this directory, if not accessed within 30 days, then automatically delete
/usr: This is the directory where users share files, but these files are usually read-only permissions
/var: this is the directory that stores frequently changing files
System Log Location:/var/log/messges

Linux file types
Normal file
Catalog files
Link file
Device files

Pipeline files
Socket file

Command aliases
Alias
Role: Set an alias for the command to see the aliases that have been set
Formatting: alias alias = ' command option parameter ' (alias can be the same as original name)
The intent of using the command
# \ Command Alias

Format for canceling command aliases: Unalias aliases

basename command
Function: Displays the base name of the file
Format: Basename/path/to/file
DirName command
Function: Displays the full name of the path where the file is located
Format: Dirname/path/to/file
Cat command
Role: Connect multiple files and display to desktop
Format: Cat [Options] file1 [file2 ....]
Options:
-N: Show line numbers
-E: Display line terminator
-S: Displays a contiguous number of blank lines as a

TAC command
With Cat

More commands
Function: Suitable for larger files, can realize split screen view
Use:
Enter: Next line
Spaces: Next Page
Shift+pagedown: Next Page
Shift+pageup: Prev
Q: Exit more mode

Less command
With more

Head command
Function: Displays the first few lines of a file (10 rows by default)
Format: Head option file name
Option:-N #: can be implemented to display only the specified row

Tail command
Function: Displays the last few lines of a file
Format: tail [options] FILENAME
Option:-N #: can be implemented to display only the specified row

echo Command
Function: Print output
Format: Echo [Options] "string, variable ...."
Options:
-E: Make special characters effective
-N: No line break after output is complete

Special characters
\ n: Line break
\ t: Horizontal tab
\v: Vertical tab
\b: Backspace

Font, Color control
"\033[xxm string \033[xm"

XXM can include three types of content
1. Background color
4xm
41m Red
42m Green
44m Blue
2. Font Color
3xm
31m Red
32m Green
34m Blue
3. Font format
Xm
5m blinking
4m underline
1m Bold

(If you want to modify multiple properties at the same time, use semicolons to split)

CP command
Role: Copying Files and directories
Format:
The CP option copies the destination address of the copied source address to a single file for replication

Note: Permissions to copy past files do not copy the source file
1, if the target exists, and is a directory, will be the original successful copy to the target, and the file name is unchanged
2, if the target does not exist, the original file will be copied and renamed to the target name
The important thought of ps:linux, all documents
Options:
-F: Forced execution
-I: In case of overwrite, require user to enter Y in order to overwrite operation (the system default is already set alias Cp=cp-i)
-r: This option must be used when copying a directory
-V: Displays replication process information
-A: Keep the properties of the file unchanged during the copy process
-D: When copying a linked file, simply copy the connection without copying the file that the connection points to
-L: Copy the actual file that the connection file points to

Soft links
Similar to Windows shortcuts
Implementation mode: Ln-s source DEST
Attention
1. Soft link color is light blue
2. If flashing, this is a damaged soft connection
MV Command
With CP

File wildcard characters in Linux
*: Any character (numbers, letters, special symbols) that match any length (0\1\n)
?: matches any single character
[]: Represents a single character within a range
The way letters are expressed
[A-z] matches lowercase letters
[A-z] matches uppercase letters
[0-9] Matching numbers
[0-9a-za-z]
Character set representation (common)
[[: Space:]] Match space
[[: Lower:]] Match lowercase
[[: Upper:]] Match uppercase
[[:d Igit:]] matches decimals
[^]: matches a single character outside the range


Author: Xiaoxiang Rain Wrong

Simple commands in Linux

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.