码迷,mamicode.com
首页 > 其他好文 > 详细

第一周1~2练习

时间:2020-03-23 00:18:48      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:mamicode   sda   absolute   zone   ptime   iptables   script   tar   ted   

1、计算器

[17:23:31 root@Centos8 ~]#bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty‘. 
ibase=2
110
6
^C
(interrupt) Exiting bc.
[17:24:08 root@Centos8 ~]#bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty‘. 
obase=2
255
11111111

2、别名

[18:10:22 root@Centos8 network-scripts]#type cdnet
-bash: type: cdnet: not found
[18:10:35 root@Centos8 network-scripts]#alias cdnet="cd /etc/sysconfig/network-scrips"
[18:12:56 root@Centos8 network-scripts]#alias cdnet
alias cdnet=‘cd /etc/sysconfig/network-scrips‘
[18:13:13 root@Centos8 network-scripts]#unalias cdnet
[18:13:40 root@Centos8 network-scripts]#cdnet
bash: cdnet: command not found...


技术图片

注意:\和 ‘ ’可以屏蔽别名启用命令原始功能。

3、防火墙

21:37:22 root@Centos8 ~]#systemctl disable firewalld service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[21:40:22 root@Centos8 ~]#systemctl stop firewalld service
[21:41:26 root@Centos8 ~]#iptables -vnL
Chain INPUT (policy ACCEPT 55 packets, 3640 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 33 packets, 3124 bytes)
 pkts bytes target     prot opt in     out     source               destination   
 

4、查看 CPU、内存、硬盘信息、内核版本、发行版本

[21:41:43 root@Centos8 ~]#lscpu
[21:57:23 root@Centos8 ~]#cat /proc/cpuinfo

[21:59:57 root@Centos8 ~]#free -h
[22:01:32 root@Centos8 ~]#cat /proc/meminfo

[21:58:43 root@Centos8 ~]#lsblk
[21:59:26 root@Centos8 ~]#cat /proc/partitions

[22:01:43 root@Centos8 ~]#uname -r
4.18.0-147.el8.x86_64
[19:51:27 liu@ubuntu1804 ~]$uname -r
4.15.0-76-generic
[22:08:07 root@Centos7 ~]#uname -r
3.10.0-1062.el7.x86_64
[22:05:48 root@Centos6 ~]#uname -r
2.6.32-754.el6.x86_64

[22:03:22 root@Centos8 ~]#cat /etc/redhat-release
[22:23:34 root@Centos8 ~]#lsb_release -a
[22:27:08 liu@ubuntu1804 ~]$lsb_release -a
[22:26:53 liu@ubuntu1804 ~]$cat /etc/issue
[22:03:54 liu@ubuntu1804 ~]$cat /etc/os-release

5、时间

[22:36:21 root@Centos8 ~]#date +%s
1584801389				          		`距离1970年1月1号凌晨的秒数`
[22:36:29 root@Centos8 ~]#date -d@1584801389
Sat Mar 21 22:36:29 CST 2020
[22:36:55 root@Centos8 ~]#date 082122372020.50
Fri Aug 21 22:37:50 CST 2020
[22:37:50 root@Centos8 ~]#clock
2020-03-21 22:38:42.382658+08:00
[22:38:10 root@Centos8 ~]#clock -s 		`以硬件时间校准系统时间`
[22:39:25 root@Centos8 ~]#date
Sat Mar 21 22:39:29 CST 2020
[22:39:29 root@Centos8 ~]#date 082122402020.50
Fri Aug 21 22:40:50 CST 2020
[22:40:50 root@Centos8 ~]#clock -w		`以系统时间校准硬件时间`
[22:41:01 root@Centos8 ~]#clock
2020-08-21 22:41:07.071379+08:00

[22:42:04 root@Centos8 ~]#uptime		 `系统开机多少时间`
 22:47:11 up  3:40,  1 user,  load average: 0.00, 0.00, 0.00

6、时区

[22:51:22 root@Centos8 ~]#timedatectl list-timezones  			`列出所有时区`
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
.............
[22:54:39 root@Centos8 ~]#ll /etc/localtime       				`显示当地时区`
lrwxrwxrwx. 1 root root 35 Mar 19 16:48 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
22:57:27 root@Centos8 ~]#timedatectl set-timezone Africa/Abidjan	`更改时区`

7、日历

[22:58:20 root@Centos8 ~]#cal 2020
                               2020                               

       January               February                 March       
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
          1  2  3  4                      1    1  2  3  4  5  6  7
 5  6  7  8  9 10 11    2  3  4  5  6  7  8    8  9 10 11 12 13 14
12 13 14 15 16 17 18    9 10 11 12 13 14 15   15 16 17 18 19 20 21
19 20 21 22 23 24 25   16 17 18 19 20 21 22   22 23 24 25 26 27 28
26 27 28 29 30 31      23 24 25 26 27 28 29   29 30 31            
..............

[23:02:34 root@Centos8 ~]#cal 9 1752
   September 1752   
Su Mo Tu We Th Fr Sa
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

技术图片

8、范例:比较 “ ” ,‘ ’, ``三者区别

[23:02:19 root@Centos8 ~]#echo "echo $HOSTNAME"		# "" 只能识别变量,弱引用;

echo Centos8.mashimaro.org

[23:02:42 root@Centos8 ~]#echo ‘echo $HOSTNAME‘		# ‘‘ 不识别变量和命令,强引用;

echo $HOSTNAME

[23:03:07 root@Centos8 ~]#echo `echo $HOSTNAME`		# `` 可以识别变量和命令。

Centos8.mashimaro.org

9、Centos8远程登录

[23:04:22 root@Centos8 ~]#systemctl disable firewalld
[23:17:42 root@Centos8 ~]#systemctl enable --now cockpit.socket
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket → /usr/lib/systemd/system/cockpit.socket.
[23:18:15 root@Centos8 ~]#ss -ntlp

技术图片
技术图片

10、liunx和windows互传文件

技术图片
技术图片

技术图片

技术图片

11、misc 目录

[22:10:07 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  
[22:13:01 root@Centos8 ~]#ls /misc
ls: cannot access ‘/misc‘: No such file or directory
[22:15:07 root@Centos8 ~]#systemctl status autofs
Unit autofs.service could not be found.
[22:20:27 root@Centos8 ~]#yum -y install autofs    #autofs 服务需要安装

[22:30:16 root@Centos8 ~]#cd /misc/cd
[22:30:40 root@Centos8 cd]#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  /misc/cd



技术图片

注意:如上第三行的绿色部分不是enabled,需要执行systemctl enabled --now autofs

或者systemctl start autofs和systemctl enabled autofs

第一周1~2练习

标签:mamicode   sda   absolute   zone   ptime   iptables   script   tar   ted   

原文地址:https://www.cnblogs.com/Mashimaro19/p/12549250.html

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