Understanding and Using Essential Tools on RHEL 8 Flashcards

1
Q

To login to a server we don’t have the IP address for, what type of login do we use?

A

Console login

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command is used to become another user?

A

su user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is sudo for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is SSH

A

a suite of commands that allow secure remote login, remote command execution, connection tunneling, and file transfers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Command to see IP address

A

ip a s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what command to become root?

A

su - root or;
su -
If you don’t specify root, the system assumes root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If you aren’t root, but you do have sudo permissions, how can you become root?

A

sudo -i
sudo -i becomes root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to generate an ssh key?

A

ssh-keygen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

command to copy a public ssh key to the remote host?

A
ssh-copy-id user@host
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Command to run a command on a remote host without connecting to it

A

ssh user@host (command)
ex. ssh user@host cat /etc/redhat release

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

command to copy a file from a remote host to local host without logging in

A

scp user@host:source destination
ex. scp user@host:/home/web_user/*.gz .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What’s a program you can use to locate and copy remote files via interactive logon?

A

sftp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What command is used to sftp to a remote server?

A

sftp user@host

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

in sftp what command is used to see a list of commands?

A

question mark, or help
? or “help” (without quotes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If your non-root account has sudo permissions, what command elevates you to root?

A

sudo -i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

sudo -i

A

Elevates you to root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

without Sudo, what command switches to another user?

A

su - user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

if you have sudo permissions and are not root, how will you switch to another user?

A

sudo su - yourusername

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

using sftp, what command is used to copy files back to your host server?

A

mget
ex. mget *.gz

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

When moving files around, why is it important to become the relevant user rather than root?

A

To maintain proper permissions. copying as root may alter permissions of the file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the cli name in RHEL8 for apache

A

httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the cli name in RHEL8 for Maria DB

A

mariadb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

what is the cli command to review manuals for programs on RHEM

A

man
ex. man httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

what is the cli command to review manuals for programs on RHEL

A

man
ex. man httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is the cli command for reviewing information pages in RHEL

A

info
ex. info httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the cli name for My SQL?

A

mysql

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Where are system documentation stored in RHEL 8?

A

/usr/share/doc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

How would you locate a system doc for mysql?

A

ls -la /usr/share/doc | egrep -i “mysql”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is egrep vs grep?

A

egrep is grep -E
It’s recommended to use grep -E over egrep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What does egrep or grep -E allow you to do?

A

uses extended regular expressions (EREs) by default. Allowing use of meta-symbols such as +, ? or |

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What is the command to install a program in RHEL 8?

A

dnf -y install <program>
ex. sudo -y install mariadb</program>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What is the -y in a dnf install command?

A

automatically confirms the installation so you aren’t prompted prior to install.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

How would you install Apache and Maria DB in RHEL 8?

A

sudo dnf -y install httpd mariadb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What’s a cli command that often works for help with installed programs in RHEL 8

A

<program? –help
ex. mariadb –help

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

How would you paginate the output of a RHEL 8 command?

A

<command></command>

ex. mariadb –help | more

more (or less)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

How can we find more information about a program and it’s man page references?

A

whatis
ex. whatis httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What command can we use to return all things pertaining to a program?

A

apropos
ex. apropos httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

if the mariadb command doesn’t work, but you know it’s installed, what’s the likely alias you should use?

A

mysql

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

true or false: the apropos command can also be used to find all things related to a program including those aliased?

A

True
For example, if mariadb is aliased to mysql, apropos mariadb will return information about it’s mysql aliases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What does dnf stand for?

A

Dandified Yum

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

You installed a dnf package, but the command isn’t found. whatis shows nothing. What other command can you use to solve this mystery?

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What key to exit man?

A

q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Command to show folder structure?

A

tree
ex. tree /var/log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What is the command to create a new directory

A

mkdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

What is the command to create a new empty file?

A

touch
ex. touch <filename></filename>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Command to redirect output of multiple files containing text into a specified file

A
grep <text> /path/to/dir/* > path/to/file

ex.
grep httpd /raw_logs/* 2> errors.log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

How to route standard errors?

A

2> path/to/log
ex. grep httpd /raw_logs/master.log 2> errors.log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

Command to ignore errors

A

2> /dev/null
ex. grep httpd /raw_logs/master.log 2> /dev/null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

command to get number of lines in a file.

A

Word count

wc

Hyphen L will show th number of lines
wc -l

ex.
wc -l raw_logs/master.log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

command to output systemd entries that match a program such as httpd?

A
journalctl --unit=<service> --no-pager >> file
journalctl --unit=httpd --no-pager >> httpd.log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

command to show all running services in RHEL 8

A
systemctl list-units --type=service --state=running
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

command to show a service status?

A
systemctl status <service-name>

ex.
systemctl status httpd
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Quick steps to resolve failing httpd service?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

command to show specific service logs

A

journalctl
ex. journalctl -u sshd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

command to redirect output that excludes strings

A

egrep -v “string1|string2” log/source > log/destination
ex. egrep -v “dnf|secure” raw_logs/master.log > httpd_logs/no_dnf_secure.log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

with the egrep command, what does the -v switch do?

A

tells egrep to exclude that string(s) from the result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Command to remove a directory?

A

rmdir

58
Q

True or false, rmdir will remove a directory with content?

A

False. The directory must be empty.

59
Q

What command will remove a directory with content?

A

rm -r
ex. rm -r <folder>
-f will force delete, so -rf</folder>

60
Q

What command in vi will remove a line?

A

dd

61
Q

in vi what is the command to delete a character?

A

x

62
Q

in vi, what is the command to delete a specified number of characters?

A

x
ex. 10 x

63
Q

in vi, how do you add text?

A

press the insert key

64
Q

in vi, how do you exist edit mode?

A

esc

65
Q

in vi, how do you replace text?

A

lower case r, followed by the text
ex. r 1

66
Q

in vi, how do you undo an edit?

A

lowercase “u”

67
Q

in vi, how do you repeat the last edit?

A

period
ex. “.”

68
Q

in vi, how would you create a new copy of a file?

A
w <filename>
69
Q

In vi, how do you add a line below another line?

A

lowercase “o”

70
Q

How do you add a line above another line?

A

uppcase “O”

71
Q

in vi how do you quit and discard changes?

A

:q!

72
Q

in vi how do you save changes when quitting?

A

:wq

73
Q

in vi, if you made no changes, how do you quit vi?

A

:q

74
Q

What is a hard link?

A

An additional name for an existing file

75
Q

True or false: Hard links can be created for directories?

A

False

76
Q

Can a hard link cross filesystem boundaries or partitions?

A

No

77
Q

What changes are made to a hard links inode number and permissions?

A

None. Hard links retain their original inode number and permissions

78
Q

What is an inode number?

A

A unique numeric string associated to each folder and file

79
Q

What is a soft link?

A

A special file that points to another file. (not a shortcut)

80
Q

True or false: soft links can be created for directories?

A

True

81
Q

True or false: soft links cannot cross filesystem boundaries and partitions?

A

False. soft links CAN cross filesystems and boundaries.

82
Q

True or false: soft links have a different inode number and file permission than the original file?

A

True

83
Q

True or False: soft links contain the data of the original file?

A

False. Soft links simply point to the original file.

84
Q

In linux file permissions, what does position 1 represent?

A

directory, file, or link.
ex. d, or -, or l

85
Q

In position 1 of linux permissions, what does a hyphen represent?

A

a normal file

86
Q

In position 1 of linux permissions, what does a “d” represent?

A

a directory

87
Q

In position 1 of linux permissions, what does an “l” (L) represent?

A

a link

88
Q

In Linux permissions, what do positions 2, 3, and 4 represent?

A

Read, write execute permissions for the user

89
Q

In Linux permissions, what do positions 5, 6, and 7 represent?

A

Read, write execute permissions for the group

90
Q

What do positions 8, 9, and 10 represent in Linux permissions?

A

read, write execute permissions for “everyone”

91
Q

what does position 11 in Linux permissions represent?

A

SELinux context(.); Any other alternative access method (ACL) (+)

92
Q

In Linux permissions what does hyphen represent?

A

No flag (permission) set.

93
Q

In Linux permissions what does r represent?

A

Readable

94
Q

In Linux permissions what does w represent?

A

Writeable

95
Q

In Linux permissions what does x represent?

A

Executable

96
Q

In Linux permissions what does s represent?

A

Set GID

97
Q

In octal permissions, who does the first digit represent?

A

user

98
Q

In octal permissions, who does the second digit represent?

A

group

99
Q

In octal permissions, who does the third digit represent?

A

everyone else

100
Q

In Octal permissions, what does 0 represent?

A

No permission

101
Q

In Octal permissions, what does 1 represent?

A

execute only

102
Q

In Octal permissions, what does 2 represent?

A

write only

103
Q

In Octal permissions, what does 3 represent?

A

write and execute

104
Q

In Octal permissions, what does 4 represent?

A

read only

105
Q

In Octal permissions, what does 5 represent?

A

read and execute

106
Q

In Octal permissions, what does 6 represent?

A

read and write

107
Q

In Octal permissions, what does 7 represent?

A

read, write, and execute (full permissions)

108
Q

In octal, what does 755 represent

A

The user has full permissions, and the group and everyone else have read and execute

109
Q

In octal, what does 777 represent

A

The user, group, and everyone else have full permissions.

110
Q

What is the cli command to manage permissions?

A

chmod

111
Q

What cli command will change the permissions of every file and folder under a specified folder so that everyone has full permissions?

A

chmod -r 777 <dir></dir>

112
Q

what cli command will give the owner read and write on a file, but everyone else read-only?

A

chmod 644 <file></file>

113
Q

In symbolic permissions, what does “a” represent?

A

All others.

114
Q

In symbolic permissions, what does “g” represent?

A

group

115
Q

In symbolic permissions, what does “o” represent?

A

Other - users who are not the owner of the file or members of the file’s group

116
Q

In symbolic permissions, what does “a” represent?

A

All of the above. Acts on each permission type.

117
Q

in cli, what does chmod a+x script.sh do?

A

Adds the execution permission to all permission types.

118
Q

in cli, what does chmod -R go-wx my_dir do?

A

It recursively removes write and execute from all content within the my_dir directory.

119
Q

in cli, what does chmod u=rw, go=r file.txt so?

A

it sets the user’s permission to read/write, and sets group and other to read only on file.txt.

120
Q

in cli, what does chown -R web_user:web_group /web_data/ do?

A

It recursively sets ownership of files and folders within the web_data folder to the web_user user, and the web_group group.

121
Q

in cli, what does the command ls -ld do?

A

lists content in long list format (-l) and displays information about the directory itself (-d)

122
Q

in cli, what does the command ls -la do?

A

Lists content in long list format (-l) and displays all files and folders, including hidden ones (-a)

123
Q

What command will show disk information in Linux?

A

df -h

124
Q

what does df stand for for the linux disk command?

A

disk free

125
Q

in the df command, what is the -h do?

A

Outputs the information in a human-readable format

126
Q

what cli command is used to create an archive?

A

tar

127
Q

in the tar command, what does cvf do?

A

c = create
v = verbose
f = file

128
Q

What does this command do? tar cvf /home/archives/user1.tar /user1

A

Creates an archive file in /home/archives/ named user1.tar. The contents of user1 will be added to the archive

129
Q

in tar, how would you list the contents of an archive?

A

tar t
ex. tar tvf archives/user1/tar

130
Q

How do you compress using tar?

A

tar z
the z tells tar to compress using gzip2
ex. tar cvfz /path/to/file.tar.gz

131
Q

true or false, if you compress with tar using the z switch, it will automatically append the .gz to the file name?

A

False. You must add that to the file name
ex. tar cvfz /path/to/file.tar.gz

132
Q

what command will iterate numerically

A

{1..#}
ex. tar cvfz archives/project_archive.tar.gz project{1..5}

133
Q

How do you decompress a single archive file using bzip2?

A

bzip2 -d /path/to/file

134
Q

What is the command to see which user you’re working as?

A

whoami

135
Q

What is the command to get information about your user?

A

id

136
Q

Vim command to change a work

A

cw
Hover over a letter, press cw to change the remaining word

137
Q

Vim command to change capitalization?

A

tilde ( ~ )

138
Q

Vim command to enter insert mode and move you to the end of the line?

A

Capital A

139
Q

Options to save and exit Vim?

A

ZZ or;
:wq

140
Q

ping command to limit the number of pings?

A

-c <count>
ex. ping -c 4</count>