更改主机名
hostnamectl set-hostname lan

江达网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站开发等网站项目制作,到程序开发,运营维护。成都创新互联公司2013年开创至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司。
创建目录命令
mkdir /xue
递归创建文件夹a/b/c
mkdir -p a/b/c
递归创建a/b,c,d三个目录
mkdir -p a/{b,c,d}
查看目录命令
ls /xue
改变当前目录/位置
cd /home
cd ~
cd -
打印当前工作目录
pwd
创建文件或者修改文件时间戳
修改文件的更改时间,
ls -l
touch -y'07101530' 1.txt
stat命令
显示文件或文件系统的状态。
#用法 stat [参数] 文件
参数列表:
-L, --dereference 跟随链接
-f, --file-system 显示文件系统状态而非文件状态
-c --format=格式 使用指定输出格式代替默认值,每用一次指定格式换一新行
--printf=格式 类似 --format,但是会解释反斜杠转义符,不使用换行作
输出结尾。如果您仍希望使用换行,可以在格式中
加入"\n"
-t, --terse 使用简洁格式输出
--help 显示此帮助信息并退出
--version 显示版本信息并退出
格式化输出参数:
%a 八进制权限
%A 用可读性较好的方式输出权限
#实例1
[root@master tmp]# stat 1.txt
File: '1.txt'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 17348002 Links: 1
(权限)Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
(最近访问)Access: 2018-07-10 15:30:00.000000000 +0800
(最近更改)Modify: 2018-07-10 15:30:00.000000000 +0800
(最近改动)Change: 2018-11-07 15:38:36.400989868 +0800
Birth: -
#实例2,显示文件权限
[root@master tmp]# stat -c %a 1.txt
644
[root@master tmp]# stat -c %A 1.txt
-rw-r--r--
vim初识
vi/vim操作流程:
- vi 打开文件 此时进入命令模式,你可以输入 i 命令,进入编辑模式
- 在编辑模式下,开始输入字符串
- 写完之后, 按下 esc 回到命令模式,按下 : 进入底线命令模式
- :w 写入不退出 :wq! 写入且强制退出
方法,命令
vi
vim
使用vi打开oldboy.py,默认是命令模式,需要输入a/i进入编辑模式,然后输入文本"Life is short,i use python"
按下esc键,回到命令模式
输入 :wq! 强制保存退出
w write 写入
q quit 退出
! 强制
或者 :x 保存退出
:q 不保存退出
:q! 不保存强制退出
查看文件内容
查看文件,显示行号
cat -n xxx.py
猫,查看文件
cat xxx.py
在每一行的结尾加上$符
[root@master tmp]# cat -E 1.txt
追加文字到文件
cat >>/tmp/oldboy.txt << EOF
难难难 道德玄
不对知音不可谈
对了知音谈几句
不对知音枉费舌尖
EOF
more和less命令
more命令查看文本会以百分比形式告知已经看到了多少, 使用回车键向下读取内容
more /etc/passwd
2. less 工具也是对文件或其它输出进行分页显示的工具。less的用法比more更加有弹性。
在more的时候,我们并没有办法向前面翻,只能往后面看,但若使用了less时,就可以使用 [pageup] [pagedown] 等按键的功能来往前往后翻看文件!
less /etc/passwd
[pagedown]: 向下翻动一页
[pageup]: 向上翻动一页
Linux快捷键
1.tab键 用于自动补全命令/文件名/目录名
2.ctrl + l 清理终端显示
3.clear/cls 清理终端显示
4.ctrl + c 终止当前操作
特殊符号
输入/输出 重定向符号
1.>> 追加重定向,把文字追加到文件的结尾
2.> 重定向符号,清空原文件所有内容,然后把文字覆盖到文件末尾
3.< 输入重定向
4.<< 将输入结果输入重定向
复制命令
Linux下面很多命令,一般没有办法直接处理文件夹,因此需要加上(参数)
cp -r 递归,复制目录以及目录的子孙后代
cp -p 复制文件,同时保持文件属性不变
cp -a 相当于-pdr, 类似与Windows系统的复制快捷方式
移动命令
cd /opt
mv ./aa /tmp/pp
文件/文件夹改名
mv a.txt b.txt
删除命令
查找命令
Linux里如何找到需要的文件 例如 oldboy.py
find 在哪里(目录) 什么类型(文件类型) 叫什么名字(文件名)
参数
-name 按照文件名查找文件
-type 查找某一类型的文件,诸如:
b - 块设备文件。
d - 目录。
c - 字符设备文件。
p - 管道文件。
l - 符号链接文件。
f - 普通文件。
s - socket文件
别名命令(alias)
Linux如何提示你,在使用这些命令时候,提醒你小心呢?
#查看系统别名
alias
默认别名
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
别名作用是:
我们在linux中使用cp时候相当于执行了cp -i
-i:删除已有文件或目录之前先询问用户;
为rm设置别名
让系统显示 do not use rm
echo do not use rm
设置rm别名
alias rm='echo do not use rm'
设置别名永久生效,写入到/etc/profile(针对登录用户的合同,设置环境变量)
vim /etc/profile #编辑文件
G 快速到达最后一行
o 当前行下一行,创建一个新行,进入编辑模式
source /etc/profile #读取文件(合同生效)
取消别名
unalias rm
管道命令
Linux提供的管道符“|”讲两条命令隔开,管道符左边命令的输出会作为管道符右边命令的输入。
常见用法:
检查python程序是否启动
ps -ef|grep "python"
将ps -ef的结果输出到文件中
ps -ef > /opt/ps.txt
找到/tmp目录下所有txt文件
ls /tmp|grep '.txt'
检查mariadb的端口是否存活
netstat -tunlp |grep mariadb
grep命令
语法:
grep [参数] [--color=auto] [字符串] filename
参数详解:
-i : 忽略大小写
-n : 输出行号
-v : 反向选择
--color = auto : 给关键词部分添加颜色
grep "我要找什么" /tmp/a.txt
排除 -v,排除我要找的东西
grep -v "我要找什么 /tmp/a.txt
head和tail命令
head显示文件前几行,默认前10行
tail显示文件后几行,默认后10行
#查看前五行
head -5 /tmp/a.txt
#查看后五行
tail -5 /tmp/a.txt
#持续刷新显示
tail -f a.log
#显示文件10-30行
head -30 /tmp/a.txt |tail -21
sed命令
sed
sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。
命令格式
sed [options] 'command' file(s)
sed [options] -f scriptfile file(s)
选项
-e
基本
文件
流程
错误
SQL
调试
- 请求信息 : 2026-05-21 22:52:06 HTTP/1.1 GET : /article/ggedeh.html
- 运行时间 : 2.2752s ( Load:0.0065s Init:1.6121s Exec:0.6471s Template:0.0096s )
- 吞吐率 : 0.44req/s
- 内存开销 : 2,260.27 kb
- 查询信息 : 12 queries 5 writes
- 文件加载 : 36
- 缓存信息 : 0 gets 0 writes
- 配置加载 : 130
- 会话信息 : SESSION_ID=qbhspb9vh43s0p8smsueu5c8n2
- /www/wwwroot/tsicrk.com/index.php ( 1.09 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/ThinkPHP.php ( 4.61 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Mode/common.php ( 2.82 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Common/functions.php ( 53.56 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/App.class.php ( 13.49 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/View.class.php ( 7.59 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Conf/convention.php ( 11.15 KB )
- /www/wwwroot/tsicrk.com/App/Common/Conf/config.php ( 2.14 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Lang/zh-cn.php ( 2.55 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Conf/debug.php ( 1.49 KB )
- /www/wwwroot/tsicrk.com/App/Home/Conf/config.php ( 0.31 KB )
- /www/wwwroot/tsicrk.com/App/Home/Common/function.php ( 3.33 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB )
- /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php ( 6.02 KB )
- /www/wwwroot/tsicrk.com/App/Home/Controller/CommController.class.php ( 1.60 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB )
- /www/wwwroot/tsicrk.com/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 17.71 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB )
- /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
- [ app_init ] --START--
- Run Behavior\BuildLiteBehavior [ RunTime:0.000006s ]
- [ app_init ] --END-- [ RunTime:0.000032s ]
- [ app_begin ] --START--
- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000292s ]
- [ app_begin ] --END-- [ RunTime:0.000312s ]
- [ view_parse ] --START--
- [ template_filter ] --START--
- Run Behavior\ContentReplaceBehavior [ RunTime:0.000070s ]
- [ template_filter ] --END-- [ RunTime:0.000100s ]
- Run Behavior\ParseTemplateBehavior [ RunTime:0.006615s ]
- [ view_parse ] --END-- [ RunTime:0.006646s ]
- [ view_filter ] --START--
- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000169s ]
- [ view_filter ] --END-- [ RunTime:0.000184s ]
- [ app_end ] --START--
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= )
- [8] Undefined index: pid /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php 第 47 行.
- [8] Undefined index: db_host /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 120 行.
- [8] Undefined index: db_port /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 121 行.
- [8] Undefined index: db_name /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 122 行.

2.2752s
