Sunteți pe pagina 1din 5

RED HAT ENTERPRISE LINUX 5, 6, AND 7

Common administrative commands


1 Be aware of potential issues when using subscription-manager
on Red Hat Enterprise Linux 5: https://access.redhat.com/
solutions/129003.

SYSTEM BASICS
TASK

RHEL
/etc/sysconfig/rhn/systemid

View subscription information

/etc/sysconfig/rhn/systemid

subscription-manager identity

subscription-manager identity
rhn_register
subscription-manager

Configure subscription

6
2

sosreport
dmidecode
hwbrowser

View system profile

View RHEL version information

3 RHN tools are deprecated on Red Hat Enterprise Linux 7.


rhn_register should be used for Satellite server 5.6 and newer
only. For details, see: Satellite 5.6 unable to register RHEL 7
client system due to rhn-setup package not included in Minimal
installation (https://access.redhat.com/solutions/737373)

rhn_register
rhnreg_ks
subscription-manager
subscription-manager
rhn_register 3

2 Subscription-manager is used for Satellite 6, Satellite 5.6 with


SAM and newer, and Red Hats CDN.

TASK

sosreport
dmidecode
lstopo
lscpu
/etc/redhat-release

RESOURCE MANAGEMENT

top
ps
sar
iostat
netstat
vmstat
mpstat
numastat

BASIC CONFIGURATION
TASK

Graphical configuration tools

RHEL
system-config-*

6
7

gnome-control-center
system-config-network

Configure network

Configure system language

Configure time and date

system-config-language

Configure keyboard

7
5

7
5

timedatectl
date

View disk usage

timedatectl
/etc/chrony.conf
ntpdate
system-config-keyboard

top
ps
sar
iostat
netstat
ss
vmstat
mpstat
numastat
tuna

df

7
5

6
7

localectl

top
ps
sar
iostat
ss
vmstat
mpstat
numastat
tuna

localectl
system-config-date
date

View system usage

nmcli
nmtui
nm-connection-editor

ntpdate
/etc/ntp.conf

Synchronize time and date

RHEL

df
iostat

Trace system calls

strace

Trace library calls

ltrace

Change process
priority

nice
renice

Text-based configuration tools

system-config-*-tui

Configure printer

system-config-printer

Change process
run location

taskset

Configure SSH

/etc/ssh/ssh_config
/etc/ssh/sshd_config
~/.ssh/config ssh-keygen

Kill a process

kill
pkill
killall

SOFTWARE MANAGEMENT
TASK

NETWORKING
RHEL

yum install
yum groupinstall

TASK
iptables and ip6tables
/etc/sysconfig/ip*tables

Install software
yum install

yum group install


yum info
yum groupinfo

Configure
firewall

View software info


7

yum group info

Update software

yum update

Upgrade software

yum upgrade

Configure software
repository

subscription-manager repos
/etc/yum.repos.d/*.repo
rpm -qf filename

Find file in package

yum provides filename-glob

View software version

rpm -q packagename

View installed
software

rpm -qa
yum list installed

iptables and ip6tables


/etc/sysconfig/ip*tables
system-config-firewall

Configure
name
resolution

/etc/hosts
/etc/resolv.conf

/etc/sysconfig/network

Configure
hostname

View network
interface info

USER MANAGEMENT
RHEL

Graphical user
management

system-config-users

Create user account

useradd

Delete user account

userdel

/etc/passwd
vipw

id

Create user group

groupadd

Delete user group

groupdel

Change group details


Change user
password

groupmod
/etc/group
passwd

Change user
permissions

usermod

Change group
permissions

groupmod

visudo

visudo

View routes

7
5

6
7

ip addr
nmcli dev show
teamdctl
brctl
bridge

/etc/sysconfig/network-scripts/ifcfg-*
nmcli con [add|mod|edit]
nmtui
nm-connection-editor
ss
lsof
netstat

ss
lsof

ip route add
system-config-network
/etc/sysconfig/route-iface

Configure
routes

usermod

View/change user
account details

View ports/
sockets

hostnamectl
/etc/hostname
nmtui
ip addr
ifconfig
brctl

Configure
network
interface

/etc/hosts
/etc/resolv.conf
nmcli con mod

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

TASK

firewall-cmd
firewall-config

yum info

RHEL

ip route add
nmcli
nmtui
nm-connection-editor
/etc/sysconfig/route-iface
ip route

SECURITY AND IDENTITY


TASK

RHEL

Configure system
security

/etc/selinux/config
chcon
restorecon
semanage
setsebool
system-config-selinux

Report on system
security

sealert

Change password
policy

chage

LDAP, SSSD,
Kerberos

authconfig
authconfig-tui
authconfig-gtk

View user sessions

Network users

getent

JOBS AND SERVICES


TASK

RHEL
/etc/syslog.conf

5
6

/etc/rsyslog.conf

Configure logging

/etc/rsyslog.conf
/etc/rsyslog.d/*.conf
/var/log/journal
systemd-journald.service
chkconfig --list
ls /etc/init.d/

List all services

List running services

Start/stop service

Enable/disable service

View service status


Check if service is enabled
Create new service file or modify
configuration

View run level/target

Change run level/target

systemctl -at service


ls /etc/systemd/system/*.service
ls /usr/lib/systemd/system/*.service
service --status-all

7
5

6
7

systemctl -t service --state=active


service name start
service name stop

systemctl start name.service


systemctl stop name.service
chkconfig name on
chkconfig name off

7
5

systemctl enable name.service


systemctl disable name.service
service name status

7
5

6
7

systemctl status name.service


chkconfig name --list

6
7

systemctl is-enabled name


chkconfig --add

systemctl daemon-reload
/etc/systemd/system/*.service
runlevel
who -r

7
5

systemctl get-default
who -r
/etc/inittab
init run_level

7
5

systemctl isolate name.target


systemctl set-default
/var/log

View logs

7
5

/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 output

aureport /var/log/faillog

Schedule/batch tasks

cron
at
batch

Find file by name

locate

Find file by characteristic

find

Create archive

tar
cpio
zip

FILE SYSTEMS, VOLUMES, AND DISKS


TASK

RHEL
ext3

Default file system

5
6

ext4

xfs
copy data to new file system
fsck (look for non-contiguous inodes)

Defragment disk space

copy data to new file system


fsck (look for non-contiguous inodes)
xfs_fsr
fdisk
parted

Create/modify disk partitions

Create volume group

Enlarge volumes formatted with


default file system

Shrink volumes formatted with


default file system

Configure NFS share

7
5

6
7

6
7

lvcreate
ssm create (if backend is lvm)
vgextend
lvextend
resize2fs

vgextend
lvextend
xfs_growfs
ssm resize
resize2fs
lvreduce
vgreduce

XFS cannot currently be shrunk; copy desired data to


a smaller file system.
fsck

Check/repair file system

vgcreate
ssm create (if backend is lvm)
lvcreate

Create logical volume

pvcreate
ssm create (if backend is lvm)
vgcreate

7
5

fsck
ssm check
/etc/exports
service nfs reload

mount
/etc/fstab
ssm mount
pvcreate

Create physical volume

mkfs.filesystem_type (ext4, xfs)


mkswap
ssm create
mount
/etc/fstab

Mount storage

fdisk
gdisk
parted
ssm create
mkfs.filesystem_type (ext4, xfs)
mkswap

Format disk partition

7
5

/etc/exports
systemctl reload nfs.service

Mount and activate swap

/etc/fstab
swapon -a

Configure static mounts

/etc/fstab

FILE SYSTEMS, VOLUMES, AND DISKS (CONT.)


TASK

RHEL

View free disk space

df

View logical volume info

lvdisplay
lvs
vgdisplay
vgs
pvdisplay
pvs

View NFS share

showmount -e
mount

Configure on-demand auto-mounts

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

Change file permissions

chmod
chown
chgrp
umask (future file creation)

Change file attributes

chattr

Change access control list

setfacl

KERNEL, BOOT, AND HARDWARE


TASK

Single user/rescue mode

RHEL
append 1 or s or init=/bin/bash to kernel cmdline

Configure default run level/target

View hardware configured

7
5

6
7

6
7

reboot
systemctl reboot
/etc/inittab

7
5

systemctl set-default
/boot/grub/grub.conf

Configure GRUB bootloader

halt
systemctl halt
reboot

Reboot system

poweroff
systemctl poweroff
halt

Halt system

shutdown
systemctl shutdown
poweroff

Power off system

append rd.break or init=/bin/bash to kernel cmdline


shutdown

Shut down system

/etc/default/grub
grub2-mkconfig
grub-set-default
hwbrowser

7
5

lshw (in EPEL)

Configure kernel module

modprobe

Configure hardware device

udev

View kernel parameters

sysctl -a
cat /proc/cmdline

Load kernel module

modprobe

Remove kernel module

modprobe -r

View kernel version

rpm -q kernel
uname -r

11/14
Copyright 2014 Red Hat, Inc. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, and JBoss are trademarks of Red Hat, Inc.,
registered in the U.S. and other countries. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

S-ar putea să vă placă și