数据仓库001 - 复习Linux shell命令 - pwd mkdir mv tail -f xxx.log 和 ail -F xxx.log
1. [root@localhost ~]# 的含义 ?
【登录的用户 机器的名称 家目录】
2. 查看当前光标所在的目录 pwd
[root@localhost ~]# pwd
/root
3. 切换目录 cd
[root@localhost ~]# cd /home
[root@localhost home]# pwd
/home
root用户 家目录 /root 规定
xxx用户 家目录 /home/xxx 默认
回退家目录 的三种方法:
[root@localhost home]# cd -
/root
[root@localhost ~]# cd /home
[root@localhost home]# cd ~
[root@localhost ~]# cd /home
[root@localhost home]# cd /root
[root@localhost ~]#
cd ../ 回退上一层目录
cd ../../ 回退上2层目录
[root@localhost ~]# cd /home/linux/
[root@localhost linux]# pwd
/home/linux
[root@localhost linux]# cd ../
[root@localhost home]# pwd
/home
[root@localhost home]# cd /home/linux
[root@localhost linux]# pwd
/home/linux
[root@localhost linux]# cd ../../
[root@localhost /]# pwd
/
[root@localhost /]#
4.目录 文件夹 路径
·绝对路径 /根目录 以根目录
·相对路径 不以根目录为开始,以当前光标所在的目录为开始
5.clear 清空屏幕
6.ls查看当前光标所在的目录下,文件和文件夹都有哪些
其中ls 、ll的区别,其中ll 就是ls -l:
[root@localhost /]# ls
bin dev home lost+found misc net proc sbin srv tftpboot usr
boot etc lib media mnt opt root selinux sys tmp var
[root@localhost /]# ll
总计
drwxr-xr-x root root - : bin
drwxr-xr-x root root - : boot
drwxr-xr-x root root - : dev
drwxr-xr-x root root - : etc
drwxr-xr-x root root - : home
drwxr-xr-x root root - : lib
drwx------ root root - : lost+found
drwxr-xr-x root root - : media
drwxr-xr-x root root - : misc
drwxr-xr-x root root - : mnt
drwxr-xr-x root root - : net
drwxr-xr-x root root -- opt
dr-xr-xr-x root root - : proc
drwxr-x--- root root - : root
drwxr-xr-x root root - : sbin
drwxr-xr-x root root - : selinux
drwxr-xr-x root root -- srv
drwxr-xr-x root root - : sys
drwxr-xr-x root root - : tftpboot
drwxrwxrwt root root - : tmp
drwxr-xr-x root root - : usr
drwxr-xr-x root root - : var
[root@localhost /]#
小结:
ls -l ==> 等价于ll
ls -l -a 查看当前的文件文件夹+ 隐藏文件文件夹 以.开头
ll -h 文件的大小
ll -rt 按时间排序
ls
ls -l
ls -a
ls -l -a ==> ls -la
实例:
[root@localhost /]# cd /home/linux/
[root@localhost linux]# ls
Desktop file1.txt file2.txt ml
[root@localhost linux]# ls -l
总计
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]# ls -a
. .eggcups .gstreamer-0.10 .redhat
.. .emacs .gtkrc-1.2-gnome2 .scim
.bash_history file1.txt .ICEauthority .ssh
.bash_logout file2.txt .kde .Trash
.bash_profile .gconf .metacity .viminfo
.bashrc .gconfd ml .xsession-errors
.chewing .gnome .mozilla .zshrc
Desktop .gnome2 .nautilus
.dmrc .gnome2_private .recently-used.xbel
[root@localhost linux]# ls -l -a
总计
drwx------ linux linux - : .
drwxr-xr-x root root - : ..
-rw------- linux linux - : .bash_history
-rw-r--r-- linux linux -- .bash_logout
-rw-r--r-- linux linux -- .bash_profile
-rw-r--r-- linux linux -- .bashrc
drwx------ linux linux - : .chewing
drwxr-xr-x linux linux - : Desktop
-rw------- linux linux - : .dmrc
drwxr-x--- linux linux - : .eggcups
-rw-r--r-- linux linux -- .emacs
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwx------ linux linux - : .gconf
drwx------ linux linux - : .gconfd
drwxrwxr-x linux linux - : .gnome
drwx------ linux linux - : .gnome2
drwx------ linux linux - : .gnome2_private
drwxrwxr-x linux linux - : .gstreamer-0.10
-rw-r--r-- linux linux - : .gtkrc-1.2-gnome2
-rw------- linux linux - : .ICEauthority
drwxr-xr-x linux linux - : .kde
drwx------ linux linux - : .metacity
drwxrwxr-x linux linux - : ml
drwxr-xr-x linux linux - : .mozilla
drwxr-xr-x linux linux - : .nautilus
-rw-rw-r-- linux linux - : .recently-used.xbel
drwxrwxr-x linux linux - : .redhat
drwx------ linux linux - : .scim
drwx------ linux linux - : .ssh
drwx------ linux linux - : .Trash
-rw------- linux linux - : .viminfo
-rw-r--r-- linux linux - : .xsession-errors
-rw-r--r-- linux linux -- .zshrc
[root@localhost linux]# ls -la
总计
drwx------ linux linux - : .
drwxr-xr-x root root - : ..
-rw------- linux linux - : .bash_history
-rw-r--r-- linux linux -- .bash_logout
-rw-r--r-- linux linux -- .bash_profile
-rw-r--r-- linux linux -- .bashrc
drwx------ linux linux - : .chewing
drwxr-xr-x linux linux - : Desktop
-rw------- linux linux - : .dmrc
drwxr-x--- linux linux - : .eggcups
-rw-r--r-- linux linux -- .emacs
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwx------ linux linux - : .gconf
drwx------ linux linux - : .gconfd
drwxrwxr-x linux linux - : .gnome
drwx------ linux linux - : .gnome2
drwx------ linux linux - : .gnome2_private
drwxrwxr-x linux linux - : .gstreamer-0.10
-rw-r--r-- linux linux - : .gtkrc-1.2-gnome2
-rw------- linux linux - : .ICEauthority
drwxr-xr-x linux linux - : .kde
drwx------ linux linux - : .metacity
drwxrwxr-x linux linux - : ml
drwxr-xr-x linux linux - : .mozilla
drwxr-xr-x linux linux - : .nautilus
-rw-rw-r-- linux linux - : .recently-used.xbel
drwxrwxr-x linux linux - : .redhat
drwx------ linux linux - : .scim
drwx------ linux linux - : .ssh
drwx------ linux linux - : .Trash
-rw------- linux linux - : .viminfo
-rw-r--r-- linux linux - : .xsession-errors
-rw-r--r-- linux linux -- .zshrc
[root@localhost linux]#
7.查询命令帮助 ls --help
[root@localhost linux]# ls --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort. 长选项必须用的参数在使用短选项时也是必须的。
-a, --all 不隐藏任何以 . 字符开始的项目
-A, --almost-all 列出除了 . 及 .. 以外的任何项目
--author 和 -l 同时使用时列出每个文件的作者
-b, --escape 以八进制溢出序列表示不可打印的字符
--block-size=大小 块以指定<大小>的字节为单位
-B, --ignore-backups 不列出任何以 ~ 字符结束的项目
-c 配合 -lt:根据 ctime 排序及显示 ctime (文件
状态最后更改的时间)
配合 -l:显示 ctime 但根据名称排序
否则:根据 ctime 排序
-C list entries by columns
--color[=WHEN] control whether color is used to distinguish file
types. WHEN may be `never', `always', or `auto'
-d, --directory list directory entries instead of contents,
and do not dereference symbolic links
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -lst
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append `*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
-G, --no-group like -l, but do not list group
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
--si likewise, but use powers of not
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode with -l, print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k like --block-size=1K
-l 使用较长格式列出信息
-L, --dereference 当显示符号链接的文件信息时,显示符号链接所指示
的对象而并非符号链接本身的信息
-m 所有项目以逗号分隔,并填满整行行宽
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars 以 ? 字符代替无法打印的字符
--show-control-chars 直接显示无法打印的字符 (这是默认方式,除非调用
的程序名称是“ls”而且是在终端机画面输出结果)
-Q, --quote-name 将项目名称括上双引号
--quoting-style=方式 使用指定的 quoting <方式>显示项目的名称:
literal、locale、shell、shell-always、c、escape
-r, --reverse 逆序排序
-R, --recursive 递归列出所有子目录
-s, --size 和 -l 同时使用时以块为单位列出每个文件的大小
-S 根据文件大小排序
--sort=WORD 以下是可选用的 WORD 和它们代表的相应选项:
extension -X status -c
none -U time -t
size -S atime -u
time -t access -u
version -v use -u
--time=WORD 和 -l 同时使用时显示 WORD 所代表的时间而非修改时
间:atime、access、use、ctime 或 status;加上
--sort=time 选项时会以指定时间作为排序关键字
--time-style=STYLE 和 -l 同时使用时根据 STYLE 代表的格式显示时间:
full-iso、iso、locale、posix-iso、+FORMAT。
FORMAT 即是“date”所用的时间格式;如果 FORMAT
是 FORMAT1<新行>FORMAT2,FORMAT1 适用于较旧
的文件而 FORMAT2 适用于较新的文件;如果 STYLE
以“posix-”开头,则 STYLE 仅在 POSIX 语系之外
生效。
-t 根据修改时间排序
-T, --tabsize=宽度 自行指定 tab 的<宽度>,而非 个字符
-u with -lt: sort by, and show, access time
with -l: show access time and sort by name
otherwise: sort by access time
-U do not sort; list entries in directory order.
In combination with one_per_line format `-',
it will show files immediately and it has no
memory limitations.
-v sort by version
-w, --width=COLS 自行指定萤幕宽度而不使用目前的数值
-x 逐行列出项目而不是逐栏列出
-X 根据扩展名排序
- 每行只列出一个文件 SELinux options: --lcontext Display security context. Enable -l. Lines
will probably be too wide for most displays.
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
--scontext Display only security context and file name. --help 显示此帮助信息并退出
--version 输出版本信息并退出 [大小]可以是以下的单位(单位前可加上整数):
kB ,K ,MB ,M ,还有 G、T、P、E、Z、Y。 By default, color is not used to distinguish types of files. That is
equivalent to using --color=none. Using the --color option without the
optional WHEN argument is equivalent to using --color=always. With
--color=auto, color codes are output only if standard output is connected
to a terminal (tty). The environment variable LS_COLORS can influence the
colors, and can be set easily by the dircolors command. Exit status is if OK, if minor problems, if serious trouble. 请向 <bug-coreutils@gnu.org> 报告错误。
[root@localhost linux]#
ls --help
8.mkdir 创建文件夹
[root@localhost linux]# ll
总计
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
You have new mail in /var/spool/mail/root
[root@localhost linux]# mkdir a
[root@localhost linux]# mkdir -p b/c/d
[root@localhost linux]# mkdir
[root@localhost linux]# ll
总计
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - : a
drwxr-xr-x root root - : b
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file1.txt
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]#
9.mv移动
始终只有1份 cp拷贝 原文件不动,新增一份
[root@localhost linux]# ll
总计
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - :
drwxr-xr-x root root - : a
drwxr-xr-x root root - : b
drwxr-xr-x linux linux - : Desktop
-rw-rw-r-- linux linux - : file2.txt
drwxrwxr-x linux linux - : ml
[root@localhost linux]# mv file2.txt /
[root@localhost linux]# ll /
总计
-rw-rw-r-- linux linux - : file2.txt
10.如何创建一个空文件 或者把一个文件设置为空
touch rz.log 如何创建一个空文件
echo "" > rz.log1 慎用
cat /dev/null > ruoze.log20191113 把一个文件设置为空
[root@localhost ]# ll
总计
[root@localhost ]# touch rz.log
[root@localhost ]# echo "" > rz.log1
[root@localhost ]# ll
总计
-rw-r--r-- root root - : rz.log
-rw-r--r-- root root - : rz.log1
[root@localhost ]# cat /dev/null > ruoze.log20191113
[root@localhost ]# ll
总计
-rw-r--r-- root root - : ruoze.log20191113
-rw-r--r-- root root - : rz.log
-rw-r--r-- root root - : rz.log1
[root@localhost ]#
11.查看文件内容
cat 文件内容一下子全部显示
more 文件内容一页一页的往下翻,按空格键往下,回退不了,按q退出
less 文件内容 往下 往上 按上下箭头的按键 按q键退出
12.实时 tail -f xxx.log 和 ail -F xxx.log 的查看日志的区别:
配置文件 内容较少 cat more less
log日志 内容较多
实时查看 :
tail -f xxx.log
tail -F xxx.log -f+ retry
flume exec source 切记使用 -F
xxx.log log4j代码项目 配置输出的日志
规则: xxx.log 保留10份 100M
aaa-->xxx.log 99m
xxx.log 100m
mv xxx.log xxx.log1
touch xxx.log 空文件
13.当发生ERROR 如何快速定位
a.文件内容很小 几十兆,上传给window,用editplus工具打开
上传下载 yum install -y lrzsz
b.文件内容很大 几百兆 2G
cat xxx.log | grep ERROR
14.命令输出结果 | 命令输入的 管道符
grep过滤:
cat xxx.log | grep -A ERROR 后10行
cat xxx.log | grep -B ERROR 前10行
cat xxx.log | grep -C ERROR 前后各30行 经常用 迅速定位ERROR上下文 tail -300f messages 实时查看倒数300行文件
tail -300F messages 不能这样写
tail: option used in invalid context --
数据仓库001 - 复习Linux shell命令 - pwd mkdir mv tail -f xxx.log 和 ail -F xxx.log的更多相关文章
- 数据仓库002 - 复习Linux shell命令 - echo bash_profile bashrc which命令的理解 alias history
1.echo 打印 . echo 的作用是在屏幕上打印输出内容,与文件和持久化可以理解为没有丝毫关联.如:在屏幕上打印“ echo 的作用是打印文字! ” 实例1:输出系统的环境变量名称 $PATH ...
- 数据仓库005 - 复习Linux shell命令 - crontab调度 sh脚本 后台执行 软连接
一.crontab调度 对于linux 自带crontab而言, xxx.sh的一般编写格式以#!/bin/bash 解释器开头,可在脚本中加入: date 但是,shell脚本执行 需要 ...
- 数据仓库004 - 复习Linux shell命令 - vi 进程 端口号 系统命令 高危命令 wget yum rpm压缩
一.复习 1.vi的使用方法: 1.1 .正常编辑一个文件,保存退出 1.2. 粘贴的坑:必须在i键 编辑模式 2.找error cat xxx.log | grep -C 10 ERROR > ...
- 数据仓库003 - 复习Linux shell命令 - 用户用户组 sudo 权限 du-sh find
一.用户用户组 [root@localhost ~]# ll /usr/sbin/user* -rwxr-x--- root root -- /usr/sbin/useradd -rwxr-x--- ...
- Java文件操作API功能与Windows DOS命令和Linux Shell 命令类比
Java文件操作API功能与Windows DOS命令和Linux Shell 命令类比: Unix/Linux (Bash) Windows(MS-DOS) Java 进入目录 cd cd - 创建 ...
- 73条日常Linux shell命令汇总,总有一条你需要!
转载: 73条日常Linux shell命令汇总,总有一条你需要! 1.检查远程端口是否对bash开放: echo >/dev/tcp/8.8.8.8/53 && echo &q ...
- [Python2.x] 利用commands模块执行Linux shell命令
用Python写运维脚本时,经常需要执行linux shell的命令,Python中的commands模块专门用于调用Linux shell命令,并返回状态和结果,下面是commands模块的3个主要 ...
- java使用Runtime.exec()运行windwos dos或linux shell命令
使用Runtime.exec()运行windwos dos或linux shell命令,按实际情况具体测试 实例代码: package com.bookoo.test.command; imp ...
- Linux shell命令中expr
在Linux shell命令中expr虽然不是很起眼,但是它的作用是非常大的!到目前为止,我个人看来最大的作用就是两个——四则运算和字符串的操作. 先说四则运算,在Shell中四则运算不能简简单单的加 ...
随机推荐
- import和from...import
目录 一.import 模块名 二.from 模块名 import 具体的功能 三.import和from...import...的异同 一般使用import和from...import...导入模块 ...
- Python程序中的进程操作-进程间通信(multiprocess.Queue)
目录 一.进程间通信 二.队列 2.1 概念介绍--multiprocess.Queue 2.1.1 方法介绍 2.1.2 其他方法(了解) 三.代码实例--multiprocess.Queue 3. ...
- 机器学习--matplotlib绘制各种图表
机器学习三剑客:numpy.pandas.matplotlib NumPy系统是Python的一种开源的数值计算扩展.这种工具可用来存储和处理大型矩阵. pandas 是基于numpy的一种工具,该工 ...
- 大话设计模式Python实现-命令模式
命令模式(Command Pattern):将请求封装成对象,从而使可用不同的请求对客户进行参数化:对请求排队或记录请求日志,以及支持可撤消的操作. 下面是一个命令模式的demo: #!/usr/bi ...
- 《细说PHP》 第四版 样章 第二章 PHP的应用与发展 3
2.3 PHP的开发优势 每种编程语言都有针对的领域,当然相同领域也有多个编程语言可以选择, 所以需要了解每种编程语言的优势和劣势,才能更好地去选择使用,在对的开发领域充分发挥它的优势,编写出最优质 ...
- 有了faker,再也不用为了构造测试数据而烦恼啦!
在软件需求.开发.测试过程中,有时候需要使用一些测试数据,针对这种情况,我们一般要么使用已有的系统数据,要么需要手动制造一些数据.在手动制造数据的过程中,可能需要花费大量精力和工作量,此时可以借助Py ...
- C#测试对比不同类型的方法调用的性能
一. 测试方法调用形式 1. 实例方法调用 2. 静态方法调用 3. 实例方法反射调用 4. 委托方法的Invoke调用 5. 委托方法的DynamicInvoke调用 6.委托方法的BeginInv ...
- PDF怎么转换为CAD文件?这两种方法你的会
在日常的办公中,我们最常见的文件格式就是PDF格式的,因为PDF文件的安全性是比较高的,可以防止不小心触碰到键盘修改文件内容,而且PDF文件便于进行文件的传输.但是有时候也需要将PDF转换成CAD,那 ...
- JS是解释型还是编译型语言?
解释型和编译型语言 解释型语言 解释型语言是对代码进行一句一句的直接运行,在程序运行期间,使用解释器动态将代码解释为机器码,再运行. 编译型语言 编译型语言是需要使用编译器先对代码进行编译为机器码,再 ...
- 「SAP技术」SAP不够严谨?
SAP不够严谨? 大家知道采购业务里,有一种特殊的采购形式,就是按单采购,意思是所采购的物料只用于指定的销售订单的销售出库.这种业务场景在SAP项目实践中,比较常见. 强大无比的SAP系统当然有解决方 ...