首页 技术 正文
技术 2022年11月21日
0 收藏 874 点赞 2,626 浏览 4190 个字

查看网卡命令

[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:2c:7b:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.182.136/24 brd 192.168.182.255 scope global dynamic ens32
valid_lft 1474sec preferred_lft 1474sec
inet6 fe80::d323:fa:581f:5e96/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]#   

重启网卡命令:

systemctl restart network.service

修改主机名

# 临时生效
hostname centos7
# 编辑配置文件/etc/hostname
# 以下命令可以直接修改配置文件
hostnamectl set-hostname centos7

操作:

[root@localhost ~]# hostnamectl set-hostname centos7
[root@localhost ~]# hostnamectl status
Static hostname: centos7
Icon name: computer-vm
Chassis: vm
Machine ID: c981bff1414443848dc72e55d6f69e26
Boot ID: 338c4215248c40598401ca7fa697636e
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.el7.x86_64
Architecture: x86-64
[root@localhost ~]# hostname
centos7
[root@localhost ~]# cat /etc/hostname
centos7

修改字符集

# 两种方法
localectl set-locale LANG=zh_CN.UTF-8编辑/etc/locale.conf

操作:

[root@localhost ~]# localectl set-locale LANG=zh_CN.UTF-8
[root@localhost ~]# cat /etc/locale.conf
LANG=zh_CN.UTF-8
[root@localhost ~]# localectl status
System Locale: LANG=zh_CN.UTF-8
VC Keymap: us
X11 Layout: us
[root@centos7 ~]# echo $LANG
zh_CN.UTF-8

更改系统时间

[root@centos7 ~]# date
2017年 11月 02日 星期四 12:02:26 CST
[root@centos7 ~]# timedatectl set-time "2017-11-02 12:01:01"
[root@centos7 ~]# timedatectl status
Local time: 四 2017-11-02 12:01:12 CST
Universal time: 四 2017-11-02 04:01:12 UTC
RTC time: 四 2017-11-02 04:01:12
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@centos7 ~]#

更改系统时区

/usr/bin/timedatectl list-timezones # 列出所有时区
/usr/bin/timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海

查看系统版本号

查看系统版本号:

cat /etc/redhat-release 

所有支持systemd系统的统一发行版名称和版本号文件:

cat /etc/os-release

操作:

[root@centos7 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@centos7 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

查看系统启动级别

文件查看

cat /etc/inittab

命令查看当前启动级别

systemctl get-default

设置启动级别

# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5systemctl set-default multi-user.target

操作:

[root@centos7 ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
[root@centos7 ~]# systemctl get-default
multi-user.target
[root@centos7 ~]# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

管理服务

systemctl:融合service和chkconfig的功能于一体,兼容sysV和LSB得启动脚本,而且能够在进程启动过程中更有效地引导加载服务。

CentOS7系统基本操作

CentOS7系统基本操作

获取云主机外网IP地址

echo "`curl -s myip.ipip.net | awk -F " " '{print $2}'|awk -F":" '{print $2}'`_`hostname`" > /etc/hostname

设置开机启动

针对svn,nginx每次重启后均要手工启动,好麻烦,所以考虑将其做成开机启动,做成服务好麻烦,考虑像windows 一样,放在某个启动项中完成。

打开启动文件后,发现里面文件内容如下:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

意思很简单,需要将此文件权限改为可执行的,这也是为何开机后此文件不能执行的原因

操作步骤:

a. 添加可执行权限:
# chmod +x /etc/rc.d/rc.localb. 打开文件rc.local:
# vim /etc/rc.d/rc.localc. 在文件rc.local末添加开机应启动的脚本:
svnserve -d -r /var/svn
/usr/nginx/sbin/nginxd. 重启机器,验证svn和nginx已经启动成功
# reboot
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,994
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,508
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,351
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,135
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,768
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,846