Understanding and Using Essential Tools on RHEL 8 Flashcards
To login to a server we don’t have the IP address for, what type of login do we use?
Console login
What command is used to become another user?
su user
what is sudo for?
It allows authorized users to execute commands with the privileges of another user, typically the superuser or root user, without having to switch to that user’s account.
what is SSH
a suite of commands that allow secure remote login, remote command execution, connection tunneling, and file transfers
Command to see IP address
ip a s
what command to become root?
su - root or;
su -
If you don’t specify root, the system assumes root
If you aren’t root, but you do have sudo permissions, how can you become root?
sudo -i
sudo -i becomes root
How to generate an ssh key?
ssh-keygen
command to copy a public ssh key to the remote host?
ssh-copy-id user@host
Command to run a command on a remote host without connecting to it
ssh user@host (command)
ex. ssh user@host cat /etc/redhat release
command to copy a file from a remote host to local host without logging in
scp user@host:source destination
ex. scp user@host:/home/web_user/*.gz .
What’s a program you can use to locate and copy remote files via interactive logon?
sftp
What command is used to sftp to a remote server?
sftp user@host
in sftp what command is used to see a list of commands?
question mark, or help
? or “help” (without quotes)
If your non-root account has sudo permissions, what command elevates you to root?
sudo -i
sudo -i
Elevates you to root
without Sudo, what command switches to another user?
su - user
if you have sudo permissions and are not root, how will you switch to another user?
sudo su - yourusername
using sftp, what command is used to copy files back to your host server?
mget
ex. mget *.gz
When moving files around, why is it important to become the relevant user rather than root?
To maintain proper permissions. copying as root may alter permissions of the file.
What is the cli name in RHEL8 for apache
httpd
What is the cli name in RHEL8 for Maria DB
mariadb
what is the cli command to review manuals for programs on RHEM
man
ex. man httpd
what is the cli command to review manuals for programs on RHEL
man
ex. man httpd
What is the cli command for reviewing information pages in RHEL
info
ex. info httpd
What is the cli name for My SQL?
mysql
Where are system documentation stored in RHEL 8?
/usr/share/doc
How would you locate a system doc for mysql?
ls -la /usr/share/doc | egrep -i “mysql”
What is egrep vs grep?
egrep is grep -E
It’s recommended to use grep -E over egrep
What does egrep or grep -E allow you to do?
uses extended regular expressions (EREs) by default. Allowing use of meta-symbols such as +, ? or |
What is the command to install a program in RHEL 8?
dnf -y install <program>
ex. sudo -y install mariadb</program>
What is the -y in a dnf install command?
automatically confirms the installation so you aren’t prompted prior to install.
How would you install Apache and Maria DB in RHEL 8?
sudo dnf -y install httpd mariadb
What’s a cli command that often works for help with installed programs in RHEL 8
<program? –help
ex. mariadb –help
How would you paginate the output of a RHEL 8 command?
<command></command>
ex. mariadb –help | more
more (or less)
How can we find more information about a program and it’s man page references?
whatis
ex. whatis httpd
What command can we use to return all things pertaining to a program?
apropos
ex. apropos httpd
if the mariadb command doesn’t work, but you know it’s installed, what’s the likely alias you should use?
mysql
true or false: the apropos command can also be used to find all things related to a program including those aliased?
True
For example, if mariadb is aliased to mysql, apropos mariadb will return information about it’s mysql aliases.
What does dnf stand for?
Dandified Yum
You installed a dnf package, but the command isn’t found. whatis shows nothing. What other command can you use to solve this mystery?
apropos. Which will find all things pertaining to the package.
ex. apropos mariadb will return:
mysql (1) - the MariaDB command-line tool
mysql_plugin (1) - configure MariaDB server plugins
mysqladmin (1) - client for administering a MariaDB server
So you know while you installed “mariadb” you interact with it using mysql. Thanks apropos!
What key to exit man?
q
Command to show folder structure?
tree
ex. tree /var/log
What is the command to create a new directory
mkdir
What is the command to create a new empty file?
touch
ex. touch <filename></filename>
Command to redirect output of multiple files containing text into a specified file
grep <text> /path/to/dir/* > path/to/file
ex.
grep httpd /raw_logs/* 2> errors.log
How to route standard errors?
2> path/to/log
ex. grep httpd /raw_logs/master.log 2> errors.log
Command to ignore errors
2> /dev/null
ex. grep httpd /raw_logs/master.log 2> /dev/null
command to get number of lines in a file.
Word count
wc
Hyphen L will show th number of lines
wc -l
ex.
wc -l raw_logs/master.log
command to output systemd entries that match a program such as httpd?
journalctl --unit=<service> --no-pager >> file
journalctl --unit=httpd --no-pager >> httpd.log
command to show all running services in RHEL 8
systemctl list-units --type=service --state=running
command to show a service status?
systemctl status <service-name>
ex.
systemctl status httpd
Quick steps to resolve failing httpd service?
Stop the httpd service:
sudo systemctl stop httpd.service
Check if there are any processes running that are related to the httpd service using the following command:
sudo ps -ef | grep httpd
This command will display a list of processes that match the search term “httpd”. If there are any processes running, note the process IDs (PIDs) and terminate them using the following command:
sudo kill <PID>
Replace <PID> with the process ID of the httpd process that you want to terminate.</PID>
Start the httpd service using the following command:
sudo systemctl start httpd.service
Check the status of the httpd service using the following command:
sudo systemctl status httpd.service
If the service has started successfully, the output should indicate that the service is active (running). If there are still errors, you can check the log files for more information about the issue.
Copy code
sudo journalctl -xe
This command will display the system log, including any error messages related to the httpd service.
command to show specific service logs
journalctl
ex. journalctl -u sshd
command to redirect output that excludes strings
egrep -v “string1|string2” log/source > log/destination
ex. egrep -v “dnf|secure” raw_logs/master.log > httpd_logs/no_dnf_secure.log
with the egrep command, what does the -v switch do?
tells egrep to exclude that string(s) from the result.