1,[[email protected] ~]# cat /etc/redhat-release #查看系统版本信息
CentOS Linux release 7.2.1511 (Core)
2,[[email protected] ~]# uname -a #查看内核信息
Linux docker1 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
3,[[email protected] ~]# ip a # 显示IP地址信息
4,[[email protected] ~]# ip r #显示默认网关 路由信息
5,[[email protected] ~]# mkdir server # 创建目录
-p #递归创建目录
6,[[email protected] ~]# ls #显示目录下的内容
anaconda-ks.cfg server test.txt zhang
参数 :
ls -l (long ) #显示详细信息
-F #给不同类型的文件加上标记
7, [[email protected] ~]# cd /etc/ #进入到指定的目录下
8,[[email protected] etc]# pwd #显示当前所在的位置
/etc
9,[[email protected] ~]# touch day.txt #创建文件 修改文件的时间戳
10,[[email protected] ~]# cat day.txt # 显示文件的内容
11,[[email protected] ~]# vim day.txt # vi /vim 文件编辑器
12,cp 复制命令 ;
[[email protected] ~]# cp day.txt /tmp/ #cp 文件到tmp 目录下
[[email protected] ~]# cd /tmp/
[[email protected] tmp]# ls
day.txt
参数: -a 相当于-pdr
-r 递归,复制目录,目录及其子孙后代
-p 复制文件同时保持性不变,
++++++++++++cp覆盖不提示直接覆盖 ;
###方法一
[[email protected] data]# \cp /mnt/test.txt /tmp/ ( 直接使用 \ )
###方法二
使用命令cp 的全路径(绝对路径)
[[email protected] data]# which cp (which 查看命令绝对路径)
/bin/cp
[[email protected] data]# /bin/cp /mnt/test.txt /tmp/ (开始覆盖)
13, [[email protected] ~]# rm day.txt # 删除
rm: remove regular empty file ‘day.txt’? y
14,[[email protected] ~]# mv test.txt /tmp/ # 转移文件位置
[[email protected] ~]# cd /tmp/
[[email protected] tmp]# ls
day.txt test.txt
[[email protected] tmp]# mv test.txt www.txt #重命名文件
[[email protected] tmp]# ls
day.txt www.txt
15, /etc/init.d/network restart #重启网卡
16, ifdown eth0 && ifup eth0 #重启某块网卡
17,[[email protected] tmp]# runlevel #显示系统当前的运行级别
N 3
18, [[email protected] tmp]# reboot # 服务器进行重启
19, rz sz (lrzsz) 上传下载命令 ;
# 把windows 文件上传到 linux rz
#把 linux 文件下载到 windows sz
20,[[email protected] tmp]# rpm -qa nginx #查询系统中是否安装 nginx
参数 :
-qa #查询是否安装
-ql #显示软件包内容
-ivh #安装rpm软件包
21,[[email protected] tmp]# free -m #显示内存信息
total used free shared buffers cached
Mem: 2016 1973 42 0 163 1497
-/+ buffers/cache: 312 1703
Swap: 4094 0 4094
选项:
-b:以Byte为单位显示内存使用情况;
-k:以KB为单位显示内存使用情况;
-m:以MB为单位显示内存使用情况;
-o:不显示缓冲区调节列;
-s<间隔秒数>:持续观察内存使用状况;
-t:显示内存总和列;
-V:显示版本信息。
+++++++++++++第一部分Mem行解释:
total:内存总数;
used:已经使用的内存数;
free:空闲的内存数;
shared:当前已经废弃不用;
buffers Buffer:缓存内存数;
cached Page:缓存内存数。
关系:total = used + free
++++++++++第二部分(-/+ buffers/cache)解释:
(-buffers/cache) used内存数:第一部分Mem行中的 used – buffers – cached
(+buffers/cache) free内存数: 第一部分Mem行中的 free + buffers + cached
可见-buffers/cache反映的是被程序实实在在吃掉的内存,而+buffers/cache反映的是可以挪用的内存总数。
第三部分Swap: 是指交换分区。
22, [[email protected] tmp]# w # 显示的负载信息和哪个用户登陆了系统
01:16:09 up 1:02, 1 user, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root pts/0 IP 00:14 1.00s 0.47s 0.00s w
23,tar 命令
tar zcf 创建压缩包
tar tf 查看压缩包内容
tar xf 解压
24,ifdown eth0 ##关闭第一块网卡 ,
ifup eth0 ##开启第一块网卡
ifconfig ##查看ip地址
25,绝对or相对路径:
绝对路径:绝对路径是只要是从 “ / ” 开始的路径都成为绝对路径
相对路径:相对路径是相对于 当前路径
26,
>> (追加+重定向) 追加内容到文件的尾部 (也就是文件最后一行)
> (重定向) 清除文件里的所有内容 (用的时候需要想清楚)
命令实列
[[email protected] ~]# echo "Hello word" >>/tmp/hello.txt #把 "Hello word" 追加重定向到hello.txt文件中
[[email protected] ~]# echo "Hello word!" >/tmp/hello.txt #把 "Hello word!" 重定向 到hello.txt 文件中
27,一次向文件中追加多行内容 ;
[[email protected] ~]# cat >> linux.txt <<EOF
> Linux Linux
> 1233333
> centos
> EOF
[[email protected] ~]# cat linux.txt
Linux Linux
1233333
centos
[[email protected] ~]#
28 ,find 命令, 主要查找文件 ;
命令实列 - [[email protected] ~]#find / -type f -name "linux.txt"
其他参数 -
-type: 查找某一类型文档
b:块设备文档
d:目录
c:字符设备文档
P:管道文档
l:符号链接文档
f:普通文档
29,Find + xargs
1,当尝试用rm 删除太多的文件,可能得到一个错误信息:/bin/rm Argument list too long. 用xargs 去避免这个问题
find ~ -name ‘*.log' -print0 | xargs -0 rm -f
2. 获得/etc/ 下所有*.conf 结尾的文件列表,在这个例子中实用 xargs将find 命令的输出传递给ls -l
[[email protected] ~]# find /etc/ -name "*.conf" | xargs ls -l
3. 如你有一个文件包含了很多你希望下载的URL, 你能够使用xargs 下载所有链接
cat url-list.txt | xargs wget –c
4. 查找所有的jpg 文件,并且压缩它
find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz
30,head & tail 命令说明 ;
功能说明:
head: 取文件的前几行,默认文件的前10行
tail : 取文件的结尾的几行,默认文件的结尾的10行
语法格式:
head/tail [参数] 文件
参数:
-n : num,数字
tail –f : 显示文件的实时更新
查看文件前五行
[[email protected] ~]# head -5 ett.txt
1
2
3
4
5
查看文件后五行
[[email protected] ~]# tail -5 ett.txt
6
7
8
9
10
31 ,alias 别名配置 ;
查看并配置别名
[[email protected] ~]# alias mkdir='echo hello'
[[email protected] ~]# alias
alias cp='cp -i'
alias mkdir='echo hello'
alias mv='mv -i'
alias rm='rm -i'
[[email protected] ~]# mkdir /wer
hello /wer
取消别名
[[email protected] ~]# unalias mkdir
[[email protected] ~]# alias
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[[email protected] ~]# mkdir /wer
[[email protected] ~]# rm -rf /wer/
32, wc 统计文件信息 ;
参数:
-l : line, 统计文件中内容有多少行
查看/etc/services文件内容有多少行?
[[email protected] ~]# wc -l /etc/services
10774 /etc/services
33,du命令使用 ;
du 命令计算文件所占的空间
-s summary 简介
-h 人类可读的方式显示大小
[[email protected] ~]# du -sh /etc/
26M /etc/
[[email protected] ~]# du -sh /etc/passwd
4.0K /etc/passwd
[[email protected] ~]# du -sh /*
6.2M /bin
23M /boot
16K /data
156K /dev
26M /etc
[[email protected] ~]# du -sh /var/log/messages
1.8M /var/log/messages
+++++++++可以+ grep找上G的文件
[[email protected] tmp]# du -sh /*|grep G
du: cannot access `/proc/5496/task/5496/fd/4': No such file or directory
du: cannot access `/proc/5496/task/5496/fdinfo/4': No such file or directory
du: cannot access `/proc/5496/fd/4': No such file or directory
du: cannot access `/proc/5496/fdinfo/4': No such file or directory
1.2G /usr
2.9G /var
[[email protected] tmp]# du -sh /var/|grep G
2.9G /var/
[[email protected] tmp]# du -sh /var/*|grep G
2.7G /var/log
[[email protected] tmp]# du -sh /var/log/*|grep G
2.7G /var/log/messages
34,查找系统中的大文件显示前几行 ;
[[email protected] ~]# du -sh * |sort -nr |head
16K install.log
4.0K zuidade.sh
4.0K url.txt
4.0K text.txt
4.0K passwd1
4.0K passwd
4.0K install.log.syslog
4.0K check.txt
4.0K chech.md5
4.0K anaconda-ks.cfg
35 , tmp 目录有一个机制 ,可以删除10 天未访问过的文件删除
36 、 显示文件内容 ;
cat 、 more 、 less 、head 、tail
37 、 目录查看 ;
38 、 文件和目录操作 ;
39 、 linux 下的文件上传和下载 ;
40 、 linux 压缩和解压缩 ;
41 、linux 权限管理说明 ;
42 、 用户管理说明 ;
43 、 Linux 下文件查找 ;
44 、 Linux 下快捷键使用说明 ;
============================ 未完待续!! ===================================