Notes for common Linux commands

Source: Internet
Author: User
Tags inode usage

Notes for common Linux commands

This is a frequently used command note when I was a beginner in Linux. I deleted some notes based on my current familiarity. I also used backups to check the notes. I hope you can make reference to the useful ones.

// Output the used content to the screen and only check the syntax
Sh-nx scripts. sh

// Output all current set values
Echo $-

// List the last n commands
History-n
// Write data by default ~ /. Bash_history
History-raw histfiles

// Ignore blank rows-case differences
// To-file can be replaced by '-', which is a standard input.
Diff-bBi from-file to-file

// List all bitwise differences
Cmp-l from-file to-file

// Existence
Test-e filename
// Whether the file exists
Test-f filename
// Whether or not it exists and is (first letter): directory, block device, character device, Socket, pipe, Link
// Existence and permission: r, w, x, u, g, k (Sticky bit), s (not empty)

// Whether file1 is newer or older than file2
Test file1-nt/ot file2
// Whether the file is the same and whether it points to the same iNode to determine the hard link
Test file1-ef file2

// Define the variable type as array, integer, envirnment, readonly
Declare-aixr variable

// Set the prompt and wait description
Read-p "This is hint"-t 30 variable

// Display path without Parameters
// Display as file, alias, builtin
Type-t name

// Convert the text format
Iconv-f frommap-t tomap filename [-o newfile]

// The interval is 1 second. The filtered content is highlighted.
Watch-n 1-d 'pstree | grep sys'

// Find a specific process
Ps-ef | grep xxx
// Observe all processes of the system
Ps aux
// Tree display
Ps axjf

// Count the following parts of the directory (including the current directory)
Ls-l | wc-l

// Copy data locally to the server and use the-r recursive directory
Scp local_file remote_username @ remote_ip: remote_folder/file

// Display processes that only use TCP and are in the listening status
Ss-tpl
// Display the Socket Overview
Ss-s

// Display the processes in the listening status using TCP
Netstat-apt
// Display the NIC list
Netstat-I
// Display route table information
Netstat-r
// Display the network Overview
Netstat-s

// The interval is 2 seconds. The TTL is 255. ping 10 times to a gateway.
Ping-c 10-I 2-t 255-B 8.8.8.8

// List the files whose users are root and whose processes are mysql and whose files are TCP
Lsof-u root-c mysql-I tcp

// Display disk statistics
Vmstat-d
// Display memory statistics
Vmstat-s

// Stop the system service and restart it;-h indicates shutdown;-c cancels the command content;
Shutdown-r
// Halt: shutdown, poweroff: shutdown, reboot: restart, suspend: Sleep
Systemctl reboot

// Display the man page of a command at random
Man $ (ls/bin | shuf | head-1)

// Display inode usage of the file system in a more readable manner
Df-hi

// Display the sum of multiple files in a more readable manner
Du-sh text.txt text2.txt

// Make the time stamp of test1.txtthe same as that of test2.txt
Touch-c test1.txt test2.txt

// Forced, interactive. If this parameter is set, the link file and file attributes are copied.
Cp-pdfi from_file to_file

// Use ASCII, decimal, floating point, octal, and hexadecimal to output text
Od [-cdfox] file_name
// Read the records of the last 10 rows
Tail-n 10 file_name
// Output content except the last 10 rows
Head-n-10 file_name
// Output two rows at a time starting from row 3
More + 3-2 file_name
// Display percentage, row number
Less-mN file_name
// Display all row numbers, merge empty rows, and display TAB
Cat-nsT file_name

// A: When A file (or directory) is accessed, the access time atime will not be modified.
// S: if any modification is made, it will be "synchronized" to the disk
// A: Only content can be added and cannot be deleted or modified.
// C: automatic compression
// D: it will not be backed up by dump
// I: cannot be deleted, renamed, or set link
// S: removed from the disk after deletion
// U: the disk is retained after deletion.
Chattr [+-=] [ASacdistu] file_name


// Search
Whereis file_name
// Ignore case sensitivity and output the first five
Locate-il 5 file_name
// Many parameters: Time-type group permission size
// Search for large files
Find.-type f-size + 800 M-print0 | xargs-0 du-mh | sort-nr
// Search for large Directories
Du-hm -- max-depth = 2 | sort-nr | head-5
Find-name t *. txt
// Find the command location in PATH
Which exc_name

// Compression: For * .tar.gz
Tar-zcvf file_name
// Extract
Tar-zxvf file_name
// View included content
Tar-ztvf file_name

// Create a file-Backup
Dd if = "input_file" of = "output_file" bs = "block_size" count = "number"

This article permanently updates the link address:

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.