Simple Help for Command--help command
man = = Command Help
Help for command (bash built-in commands)
ls = = view directory List-L (long)-D (directory)
mkdir = = Make directory function is to create a directory, for example: Mkdir/data-p recursively create a directory
cd = = Change Directory action switch path, for example: CD/
Touch = = Creates a file, for example: Touch oldboy.txt
VI = = Editor, equivalent to Notepad, with edit function, single weak
Vim = = Complex Editor
Echo is a common command to print out content, with "> or >>" to overwrite and append to the file. The ">" redirect will erase the data in the file, and ">>" is appended to the content.
Cat = = View File contents
Special Usage: Add content
Cat > Oldboy.txt <<eof
I am studying Linux
Eof
EOF is to be paired, and EOF can be replaced by any pair of content.
CP = = copy copy command copy directory with CP-A or cp-r
-R: Recursive, for copying directories;-P hold properties.
-A: equivalent to-PDR
cp = ' Cp-i '-I Confirmation
MV = = Move directory or file, for example: mv/data/root/
PWD = = View the path of the current user
RM = = Delete file or directory-F please know-r Delete directory
Production scenario try not to use RM, if not to use, must first CP and other backup
Alternative methods:
MV moves to a temporary directory. Recycle Bin.
Find Delete find/home/abelxu/data/-type f-exec rm-f {} \;
find/home/abelxu/data/-type F | Xargs rm-f
Delete all files under one directory, but one file does not delete: find/home/abelxu/data/-type f! -name "Oldgril.txt" | Xargs rm-f
find/home/abelxu/data/-type F! -name "Oldgril.txt"-exec rm-f {} \;
Head = = Fetch the first n rows of the file, default to the first 10 rows, take the first 3 rows-N 3
Tail = = takes the last n rows of the file, defaults to the last 10 rows, takes the last 3 rows-n 3-f tracks the real-time changes of a file's tail
grep = = filter, separating the desired or unwanted. -V Exclusion
-B In addition to displaying a row of matching rows and displaying the num rows before the row
-a displays the num rows after the row, except for a row that matches the row
-c Displays the num rows before and after the line, except for a row that matches the row
sed = = (Stream editor) filter: Sed-n '/filtered contents/processed commands ' file
-N cancels the default output
-I change file contents
Commands processed: P Print Printing
D Delete Delete
Example: Sed-n '/oldboy/p ' test.txt
Sed '/oldboy/d ' test.txt
SED replacement
Sed-i ' S#boy#gril#g ' test.txt
s find and replace
When G Global is used in conjunction with S, replace all
"#" is the delimiter
awk A language, filtering content (fetching columns)
Awk-f "delimiter" ' {print $} ' file <== the first column, the second column ... $NF the last column, $ (NF-1)
NR representative Line number
Full line
Example:
Awk-f ":" ' {print $ ' "$/etc/passwd} '
Yum = Linux Package Manager, Yum helps resolve dependency issues
RPM-IVH (installation, display output, human readable display)
Example: RPM-IVH package name. rpm
Yum Install tree nmap sysstat Lrzsz doc2unix-y
Package download down RPM format RPM-IVH package name
source code./configure; Make Make install
Yum Install updates the latest version of all software
Tree displays the directory tree structure-L layer-D directory
Alias view and define aliases
Example: Alias oldboy= ' echo ' I am Oldboy "'
Alias rm= ' echo ' RM can not is used, pls use MV "'
Where aliases are valid: for the root User:/ROOT/.BASHRC
All users are in effect:/ETX/BASHR or/etc/profile definition
Effective Source/etc/profiles
Unalias Canceling aliases
Seq Sequence-s Specifies the delimiter of the sequence-W
Usage: seq [options] ... Tail
Or: seq [options] ... First Count Mantissa
Or: seq [options] ... First number increment Mantissa
History of Print user action- C clears all records-D clears the specified record
Hostname Viewing host names
Uname Print System Information-r core-M or 64bit-n hostname-a View all
WHOAMI View Current User
Su User role switch Su-user name-parameter switch User environment variable
Getenforce Checking selinux status
Setenforce setting SELinux Status 1 Enable 0 warning not enabled
RunLevel viewing run Levels
init switches the runtime, followed by the corresponding level of the number
Shortcut keys:
TAB command, PATH completion
CTRL + a switch to the command line start
Ctrl+e switch to the end of the command line
Ctrl+l Clear Screen Contents
Ctrl+u clear the content before the cut cursor
Ctrl+k clear the contents after the cut cursor
Special character Commands:
> or 1> redirection, covering
>> or 1>> chasing heavier orientation,
< or <0 input redirect
<< or <<0 Append input redirection
2> Error Redirection
2>> Error Append redirect
The direction of the arrows is the flow of data
\ Let a meaningful character, take off the vest.
.. Parent Directory
. Current directory \. Represents a point number.
| Pipeline
~ User's home directory, for root ~ for/root
{}
!...
Standard input (stdin): code 0, using < or << data flow from right to left
Standard normal output (STDOUT): Code 1, using > or >> Data flow from left to right
Standard error Output (STDERR): Code 2, using 2> or 2>>
View the default file descriptor maximum value Ulimit-n
View process: Ps-ef
View Port: Netstat-lntup
View the configured Ip:ifconfig or IP add
Shut down firewall:/etc/init.d/iptables stop
Cat/etc/redhat-release
CentOS Linux release 7.3.1611 (Core) version
Uname-r
3.10.0-514.el7.x86_64 kernel
Uname-m
X86_64 32-bit or 64-bit
hostname = = Uname-n
Localhost.localdomain Host Name
Init 6 Restart
Init 5 = = = StartX
Tar zxvf python.xx.tgz Decompression
Turn off SELinux
Solution one: sed ' s#selinux=enforcing#selinux=disabled#g '/etc/selinux/config
Getenforce
Setenforce 0
Shutting down the firewall
/etc/init.d/iptables stop
Linux directory structure:
Vertex/, all other directories are under the root
The Linux directory structure and disk partitioning are separate. Free to combine
/
├──bin-Usr/bin
├──boot
├──dev
├──etc Placing the system configuration file
├──home
├──lib-Usr/lib
├──LIB64-usr/lib64
├──media
├──mnt
├──opt
├──proc
├──root
├──run
├──sbin-Usr/sbin
├──srv
├──sys
├──tmp
├──usr
└──var
The known file Test.txt content is:
Test
Liyao
Oldboy
Please give a command that does not contain a Oldboy string when printing test.txt content
Cat >> test.txt << EOF
Test
Liyao
Oldboy
Eof
Solution One: head-2 test.txt
Solution Two: Grep-v "Oldboy" test.txt
Solution Three: Cat Test.txt | Grep-v Oldboy Test.txt
Solution four: sed '/oldboy/d ' test.txt
9. Use a command to complete the creation of the directory/oldboy/test
Mkdir-p/oldboy/test
10, the known/tmp directory already exists test.txt file, how to execute the command to the/mnt/test.txt copy to/tmp cover off/tmp/test.txt, and let the Linux system does not prompt whether to overwrite
Solution One:/bin/cp/mnt/test.txt/tmp/test.txt
Solution Two: \cp/mnt/test.txt/tmp/test.txt
11. View only the contents of lines 20th through 30th in the Ett.txt file (100 lines)
Seq > Test.txt
Solution One: head-n-test.txt | Tail-n 11
Solution two: Sed-n ' 20,30p ' test.txt
Solution Three: awk ' {if (nr<31 && nr>19) print $ ' test.txt
Solution IV: grep 30-b test.txt
13. Replace all the strings in the/oldboy directory and its subdirectories with the./hostlists.txt string in the file with the extension. Sh. /idctest_iplist
Solution One: Find/-type f-name "Test.txt" | Xargs sed-i ' s#oldboy#oldgril#g '
Solution Two: Find/-type f-name "test.txt"-exec sed-i ' s#oldboy#oldgril#g ' {} \;
echo 123456|passwd--stdin Oldboy
Changing passwords in a non-interactive manner
TIMEOUT=10: Time-out control variable for the connection
Histsize=5: Command-line History quantity variable
histfilesize=10: Number of command variables for history files (~/.bash_history)
This article is from the "Xu Big Tree" blog, please be sure to keep this source http://abelxu.blog.51cto.com/9909959/1980408
Linux Learning Notes