RED HAT ENTERPRISE 5, 6, AND 7 Common administrative commands

1 Be aware of potential issues when using subscription-manager SYSTEM BASICS on Red Hat Enterprise Linux 5: https://access.redhat.com/ solutions/129003. TASK RHEL 2 Subscription-manager is used for Satellite 6, Satellite 5.6 with SAM and newer, and Red Hat’s CDN. /etc/sysconfig/rhn/systemid 5 3 RHN tools are deprecated on Red Hat Enterprise Linux 7. rhn_register should be used for Satellite server 5.6 and newer /etc/sysconfig/rhn/systemid View subscription information 6 only. For details, see: Satellite 5.6 unable to register RHEL 7 subscription-manager identity client system due to rhn-setup package not included in Minimal installation (https://access.redhat.com/ subscription-manager identity 7 solutions/737373) rhn_register 5 subscription-manager 1

rhn_register Configure subscription rhnreg_ks 6 subscription-manager

2 subscription-manager 7 rhn_register 3

sosreport dmidecode 5 hwbrowser View system profile sosreport RESOURCE MANAGEMENT dmidecode 6 7 lstopo TASK RHEL lscpu top View RHEL version information /etc/redhat-release 5 6 7 sar iostat 5 netstat vmstat mpstat BASIC CONFIGURATION numastat TASK RHEL top ps system-config-* 5 6 sar Graphical configuration tools iostat gnome-control-center 7 netstat 6 ss system-config-network 5 6 View system usage vmstat nmcli mpstat Configure network numastat nmtui 7 tuna -connection-editor top system-config-language 5 6 ps Configure system language sar localectl 7 iostat ss 7 system-config-date 5 6 vmstat date mpstat Configure and date numastat timedatectl 7 tuna date 5 ntpdate 5 6 View disk usage /etc/ntp.conf df 6 7 iostat Synchronize time and date timedatectl /etc/chrony.conf 7 Trace system calls strace 5 6 7 ntpdate Trace library calls ltrace 5 6 7 system-config-keyboard 5 6 Configure keyboard Change process localectl 7 5 6 7 priority renice Text-based configuration tools system-config-*-tui 5 6 7 Change process taskset 5 6 7 Configure printer system-config-printer 5 6 7 run location

/etc/ssh/ssh_config Configure SSH /etc/ssh/sshd_config 5 6 7 Kill a process pkill 5 6 7 ~/.ssh/config ssh-keygen killall SOFTWARE MANAGEMENT NETWORKING

TASK RHEL TASK RHEL

yum install iptables and ip6tables 5 6 5 yum groupinstall /etc/sysconfig/ip*tables Install software iptables and ip6tables yum install Configure 7 /etc/sysconfig/ip*tables 6 yum group install firewall system-config-firewall

yum info firewall-cmd 5 6 7 View software yum groupinfo firewall-config info /etc/hosts yum info 5 6 7 /etc/resolv.conf yum group info Configure name /etc/hosts Update software yum update 5 6 7 resolution /etc/resolv.conf 7 nmcli con mod Upgrade software yum upgrade 5 6 7 /etc/sysconfig/network 5 6 Configure Configure hostnamectl subscription-manager repos hostname software 5 6 7 /etc/hostname 7 /etc/yum.repos.d/*.repo repository nmtui ip addr in rpm -qf filename 5 6 7 ifconfig 5 6 package yum provides filename-glob brctl View network View software ip addr rpm -q packagename 5 6 7 interface info nmcli dev show version teamdctl 7 brctl rpm -qa View installed 5 6 7 bridge software yum list installed /etc/sysconfig/network-scripts/ifcfg-* 5 6 Configure /etc/sysconfig/network-scripts/ifcfg-* network nmcli con [add|mod|edit] interface 7 USER MANAGEMENT nmtui nm-connection-editor

TASK RHEL ss lsof 5 6 Graphical user View ports/ system-config-users 5 6 7 netstat management sockets ss 7 Create user lsof useradd 5 6 7 account ip route add system-config-network 5 6 Delete user /etc/sysconfig/route-iface userdel 5 6 7 account Configure ip route add routes usermod nmcli nmtui 7 View/change user /etc/passwd 5 6 7 nm-connection-editor account details vipw /etc/sysconfig/route-iface id View routes ip route 5 6 7 Create user group groupadd 5 6 7

Delete user group groupdel 5 6 7 SECURITY AND IDENTITY Change group groupmod 5 6 7 details /etc/group TASK RHEL

Change user /etc/selinux/config passwd 5 6 7 password chcon Configure system restorecon 5 6 7 Change user usermod security semanage 5 6 7 permissions visudo setsebool system-config-selinux Change group groupmod 5 6 7 Report on system permissions visudo sealert 5 6 7 security

Change password authconfig chage 5 6 7 LDAP, SSSD, policy authconfig-tui 5 6 7 Kerberos authconfig-gtk View user w 5 6 7 sessions Network users getent 5 6 7 JOBS AND SERVICES

TASK RHEL

/etc/syslog.conf 5

/etc/rsyslog.conf 6

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

chkconfig --list 5 6 /etc/init.d/

List all services systemctl - service ls /etc/systemd/system/*.service 7 ls /usr/lib/systemd/system/*.service

service --status-all 5 6 List running services systemctl -t service --state=active 7

service name start 5 6 service name stop Start/stop service systemctl start name.service 7 systemctl stop name.service

chkconfig name on 5 6 chkconfig name off Enable/disable service systemctl enable name.service 7 systemctl disable name.service

service name status 5 6 View service status systemctl status name.service 7

chkconfig name --list 5 6 Check if service is enabled systemctl is-enabled name 7

chkconfig --add 5 6 Create new service file or modify systemctl daemon-reload configuration 7 /etc/systemd/system/*.service

runlevel 5 6 -r View run level/target systemctl get-default 7 who -r

/etc/inittab 5 6 init run_level Change run level/target systemctl isolate name.target 7 systemctl set-default

/var/log 5 6

View logs /var/log 7 journalctl

add audit=1 to kernel cmdline auditctl /etc/audit/auditd.conf Configure system audit /etc/audit/audit.rules 5 6 7 authconfig /etc/pam.d/system-auth pam_tty_audit kernel module

View audit output aureport /var/log/faillog 5 6 7

Schedule/batch tasks at 5 6 7 batch

Find file by name locate 5 6 7

Find file by characteristic find 5 6 7

tar Create archive cpio 5 6 7 zip FILE SYSTEMS, VOLUMES, AND DISKS

TASK RHEL

5

Default file system 6

7

copy data to new file system 5 fsck (look for ‘non-contiguous inodes’)

Defragment disk space copy data to new file system fsck (look for ‘non-contiguous inodes’) 6 7 xfs_fsr

fdisk 5 6 parted

Create/modify disk partitions fdisk gdisk 7 parted ssm create

mkfs.filesystem_type (ext4, xfs) 5 6 mkswap

Format disk partition mkfs.filesystem_type (ext4, xfs) mkswap 7 ssm create

5 6 /etc/fstab

Mount storage mount /etc/fstab 7 ssm mount

pvcreate 5 6

Create physical volume pvcreate 7 ssm create (if backend is lvm)

vgcreate 5 6

Create volume group vgcreate 7 ssm create (if backend is lvm)

lvcreate 5 6

Create logical volume lvcreate 7 ssm create (if backend is lvm)

vgextend lvextend 5 6 resize2fs Enlarge volumes formatted with default file system vgextend lvextend 7 xfs_growfs ssm resize

resize2fs lvreduce 5 6 Shrink volumes formatted with vgreduce default file system XFS cannot currently be shrunk; copy desired data to 7 a smaller file system.

fsck 5 6 Check/repair file system fsck 7 ssm check

/etc/exports 5 6 service nfs reload Configure NFS share /etc/exports 7 systemctl reload nfs.service

/etc/fstab Mount and activate swap 5 6 7 swapon -a

Configure static mounts /etc/fstab 5 6 7

View free disk space df 5 6 7 FILE SYSTEMS, VOLUMES, AND DISKS (CONT.)

TASK RHEL

lvdisplay lvs vgdisplay View logical volume info 5 6 7 vgs pvdisplay pvs

showmount -e View NFS share 5 6 7 mount

/etc/auto.master.d/*.autofs Configure on-demand auto-mounts 5 6 7 /etc/auto.*

Change file permissions 5 6 7 (future file creation)

Change file attributes chattr 5 6 7

Change access control list setfacl 5 6 7

KERNEL, BOOT, AND HARDWARE

TASK RHEL

append 1 or s or init=/bin/bash to kernel cmdline 5 6 Single user/rescue mode append rd.break or init=/bin/bash to kernel cmdline 7

shutdown 5 6

Shut down system shutdown 7 systemctl shutdown

poweroff 5 6

Power off system poweroff 7 systemctl poweroff

halt 5 6

Halt system halt 7 systemctl halt

reboot 5 6

Reboot system reboot 7 systemctl reboot

/etc/inittab 5 6 Configure default run level/target systemctl set-default 7

/boot/grub/grub.conf 5 6

Configure GRUB bootloader /etc/default/grub grub2-mkconfig 7 grub-set-default

hwbrowser 5 View hardware configured lshw (in EPEL) 6 7

Configure kernel module modprobe 5 6 7

Configure hardware device udev 5 6 7

sysctl -a View kernel parameters 5 6 7 /proc/cmdline

Load kernel module modprobe 5 6 7

Remove kernel module modprobe -r 5 6 7

rpm -q kernel View kernel version 5 6 7 -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.