Linux section commands simple usage introduction-ssh, SCP, less, tail, find, grep (continuous add)

Source: Internet
Author: User
Tags file copy glob save file

Ssh

An encrypted network protocol that provides a customer-service model.

Login
SSH [email protected]
SSH IP #不提供用户名是默认使用当前用户的用户名
-C Option: Data is compressed during transmission
-p+ Port number: Specify port number (default port number 22)
-V Option: Debug mode
-f+ file path: Using the specified configuration file

Reference: https://linux.cn/article-2933-1.html

Scp

The same as CP for File replication, but is mainly used between different Linux systems. File copy with security, SSH-based login
CP [OPTIONS] File_source File_target
-R option: Source has directory, recursive replication
-F option: Force, overwrite directory with same name
SCP [OPTIONS] File_source File_target
-V option: Display status
-C option: Use compression
-P option: Select Port
Example:
From local to remote scp/file/from.txt [email protected]:/file/to.txt
From remote to local SCP [email protected]/file/from.txt/file/to.txt

Less
As with more to view the contents of the file, but the function is more powerful. Supports front and rear page and front and back lookups. And less does not load the entire file until it is viewed, and the maximum file processing is faster.
Less [OPTIONS] File
-b < buffer size;: Set buffer
-E: End auto Leave
-F: Forcing special files, devices, directories and binaries to be opened
-I: ignoring case when searching
-N: Displays the line number of each line
Commands that you can use when you open
/<word>: Search Forward
N: Next
N: Previous
? <word>: Search Backwards
J: Line Down
K: Up one line
G: to the last line
G: to the first line
U: up one page
D: one PAGE Down
V: Enter edit mode

Tail
Displays the end content of the specified file.
tail [OPTIONS] File
-F Loop Read
-Q does not display processing information
-N: Displays the number of rows
--pid=pid is combined with-F to end the process with process ID PID
-S: Shared with-F, which indicates the number of seconds to sleep in each repetition interval

Find
Find files in the specified directory according to the specified rules
Find [dir dir ...] [OPTIONS] [-exec command {} \;]
-name < filename >: The name of the file to find, you can use the Glob rule
Glob: ' * ' wildcard any character
'? ' wildcard any one character
' [ABC] ' wildcard any one of the characters in parentheses
' [a-c1-9] ' wildcard any one character within the range of characters in parentheses
-atime n|-n|+n: Last access time equals n| less than n| greater than n
-mtime n|-n|+n: Last Modified content time
-ctime n|-n|+n: Last modified attribute time (i.e. I node information modification time)
-type: Search by file type
F: Normal file
D: Catalogue
L: Link
B: Block device files
C: Character device
P: Piping
S:socket file
-size 2m|+2m|-2m: Find files by size (size is 2m| greater than 2m| less than 2M)

[EXEC command {} \;] : Perform an action on the find result, command is the action to be performed, {} placeholder, can be understood as the result of find put here, \; Is the end flag, \ There is a space before
You can also use Xargs or ' implement
Find [] [] [EXEC command {} \;]
Find [] [] | Xargs command
Command ' Find [] [] '

Grep
grep (Global search Regular expression (RE) and print out of the line, full search of regular expressions and print out rows) is a powerful text search tool that uses regular expressions to search for text. and print out the matching lines.
grep [OPTIONS] str_to_search filename
-A: Find the binary file in the form of a text file
-C: Outputs the number of rows matching rows
-I: Ignore case
-N: Output line number at output
-V: Reverse selection, output no matching rows
Str_to_search can use regular expressions (the glob mentioned above is a simplified regular)
[^ABC]: Reverse selection, cannot be a,b,c
[ABC]: one of ABC
[A-z1-9]: one in A-Z and 1-9
^: Beginning of the line
$: End of line
. : any one character
*: Any number of characters, including 0
{}: Limit the number of repetitions, ' {', '} ' two symbols have a special meaning in the shell, so use ' \ ' to make them lose their special meaning
O\{2\}: o repeat two times
O\{2,5\}: O repeat two to five times
o\{2,\}: o repeat more than two times

Reference: http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html

Curl
Use URL syntax to complete file transfers under the command line.
Curl [OPTIONS] url
-O [file_name]: Save file to file_name
-O: Save files by file name in URL
-L: Forced redirection
-C: Breakpoint continued to pass
-U username:password: Provide user name password
-V: View all work process outputs
--data-urlencode "" | @filename: Using the Post method
Example:
Get FTP Server files
Curl-o ftp://ftp_server/xxx.php
Uploading files to an FTP server
CURL-T MyFile.txt ftp://ftp.server.com
Reference: http://www.cnblogs.com/gbyukg/p/3326825.html

Strace
Tracks system calls and received signals when the process executes.
-C: Counts the execution time, number of times, and number of errors for each system call
-F: Tracks child processes produced by fork calls
-FF: If you provide-o filename, the trace results for all process pairs are output to the corresponding filename.pid, and the PID is the process number of each process
-F: Trace Vfork call
-P [PID]: Tracking Process PID
-E: Use this parameter to customize the tracking
REACE=OPEN,CLOSE: Tracking only specified system calls
Trace=file: Trace only file-related system calls
Trace=process: Trace only Process Control related system calls
TRACE=NETWORK: Tracking only network-related system calls
Trace=signal: Only trace system signal related system calls
... There are some now.

Ulimit
Linux system built-in functionality to set limits on the use of resources with the shell process and its child processes that it generates, including the size of the kernel file created, the size of the process data block, the size of the shell process creation file, the memory lock size, the size of the resident memory set, the number of open file descriptors, The maximum size of the allocation stack, the CPU time, and the maximum virtual memory that a single user can use.
* * (SCOPE) Ulimit restricts the current shell process and its child processes, so you can use Shell configuration files for the appropriate shell
Ulimit [OPTIONS] [limit]
-A: Displays all current limit information
-C: Set maximum core file size, unit blocks (512B)
-D: Process maximum data segment size, unit blocks
-F: Process can create maximum file value, unit blocks
-L: Maximum lockable memory size, in kilobytes
-M: Maximum memory size
-N: Maximum file descriptor that can be opened
-P: Pipe buffer size, in kilobytes
-S: Thread stack size, per kb
-T: Maximum CPU time in seconds
-U: Maximum number of user processes available
-V: Process maximum available virtual memory, in kilobytes
Cases:
No restrictions on core file size
Ulimit-c Unlimited
Reference: http://blog.csdn.net/wanghai__/article/details/6332540

Core Dump
Role: A way to diagnose and debug program errors. When the program runs abnormally terminated or crashed, the operating system saves the program's memory status, register information (program pointers, stack pointers), memory management information, and operating system state information to a file, which is called core Dump. With Ulimit-c you can see the maximum size of the core file that is allowed to be saved by the current terminal, and if it is zero, the core file will not be output. You can change from Ulimit-c Unlimited to no size setting or directly to a value.
Use: The core file can be viewed through GDB
1. Compile the program using the GCC-G parameter to generate debug information
2. Run the program, crash will default in the execution file directory to generate core files
3. Use GDB./exefielname corefilename to view the core file
Reference: http://www.cnblogs.com/hazir/p/linxu_core_dump.html

Linux section commands simple usage introduction-ssh, SCP, less, tail, find, grep (continuous add)

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.