Linux常用命令——OS实用命令

查看操作系统版本

[root@T-DB-1 ~]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)

查看主机名

[root@T-DB-1 ~]# hostname
T-DB-1

查看系统时间

[root@T-DB-1 ~]# date
Thu Jul 30 16:50:14 CST 2020

查看CPU、内存使用率

[root@T-DB-1 ~]# top
top - 16:04:39 up 96 days, 14:02,  1 user,  load average: 0.08, 0.08, 0.01
Tasks: 268 total,   1 running, 267 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.1%us,  0.3%sy,  0.0%ni, 98.2%id,  0.3%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3924440k total,  3684316k used,   240124k free,   413496k buffers
Swap:  8388600k total,   642880k used,  7745720k free,  2817368k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                         
16727 root      20   0 15160 1348  896 R  1.9  0.0   0:00.01 top                              
    1 root      20   0 19236  724  536 S  0.0  0.0   2:00.40 init                             
    2 root      20   0     0    0    0 S  0.0  0.0   0:03.41 kthreadd                         
    3 root      RT   0     0    0    0 S  0.0  0.0   1:11.43 migration/0                      
    4 root      20   0     0    0    0 S  0.0  0.0   0:30.90 ksoftirqd/0                      
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                      

查看内存和swap信息

[root@T-DB-1 ~]# free     //单位为K
             total       used       free     shared    buffers     cached
Mem:       3924440    3674372     250068          0     413684    2817444
-/+ buffers/cache:     443244    3481196
Swap:      8388600     642880    7745720

[root@T-DB-1 ~]# free -m     //单位为M
             total       used       free     shared    buffers     cached
Mem:          3832       3588        244          0        404       2751
-/+ buffers/cache:        432       3399
Swap:         8191        627       7564

查看当前工作目录

[root@T-DB-1 admin]# pwd
/u01/app/oracle/admin

复制剪切命令

复制:cp 源文件 目标文件
剪切:mv 源文件 目标文件

查看当前在线的用户

[root@T-DB-1 ~]# who
root     pts/1        2020-07-30 16:03 (172.1.2.12)

查看目录下的文件信息

[root@T-DB-1 u01]# ls   //列出文件信息
app  initesmskn.ora  linuxx64_12201_database.zip  lost+found

[root@EmerOraLinux-T-DB-1 u01]# ll   //列出文件详细信息
total 3372780
drwxr-xr-x 4 ora12c dba       4096 Jun  4 17:54 app
-rw-r----- 1 ora12c dba       1402 Jun  4 15:13 initesmskn.ora
-rw-r----- 1 ora12c dba 3453696911 Jun  4 10:26 linuxx64_12201_database.zip
drwx------ 2 ora12c dba      16384 Jun  4 10:21 lost+found

[root@T-DB-1 u01]# ls -la     //列出隐藏文件详细信息
total 3372788
drwxr-xr-x   4 ora12c dba        4096 Jun  4 17:44 .
dr-xr-xr-x. 42 root   root       4096 Jul 30 14:28 ..
drwxr-xr-x   4 ora12c dba        4096 Jun  4 17:54 app
-rw-r-----   1 ora12c dba        1402 Jun  4 15:13 initesmskn.ora
-rw-r-----   1 ora12c dba  3453696911 Jun  4 10:26 linuxx64_12201_database.zip
drwx------   2 ora12c dba       16384 Jun  4 10:21 lost+found

[root@EmerOraLinux-T-DB-1 u01]# ls -lt  //按时间倒序列出文件详细信息
total 3372780
drwxr-xr-x 4 ora12c dba       4096 Jun  4 17:54 app
-rw-r----- 1 ora12c dba       1402 Jun  4 15:13 initesmskn.ora
-rw-r----- 1 ora12c dba 3453696911 Jun  4 10:26 linuxx64_12201_database.zip
drwx------ 2 ora12c dba      16384 Jun  4 10:21 lost+found

[root@EmerOraLinux-T-DB-1 u01]# ls -lrt  //按时间顺序列出文件详细信息
total 3372780
drwx------ 2 ora12c dba      16384 Jun  4 10:21 lost+found
-rw-r----- 1 ora12c dba 3453696911 Jun  4 10:26 linuxx64_12201_database.zip
-rw-r----- 1 ora12c dba       1402 Jun  4 15:13 initesmskn.ora
drwxr-xr-x 4 ora12c dba       4096 Jun  4 17:54 app

搜索文件所在目录

语法:
find 路径 -name filename  //在指定路径下查找指定文件所在的目录
示例:
[root@T-DB-1 ~]# find / -name alert*.log
/u01/app/oracle/product/12.2.0/dbhome_1/rdbms/log/alert_acts.log
/u01/app/oracle/product/12.2.0/dbhome_1/rdbms/log/alert_cdbimp.log
/u01/app/oracle/diag/rdbms/cdbimp/cdbimp/trace/alert_cdbimp.log

查看进程信息

[root@T-DB-1 ~]# ps -ef|grep pmon
root     20413 19992  0 16:47 pts/1    00:00:00 grep pmon
ora12c   29440     1  0 Jun15 ?        00:06:22 ora_pmon_cdbimp

切换OS用户

示例:root用户切换为oracle用户
[root@T-DB-1 ~]# su - oracle
[oracle@T-DB-1 ~]$

查看软件安装目录

注释:需要用软件安装用户执行命令
[postgres@T-DB-1 ~]$ which pgpool
/PostgreSQL/pgpool/pgpool4.1.2/bin/pgpool

查看文件内容

1.vi test.sh    //可以进行编辑
  vim test.sh   //颜色区分不同内容
2.cat test.sh   //会显示test.sh的所有内容
3.more test.sh  //从头开始显示test.sh内容,按enter键继续查看  

你可能感兴趣的:(Linux,linux,运维)