RHEL5/6/7中常用命令及命令之间的差异

 

System basics

TaskRHEL5RHEL6RHEL7
View subscription information/etc/sysconfig/rhn/systemid

/etc/sysconfig/rhn/systemid

subscription-manager identity

subscription-manager identity
Configure subscription

rhn_register

subscription-manager 1

rhn_register

rhnreg_ks

subscription-manager

subscription-manager2

rhn_register 3

View RHEL version information/etc/redhat-release
View system profile

sosreport

dmidecode

hwbrowser

sosreport

dmidecode

lstopo

lscpu

Basic configuration

TaskRHEL5RHEL6RHEL7
Graphical configuration toolssystem-config-*gnome-control-center
Text-based configuration toolssystem-config-*-tui 
Configure printersystem-config-printer
Configure networksystem-config-network

nmcli

nmtui

nm-connection-editor

Configure system languagesystem-config-languagelocalectl
Configure time and date

system-config-date

date

timedatectl

date

Synchronize time and date

ntpdate

/etc/ntp.conf

timedatectl

/etc/chrony.conf

ntpdate
Configure keyboardsystem-config-keyboardlocalectl
Configure SSH

/etc/ssh/ssh_config

/etc/ssh/sshd_config

~/.ssh/config ssh-keygen

Jobs and services

TaskRHEL5RHEL6RHEL7
List all services

chkconfig --list

ls /etc/init.d/

systemctl -at service

ls /etc/systemd/system/*.service

ls /usr/lib/systemd/system/*.service

List running servicesservice --status-allsystemctl -t service --state=active
Start/stop service

service name start

service name stop

systemctl start name.service

systemctl stop name.service

Enable/disable service

chkconfig name on

chkconfig name off

systemctl enable name.service

systemctl disable name.service

View service statusservice name statussystemctl status name.service
Check if service is enabledchkconfig name --listsystemctl is-enabled name
Create new service file or modify configurationchkconfig --add

systemctl daemon-reload

/etc/systemd/system/*.service

View run level/target

runlevel

who -r

systemctl get-default

who -r

Change run level/target

/etc/inittab

init run_level

systemctl isolate name.target

systemctl set-default

Configure logging/etc/syslog.conf/etc/rsyslog.conf

/etc/rsyslog.conf

/etc/rsyslog.d/*.conf

/var/log/journal

systemd-journald.service

View logs/var/log

/var/log

journalctl

Configure system audit

add audit=1 to kernel cmdline

auditctl

/etc/audit/auditd.conf

/etc/audit/audit.rules

authconfig

/etc/pam.d/system-auth

pam_tty_audit kernel module

View audit outputaureport /var/log/faillog
Schedule/batch tasks

cron

at

batch

Find file by namelocate
Find file by characteristicfind
Create archive

tar

cpio

zip

Kernel, boot, and hardware

TaskRHEL5RHEL6RHEL7
Single user/rescue modeappend 1 or s or init=/bin/bash to kernel cmdlineappend rd.break or init=/bin/bash to kernel cmdline
Shut down systemshutdown
Power off systempoweroff

poweroff

systemctl poweroff

Halt systemhalt

halt

systemctl halt

Reboot systemreboot

reboot

systemctl reboot

Configure default run level/target/etc/inittabsystemctl set-default
Configure GRUB bootloader/boot/grub/grub.conf

/etc/default/grub

grub2-mkconfig

grub-set-default

Configure kernel modulemodprobe
View hardware configuredhwbrowserlshw (in EPEL)
Configure hardware deviceudev
View kernel parameters

sysctl -a

cat /proc/cmdline

Load kernel modulemodprobe
Remove kernel modulemodprobe -r
View kernel version

rpm -q kernel

uname -r

Software management

TaskRHEL5RHEL6RHEL7
Install software

yum install

yum groupinstall

yum install

yum group install

View software info

yum info

yum groupinfo

yum info

yum group info

Update softwareyum update
Upgrade softwareyum upgrade
Configure software repository

subscription-manager repos

/etc/yum.repos.d/*.repo

Find package owning file

rpm -qf filename

yum provides filename-glob

View software versionrpm -q packagename
View installed software

rpm -qa

yum list installed

User management

TaskRHEL5RHEL6RHEL7
Graphical user managementsystem-config-users
Create user accountuseradd
Delete user accountuserdel
View/change user account details

usermod

/etc/passwd

vipw

id
Create user groupgroupadd
Delete user groupgroupdel
Change group details

groupmod

/etc/group

Change user passwordpasswd
Change user permissions

usermod

visudo

Change group permissions

groupmod

visudo

Change password policychage
View user sessionsw

File systems, volumes, and disks

TaskRHEL5RHEL6RHEL7
Default file systemext3ext4xfs
Create/modify disk partitions

fdisk

parted

fdisk

gdisk

parted

ssm create

Format disk partition

mkfs.filesystem_type (ext4, xfs)

mkswap

mkfs.filesystem_type (ext4, xfs)

mkswap

ssm create

Defragment disk space

copy data to new file system

fsck (look for 'non-contiguous inodes')

copy data to new file system

fsck (look for 'non-contiguous inodes')

xfs_fsr

Mount storage

mount

/etc/fstab

mount

/etc/fstab

ssm mount

Mount and activate swap

/etc/fstab

swapon -a

Configure static mounts/etc/fstab
View free disk spacedf
View logical volume info

lvdisplay

lvs

vgdisplay

vgs

pvdisplay

pvs
Create physical volumepvcreate

pvcreate

ssm create (if backend is lvm)

Create volume groupvgcreate

vgcreate

ssm create (if backend is lvm)

Create logical volumelvcreate

lvcreate

ssm create (if backend is lvm)

Enlarge volumes formatted with default file system

vgextend

lvextend

resize2fs

vgextend

lvextend

xfs_growfs

ssm resize

Shrink volumes formatted with default file system

resize2fs

lvreduce

vgreduce

XFS cannot currently be shrunk; copy desired data to a smaller file system.
Check/repair file systemfsck

fsck

ssm check

View NFS share

showmount -e

mount
Configure NFS share

/etc/exports

service nfs reload

/etc/exports

systemctl reload nfs.service

Configure on-demand auto-mounts

/etc/auto.master.d/*.autofs

/etc/auto.*

Change file permissions

chmod

chown

chgrp

umask (future file creation)

Change file attributeschattr
Change access control listsetfacl

Networking

TaskRHEL5RHEL6RHEL7
Configure name resolution

/etc/hosts

/etc/resolv.conf

/etc/hosts

/etc/resolv.conf

nmcli con mod

Configure hostname/etc/sysconfig/network

hostnamectl

/etc/hostname

nmtui

View network interface info

ip addr

ifconfig

brctl

ip addr

nmcli dev show

teamdctl

brctl

bridge
Configure network interface/etc/sysconfig/network-scripts/ifcfg-*

/etc/sysconfig/network-scripts/ifcfg-*

nmcli con [add|mod|edit]

nmtui

nm-connection-editor

View routesip route
Configure routes

ip route add

system-config-network

/etc/sysconfig/route-iface

ip route add

nmcli

nmtui

nm-connection-editor

/etc/sysconfig/route-iface

Configure firewall

iptables and ip6tables

/etc/sysconfig/ip*tables

iptables and ip6tables

/etc/sysconfig/ip*tables

system-config-firewall

firewall-cmd

firewall-config

View ports/sockets

ss

lsof

netstat

ss

lsof

Security and identity

TaskRHEL5RHEL6RHEL7
Configure system security

/etc/selinux/config

chcon

restorecon

semanage

setsebool

system-config-selinux

Report on system securitysealert
LDAP, SSSD, Kerberos

authconfig

authconfig-tui

authconfig-gtk

Network usersgetent

Resource management

TaskRHEL5RHEL6RHEL7
Trace system callsstrace
Trace library callsltrace
Change process priority

nice

renice

Change process run locationtaskset
Kill a process

kill

pkill

killall

View system usage

top

ps

sar

iostat

netstat

vmstat

mpstat

numastat

top

ps

sar

iostat

netstat

ss

vmstat

mpstat

numastat

tuna

top

ps

sar

iostat

ss

vmstat

mpstat

numastat

tuna

View disk usagedf

df

iostat

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值