Each of The Bottom Line sections in the chapters suggest exercises to deepen skills and understanding. Sometimes there is only one possible solution, but often you are encouraged to use your skills and creativity to create something that builds on what you know and lets you explore one of many possible solutions.
kernel.org
website. Go to that website and determine the version number of the latest stable release. What version is currently under development?www.gnu.org/software/coreutils/
. Go to that website and determine the current version of the GNU coreutils package.www.gnu.org/software/bash/
. According to that website, what is the most recent version of bash available for download?www.distrowatch.com
website is a popular place to get information on new releases for lots of different distributions. Go to that site and list the current top five Linux distribution downloads.sudo apt update
command. After that is completed, they will need to update the software through the sudo apt dist‐upgrade
command.uname ‐r
or the cat /proc/version
command.dpkg
for Debian‐based systems, and rpm
for Red Hat–based systems.
packages.debian.org
website and determine what version of the systat
application is available as a stable Debian package.packages.debian.org
website, enter sysstat
in the search text box to search for that package name. In the Exact Hits section, notice that there are different versions of sysstat available in the different Debian distribution versions. At the time of this writing, the current stable version (called buster) only supports sysstat version 12.0.3‐2. However, the testing version (called bullseye) supports version 12.4.0‐1.dpkg
utility to interface with the package management system from the command line, and they use the apt‐cache
and apt‐get
utilities to interface with a common repository to easily download and install new software. A front end to these utilities is apt
. It provides simple command‐line options for working with software packages in the dpkg
format.
apt
utility. Just enter the command sudo apt install csh
at the command prompt. To test the new shell, enter the command csh
at the command prompt. This opens an instance of the C shell, which uses the percent symbol (%
) as the shell prompt. To return to your Bash Shell, type exit
.snap install powershell
, you'll receive an error message warning you that it uses the old format and telling you to use the ‐‐classic
option. So, to install the PowerShell snap package, you must enter the command sudo snap ‐‐classic install powershell
.tar
command allows you to unpack the source code files from the tarball, and then the configure
and make
commands allow you to build the final executable program from the source code.
sysstat
tool. The sysstat
tool provides statistics for various features of your Linux system. You can find the sysstat
tool on the developer's website, sebastien.godard.pagesperso-orange.fr
. After downloading the package tarball, what commands would you need to use to compile the software and install it on your Linux server?sysstat
source code is provided using several different package types. The one that creates the smallest package size is the .xz
version. At the time of this writing you should download the sysstat‐12.5.1.tar.xz
package. Once you have that package downloaded, extract it using the command tar ‐Jxvf sysstat‐12.5.1.tar.xz
. This creates the sysstat‐12.5.1
directory. Change to that directory using the command cd sysstat‐12.5.1
. The next step is to run the configuration script using the command ./configure
. This generates the Makefile
file. The next step is to run the make
command. After the software compiles, you can install it on your system using the command sudo make install
.dnf install ‐y centos‐release‐stream
command, using super user privileges. After that is completed, they will need to update the software using super user privileges through the dnf update
command.dmesg
command. The journalctl
command will also contain boot messages. However, the log file that contains boot messages on a CentOS system is /var/log/boot.log
, and it is best to use the less
command to view it for finding boot problems.rpm
command‐line tool provides access to the package management database, allowing you to quickly determine the status of installed packages.
rpm ‐q
command. At the command prompt, type rpm ‐q curl
. If the package is installed, you will see it listed in the output. To obtain additional information on the installed package, type the command rpm ‐qi curl
.dnf
for installing and managing software packages. The dnf
tool automatically installs any software packages required by the package you install.
dnf
command to check whether the perf software package is available, install it, and remove it when necessary. Enter the command dnf list perf
to see if the package is available for installation. Then, to install the package, type the command dnf install perf.
After you've installed the perf package, remove it using the command dnf remove perf
. Remember, you will need to have root privileges to install the package.rpm
command to manually install the package. The most common options used to install software are the ‐Uvh
options, which will update the package if it's already installed and provide verbose information on the installation progress.
yumdownloader perf
(you don't need root privileges to do this). At the time of this writing, the download file is perf‐4.18.0‐240.1.1.el8_3.x86_64.rpm
. Once you have the RPM file transferred to your Linux system, you can manually install it by typing the command rpm ‐Uvh perf‐4.18.0‐240.1.1.el8_3.x86_64.rpm
. You will need root privileges to install the software.flatpak search cointop
. The output indicates that the package exists and displays the software version. To install the container, enter the command flatpak install cointop
. Remember that you must have root privileges to install the software.~
, which is a special character that represents your home directory.)less
utility is the pager used for the man pages. Type man less
and press Enter at the shell prompt to view the information on this command from the online manual.!42
and press the Enter key. These four simple keystrokes will display the command and then reenact it at the CLI.STDIN
, STDOUT
, and STDERR
.
tee
command within your pipeline. The tee
command will allow you to save the information to a designated file, but in addition, it sends the data to STDOUT
for viewing (or further processing).export
command on the variable. By using export
, the variable definition is available to the current parent shell as well as any subshells./usr/bin/grep
/usr/bin/zcat
/etc/hosts
~/.bashrc
file
command. From the command prompt, enter these commands:
file /usr/bin/grep
file /usr/bin/zcat
file /etc/hosts
file ~/.bashrc
ls
command is how to list the contents of directories from the command prompt. While there are lots of parameters associated with the ls
command, you'll soon find yourself using just a handful of them to view the information that you need.
/share/HR/employees.txt
. However, the user doesn't know who owns the file to ask for permission to access the file. What command and parameters should you use to determine the owner of the file?‐l
parameter of the ls
command produces a long‐format listing of the files in a directory. Part of that output shows the owner of the files. Use the command ls ‐l /share
to view the file properties and determine the file owner.mkdir
command. From the CLI prompt, enter the command mkdir /Engineering
(you must have root permissions to create a directory under the root directory). Then to create the project directories, first enter the command mkdir /Engineering/automotive
and then the command mkdir /Engineering/truck
.which
, locate
, and whereis
commands can be useful for general searches, but the find
command allows you to customize your search by specifying specific file or directory properties to look for.
find
command allows you to search for files based on file size by using the ‐size
parameter. To explore all directories on the server, you'll need to run the command with root privileges: find / ‐size +10MG ‐print
.gzip
family of commands is a popular option. For archiving multiple files into a single file, the tar
command is common. You can also compress a tar archive file to facilitate moving it to off‐site storage.
/Engineering
directory and compress it?/Engineering
directory, enter the command tar ‐cvf engineering.tar /Engineering
. Since this directory is at the root level, you'll need to have root permissions to do this. Then to compress the file using the gzip
utility, enter the command gzip engineering.tar
.vim
editor's basic features. The vim
editor is one of the most popular text editors in use. Though it can be tricky to use, modifying text files using vim
is worth the time to learn. Grasping the basics of the vim
editor is all that is needed for a system admin.
vim
editor. You only want to quickly add a paragraph of comments to the top of the file. What editor commands can you employ to accomplish this task quickly?ZZ
, :x
, or :wq
.nano
editor for everyday text file editing. The nano
text editor is a simple and quick editor to use in your daily work. You can quickly get into a file, make any needed modifications, save your work, and go on with other tasks. It's a favorite editor of system administrators because of its simplicity.
nano
editor with this file in the buffer, what editor commands covered in this chapter can you use to accomplish this task quickly?nano
editor, press Ctrl+O one time, and then press Enter to select the filename displayed. Press Ctrl+X to leave the nano
text editor and return to a shell prompt.grep
command is a utility to learn. With its ability to conduct simple or complex searches, locating the information or the files you need is a snap.
/etc
directory (but not its subdirectories) that contain the word host
. The search must be case‐insensitive, and you don't want to see any error messages concerning directory files. Assuming you need to use the sudo
command along with your grep
command, what will your command look like to conduct this search?sudo
command along with your grep
command to conduct a case‐insensitive search through all the files in the /etc
directory, find the ones that contain the word host
, and not display any error messages concerning directory files, the command is as follows: sudo grep ‐d skip ‐i host /etc/*
.tar
utility has been around for a long time. It provides useful options to create archive files. While tar
has the ability to compress files on the fly, you can also use the gzip
, bzip2
, and xz
compression utilities to compress tar
archive files as well as other files.
tar
archive file, myArchive.tar
, but did not compress it with a tar
option, because you needed to verify each file as it was processed with the ‐W
option. Now that the archive file was successfully created and verified, what command will you use to compress it to the highest level, and what will the resulting file's name be?tar
archive file, myArchive.tar
, to the highest level will use the xz
compression utility. The command is xz myArchive.tar
, and the resulting file's name will be myArchive.tar.xz
.lsmod
to list all the device driver modules currently installed on the Linux server./dev
directory that's used for applications to send data to and receive data from the devices. The kernel uses the /proc
directory to create virtual files that contain information about the devices and system status. The /sys
directory is also used by the kernel to create files useful for troubleshooting device issues.
/proc/cpuinfo
and /proc/meminfo
files, but what command(s) should you use to obtain that information?/proc
directory files are text‐based, so you can use any text editor to view them, or use the cat
command to display the contents on the monitor. Use the command cat /proc/cpuinfo
to see information about the CPU, and the command cat /proc/meminfo
to see information about the system memory.lsdev
command allows you to view the status and settings for all devices on the system. The lsblk
command provides information about block devices, such as hard drives and network cards, that are connected. The dmesg
command lets you peek at the kernel ring buffer to view kernel event messages as it detects and works with devices. The lspci
and lsusb
commands allow you to view the PCI and USB devices that are connected to the Linux system.
dmesg
. Look toward the bottom of the output to view the most recent kernel event messages. You should see messages related to the USB device, and what (if any) kernel modules the Linux system tried to load.dmesg
utility. This utility displays the kernel ring buffer, which holds kernel messages, and most Linux distributions copy the boot kernel messages into it. If, for some reason, you cannot locate the messages within the kernel ring buffer with dmesg
, look to see if your distro keeps boot log files in the /var/log
directory, such as boot
, bootstrap.log
, or boot.log
./etc/default/grub
file. You can directly edit this file with super user privileges. Look for the GRUB_TIMEOUT
key and make sure it is not set to 0
. If it is, the boot menu will not display, and you'll need to set it to the number of seconds you want the menu to show at boot time. The other key to look at is the GRUB_TIMEOUT_STYLE
. If it is set to hidden
, the boot menu will not display; you'll need to either comment it out with a hash mark (#
) or set it to menu
. When you make a change in this GRUB2 configuration file, you'll need to rebuild the grub.cfg
file using the appropriate privileges and utility.multi‐user.target
for the next boot. How can you accomplish this?linux16
or linux
command. Press the End key or use the arrow key to reach that line's end. Once your cursor is there, press the spacebar and type systemd.unit=multi‐user.target
. Then press the B key to boot the system using the new service target.systemctl
utility help in managing system services. They allow you to control what services are started at boot time, start and stop services, and analyze service issues and troubleshoot problems.
ntpd
service was not enabled to start at boot time, and you need to immediately get this service up and running. Assuming you have super user privileges, how can you use systemd to start the service and check that it is indeed started?systemctl
command and access super user privileges through either using the sudo
command or logging into the root account, depending on your Linux distribution's configuration. The full command to enter at the command line (without the potentially needed sudo
) is systemctl start ntpd
. Once you have issued that command, you can check on the service's status by typing systemctl status ntpd
at the command line and pressing Enter. Look for Active: active (running)
in the command's output.systemd‐analyze
, which has several commands you can use in troubleshooting situations.
systemd‐analyze verify
command on the newly installed service unit files to scan the files and locate any errors. This will assist in quickly determining the problem(s).fdisk
or parted
command‐line tool. For GPT disks, you can use the gdisk
tool. When you partition a drive, you must assign it a size and a filesystem type.
dmesg | tail
. Next, use either the fdisk
or gdisk
tool, depending on your server's firmware. For systems using the BIOS firmware, type sudo fdisk /dev/
xxx
, where xxx
is the device name. Type d
at the first prompt to delete the existing partition, and then type n
to create a new partition. Press Enter to select the default starting and ending blocks. Type w
to save the new partition and exit the fdisk
utility.mkfs
program is a front‐end utility that can format drives using most of the filesystems that Linux supports. The ext4 filesystem is currently the most popular Linux filesystem. It supports journaling and provides good performance. Linux also supports more advanced filesystems, such as btrfs, xfs, zfs, and, of course, the Windows vfat and ntfs filesystems. After creating a filesystem on the partition, you'll need to mount the filesystem into the Linux virtual directory using a mount point and the mount
command. The data contained in the partition's filesystem appears under the mount point folder within the virtual directory. To automatically mount partitions at boot time, make an entry for each partition in the /etc/fstab
file.
/data
directory on your server.sudo mkfs ‐t ext4 /dev/
xxx
1
, where xxx
is the device name you used to create the new partition. After Linux completes the partition formatting, you can manually mount the partition to test it. First, create a mount point by typing the command sudo mkdir /data
. Then, you can mount the new partition by typing the command sudo mount /dev/
xxx
1 /data
, where xxx
is the device name of the partition. After copying and deleting a few test files in the new partition, modify the /etc/fstab
text file to automatically mount the new partition by opening it in an editor and adding the following line:
/dev/
xxx
1 /data ext4 defaults 1 2
where xxx
is the device name of the storage device.
df
and du
command‐line commands are useful for checking disk space for partitions and the virtual directory, respectively. The fsck
utility is a vital tool for repairing corrupt partitions, and it's run automatically at boot time against all partitions automatically mounted in the virtual directory.
/home
directory has become full. How can you tell which storage device the /home
directory is located on and what user account is using up the most space?/home
directory, type the command df ‐h
. This displays the currently mounted storage devices, along with their capacities and how much space is currently being used. This allows you to determine if the /home
directory is on its own partition or under the root (/
) partition. To determine what user account has the most data stored, type the command du /home
. This displays the disk space used by each user's Home directory./etc/netplan
directory. Red Hat servers store the configuration files in the /etc/sysconfig/network‐scripts
directory. Files in those directories define the network settings for each interface.
netplan
directory by typing the command cd /etc/netplan
. List the files in that directory by typing the command ls ‐l
. View the current network configuration by using the cat
command on each of the configuration files in that directory. For example, you can view the configuration defined in the 00‐installer‐comnfig.yaml
file by typing the command cat 00‐installer‐config.yaml
. Note the interfaces listed, along with the IP addresses assigned.ifconfig
or ip
command to set the IP address and netmask values for the interface. You may also need to use the route
command to define the default router for the local network. For wireless connections, you'll need to use the iwconfig
command to set the wireless access point and SSID key.
ip address show
. If the status of the interface enp0s3
shows DOWN, you can make it active also using the ip
command. Type ip link set enp0s3 up
at the command prompt to make the interface active. Then type ip address show
at the command prompt and note the status of the network interface to ensure it's active.ping
and ping6
commands allow you to send ICMP packets to remote hosts to test basic connectivity. If you suspect issues with hostnames, you can use the host
and dig
commands to query the DNS server for hostnames.
For more advanced network troubleshooting, you can use the netstat
and ss
commands to display what applications are using which network ports on the system.
ping www.linux.org
. You should get a response from the remote server, indicating that your server is communicating. Next, to check for the web server, type ss ‐anpt
from the command line to view all open TCP sockets on the server. You should see a line with the local address/port of 0.0.0.0:443
, indicating that a web server is listening on TCP port 443 for HTTPS connections. If not, it may be time for the web administrator to restart the web server software!projectData.txt
to the lradford
home directory. This user will need access to the file, which includes being able to change its group. What command syntax should you employ to accomplish this task?projectData.txt
file to the lradford
user, you'll need to use the chown
command. The exact syntax to accomplish the task, if you are logged into the root account, is chown lradford projectData.txt
. If you are using super user privileges to accomplish this task, the syntax is sudo chown lradford projectData.txt
. It's a good idea to double‐check that the change of ownership was successful by issuing the command ls ‐l projectData.txt
when you are done with the chown
command.useradd
command is a command at the basic system level that allows you to create new accounts on the system. The needed various options are often determined by settings in the /etc/login.defs
and the /etc/default/useradd
files.
/etc/login.defs
, you find that CREATE_HOME
is defined as no
, and UID_MIN
is set to 1000
. Within the /etc/default/useradd
file, SHELL
is defined as /bin/bash
, and SKEL
is set to the /etc/skel
directory. The user's home directory should end up being /home/tpuddle
. Assuming you are either logged into the root account or have access to super user privileges, what is the command syntax to create an account for the new project manager?useradd
command. With the current system configuration settings, and if you are logged into the root account, the command is useradd ‐md /home/tpuddle tpuddle
. If you are using super user privileges to accomplish this task, the syntax is sudo useradd ‐md /home/tpuddle tpuddle
. You don't necessarily have to add a comment field through the use of the ‐c
option. It is wise to double‐check that the account addition was successful by issuing the command getent passwd tpuddle
when you are done with the useradd
command. However, don't forget that you also need to create a password for this new account using the command passwd tpuddle
or sudo passwd tpuddle
!passwd
command along with the correct privileges allows you to create an account's password. However, besides just creating a password, you can change an account's password, delete its password, force a user to change their password at the next login, and so on. In addition, without any extra privileges, you can modify your own account's password through the passwd
command.
jsnow
account while they wait. What command do you enter to lock this account?/etc/
directory, and local user files reside in each user's home directory after being copied from the /etc/skel/
directory, if your system is configured to do so.
abc123
, on the system you administer has come to an end. The project files are no longer needed by the former team, and you've been asked to change the group on these project files to the manager
group. Once you've completed that task, you'll need to remove the old abc123
project group. What is the command to accomplish this removal task?groupdel abc123
command on the system to remove the abc123
user group. You'll need to be logged into the root account or have access to super user privileges to successfully complete this task.ps
command. There are many different ways to view process information using the ps
command, allowing you to customize the display exactly how you like. For real‐time monitoring of applications, use the top
command. With the top
command, you can view a real‐time display of applications, their system state, and the resources they consume; plus it allows you to sort the display based on many different features.
top
to start the interactive display of processes. By default, top
sorts the display based on CPU usage. Note the two or three processes using the most CPU resources.nice
command allows you to start an application at a different priority level than the applications that are already running. This allows users to run applications in the background at a lower priority or allows the system administrator to start applications with a higher priority. With the renice
command, you can change the priority of an application that's already running. If an application causes problems and needs to be stopped, you can use the kill
command, but you need to know the PID assigned to the application by the system. The pkill
command is customized for stopping applications by their name instead of the PID.
inventory
, and now it's stuck running in an endless loop on the system. What command(s) should you run to find and safely stop the runaway program?HUP
signal to the runaway program so it can gently stop by typing the command sudo pkill ‐‐signal HUP inventory
. Check if the program has stopped by typing the command ps ‐ef
and looking for the program. If the program continues to run, you must send a KILL
signal to stop it. Type the command sudo pkill ‐‐signal KILL inventory
.at
command lets you schedule in individual program to run at a specific time/date. If you need to schedule a program to start on a regular schedule, use the crontab
command to add the program to the system cron
table. You must specify the schedule format to tell Linux when to start the program.
inventory
program and would like for it to run automatically every month on the first of the month at 1 AM. The program is stored in the /applications
directory. What command should she use to make that happen?cron
table using the crontab
command. To edit your user cron
table, type crontab ‐e
. In the editor, go to input mode by typing i
and then enter the schedule and command to run. To run the inventory program at 1 a.m. on the first of every month, type the following:
00 1 1 * * /applications/inventory
Save the entry by typing :qw!
.
journalctl
program is needed to view journal file entries, because unlike some logging utilities, systemd‐journald
doesn't store events in text files. Instead, it uses its own binary file format that works similar to a database. Thus, you cannot use the typical programs used to view text files, such as cat
, head
, or tail
, to view journal file entries.
journalctl
command(s) to use in this scenario?journalctl
command that allows you to see the entries as they are being logged to the journal is journalctl ‐f
or journalctl ‐‐follow
. This is similar to using the tail ‐f
command on a text‐based log file to watch as messages are added to it.systemd‐journald
journal file(s) can get rather large. Because the various services on the system are sending messages to this file, if multiple events are occurring on a regular basis, disk space can quickly become consumed. It's important to make some decisions on journal file size limits prior to lack of disk space becoming a critical emergency issue.
systemd‐journald
journal files. After running the journalctl ‐‐disk‐usage
program, you've made some decisions on journal file size limits and determine a rotation schedule, which includes an archival process for the old files. Which directives should you consider modifying in the /etc/systemd/journald.conf
file to match your decisions concerning this and prevent a critical emergency issue with disk space due to journal files?/etc/systemd/journald.conf
file, the three directives related to persistent journal file size are SystemKeepFree
, SystemMaxFileSize
, and SystemMaxUse
. Reviewing these particular directives and modifying them to meet your decisions will work. The other directives related to journal file size are for volatile journal files and do not apply in this case. You also will want to turn off the MaxFileSec
directive by setting it to 0
, because this setting is not needed when size limitations are in place./run/log/journal
directory. The /run/
directory and its contents are deleted when a system is shut down, so any journal entries are lost at that time. It is typical to change this behavior by modifying a directive in the /etc/systemd/journald.conf
file to force systemd‐journald
to keep entries in a journal that is not removed when the system is shut down or reboots. The /var/log/journal
directory is used in these cases to store the journal file(s).
systemd‐journald
configuration file. What directive should you change in the configuration files on these servers, and what should you set it to?systemd‐journald
to keep entries in a journal that is not removed when the system is shut down or reboots, you'll need to modify the Storage
directive in these servers' journald.conf
file in their /etc/systemd/
directory. If the /var/log/journal
directory already exists (or you plan on creating it), you can set the Storage
directive to auto
. Otherwise, you'll want to set it to persistent
to create the /var/log/journal
directory, if it is not there already./etc/rsyslogd.conf
, or a combination of that configuration file and additional configuration files within the /etc/rsyslog.d/
directory. Modifying the rsyslog application's configuration is fairly straightforward with the facility
.
priority action
syntax in its configuration rules.
rsyslogd
program to send the following severity level of events for all systems to everyone: crit
, alert
, and emerg
. What do you need to do?/etc/rsyslogd.conf
file. If not, check for them in the files within the /etc/rsyslog.d/
directory. Once you find the correct configuration file, look for a rule similar to the following:
# Everybody gets emergency messages
*.emerg :omusrmsg:*
If you find this rule, you'll only need to change emerg
to crit
, because rsyslogd
will log all events with the crit
severity or higher (alert
and emerg
). If you don't find this rule, add a similar line, changing emerg
to crit
.
apt
in Ubuntu, or dnf
in CentOS. Once you install the software, you'll need to make a few configuration changes to allow remote clients to use CUPS, especially if your server doesn't provide a graphical desktop. You'll also need to ensure your administrator user account has access to the CUPS administrator features by adding it to the appropriate user group.
cupsd.conf
configuration file to accommodate that configuration?cupsd.conf
configuration file, you'll first need to set the root location to allow connection from any client on the local network by adding the line ALLOW @LOCAL
to the <Location />
block. However, in the <Location /admin>
block, add the line ALLOW from 192.168.1.100
to only allow your workstation to connect to the administrative features in CUPS.sudo
command. This method allows administrators to log into their standard Linux user account and run programs with higher‐level administrator privileges, as needed.
sudo
to safely escalate privileges when needed. The record in the /etc/sudoers
configuration file that provides your account with privilege escalation is the following: %sudo ALL=(ALL:ALL) ALL
. What do you need to do to set up this new team member to use the sudo
command?sudo
command and have the ability to perform the same administrator duties that you do, you'll need to add the team member's account to the sudo
group. To do this, you'll need to use the usermod ‐aG
command covered in Chapter 13, “Managing Users and Groups.”rsa
keys, the decision was made to switch to ecdsa
key pairs, which don't exist at this time on the system. What steps do you need to take in order to implement this functionality for your accounts on the systems?ecdsa
key pairs, the first step is to log into a client system and generate ecdsa
keys via the ssh‐keygen ‐t ecdsa ‐f ~/.ssh/id_ecdsa
command. After that, copy the new public key to the server system's ~/.ssh/authorized_keys
filesystem using the ssh‐copy‐id
utility. Be aware you will need to do these steps for each client system./etc/apparmor.d/
directory and are typically installed for a particular application, when it is installed.
aa‐complain
command on the application's profile. You will also need to do this on any applications' profiles that this modified application uses on the system. By putting the various profiles into complain mode, any violations of the profile are logged, but not blocked. In addition, check all the profiles for deny
rules, which will block violations whether or not the profile is in complain mode.ufw
command‐line utility.
sudo ufw allow 1138/tcp
at the servers' command line. It is wise to only allow traffic to this port from any of the client systems, so also consider adding the from
source
, where source
is either a set of IP addresses or subnets of the client systems from where you are logging in. If UFW firewalls are implemented on the client systems, you'll need to perform similar commands on them.aulast
command to view the logins on the server. Depending on your environment, you may also want to restrict the root user account from accessing the server from a remote device. You can do that using the /etc/ssh/sshd_config
configuration file in OpenSSH. Finally, if you do allow root user access on your system, it's a good idea to restrict the idle time at the command prompt. You do that using the TMOUT
environment variable.
sudo aulast | grep root
. This displays the times the root user account logged into the system and, if from a remote device, the IP address of the device.sudo getsebool | grep httpd
. From this list, you see the policy httpd_can_network_connect_db
is turned off. To enable it, from the command prompt, type sudo setsebool ‐P httpd_can_network_connect_db 1
.firewalld
. In today's world, managing access to the Linux server is a must, especially if your Linux server has some type of connection to the Internet. Red Hat servers utilize the firewalld
program to block unwanted network connections and allow approved connections on the network. The firewalld
program defines connections as rules and applies those rules to specific zones. You can then assign network interfaces to the zone that supports the network connections needed.
sudo firewall‐cmd ‐‐list‐all
. This displays the active zones on the server and what network interface is in each one. Look for the zone the active network interface is assigned to, and enable TCP port 3306 for it by typing sudo firewall‐cmd ‐‐zone=public ‐‐permanent ‐‐add‐port=3306/tcp
. Then reload the configuration by typing sudo firewall‐cmd ‐‐reload
.bash
command to run it. What is most likely the problem?#!/bin/sh
, your script will be run by whatever shell the /bin/sh
file points to. On some systems, this file points to the Dash shell. Modify the script to use #!/bin/bash
in its first line.$1
variable in the script. This will allow the intern who is running the program to run the script and include the username as a parameter to the shell script. However, you may want to include some additional safeguards in your script to avoid typographical errors on the username and prevent the intern from entering valid but incorrect usernames into the script.if‐then
statements or, if there are only two conditions to check, through the use of Boolean logic to combine the tests.
machine0087.log
file's existence needs to be checked. In addition, a counter variable, logCount
, must be examined as well. If the file exists and the counter has reached 100
, the script should exit. What if‐then
statement(s) should you write to make this test as consolidated as possible?machine0087.log
file exists and the logCount
counter has reached 100
, you'll need to use Boolean logic in your if‐then
test statement as follows:
if [ -f machine0087.log ] && [ $logCount -eq 100 ]
then
exit
fi
You could also use the ‐e
test on the machine0087.log
file, and it would be best to use the file's absolute directory reference, instead of a relative one.
for
, while
, and until
.
stop here
. You are reading in the text file lines one at a time, keeping only the line's text, and putting it into the variable fileLine
. What type of loop should you use in your script, and what is the syntax of that loop's first line?until
loop. The format of the loop's first line would look like this:
until [ $fileLine = "stop here" ].
Properly write a function namedecho "Error in processing file, $1."
echo "Check that the $1 file exists and contains +data."
echo "This script will now exit…"
exit
errorMessage
that will allow you to turn these four lines of code into a single line (except for the function declaration) throughout the script.errorMessage
that will allow you to turn the four lines of code into a single line (except for the function declaration) throughout the script would look like this:
function errorMessage {
echo "Error in processing file, $1."
echo "Check that the $1 file exists and contains data."
echo "This script will now exit…"
exit
}
or this:
errorMessage () {
echo "Error in processing file, $1."
echo "Check that the $1 file exists and contains data."
echo "This script will now exit…"
exit
}
and then would be called by simply using errorMessage
in place of those four lines of code throughout the script.
UserDir
directive to allow users to create their own websites on the server, separate from each other. You use the VirtualHost
directives to host web pages for multiple domains on the same physical server. You can also implement client authentication on your website, requiring clients to log in to access content. The Apache server also provides for secure transactions by using HTTPS and encrypting network traffic between the client and the server.
sudo apache2ctl configtest
, or from a Red Hat server command line, type sudo apachectl configtest
. The configtest
option parses the Apache configuration file and displays any errors that would prevent the Apache web server from starting.nginx.conf
configuration file. Many of the configuration directives for nginx are similar to the Apache, so migrating from one to the other is a fairly simple process.
systemctl
command. From a command‐line prompt, type sudo systemctl status nginx
. If the status shows that the server is stopped, start it by typing the command sudo systemctl start nginx
.systemctl
command to start the service; then enable the service so that the next time the database server reboots, the RDBMS daemon is started automatically.root
account to create the database. To do this, you will need to escalate your privileges to super user and issue the mysql
command to enter into the SQL interface. After that, your next step is to issue the appropriate CREATE USER
command along with the username of the account, the hostname of the system (optional), and a password to access the SQL interface of MariaDB. After you have completed creating this account, you should log out of the mysql
interface and log back in using the new credentials. Now that this is accomplished, you can move forward with creating the database.ArtificialFlowers
within the Florist
database. The artificial flower records listed in this table have only a few fields: ProductID
(which is the primary key), FlowerName
, FlowerColor
, and StemColor
. The store manager of the florist shop wants to check the data you've entered into this table. What steps should you take after you have logged into the MariaDB server's command line where this data exists?USE Florist;
command. After that, you can display the data to the screen, using the SQL command SELECT * FROM ArtificialFlowers
;. Keep in mind that if there is a lot of data in this table, it will scroll off the screen. The store manager may prefer a report from which they can view the data as opposed to looking at it on your computer screen.postgresql‐server
. So, to install it, you'll need to escalate your privileges to super user status and issue a command similar to dnf install postgresql‐server
. After the installation, to finish this task, you will need to again escalate your account's privileges and run a PostgreSQL database initialization by issuing the following command with super user privileges: /usr/bin/postgresql‐setup ‐‐initdb
. When this is completed, be sure to enable PostgreSQL to start at boot, and start the daemon.admin
. This role has super user privileges in the database as well as the ability to create roles and databases. What, if any, changes should be made to your account to improve the security levels of administering this database?CREATEROLE
and SUPER USER
to other database roles besides postgres
is considered risky. It would be best to remove the CREATEROLE
and SUPER USER
from the admin
role, and only use the postgres
account for those functions. While it is troublesome to have to log in to the postgres
account to add roles to the database, it does provide an extra layer of security around the data.docker
snap package using the command sudo snap install docker
. The Snap framework comes pre‐installed on Ubuntu, so there is no need to install it. Once you have the docker
snap package successfully installed, you can start a Docker CentOS container with access to the Bash shell for the software developers to test using the command sudo docker run ‐it centos bash
.snapd
daemon updates these packages on a regular basis through the appropriate Snap channel. When run, snaps operate in an isolated sandbox, protecting other data and applications on a Linux system, including other running snaps.
latest/edge
channel. You can run this snap package alongside your production Multipass snap (which you should have installed from the latest/stable
channel). This way, you'll gain hands‐on access and can try newfangled features before they hit the latest/stable
channel and your production Multipass snap.flathub
. What steps should you take to get this framework and text editor installed for the developers on this current system?dnf install flatpak
command. After that step is successfully completed, connect to the flathub
repository by using super user privileges and typing in flatpak remote‐add flathub
https://flathub.org/repo/flathub.flatpakrepo
at the command line. Once the Flatpak framework is installed and your system is connected to the repository, install the desired text editor flatpak by using super user privileges and entering the command flatpak install
package
, where package
is the name of the flatpak package.