美文网首页
01.linux -- 常用命令

01.linux -- 常用命令

作者: QXPLUS | 来源:发表于2022-05-21 08:53 被阅读0次
  • history 查看历史命令

  • ssh 登录
    ssh jmzeng@192.168.0.100
    用户名@ip地址

  • su切换用户
    su pc

  • top:实时动态地查看系统的整体运行情况

top - 21:36:15 up 907 days, 17:22,  1 user,  load average: 0.26, 0.61, 0.57
Tasks:  28 total,   1 running,  27 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.0 us,  1.6 sy,  0.1 ni, 93.7 id,  0.5 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem : 16425212 total,  5350052 free,  3207492 used,  7867668 buff/cache
KiB Swap:   969964 total,   747960 free,   222004 used. 12304796 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                           
    1 root      20   0   22144   3216   2952 S   0.0  0.0   0:00.04 init.sh                           
   24 shiyanl+  20   0  257344  55556  30108 S   0.0  0.3   0:00.47 Xvnc                              
   32 shiyanl+  20   0   13672   2372   2172 S   0.0  0.0   0:00.00 sh                                
   33 shiyanl+  20   0   13684   2968   2748 S   0.0  0.0   0:00.00 sh                                
   39 shiyanl+  25   5   97180   1496   1288 S   0.0  0.0   0:00.12 guac-clipboard                    
   51 root      20   0   51844  18352   6752 S   0.0  0.1   0:00.17 supervisord                       
   53 shiyanl+  20   0  261784  18908  17052 S   0.0  0.1   0:00.12 xfce4-session                     
   56 shiyanl+  20   0   43732   2368   1932 S   0.0  0.0   0:00.00 dbus-launch                       
   57 shiyanl+  20   0   43020   3208   2628 S   0.0  0.0   0:00.03 dbus-daemon                       
   59 shiyanl+  20   0   47636   4500   4012 S   0.0  0.0   0:00.02 xfconfd                           
   64 shiyanl+  20   0   11144    308      0 S   0.0  0.0   0:00.00 ssh-agent                         
   66 shiyanl+  20   0  184452  18424  16416 S   0.0  0.1   0:00.11 xfwm4                             
  • w: 查看用户
shiyanlou:~/ $ w                                                                            [21:35:12]
 21:35:14 up 907 days, 17:21,  1 user,  load average: 0.49, 0.71, 0.60
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
shiyanlo pts/0    172.16.2.44      21:34    2.00s  0.72s  0.00s w
  • & : 任务在后台运行
shiyanlou:~/ $ sleep 100 &                                                                  [21:42:08]
[1] 283    # 进程号
  • 查看命令所在的位置
shiyanlou:~/ $ where ls                                                                     [21:38:45]
ls: aliased to ls --color=tty
/bin/ls
  • 查看系统自带的命令
shiyanlou:~/ $ ls /bin/                                                                     [21:39:28]
bash           false       mount             rbash                           touch
bunzip2        fgrep       mountpoint        readlink                        true
bzcat          findmnt     mv                rm                              udevadm
bzcmp          fuser       nano              rmdir                           ulockmgr_server
bzdiff         fusermount  nc                rnano                           umount
bzegrep        getfacl     nc.traditional    run-parts                       uname
bzexe          grep        netcat            rzsh                            uncompress
bzfgrep        gunzip      netstat           sed                             vdir
bzgrep         gzexe       networkctl        setfacl                         vmmouse_detect
bzip2          gzip        nisdomainname     sh                              wdctl
bzip2recover   hostname    ntfs-3g           sh.distrib                      which
bzless         ip          ntfs-3g.probe     sleep                           whiptail
bzmore         journalctl  ntfs-3g.secaudit  ss                              ypdomainname
cat            kill        ntfs-3g.usermap   stty                            zcat
chacl          less        ntfscat           su                              zcmp
chgrp          lessecho    ntfscluster       sync                            zdiff
chmod          lessfile    ntfscmp           systemctl                       zegrep
chown          lesskey     ntfsfallocate     systemd                         zfgrep
cp             lesspipe    ntfsfix           systemd-ask-password            zforce
dash           ln          ntfsinfo          systemd-escape                  zgrep
date           login       ntfsls            systemd-hwdb                    zless
dd             loginctl    ntfsmove          systemd-inhibit                 zmore
df             lowntfs-3g  ntfstruncate      systemd-machine-id-setup        znew
dir            ls          ntfswipe          systemd-notify                  zsh
dmesg          lsblk       pidof             systemd-tmpfiles                zsh5
dnsdomainname  mkdir       ping              systemd-tty-ask-password-agent
domainname     mknod       ping6             tailf
echo           mktemp      ps                tar
egrep          more        pwd               tempfile
  • ps -ef : 标准格式显示进程
  • grep <str> 查找命令
shiyanlou:~/ $ ps -ef | grep sleep                                                          [21:43:30]
shiyanl+   283   133  0 21:43 pts/0    00:00:00 sleep 100
shiyanl+   293   133  0 21:43 pts/0    00:00:00 grep --color=auto --exclude-
  • echo: 内容打印到屏幕
shiyanlou:~/ $ echo $PATH                                                                   [21:46:47]
/usr/lib/jvm/java-8-openjdk-amd64/bin:/usr/lib/jvm/java-8-openjdk-amd64/jre:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/shiyanlou/golang/bin:/usr/share/maven/bin:/usr/local/bin:/usr/sbin/nodejs/bin:/usr/sbin/yarn/bin
  • {1..5}: 1,2,3,4,5。{ } 在此处起到扩展的作用
shiyanlou:~/ $ echo 1..5                                                                    [21:57:01]
1..5
# { } 在此处起到扩展的作用
shiyanlou:~/ $ echo {1..5}                                                                  [21:55:23]
1 2 3 4 5

一次创建多个文件(夹)

shiyanlou:~/ $ mkdir file{1..3}.txt
shiyanlou:~/ $ ll                                                                           [21:59:47]
drwxrwxr-x 2 shiyanlou shiyanlou 4.0K 5月  19 21:59 file1.txt
drwxrwxr-x 2 shiyanlou shiyanlou 4.0K 5月  19 21:59 file2.txt
drwxrwxr-x 2 shiyanlou shiyanlou 4.0K 5月  19 21:59 file3.txt
  • man 查看命令的说明
shiyanlou:~/ $ man ls

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabeti‐
       cally if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters

       --block-size=SIZE
...
  • mkdir -p 创建路劲
shiyanlou:~/ $ mkdir -p 1/2/3                                                               [22:04:43]
shiyanlou:~/ $ ls 1/2/                                                                      [22:05:40]
3
shiyanlou:~/ $ ls 1/2/3/

shiyanlou:~/ $ cd 1/2/3                                                                     [22:06:20]
shiyanlou:3/ $ pwd                                                                          [22:06:47]
/home/shiyanlou/1/2/3
  • cd - : 回到上一个目录
shiyanlou:~/ $ pwd                                                                          [22:08:05]
/home/shiyanlou
shiyanlou:~/ $ cd 1/2/3                                                                     [22:08:10]
shiyanlou:3/ $ pwd                                                                          [22:08:13]
/home/shiyanlou/1/2/3
shiyanlou:3/ $ cd -                                                                         [22:08:16]
~
shiyanlou:~/ $ pwd                                                                          [22:08:19]
/home/shiyanlou
shiyanlou:~/ $ cd -                                                                         [22:08:22]
~/1/2/3
shiyanlou:3/ $ cd -                                                                         [22:09:01]
~
  • cd ~ : 回到home目录
shiyanlou:Code/ $ cd ~                                                                      [22:10:02]
shiyanlou:~/ $ pwd                                                                          [22:10:12]
/home/shiyanlou
  • /: 根目录
shiyanlou:~/ $ ls /                                                                         [22:11:16]
anaconda3  boot  dev  home  lib64  mnt  proc  run   srv  tmp  var
bin        data  etc  lib   media  opt  root  sbin  sys  usr

shiyanlou:~/ $ ls /home/                                                                    [22:10:13]
labex  project  shiyanlou
shiyanlou:~/ $ ls home                                                                      [22:11:05]
ls: 无法访问'home': 没有那个文件或目录
  • 2>err.log: 将错误信息输入到指定文件
shiyanlou:~/ $ abcd                                                                         [22:15:15]
zsh: command not found: abcd
shiyanlou:~/ $ abcd 2>err.log                                                               [22:16:26]
shiyanlou:~/ $ cat err.log                                                                  [22:16:43]
zsh: command not found: abcd

相关文章

  • 01.linux -- 常用命令

    history 查看历史命令 ssh 登录ssh jmzeng@192.168.0.100用户名@ip地址 su...

  • 七月 Linux从零入门实战 百度网盘分享

    01.Linux介绍02.Linux常用操作命令03.linux代码编辑器04.linux shell编程05.l...

  • 大数据学习书籍

    01.Linux学习(跟鸟哥学就ok了) 02.Java 高级学习(《深入理解Java虚拟机》、《Java高并发实...

  • 01.Linux简介与安装

    Linux简介 Linux简介:Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UN...

  • Day12 Linux指令

    01.linux系统介绍 02.远程连接 03.简单指令 04.ssh 05.目录结构 06.ls 07.vi、v...

  • day01.Linux、命令【python教程】

    01.Linux、命令 一、认识Linux 1.什么是操作系统 小红和小明通过聊天软件QQ进行通信,从此图能反应出...

  • 其他

    Git常用命令mac常用命令Linux 常用命令汇总Linux 常用命令0Linux 常用命令1--ls命令

  • Docker

    目录 常用命令 常用命令

  • Linux CentOS基础知识和常用命令

    常用命令1 常用命令2 常用命令3 常用命令4 Linux 目录配置 1、根目录(/)根目录(/)所在分区应该越小...

  • Shell命令汇总

    1、一般常用命令 (1)Shell 常用命令总结 (2)Shell的18条常用命令整理 2、文件操作常用命令 (1...

网友评论

      本文标题:01.linux -- 常用命令

      本文链接:https://www.haomeiwen.com/subject/xbbtprtx.html