码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 基础一

时间:2020-10-05 21:59:07      阅读:31      评论:0      收藏:0      [点我收藏+]

标签:uname   oracl   only   执行   stderr   pcl   start   form   average   

Linux 常用命令

显示内核版本

[root@centos8 ~]# uname -r
4.18.0-147.el8.x86_64

显示操作系统发型版本

[root@centos8 ~]# cat /etc/centos-release
CentOS Linux release 8.1.1911 (Core)
[root@centos8 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

显示当前主机的名称

[root@centos8 ~]# hostname
centos8.1.abyss

显示CPU型号

[root@centos8 ~]# lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  2
Socket(s):           2
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               142
Model name:          Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Stepping:            11
CPU MHz:             1799.999
BogoMIPS:            3599.99
Hypervisor vendor:   VMware
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            6144K
NUMA node0 CPU(s):   0-3
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat flush_l1d arch_capabilities

显示内存大小

[root@centos8 ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:          1.9Gi       359Mi       882Mi       9.0Mi       722Mi       1.4Gi
Swap:         4.0Gi          0B       4.0Gi

查看硬盘和分区情况

[root@centos8 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        967M     0  967M   0% /dev
tmpfs           983M     0  983M   0% /dev/shm
tmpfs           983M  9.2M  974M   1% /run
tmpfs           983M     0  983M   0% /sys/fs/cgroup
/dev/sda2       100G  4.7G   96G   5% /
/dev/sda3        50G  390M   50G   1% /data
/dev/sda1       976M  123M  787M  14% /boot
/dev/sr0        7.1G  7.1G     0 100% /run/media/abyss/CentOS-8-1-1911-x86_64-dvd
[root@centos8 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part
└─sda5   8:5    0    4G  0 part [SWAP]
sr0     11:0    1    7G  0 rom  /run/media/abyss/CentOS-8-1-1911-x86_64-dvd

重启命令

init 6 
reboot
shudown -r show

关机命令

init 0
halt
pweroff
showdown -h now

显示日期和时间
date

[root@centos8 ~]# date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING          display time described by STRING, not ‘now‘
      --debug                annotate the parsed date,
                              and warn about questionable usage to stderr
  -f, --file=DATEFILE        like --date; once for each line of DATEFILE
  -I[FMT], --iso-8601[=FMT]  output date/time in ISO 8601 format.
                               FMT=‘date‘ for date only (the default),
                               ‘hours‘, ‘minutes‘, ‘seconds‘, or ‘ns‘
                               for date and time to the indicated precision.
                               Example: 2006-08-14T02:34:56-06:00
  -R, --rfc-email            output date and time in RFC 5322 format.
                               Example: Mon, 14 Aug 2006 02:34:56 -0600
      --rfc-3339=FMT         output date/time in RFC 3339 format.
                               FMT=‘date‘, ‘seconds‘, or ‘ns‘
                               for date and time to the indicated precision.
                               Example: 2006-08-14 02:34:56-06:00
  -r, --reference=FILE       display the last modification time of FILE
  -s, --set=STRING           set time described by STRING
  -u, --utc, --universal     print or set Coordinated Universal Time (UTC)
      --help     display this help and exit
      --version  output version information and exit

FORMAT controls the output.  Interpreted sequences are:

  %%   a literal %
  %a   locale‘s abbreviated weekday name (e.g., Sun)
  %A   locale‘s full weekday name (e.g., Sunday)
  %b   locale‘s abbreviated month name (e.g., Jan)
  %B   locale‘s full month name (e.g., January)
  %c   locale‘s date and time (e.g., Thu Mar  3 23:05:25 2005)
  %C   century; like %Y, except omit last two digits (e.g., 20)
  %d   day of month (e.g., 01)
  %D   date; same as %m/%d/%y
  %e   day of month, space padded; same as %_d
  %F   full date; same as %Y-%m-%d
  %g   last two digits of year of ISO week number (see %G)
  %G   year of ISO week number (see %V); normally useful only with %V
  %h   same as %b
  %H   hour (00..23)
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale‘s equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %q   quarter of year (1..4)
  %r   locale‘s 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab
  %T   time; same as %H:%M:%S
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale‘s date representation (e.g., 12/31/99)
  %X   locale‘s time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99)
  %Y   year
  %z   +hhmm numeric time zone (e.g., -0400)
  %:z  +hh:mm numeric time zone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)

By default, date pads numeric fields with zeroes.
The following optional flags may follow ‘%‘:

  -  (hyphen) do not pad the field
  _  (underscore) pad with spaces
  0  (zero) pad with zeros
  ^  use upper case if possible
  #  use opposite case if possible

After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
E to use the locale‘s alternate representations if available, or
O to use the locale‘s alternate numeric symbols if available.

Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
  $ date --date=‘@2147483647‘

Show the time on the west coast of the US (use tzselect(1) to find TZ)
  $ TZ=‘America/Los_Angeles‘ date

Show the local time for 9AM next Friday on the west coast of the US
  $ date --date=‘TZ="America/Los_Angeles" 09:00 next Fri‘

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation at: <https://www.gnu.org/software/coreutils/date>
or available locally via: info ‘(coreutils) date invocation‘

用户登录

[root@centos8 ~]# whoami
root
[root@centos8 ~]# who am i
root     pts/2        2020-10-05 09:50 (10.0.0.1)
[root@centos8 ~]# who
root     tty3         2020-09-22 19:24
root     tty4         2020-09-22 19:25
root     tty1         2020-09-22 20:17
root     pts/1        2020-09-25 14:20 (10.0.0.1)
root     pts/2        2020-10-05 09:50 (10.0.0.1)
[root@centos8 ~]# w
 10:06:46 up  4:02,  6 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty3     -                22Sep20 12days  0.86s  0.86s -bash
root     tty4     -                22Sep20 12days  0.03s  0.03s -bash
root     tty1     -                22Sep20 17:10   2.22s  2.22s -bash
root     pts/1    10.0.0.1         25Sep20  9days  0.07s  0.07s -bash
root     pts/2    10.0.0.1         09:50    6.00s  0.11s  0.00s w

显示字符
echo

[root@centos8 ~]# echo "hello"
hello
[root@centos8 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Linux三大主流发行版

Debian、RedHat、SUSE
Debian是包括Ubuntu在内的多发行版的上游

  • Debian是一个纯开源计划并重点关注稳定性
  • Debian三个版本分支:Stable,testing和unstable
  • Ubuntu是基于Debian的unstable 版本加强而来的
    RedHat Linux系列由红帽公司研发的linux发行版,包括Fedora、RHEL、CentOS和Oracle Linux多种版本

linux哲学思想

  • 一切皆文件
  • 提供很多小型的单一用途的程序
  • 连接程序,共同完成复杂功能
  • 避免令人困惑的用户界面
  • 配置数据存储在文本中

配置环境变量,实现执行history命令时可以看到执行命令时间

[root@centos8 ~]# cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

[root@centos8 ~]# export PATH
[root@centos8 ~]# export HISTCONTROL=ignoreboth
[root@centos8 ~]# export HISTTIMEFORMAT="%F %T"
[root@centos8 ~]# history
    1  2020-10-05 09:50:43cd /etc
    2  2020-10-05 09:50:43ls
    3  2020-10-05 09:50:43cat /etc/issue
    4  2020-10-05 09:50:43vi /etc/issue
    5  2020-10-05 09:50:43echo ¥SHELL

CentOS7 安装

Workstations 部分操作

技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
编辑虚拟机配置,插入ISO光盘:
技术图片
技术图片
启动虚拟机,Workstation部分结束。

CentOS 7 安装部分

Test OR install CentOS7
技术图片
技术图片

DATE & TIME:Aisa/shanghai
技术图片
技术图片
技术图片
技术图片
技术图片

Linux 基础一

标签:uname   oracl   only   执行   stderr   pcl   start   form   average   

原文地址:https://blog.51cto.com/abyssce/2540016

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!