linux gret 文件内容,Linux常用命令详解(二)--技术流ken

本节内容

alias

unalias

uname

su

hostname

history

which

wc

w

who

whoami

ping

kill

seq

du

df

free

date

命令详解

1. alias

设置、’查看别名

实例1:查看别名

[[email protected] ~]# 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 man=‘man -M /usr/local/manpage/share/man/zh_CN‘alias mv=‘mv -i‘alias rm=‘rm -i‘alias which=‘alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde‘

实例2:设置别名

[[email protected] ~]# alias "ken=ls -l"]# ken

total85452

-rw-r--r-- 1 root root 22 Jan 13 12:12 1

-rw-r--r-- 1 root root 23 Jan 13 12:12 2drwxr-xr-x 2 root root 6 Jan 13 12:05 2.txt

实例3:取消别名

[[email protected] ~]# ken-bash: ken: command not found

2.uname

显示输出系统信息

-a:显示所有的信息

-r: 显示操作系统发行版本

实例1:

[[email protected] ~]# uname -a

Linux ken3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

实例2:

显示内核版本

[[email protected] ~]# uname -r3.10.0-862.el7.x86_64

3.su

运行替换用户和组标识的shell

实例1:

-:使得shell为可登录的shell

[[email protected] ~]# su -ken

Last login: Fri Jan11 11:27:19 CST 2019 on pts/0

退出

4. hostname

显示并设置主机名

实例1:显示主机名

[[email protected] ~]# hostname

ken

实例2:设置主机名(重启失效)

[[email protected] ~]# hostname ken1

5.history

查看历史命令

实例1:

6. which

显示命令的完整路径

实例1:

[[email protected] ~]# which ls

alias ls=‘ls --color=auto‘

/usr/bin/ls

7.wc

统计文本信息

常用选项:

-c: 字节

-w: 单词数量

-l: 统计行数

实例1:

[[email protected] ~]# cat /etc/passwd | wc -l38

实例2:

[[email protected] ~]# echo "this is ken" | wc -c12

实例3:

[[email protected] ~]# echo "this is ken" | wc -w3

8.w

显示已经登录的用户以及他们在做什么

实例:

[[email protected] ~]# w13:04:06 up 2 days, 3:30, 7 users, load average: 0.61, 0.16, 0.09USER TTY FROM [email protected] IDLE JCPU PCPU WHAT

root tty1 Mon19 3days1.35s 0.02s -bash

root pts/0 172.20.10.4 09:47 1:44m 0.16s 0.00s less -s

root pts/1 172.20.10.4 10:34 1:43m 0.02s 0.02s -bash

root pts/2 172.20.10.4 12:00 20:38 0.15s 0.15s -bash

root pts/3 172.20.10.4 12:00 15:02 0.03s 0.03s -bash

root pts/4 172.20.10.4 13:03 6.00s 0.04s 0.01s w

root pts/5 172.20.10.4 13:03 11.00s 0.02s 0.02s -bash

9. who

显示已经登录的用户

[[email protected] ~]# who

root tty12019-01-07 19:24root pts/0 2019-01-13 09:47 (172.20.10.4)

root pts/1 2019-01-13 10:34 (172.20.10.4)

root pts/2 2019-01-13 12:00 (172.20.10.4)

root pts/3 2019-01-13 12:00 (172.20.10.4)

root pts/4 2019-01-13 13:03 (172.20.10.4)

root pts/5 2019-01-13 13:03 (172.20.10.4)

10.whoami

显示当前用户

11.ping

向网络主机发送ICMP(检测主机是否在线)

常用选项:

-c: 发送包的数量

-w: 等待时间(当试图检测不可达主机时此选项很有用)

实例1:

[[email protected] ~]# ping -c 3 -w 3www.baidu.com

PING www.a.shifen.com (163.177.151.110) 56(84) bytes of data.64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=1 ttl=53 time=81.5ms64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=2 ttl=53 time=97.8ms64 bytes from 163.177.151.110 (163.177.151.110): icmp_seq=3 ttl=53 time=90.9ms--- www.a.shifen.com ping statistics ---

3 packets transmitted, 3 received, 0%packet loss, time 2004ms

rtt min/avg/max/mdev = 81.522/90.091/97.811/6.686 ms

12. kill

终止进程(kill后面指定pid号码)

-9: 强制终止

实例:

[[email protected] ~]# ps

PID TTY TIME CMD23790 pts/4 00:00:00bash24269 pts/4 00:00:009 23790Connection closed by foreign host.

Disconnectedfrom remote host(172.20.10.6) at 13:11:32.

Type `help‘to learn how to use Xshell prompt.

[d:\~]$

13.seq

生成数列

实例1:指定结束位置

实例2:指定起始位置和结束位置

实例3:指定起始位置和结束位置以及步长

[[email protected] ~]# seq 2 2 10

2

4

6

8

10

14.du

文件及目录大小

常用选项:

-s: 仅显示总和

-h: 人类易读

实例1:

[[email protected] ~]# du -s /root117064 /root

实例2:

[[email protected] ~]# du -sh /root

115M/root

15.df

报告文件系统磁盘空间的使用情况

-h:人类易读

实例1:

[[email protected] ~]# df -h

Filesystem Size Used Avail Use%Mounted on/dev/mapper/centos-root 17G 5.5G 12G 33% /devtmpfs 233M0 233M 0% /dev

tmpfs 245M0 245M 0% /dev/shm

tmpfs 245M9.1M 235M 4% /run

tmpfs 245M0 245M 0% /sys/fs/cgroup/dev/sr0 56M 56M 0 100% /mnt/dev/sda1 1014M 130M 885M 13% /boot

tmpfs 49M0 49M 0% /run/user/0

16.free

显示系统中已用和未用的内存空间总和

常用选项:

-m: 以m为单位

-h: 人类易读

实例1:

[[email protected] ~]# free -m

total used free shared buff/cache available

Mem:488 373 21 1 93 76Swap:2047 423 1624

实例2:

[[email protected] ~]# free -h

total used free shared buff/cache available

Mem: 488M 373M 21M1.8M93M 76M

Swap:2.0G 423M 1.6G

17. date

打印或设置系统日期和时间

常用选项:

-s: 根据 STRING 设置时间

%Y     年(用 4 位表示) (1970...)

%m     月份(用两位表示) (01..12)

%d     (月份中的)几号(用两位表示) (01..31)

%H     小时(按 24 小时制显示,用两位表示) (00..23)

%M     分钟数(用两位表示) (00..59)

%S     秒数(用两位表示)(00..60)

%T 时间,按 24 小时制显示(hh:mm:ss)

%F 显示 %Y-%m-%d

实例1:

[[email protected] ~]# date ‘+%F %T‘

2019-01-13 13:29:56

实例2:

[[email protected] ~]# date -s "2019-01-13 13:30:00"Sun Jan13 13:30:00 CST 2019]# date

Sun Jan13 13:30:01 CST 2019

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值