Vous êtes sur la page 1sur 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 1

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


SAM and newer, and Red Hats CDN.
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

Configure subscription

rhnreg_ks
subscription-manager
subscription-manager 2

rhn_register 3
sosreport
dmidecode

hwbrowser

View system profile

RESOURCE MANAGEMENT

sosreport
dmidecode
lstopo

TASK

lscpu

View RHEL version information

/etc/redhat-release

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

View system usage

nmcli

nmtui
nm-connection-editor

Configure system language

system-config-language

system-config-date

Configure time and date

date

7
5

timedatectl

date
ntpdate
/etc/ntp.conf

Synchronize time and date

View disk usage

timedatectl

/etc/chrony.conf
ntpdate

Configure keyboard

system-config-keyboard

top
ps
sar
iostat
netstat
ss
vmstat
mpstat
numastat
tuna

df

6
7

localectl

top
ps
sar
iostat
ss
vmstat
mpstat
numastat
tuna

localectl

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

Kill a process

kill
pkill
killall

/etc/ssh/ssh_config

Configure SSH

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

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

View software
info

yum groupinfo

Update software

yum update

Upgrade software

yum upgrade

Find file in
package
View software
version
View installed
software

subscription-manager repos
/etc/yum.repos.d/*.repo

rpm -qf filename


yum provides filename-glob

rpm -q packagename

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

Configure
network
interface
RHEL

system-config-users

Create user
account

useradd

Delete user
account

userdel

usermod

View/change user
account details

/etc/passwd
vipw

View ports/
sockets

id

Create user group

groupadd

Delete user group

groupdel

Change group
details

groupmod

Change user
password

/etc/group

passwd

Change user
permissions

usermod

Change group
permissions

groupmod

visudo

visudo

Change password
policy

chage

View user
sessions

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

hostnamectl
/etc/hostname
nmtui
ip addr
ifconfig
brctl

USER MANAGEMENT
Graphical user
management

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

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

TASK

firewall-cmd
firewall-config

yum group info

Configure
software
repository

Configure
firewall

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

LDAP, SSSD,
Kerberos

authconfig
authconfig-tui
authconfig-gtk

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

ext4

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

Defragment disk space

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

copy data to new file system


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

Create/modify disk partitions

7
5

/etc/exports
systemctl reload nfs.service

Mount and activate swap

/etc/fstab
swapon -a

Configure static mounts

/etc/fstab

View free disk space

df

FILE SYSTEMS, VOLUMES, AND DISKS (CONT.)


TASK

RHEL

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

6
7

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


shutdown

Shut down system

Configure default run level/target

View hardware configured

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

7
5

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