Monday, October 20, 2014

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

System basics
Task
RHEL5
RHEL6
RHEL7
View subscription information
/etc/sysconfig/rhn/systemid
/etc/sysconfig/rhn/systemid 
subscription-manager identity
subscription-manager identity
Configure subscription
rhn_register
rhn_register 
rhnreg_ks 
subscription-manager
subscription-manager1
rhn_register 2
View RHEL version information
/etc/redhat-release
View system profile
sosreport 
dmidecode 
hwbrowser
sosreport 
dmidecode 
lshw
Basic configuration
Task
RHEL5
RHEL6
RHEL7
Graphical configuration tools
system-config-*
gnome-control-center
Text-based configuration tools
system-config-*-tui

Configure printer
system-config-printer
Configure network
system-config-network
nmcli 
nmtui 
nm-connection-editor
Configure system language
system-config-language
localectl
Configure time and date
system-config-date
timedatectl 
date
Synchronize time and date
ntpdate 
/etc/ntp.conf
timedatectl 
/etc/chrony.conf
Configure keyboard
system-config-keyboard
localectl
Configure samba
smbclient 
/etc/samba/smb.conf 
smbpasswd
Configure SSH
/etc/ssh/ssh_config 
/etc/ssh/sshd_config 
~/.ssh/config ssh-keygen
Jobs and services
Task
RHEL5
RHEL6
RHEL7
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 services
service --status-all
systemctl -t service --state=active
Start/stop service
service name start 
service name stop
systemctl startname.service 
systemctl stopname.service
Enable/disable service
chkconfig name on 
chkconfig name off
systemctl enablename.service 
systemctl disablename.service
View service status
service name status
systemctl statusname.service
Check if service is enabled
chkconfig name
systemctl is-enabledname
Create new service file or modify configuration
chkconfig --add
systemctl daemon-reload
View run level/target
runlevel 
who -r
systemctl get-default 
who -r
Change run level/target
/etc/inittab 
init run_level
systemctl isolatename.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 output
aureport /var/log/faillog
Schedule tasks
cron 
at
Configure batch tasks
batch
Find file by name
locate
Find file by characteristic
find
Create archive
tar 
cpio 
zip 
gzip 
bzip2
Kernel, boot, and hardware
Task
RHEL5
RHEL6
RHEL7
Single user/rescue mode
append 1 or s or init=/bin/bash to kernel cmdline
append rd.break orinit=/bin/bash to kernel cmdline
Shut down system
shutdown
systemctl shutdown
Power off system
poweroff
systemctl poweroff
Halt system
halt
systemctl halt
Reboot system
reboot
systemctl reboot
Configure default run level/target
/etc/inittab
systemctl set-default
Configure GRUB bootloader
/boot/grub/grub.conf
/etc/default/grub 
grub2-mkconfig 
grub-set-default
Configure kernel module
modprobe
View hardware configured
hwbrowser
lshw
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
Software management
Task
RHEL5
RHEL6
RHEL7
Install software
yum install 
yum groupinstall
yum install 
yum group install
View software info
yum info 
yum groupinfo
yum info 
yum group info
Update software
yum update
Upgrade software
yum upgrade
Configure software repository
/etc/yum.repos.d/*.repo
Find file in package
rpm -qf filename
View software version
rpm -q packagename
View installed software
rpm -qa
User management
Task
RHEL5
RHEL6
RHEL7
Graphical user management
system-config-users
Create user account
useradd
Delete user account
userdel
Change user account details
usermod
View user account details
usermod 
/etc/passwd
Create user group
groupadd
Delete user group
groupdel
Change group details
groupmod
Change user password
passwd username
Change user permissions
usermod 
/etc/sudoers
Change group permissions
groupmod 
/etc/sudoers
Change password policy
chage
Encrypted password location
/etc/shadow
View/end user sessions
w
File systems, volumes, and disks
Task
RHEL5
RHEL6
RHEL7
Default file system
ext3
ext4
xfs
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
Automatically mount at boot
/etc/fstab
View free disk space
df
View logical volume info
lvdisplay 
lvs 
vgdisplay 
vgs 
pvdisplay 
pvs
Create physical volume
pvcreate
pvcreate 
ssm create (if backend is lvm)
Create volume group
vgcreate
vgcreate 
ssm create (if backend is lvm)
Create logical volume
lvcreate
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 system
fsck
fsck 
ssm check
View NFS share
showmount -e 
mount
Configure NFS share
/etc/exports 
service nfs reload
/etc/exports 
systemctl reload nfs.service
Automatically mount after boot
/etc/auto.master.d/*.autofs 
/etc/auto.*
Change file permissions
chmod 
chown 
chgrp 
umask
Change access control list
setfacl
Networking
Task
RHEL5
RHEL6
RHEL7
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 routes
ip route
Configure routes
/etc/sysconfig/network 
system-config-network
Configure firewall
iptables and ip6tables 
/etc/sysconfig/ip*tables
iptables and ip6tables 
/etc/sysconfig/ip*tables 
system-config-firewall
firewall-cmd 
firewall-config
Configure DHCP client
/etc/dhcpd.conf 
/etc/dhcp6c.conf
dhcpd 
/etc/dhcp/dhcpd.conf 
/etc/sysconfig/dhcpd
View ports/sockets
ss 
lsof 
netstat
ss 
lsof
Security and identity
Task
RHEL5
RHEL6
RHEL7
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
Resource management
Task
RHEL5
RHEL6
RHEL7
Trace system calls
strace
Trace library calls
ltrace
Change process priority
nice 
renice
Change process run location
taskset
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 usage
df
df 
iostat


Reference : https://access.redhat.com/articles/1189123

1 comment: