【随笔记】Linux常用命令

1、rename

rename bcp.bad bcp *.bad

2、screen

Ctrl+A,然后快速按D退出screen窗口

安装screen

[root@aaa ~]# yum install screen -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base                                                                                   | 3.6 kB  00:00:00
extras                                                                                 | 3.4 kB  00:00:00
updates                                                                                | 3.4 kB  00:00:00
(1/2): extras/7/x86_64/primary_db                                                      | 187 kB  00:00:00
(2/2): updates/7/x86_64/primary_db                                                     | 5.2 MB  00:00:02
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package            Arch               Version                                         Repository        Size
==============================================================================================================
Installing:
 screen             x86_64             4.1.0-0.25.20120314git3c2946.el7                base             552 k

Transaction Summary
==============================================================================================================
Install  1 Package

Total download size: 552 k
Installed size: 914 k
Downloading packages:
screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm                                     | 552 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64                                             1/1
  Verifying  : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64                                             1/1

Installed:
  screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7

Complete!

查看是否安装成功

[root@aaa ~]# rpm -qa | grep screen
gnome-screenshot-3.22.0-1.el7.x86_64
screen-4.1.0-0.25.20120314git3c2946.el7.x86_64

3、防火墙

查看防火墙开启端口号

iptables -L -n

开启端口号


firewall-cmd --permanent --add-port=8080/tcp --zone=public
firewall-cmd --reload

关闭端口号

firewall-cmd --permanent --remove-port=8080/tcp --zone=public
firewall-cmd --reload

4、scp

4.1 从本地复制到远程

复制文件

scp /data/1.txt [email protected]:/data/

复制目录命令格式

scp -r /data/ [email protected]:/data/

4.2 从远程复制到本地

scp [email protected]:/data/ /data/1.txt
scp -r [email protected]:/data/ /data/

5、查看系统日志

cat /var/log/messages

6、显示系统运行时间信息

uptime/w/top

w命令的第一行与uptime命令的输出是相同的

top命令的第一行与uptime命令的输出是相同的,另外几行与free命令的输出相似。

两个法则,作为判断系统负荷是否过大:

“有多少核心即为有多少负荷”法则:在多核处理中,你的系统均值不应该高于处理器核心的总数量。(尤其是第三个值,即15分钟平均系统负荷)

“核心的核心”法则:核心分布在分别几个单个物理处理中并不重要,其实两颗四核的处理器 等于 四个双核处理器 等于 八个单处理器。所以,它应该有八个处理器内核。

[root@web ~]# uptime
 17:38:46 up 70 days,  8:38,  3 users,  load average: 0.05, 0.06, 0.05

[root@web ~]# w
 17:38:51 up 70 days,  8:39,  3 users,  load average: 0.04, 0.06, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    172.16.0.156     15:28    2:10m  0.06s  0.06s -bash
root     pts/1    172.16.0.155     09:30    8:08m  0.07s  0.07s -bash
root     pts/2    172.16.0.157     17:38    3.00s  0.08s  0.01s w

[root@web ~]# top

top - 17:38:21 up 70 days,  8:38,  3 users,  load average: 0.07, 0.07, 0.05
Tasks: 540 total,   1 running, 539 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.4 sy,  0.0 ni, 99.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 29671600+total, 86688648 free, 20272104 used, 18975524+buff/cache
KiB Swap: 13421772+total, 13416320+free,    54528 used. 25605281+avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
18771 root      20   0  162368   2560   1524 R  11.8  0.0   0:00.03 top
    1 root      20   0  197228   6644   4188 S   0.0  0.0   9:41.74 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:04.37 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:09.69 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+
    8 root      rt   0       0      0      0 S   0.0  0.0   0:11.49 migration/0
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
   10 root      20   0       0      0      0 S   0.0  0.0  30:09.82 rcu_sched
   11 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-dr+
   12 root      rt   0       0      0      0 S   0.0  0.0   0:13.36 watchdog/0
   13 root      rt   0       0      0      0 S   0.0  0.0   0:12.82 watchdog/1
   14 root      rt   0       0      0      0 S   0.0  0.0   0:11.05 migration/1
   15 root      20   0       0      0      0 S   0.0  0.0   0:02.00 ksoftirqd/1
   17 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:+
   18 root      rt   0       0      0      0 S   0.0  0.0   0:10.93 watchdog/2
   19 root      rt   0       0      0      0 S   0.0  0.0   0:10.65 migration/2
   20 root      20   0       0      0      0 S   0.0  0.0   0:01.10 ksoftirqd/2
   22 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/2:+

猜你喜欢

转载自blog.csdn.net/hellboy0621/article/details/80664056