cheat-sheets/EL7.md at master · bertvv/cheat-sheets · GitHub https://github.com/bertvv/cheat-sheets/blob/master/src/EL7.
md
This repository Explore Features Enterprise Blog Sign up Sign in
bertvv / cheat-sheets Watch 1 Star 3 Fork 15
master cheat-sheets / src / EL7.md
bertvv on 20 Jan Added section Runlevels and host name
1 contributor
145 lines (110 sloc) 9.649 kB Raw Blame History
Enterprise Linux 7 (RedHat, CentOS)
Last Modified: 2015-01-20 16:12:38
Command cheat sheet for EL7. For every action, I try to give the 'canonical' command, as recommended by RedHat.
That means using systemd , NetworkManager, journald , etc.
Network configuration
Action Command
List interfaces (and IP addresses) ip0address , ip0a
Route table ip0route , ip0r
DNS servers cat0/etc/resolv.conf
Set IP address of an interface* ip0address0add0192.168.56.1/240dev0vboxnet0
(*) This example is actually a workaround for a bug that causes NetworkManager 0.9.9 to manage virtual network
interfaces.
NetworkManager
Action Command
Show available network connection profiles nmcli0connection0show
Show active network connection profiles nmcli0connection0show0active
Show network device status nmcli0device0status
Connect to profile CONNECTION nmcli0connection0up0id0CONNECTION
Disconnect profile CONNECTION nmcli0connection0down0id0CONNECTION
Query Wifi status nmcli0radio0wifi
Turn Wifi on/off nmcli0radio0wifi0{on,off}
List available wireless networks nmcli0device0wifi0list
Refresh list of wireless networks nmcli0device0wifi0rescan
Connect to wireless network SSID nmcli0device0wifi0connect0SSID
connection and device can be abbreviated to con and dev , respectively.
Host name
1 of 4 03/06/15 16:22
cheat-sheets/EL7.md at master · bertvv/cheat-sheets · GitHub https://github.com/bertvv/cheat-sheets/blob/master/src/EL7.md
There are three kinds of host names:
Static: "traditional" host name, stored in /etc/hostname
Transient: dynamic, set in kernel. Default value is the static host name, can be set by e.g. DHCP or mDNS.
Pretty: free form, for presentation to the user. Default value is the static host name.
Action Command
Get hosti names hostnamectl
Set (all) host names hostnamectl0setMhostname0HOSTNAME
Set specific host name hostnamectl0setMhostname0MMstatic0HOSTNAME
hostnamectl0setMhostname0MMtransient0HOSTNAME
hostnamectl0setMhostname0MMpretty0HOSTNAME
Resources
RedHat Enterprise Linux 7 Networking Guide
Fedora Wiki: Networking/CLI
RHEL 7: How to get started with Systemd, at certdepot.net
Managing services with systemctl
Action Command
List services systemctl0listMunits0MMtype0service
Query SERVICE status sudo0systemctl0status0SERVICE.service
List failed services on boot sudo0systemctl0MMfailed
Start SERVICE sudo0systemctl0start0SERVICE.service
Stop SERVICE sudo0systemctl0stop0SERVICE.service
Restart SERVICE sudo0systemctl0restart0SERVICE.service
Kill SERVICE (all processes) with SIGTERM sudo0systemctl0kill0SERVICE.service
Kill SERVICE (all processes) with SIGKILL sudo0systemctl0kill0Ms0SIGKILL0SERVICE.service
Start SERVICE on boot sudo0systemctl0enable0SERVICE.service
Don't start SERVICE on boot sudo0systemctl0disable0SERVICE.service
Runlevels
Run with root privileges ( sudo )
Action Command
Go to single user mode systemctl0rescue
Go to multi-user mode systemctl0isolate0multiMuser.target
(= old runlevel 3) systemctl0isolate0runlevel3.target
Go to graphical level systemctl0isolate0graphical.target
Get default runlevel systemctl0getMdefault
Set default runlevel systemctl0setMdefault0graphical.target
2 of 4 03/06/15 16:22
cheat-sheets/EL7.md at master · bertvv/cheat-sheets · GitHub https://github.com/bertvv/cheat-sheets/blob/master/src/EL7.md
Action Command
Shutdown systemctl0poweroff
Reboot, suspend, hibernate systemctl0STATE
Resources
RedhHat 7 System Administrator's Guide
Systemd for Administrators, Part IV: Killing Services
Perusing system logs with journalctl
Viewing logs requires root privileges. However, users that are members of the adm group get access as well. So, add
your user to the adm group to make viewing logs easier.
Action Command
Show log since last boot journalctl0Mb
Kernel messages (like dmesg ) journalctl0Mk
Show latest log and wait for changes journalctl0Mf
Reverse output (newest first) journalctl0Mr
Show only errors and worse journalctl0Mb0Mp0err
Filter on time (example) journalctl0MMsince=2014M06M000MMuntil="2014M06M07012:00:00"
Since yesterday journalctl0MMsince=yesterday
Show only log of SERVICE journalctl0Mu0SERVICE
Match executable, e.g. dhclient journalctl0/usr/sbin/dhclient
Match device node, e.g. /dev/sda journalctl0/dev/sda
Resources
Systemd for Administrators, Part XVII: Using the journal
Configuring the firewall with firewalld
The firewalldMcmd should run with root privileges, do always use sudo .
Action Command
Firewall state firewallMcmd0MMstate
Reload permanent rules firewallMcmd0MMreload
Currently enabled features firewallMcmd0MMlistMallMzones
List supported zones firewallMcmd0MMgetMzones
List preconfigured services firewallMcmd0MMgetMservices
Enabled features in current zone firewallMcmd0MMlistMall
Enabled features in zone firewallMcmd0[MMpermanent]0[MMzone=ZONE]0MMlistMall
Enable a service in zone firewallMcmd0[MMpermanent]0[MMzone=ZONE]0MMaddMservice=http
Remove service frome zone firewallMcmd0[MMpermanent]0[MMzone=ZONE]0MMremoveMservice=http
3 of 4 03/06/15 16:22
cheat-sheets/EL7.md at master · bertvv/cheat-sheets · GitHub https://github.com/bertvv/cheat-sheets/blob/master/src/EL7.md
Action Command
Enable a port in zone firewallMcmd0[MMpermanent]0[MMzone=ZONE]0MMaddMport=80/tcp
Remove a port from zone firewallMcmd0[MMpermanent]0[MMzone=ZONE]0MMremoveMport=80/tcp
Turn panic mode on firewallMcmd0MMpanicMon
Turn panic mode off firewallMcmd0MMpanicMoff
Configuration is stored in /etc/firewalld and /usr/lib/firewalld
The default zone is public , which you don't have to specify on the command line when adding/removing rules
Adding permanent rules
Resources
Using Firewalls, in RHEL 7 Security Guide
FirewallD, in Fedora Project Wiki
© 2015 GitHub, Inc. Terms Privacy Security Contact Status API Training Shop Blog About
4 of 4 03/06/15 16:22