Linux常用命令

时间:2021-08-18 15:26:21   收藏:0   阅读:24

博客地址:https://www.hz-bin.cn/Linux-cmd

echo

root@ubuntu:~# echo HelloWorld
HelloWorld
root@ubuntu:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

date

root@ubuntu:~# date
Tue Aug 10 10:50:07 CST 2021
root@ubuntu:~# date "+%Y-%m-%d %H:%M:%S"
2021-08-10 10:50:10
root@ubuntu:~# date "+%j"
222

reboot

poweroff

wget

ps

root@ubuntu:~# ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1 159724  3464 ?        Ss   Aug09   0:01 /sbin/init maybe-ubiquity
root         2  0.0  0.0      0     0 ?        S    Aug09   0:00 [kthreadd]
root         4  0.0  0.0      0     0 ?        I<   Aug09   0:00 [kworker/0:0H]
root         6  0.0  0.0      0     0 ?        I<   Aug09   0:00 [mm_percpu_wq]
root         7  0.0  0.0      0     0 ?        S    Aug09   0:14 [ksoftirqd/0]
root         8  0.0  0.0      0     0 ?        I    Aug09   1:27 [rcu_sched]
root         9  0.0  0.0      0     0 ?        I    Aug09   0:00 [rcu_bh]
root        10  0.0  0.0      0     0 ?        S    Aug09   0:00 [migration/0]
...... 省略
VSZ:虚拟内存使用量,单位KB
RSS:占用的固定内存量,单位KB
STAT:进程状态,R(运行),S(终端),D(不可中断),Z(僵死),T(停止)
TIME:实际使用CPU的时间

top

root@ubuntu:~# top
top - 11:01:58 up 1 day,  1:30,  3 users,  load average: 0.00, 0.00, 0.00
      系统时间       运行时间     登录终端数  系统负载:1分钟,5分钟,15分钟内的平均值
Tasks: 101 total,   1 running,  58 sleeping,   0 stopped,   0 zombie
       进程总数      运行中       睡眠中         已停止        僵死
%Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st
KiB Mem :  2040924 total,  1500768 free,   290220 used,   249936 buff/cache
           物理内存总量     内存空闲两       内存使用量      作为内核缓存的内存量
KiB Swap:  2097148 total,  2089968 free,     7180 used.  1569476 avail Mem
           虚拟内存总量

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  159724   3464   1116 S  0.0  0.2   0:01.28 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    4 root       0 -20       0      0      0 I  0.0  0.0   0:00.00 kworker/0:0H
    6 root       0 -20       0      0      0 I  0.0  0.0   0:00.00 mm_percpu_wq
    7 root      20   0       0      0      0 S  0.0  0.0   0:14.30 ksoftirqd/0
    8 root      20   0       0      0      0 I  0.0  0.0   1:27.94 rcu_sched
    9 root      20   0       0      0      0 I  0.0  0.0   0:00.00 rcu_bh
   10 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
...... 省略

pidof

root@ubuntu:~# pidof mysqld
1103

kill

killall

ifconfig

uname

root@ubuntu:~# uname
Linux
root@ubuntu:~# uname -a
Linux ubuntu 4.15.0-153-generic #160-Ubuntu SMP Thu Jul 29 06:54:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

uptime

root@ubuntu:~# uptime
 11:19:31 up 1 day,  1:48,  3 users,  load average: 0.00, 0.00, 0.00

free

root@ubuntu:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        262M        1.4G        724K        274M        1.6G
Swap:          2.0G          0B        2.0G

who

last

history

root@ubuntu:~# history
...... 省略
  162  cd ~
  163  clear
  164  uptime
  165  free -h
  166  who
  167  last
  168  history
root@ubuntu:~# !164
uptime
 11:27:19 up 6 min,  1 user,  load average: 0.00, 0.00, 0.00

sosreport

root@ubuntu:~# sosreport

sosreport (version 3.9)

This command will collect system configuration and diagnostic
information from this Ubuntu system.

For more information on Canonical visit:

  https://www.ubuntu.com/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.


Press ENTER to continue, or CTRL-C to quit.

Please enter the case id that you are generating this report for []:

 Setting up archive ...
 Setting up plugins ...
[plugin:networking] skipped command ‘nft list ruleset‘: required kmods missing: nf_tables.
[plugin:networking] skipped command ‘ip -s macsec show‘: required kmods missing: macsec.  Use ‘--allow-system-changes‘ to enable collection.
[plugin:networking] skipped command ‘ss -peaonmi‘: required kmods missing: tcp_diag, af_packet_diag, inet_diag, udp_diag, netlink_diag, unix_diag.  Use ‘--allow-system-changes‘ to enable collection.
 Running plugins. Please wait ...

  Finishing plugins              [Running: ubuntu]
  Finished running plugins
Creating compressed archive...

Your sosreport has been generated and saved in:
  /tmp/sosreport-ubuntu-2021-08-10-shnpxye.tar.xz

 Size   2.76MiB
 Owner  root
 md5    7b43aab2e9a6110e4e8a188e39133440

Please send this file to your support representative.

pwd

cd

ls

cat

more

tail

tr

wc

root@ubuntu:~# wc -l /etc/passwd
32 /etc/passwd

stat

root@ubuntu:~# stat /etc/passwd
  File: /etc/passwd
  Size: 1673            Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 416695      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-08-09 16:02:09.921445530 +0800
Modify: 2021-08-09 16:02:09.893445577 +0800
Change: 2021-08-09 16:02:09.897445570 +0800
 Birth: -

cut

root@ubuntu:~# cut -d: -f1 /etc/passwd
root
daemon
bin
sys
...... 省略

diff

touch

mkdir

cp

mv

rm

file

tar

grep

find

参考文档:新手必须掌握的Linux命令
本文由博客一文多发平台 OpenWrite 发布!

原文:https://www.cnblogs.com/hz-bin/p/15156164.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!