Configure System Settings on Oracle Linux
Introduction
The following tutorial provides step-by-step procedures to modify system configuration files, view and modify kernel settings, and discover hardware device and device driver attributes. This tutorial is targeted at users of Oracle Linux 8 or later.
Objectives
In this lab, you'll:
- Modify system configuration files
- View and modify kernel settings
- View hardware device and device driver attributes
What Do You Need?
- A fully patched Oracle Linux instance
Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.
Explore the /etc/sysconfig
Directory
In this section, you explore the /etc/sysconfig
directory and selected files in it. You see that many initialization scripts derive values from files in the directory. You view documentation that describes the entries in the directory. And, you make changes to files and observe the effect of the changes.
As the root user, use the
cd
command to change to the/etc/sysconfig
directory, and then use thels
command to explore the contents of it.cd /etc/sysconfig ls -l
- Some of these files contain configuration settings for the respective service.
- Some of these files contain command-line arguments for the respective service.
- Some of these are directories and some are symbolic links.
Use the
less
command to view selected files.- Press
q
to quit theless
command and close the file. - Some files are given as examples but you can view files and directories of your choice.
less firewalld less crond less kernel
Note that the files contain configuration settings, command-line options, and so on.
- Press
Use the
cd
command to change to the/usr/share/doc/initscripts*
directory and explore its contents.cd /usr/share/doc/initscripts* ls
Use the
less
command to display the contents of thesysconfig.txt
file.less sysconfig.txt
Search the contents of the
sysconfig.txt
file for/etc/sysconfig
.- While viewing the file using the
less
command, use the slash (/
) key followed byetc/sysconfig
to search for this string. - Press
n
(lowercase for “next”) to display the next instance of the string. - Continue to view the
/etc/sysconfig
entries in this file. - At the
/etc/sysconfig/network
entry, notice some of the variables initialized in this file. Here are some examples:
NETWORKING=yes|no
GATEWAY=<gateway IP>
NISDOMAIN=<nis domain name>
- Press
q
to quit the “less
” command.
- While viewing the file using the
Explore the /proc
File System
In this section, you explore the proc
file system (directory), view various files and directories that represent the current state of the kernel, and change the value of current settings. Where needed, scroll through output using navigation keys such as Page Up and Page Down. Also where needed, enter "q
" to terminate output and return to the prompt.
As the root user, use the
ls
command to display the contents of the/proc
directory.ls /proc
- Numbered entries are directories referring to process IDs.
- Numbered entries are directories referring to process IDs.
Use the
ls
command to display entries without numerical names.- Output shows partial directory listing.
ls -ld /proc/[a-z]* | less
- Notice that some entries are files and some entries are directories.
- Output shows partial directory listing.
View the
meminfo
file to display information about RAM.less /proc/meminfo
View the
cpuinfo
file to display information about the processors used by your system.less /proc/cpuinfo
View the
devices
file to display information about the various character and block devices currently configured.less /proc/devices
Change to the
/proc
directory, and then use thels
command to display only the directories in/proc
with numerical names.- Output shows partial directory listing.
cd /proc ls -d [0-9]*
- Output shows partial directory listing.
Show that one process directory exists for each process running on your system.
ls -d [0-9]* | wc -l ps -e | wc -l
- The
ps
command produces one more entry due to the column headings.
- The
Use the
ps
command to show that the process id (PID
) of thesystemd
process is "1
", and then change directory to thePID
directory in/proc
and view its contents.ps -e | less cd /proc/1 ls -l
- Notice that some entries are files, some entries are directories, and some entries are symbolic links.
- Notice that some entries are files, some entries are directories, and some entries are symbolic links.
Use the
less
command to display the status ofPID=1
.less status
- Note output shows partial listing.
- Note output shows partial listing.
Use the
cat
command to check the status of IP forwarding.- Note that IP forwarding is disabled by default, set to
0
.
cat /proc/sys/net/ipv4/ip_forward
- If the value is 0, IP forwarding is disabled; if set to
1
, forwarding is enabled. IP forwarding allows you to set up a Linux router or gateway. - If the value of IP forwarding is currently set to
1
, use theecho
command to set the value of IP forwarding to0
and then change it back to1
. - If the value of IP forwarding is currently set to
0
, simply change it to1
by only running the secondecho
command followed by thecat
command.
echo 0 > /proc/sys/net/ipv4/ip_forward cat /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward cat /proc/sys/net/ipv4/ip_forward
- Note that IP forwarding is disabled by default, set to
Use the
cat
command to view the local port range used by TCP and UDP traffic.cat /proc/sys/net/ipv4/ip_local_port_range
- If the port range is not
32768 61000
, use theecho
command to define the local port range used by TCP and UDP traffic to be32768 61000
.
echo "32768 61000" > /proc/sys/net/ipv4/ip_local_port_range cat /proc/sys/net/ipv4/ip_local_port_range
- Notice that the first local port and the last local port allowed are surrounded by quotation marks.
- If the port range is not
Explore the sysfs
File System
In this section, you explore the sysfs file system. You view the virtual block devices and virtual interfaces, and determine which power states are supported on your system.
As the root user, use the
ls
command to display the contents of the/sys
directory.ls -l /sys
Use the
ls
command to display the virtual disk block (sd
) devices on your system.ls -l /sys/block | grep sd
Traverse the
/sys/bus
directory and display the virtual interface (virtio
) devices.cd /sys/bus/virtio/devices ls virt*
Display the operational state, MAC address, and MTU of
ens3
.cd virtio0/net/ens3 pwd ls cat operstate cat address cat mtu
Use the sysctl
Utility
As the root user, use the
sysctl
command to disable IP forwarding.- Setting the
ip_forward
variable to0
disables IP forwarding.
cat /proc/sys/net/ipv4/ip_forward sysctl -w net.ipv4.ip_forward=0 cat /proc/sys/net/ipv4/ip_forward
- Setting the
Use the
sysctl
command to enable IP forwarding.- Setting the
ip_forward
variable to1
enables IP forwarding.
sysctl -w net.ipv4.ip_forward=1 cat /proc/sys/net/ipv4/ip_forward
- Setting the
Use the
sysctl
command to display the current kernel settings, piping the output to theless
command.sysctl -a | less
- Output shows partial listing.
- Scroll through the output using navigation keys such as Page Up and Page Down. Enter "
q
" to return to the prompt.
Use the
less
command to view the contents of the/etc/sysctl.d/99-sysctl.conf
file.less /etc/sysctl.d/99-sysctl.conf
- Changes that are made by using both
echo
andsysctl
are lost when the system is rebooted. - To preserve custom settings, add them to a
/etc/sysctl.d/<name>.conf
file. - Values that are added to these files take effect each time the system boots.
- To immediately enable changes added to files in
/etc/sysctl.d/<name>.conf
, runsysctl -p /etc/sysctl.d/<name>.conf
, providing the file name. - Enter "
q
" to return to the prompt.
- Changes that are made by using both
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel . Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center .