Common administrative commands in Red Hat Enterprise Linux 5, 6, 7, and 8

Common administrative commands in Red Hat Enterprise Linux 5, 6, 7, and 8

System basics

TASK

View subscription information

/etc/sysconfig/rhn/systemid subscription-manager identity

Configure subscription

View system profile

rhnreg_ks

rhn_register 1, 3

subscription-manager 2

hwbrowser

sosreport dmidecode

lstopo lscpu

cat/proc/cpuinfo lshw

View RHEL version information

/etc/redhat-release

RHEL 56

678 6 5678 678 5 5678 678

8

5678

1 Be aware of potential issues when using subscription-manager on Red Hat Enterprise Linux 5: .

2 Subscription-manager is used for Satellite 6, Satellite 5.6 with SAM and newer, and Red Hat's 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: What subscription management services are offered by RHSM?, Transition of Red Hat Network Classic Hosted to Red Hat Subscription Management, and Satellite 5.6 unable to register RHEL 7 client system due to rhn-setup package not included in Minimal installation.

Security and identity

TASK

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

authselect

Network users getent

RHEL 5678

5678 567

8 5678

Basic configuration

TASK

Graphical configuration tools

system-config-* gnome-control-center

Text-based configuration tools

system-config-*-tui

Configure printer

Configure network

Configure system language

Configure time and date

Synchronize time and date

Configure keyboard

Configure SSH

system-config-printer

gnome-control-center

system-config-network

nmcli nmtui nm-connection-editor

gnome-control-center

system-config-language

localectl

gnome-control-center

system-config-date

timedatectl

date

gnome-control-center

/etc/ntp.conf

ntpdate

timedatectl /etc/chrony.conf

date chronyc

system-config-keyboard

localectl

gnome-control-center

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

RHEL 56 78

56

567 8

56

78

8 56

78 8

56 78

5678 8

56 567

78

8 56

78 8

5678

Jobs and services

TASK

RHEL

List all services

List running services

Start/stop service

Enable/ disable service

View service status Check if service is enabled

chkconfig --list ls /etc/init.d/

systemctl -at service ls /etc/systemd/system/*.service ls /usr/lib/systemd/system/*.

service

systemctl list-units -at service find /etc/systemd/ /usr/lib/

systemd/ /run/systemd/ -name *.service"

service --status-all

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

systemctl enable name.service systemctl disable name.service

service name status

systemctl status name.service

chkconfig name --list

56

7

8 56

78 56

78 56

78 56

78 56

systemctl is-enabled name

78

Create new service file or modify configuration

chkconfig --add

systemctl daemon-reload /etc/systemd/system/*.service

56 78

View run level/target

Change run level/target

Configure logging

View logs

Configure system audit

runlevel

systemctl get-default

who -r

/etc/inittab init run_level

systemctl isolate name.target systemctl set-default

/etc/syslog.conf

/etc/rsyslog.conf

/etc/rsyslog.d/*.conf /var/log/journal systemd-journald.service

journalctl

/var/log

pam_tty_audit kernel module

tlog

add audit=1 to kernel cmdline auditctl /etc/audit/auditd.conf /etc/audit/audit.rules authconfig /etc/pam.d/system-auth

56 78

5678 56

78 5

678

78

78 5678 567

8

5678

View audit output

aureport /var/log/faillog

567

Jobs and services (cont.)

TASK

Schedule/ batch tasks

cron at batch

systemd-run --on-calendar

Find file by name

locate

Find file by characteristic

find

Create archive

tar cpio zip xz

User management

TASK

Graphical user system-config-users management

gnome-control-center

Create user account

useradd gnome-control-center

Delete user account

userdel gnome-control-center

View/change user account details

usermod /etc/passwd vipw id

gnome-control-center

Create user group

groupadd gnome-control-center

Delete user group

groupdel gnome-control-center

Change group details

groupmod /etc/group

gnome-control-center

Change user password

passwd gnome-control-center

Change user permissions

usermod visudo

gnome-control-center

Change password policy

chage gnome-control-center

View user sessions

w gnome-control-center

RHEL 5678 8 5678

5678

5678

RHEL 567 8 567 8 567 8

567

8 567

8 567

8 567

8 567

8 567

8 567

8 567

8

Software management

TASK

Install software

yum groupinstall yum group install yum install

View software info

yum groupinfo yum group info yum info

Update software

yum update

RHEL 56 78 5678 56 78 5678

5678

Upgrade software

yum upgrade

5678

Configure software repository

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

5678

Find package rpm -qf filename

owning file

yum provides filename-glob

5678

View software version

rpm -q packagename

yum list installed packagename rpm -q packagename

View installed rpm -qa

software

yum list installed

56 78

5678

Install a module

yum module install module_name

8

View info on a module

yum module info module_name

8

View a

module's

yum module info module_name

8

streams

yum module remove

Change

module_name:stream

module

yum module reset module:stream

8

streams

yum module install

module:new_stream

List available modules

yum module list

8

Kernel, boot, and hardware

TASK

RHEL

Single user/ rescue mode

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

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

56 78

Shut down system

shutdown

5678

Power off system

Halt system

Reboot system

Configure default run level/target

systemctl poweroff poweroff systemctl halt halt systemctl reboot reboot /etc/inittab systemctl set-default

78 5678

78 5678

78 5678 56

78

Configure GRUB bootloader

/boot/grub/grub.conf

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

View hardware configured

hwbrowser lshw (in EPEL) lshw

Configure kernel module

modprobe

56 78

5 67 8

5678

Configure

hardware

udev

device

5678

View kernel parameters

sysctl -a cat /proc/cmdline

5678

Load kernel module

modprobe

5678

Remove kernel module

modprobe -r

5678

View kernel version

rpm -q kernel uname -r

5678

File systems, volumes, and disks

TASK

RHEL

Default file system

Create/ modify disk partitions

Format disk partition

Defragment disk space

Mount storage

ext3

ext4

xfs

ssm create

gdisk

ssm_create

fdisk parted

ssm create

mkfs.filesystem_type (ext4, xfs) mkswap

xfs_fsr

copy data to new file system fsck (look for `non-contiguous

inodes')

ssm mount

mount /etc/fstab

5 6 78 7 78 8

5678 78

5678 678

5678

78 5678

Mount and

/etc/fstab

activate swap swapon -a

5678

Configure static mounts

/etc/fstab

5678

View free disk space

df

View logical volume info

Create physical volume

lvdisplay lvs vgdisplay vgs pvdisplay pvs

ssm create (if backend is lvm)

pvcreate

5678

5678 8

5678

Create volume ssm create (if backend is lvm)

group

vgcreate

Create logical volume

ssm create (if backend is lvm) lvcreate

Enlarge volumes formatted with default file system

Shrink volumes formatted with default file system

resize2fs

xfs_growfs ssm resize

vgextend lvextend

resize2fs lvreduce vgreduce

XFS cannot currently be shrunk; copy desired data to a smaller file system.

Check/repair file system

ssm check fsck

8 5678

8 5678 56

78 5678

56

78 8

5678

File systems, volumes, and disks (cont.)

TASK

RHEL

View NFS share

showmount -e mount

5678

Configure NFS share

Configure on-demand auto-mounts

Change file permissions

Change file attributes

service nfs reload systemctl reload nfs.service /etc/exports

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

chmod chown chgrp umask (future file creation)

chattr

56 78

5678 8

8

8

Change

access

setfacl

8

control list

Resource management

TASK

Trace system

calls

strace

Trace library calls

ltrace

Change process priority

nice renice

Change process run location Kill a process

View system usage

View disk usage

taskset

kill pkill killall

netstat

ss tuna

pcp atop

top ps sar iostat vmstat mpstat numastat

iostat

pcp-dstat pmiostat

df

RHEL 5678 5678

5678

5678

5678 56

678 8

5678

678 8

5678

Networking

TASK

Configure name resolution

nmcli con mod

/etc/hosts /etc/resolv.conf

Configure hostname

/etc/sysconfig/network

hostnamectl /etc/hostname nmtui

ifconfig

View network interface info

Configure network interface

nmcli dev show teamdctl bridge

ip addr brctl

nmcli con [add|mod|edit] nmtui nm-connection-editor

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

View routes

ip route

Configure routes

Configure firewall

View ports/ sockets

system-config-network

nmcli nmtui nm-connection-editor

ip route add /etc/sysconfig/route-iface

iptables and ip6tables /etc/sysconfig/ip*tables

system-config-firewall

firewall-cmd firewall-config

nftables

pcp-dstat--socket

ss lsof netstat

RHEL 78

5678 56

78 56

78

5678

78

5678 5678 56

78

5678 56

6 78 8 8

5678

5/19

Copyright ? 2019 Red Hat, Inc. Red Hat, Red Hat Enterprise Linux, the Red Hat logo, and JBoss are trademarks or registered trademarks of Red Hat, Inc. or its subsidiaries in the United States and other countries. Linux? is the registered trademark of Linus Torvalds in the U.S. and other countries.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download