First, the basic format of the command
[[Email protected]~]
Root is the user name
~ Indicates the current location
LocalHost host name
' # ' Super User
' $ ' for ordinary users
Basic format of the command:
command [options] [parameters]
Second, the contents of the query directory
Command format:
ls [选项][文件或目录]
Options:
-A All Files
-L View Details
-D View Directory properties
-H Show File size
Third, File Processing command
1. Create a Directory
mkdir -p [目录名]
-P Expression Recursive folder
Example:
mkdir japanmkdir -p japan/cangjk
2. Switch directories
[目录]
Simplified operation:
Cd~ entering the current user directory
cd-Last Directory
CD: Go to the top level directory
PWD see where the current directory is located
3. Deleting a directory
[目录]
Delete all Files
[目录]
Delete directory All files
4. Copying a directory
cp[选项][原文件目录][目标目录]
Options:
-R Copy Directory
-p even copy file attributes together
-A equals-pdr
5. Cut, rename
mv[原文件目录][目标文件目录]
6. Common Directory Role
/root directory
/bin Command Save Directory
/boot Directory
/dev Device File command
/etc configuration File Save Directory
Home Directory
/lib System Library Save command
/MNT System Mount Directory
Third, File Search command
1.locate
[文件名]
To find files in the system database
New file, to perform the updatedb operation before searching
2. Command Search
whereis [选项] [命令名]或者which [选项][命令名]
Options:
-B Find only executable files
-M only find help files
3. File Search
find [搜索范围][选项][条件]
To give an example directly:
find / -name install.log 在根目录下查找名为install.log文件
find /root -inname install.log忽略大小写查找文件
find /var/log -mtime +10其中-mtime 文件修改时间-atime 文件访问时间-ctime 改变文件属性时间+10 10天前10 10天-10 10天内
find /etc -size +20M查找文件大于20M的文件
Iv. Compression and Decompression commands
Common compression formats:. zip,. gz,. bz2,
. tar.gz,. tar.bz2
1.zip format
//压缩文件zip [压缩文件名][原文件]//压缩目录zip -r [压缩文件名][原文件]
Example:
jp/canglstouch jp/longlszip -r jp.zip jp
#解压:unzip [压缩文件名]
- GZ format
# 压缩为gz格式,原文件不保留gzip [原文件]#压缩.gz格式,原文件保留gzip -c 原文件 > 压缩文件# 压缩目录:gzip -r 目录
Extract:
[文件]guzip -r [目录]
3.tar
# 打包tar -cvf 打包文件名 原文件# 解压tar -xvf jp.tar
4.tar.gz
#打包tar -zcvf 压缩包名.tar.gz 原文件#解压tar -zxvf 压缩包名.tar.gz
V. Shutdown and restart
shutdown [选项][时间]#选项:-c 取消前一个关机命令-h 关机-r 重启init 6重启init 0关机logout退出登陆
Vi. Viewing user information
wwholastlastlog
Vii. Shell Basics
1. What is a shell
The shell is the command-line interpreter.
2.echo Output command
echo[选项][输出内容]
Options:
-E: Support escaping
3. Create a script
Create hello.sh
Vim hello.sh
Go to edit:
#!/bin/bash# the first programecho "hello world!"
Perform:
chmod 755 hello.sh./hello.sh
Or:
bash hello.sh
Viii. Order of History
history 查看历史命令history [选项][历史保存文件]选项:-c清空历史-w把缓存中的历史写入历史命令保存文件
Ix. output Redirection
命令>文件 以覆盖的方式,把正确的命令输出到指定文件命令>>文件 2> 文件 以覆盖的方式把错误的命令覆盖到指定文件错误命令 2>> 文件 以追击的方式把错误的命令覆盖到指定文件 命令>>文件 2>&1 同时追加正确命令和错误命令到 指定文件命令 >>文件1 2>>文件2 把正确的命令输出到文件1错误的文件2
As an example:
#/bin/bashwhile commanddocurl -d "userid=123343,action=getuserinfo" https://app.testasss.com.cn/ >test.txttime=$(date)cat=$(cat test.txt |cut -d \: -f 3|cut -d \" -f 2)echo "$time $cat" >>test.logsleep 15sdone
Ten, network-related
1.ifconfig View IP
As an example:
ifconfig>> ip.logcat ip.log
2. View network status
[选项]
Options:
-T: List TCP protocol ports
-U: List UPD protocol ports
-N IP Address port number
-L lists the listening status of the
-A All
3. View the Routing list
netstat -rn或者route -n
4. View the network status of a domain name and your computer
ping www.baodu.com
Xi. VI Editor
The upgraded version of VI is VIM
Operation Mode of 1.vim
mode 命令模式inser tmode 编辑模式lastline mode 底行模式
2. Mode switch
I enter edit mode
ESC enters command line mode
3. Command mode
[文件] 进入文件或者创建文件(文件不存在的情况下)vim + [文件名] 进入文件尾部vim +/[字符串] [文件名] 光标定位到文件第一次出现该字符串的位置
4. Bottom-line mode
:w 保存:q 退出:! 强制:15 定位的第15行/[字符串] 光标位置向后搜索该字符串?[字符串] 光标位置向前搜索该字符串dd 删除光标所在行ctr+f 向下翻页ctr+b 向上翻页
12, common operation shortcut keys
ctr+c 终止当前命令ctr+l 清屏 clearctr+a 光标移到行首ctr+e 光标移到行尾ctr+u 把光标所在位置删除到行首ctr+z 把命令放入后台ctr+r 在历史命令中搜索
13. Other
Common tools:
Vmware 虚拟机centos.iso centos系统镜像 ,绝大多数服务器是这个系统SecureCRT copy文件工具
Common command articles for Linux basics