CompTIA Linux + LX0-104 Flash Cards!

LX0-104 Flash Cards

If you have or want to try a flash card program, I use Anki, which is a free program.
link to anki: https://apps.ankiweb.net/

I have uploaded my Anki flash cards here for download
https://upw.io/u5/LX0-104.apkg

Below are all of the flash cards in text!

Name the 4 X Window Servers currently available from oldest to newest
XFree86 was the first
Xorg-X11 came second
Accelerated-X came third and is a commercial X server
Wayland is the latest replacement for Xorg-X11

What command creates an xorg config file?
Xorg -configure

What are the 5 available sections that go in the ServerLayout?
screen, monitor, input device, device, Module

Name the two super server daemons available
Inetd and xinetd

What role does the super server perform?
Acts as a reverse proxy for services and turns them on only when needed and allowed via config files like hosts.allow or hosts.deny

List the two config files for inetd and xinetd, then list where to store custom configs for them.
/etc/inetd.conf
etc/inetd.d/
/etc/xinetd.conf
/etc/xinetd.d/

“How would you disable the service named “nginx” on a sysV system?”
chkconfig nginx off

“How would you disable the service named “nginx” on a upstart system?
” update-rc.d nginx remove

“How would you disable the service named “nginx” on a systemd system?
” systemctl disable nginx

How would you enable a specific xinetd server config file?
Find the file in /etc/xinetd.d/ and change disabled = yes to no then restart xinetd

What does GNUpg stand for?
GNU Privacy Guard

What two ways can you use GNUpg?
You can use it to sign messages with your private key and readers can verify it with your public key
or you can use it to encrypt messages with someone’s public key and they can decrypt the message with their private key

What command would you use to generate a GPG key?
gpg –gen-key

in GPG/SSH, what is the key fingerprint for?
The fingerprint is so that one can easily verify a public key by a short string.

In GPG what command would you use to export a public key to the mykey.pub file?
gpg –armor –export user@mydomain.com > mykey.pub

In GPG what command do you use to import someone’s public key?
gpg –import publickeyhere

in GPG, what command would you use to encrypt a file with a public key?
gpg -e myfile
then specify the user’s public key via email Adress

or

gpg -r dest@domain.com -e myfile

In GPG , what command would you use to decrypt an encrypted file?
gpg myfile

In GPG, why would we also password protect our private key?
Password protecting the private key provides us with a form of two factor authentication for the key so that if stolen it cannot be used without the password.

In GPG what command would you use to list all keys?
gpg –list-keys

in GPG how would you revoke a public key?
“1. Revoke it with “gpg –gen-revoke myuser@mydomain.com”
2. Copy the output to a a file like revocation.gpg
3. import the file.gpg with “gpg –import revocation.gpg”
4. Distribute the revocation to the key server via “gpg –keyserver gpgserver.domain.com –send-keys myuser@mydomain.com”

Now as long as the original key was created to check for revocations at the keyserver, they will revoke this key.

in GPG, how would you sign a file with your private key, then let someone verify it with your public key?
gpg –clearsign myfile

The above signs the file with your private key and saves it with a .asc extension

gpg –verify myfile.asc

The above verifies the file via the public key imported into the computer

Why is SSH better than telnet?
SSH is encrypted whereas telnet is not.

What two command sets can you use to login to a server via ssh?
server = 10.0.0.10 and user = root, type out the commands
ssh user@server
ssh -l user server

What is the known_hosts file and what purpose does it serve?
This file, stored in the user’s .ssh folder, is used to store public keys of servers so that you can verify it’s the same server you are connecting to.

What command can you use to generate ssh keys, then where are they stored?
ssh-keygen; they are stored in the user’s .ssh directory

In CentOS 7, how do you configure a server to accept your SSH key (private key) then disable password login?
1.Copy the contents of your public key, save it under the server’s ~/.ssh/authorized_keys ( or use ssh-copy-id).

2.Make sure the .ssh directory is CHMOD’d to 700 and the authorized_keys file is CHMOD’d to 600.

3.Edit /etc/ssh/sshd_config and set the paramater PasswordAuthentication no

4.Now restart SSH

How would you copy a local file (/home/user/myfile) in the directory to the user home directory on the remote server (10.0.0.102) via ssh as the root user?

SCP /home/user/myfile user@server:/home/user/myfile

What parameter can be used for SSH to forward X window back to the client? Give an example.
ssh -X root@server

How would you create a SSH tunnel on port 80 to the server’s port 80? Give an example.
ssh -f <ssh destination> -L <local port>:destination to redirect/trigger:<remoteport> -N
ssh -f root@server -L 80:server:80 -N

-f says run in background
-L says my local port to this remote port
-N says don’t run any commands on remote server

Now if you browse to http://127.0.0.1 on your local PC, it will redirect the port to the sever’s port 80

What format are hosts.allow and hosts.deny rules written?
service : x.x.x.x
x.x.x.x above is IP address.

What file can you edit to enable someone to sudo?
What command should be used instead of directly editing it? /etc/sudoers; visudo

What group can you add a user into to allow them to sudo?
Give the full example command. usermod -aG wheel myuser

Name the commands to execute as root or become root
sudo, and su

What files stores the user’s password hashed?
/etc/shadow

What file is the SSH config stored in?
/etc/ssh/sshd_config

On CentOS 7, how do you set an SSH server to only use Protocol 2?
“Edit /etc/ssh/sshd_config and set “Protocol 2″ then restart ssh via systemctl restart sshd”

“What command do you use to create “shortcuts” to other commands?
Give an Example” Alias is used to create shortcuts, ex: alias listall=’ls -la’

“What command would you use to delete the alias “listall” ?”
unalias listall

What prerequisite do you need to do before SSH tunneling will work?
“Edit /etc/ssh/sshd_config and set “AllowTCPForwarding yes”

What prereq must be completed before X forwarding over SSH will work?
“Edit /etc/ssh/ssd_config and set “X11Forwarding yes””

What is the /etc/skel directory for?
This is where all of the default files are, these files are copied into new user’ home directories when they are created.

How would you edit the hostname variable then make it available to sub shells as a variable?
HOSTNAME=myhostname.domain.com

export HOSTNAME

In bash scripting, how would you combine different commands, in one line? Give an example.
“I would do something like this “ls -la ; clear”
The above runs the list command, then clears the screen, all in one line.

What 3 commands will list out all of the ENV variables?
env ; printenv ; set

In a user’s home directory list the bash scripts in order of most preferred, to least preferred.
.bash_profile, .bash_login , .profile

What is the bash logout script called in the user’s home directory that is executed on log out?
.bash_logout

What is /etc/inputrc for?
Keyboard and terminal customization

What string must come at the beginning of every script for it to execute properly?
What is an easy way to remember it ? #! /bin/bash ; One can remember it by thinking SHE BANG BIN BASH

“What is required before running this shell script like this : “./myscript.sh” ; Write out how.”
Before executing the script it requires execute permission ; chmod u+x myscript.sh; then run ./myscript.sh

How can you execute a linux script, without giving it execute permissions?
bash myscript.sh

What is the main difference between sourcing a script and executing it?
Sourcing it runs it in the current shell’s language, while executing it runs it in the configured shell. Also, sourcing it does not require execution permission while executing it does.

How can you pass variables into a bash script? Give an example.
“By using positional variables such as $1 and $2.

./myscript.sh variable variable2

Then in the script you should have references to these variables like so

echo “this command executes $1″
echo ” this command executes $2″

Create a variable called myname with the value of victor, syntactically correct.
“myname=”Victor””

Why would you not set a password like this?
useradd victor -p mypassword It stores it in /etc/shadow unhashed.

“What does the “unset” command do? Give an example.”
“It unsets variables. Like this “Unset myvar””

“How would you store the results of a command in a variable? Store the result of “ls” in a variable.
mylist=$(ls)

How would you accept user prompt in a bash script? Give an example.
By using the read command.

echo “what is your name?”
read name
echo “your name is $name”

Write out all of the commands necessary to create a bash script, with a if then condition, then execute it.
“vi myscript.sh

#! /bin/bash

myname=”victor”

if [ $myname == “victor” ]
then
echo “Your name is Victor”
else
echo “Your name is not Victor :(”
fi

chmod u+x
./myscript.sh

“What does the “test” command do in a bash script?”
It tests if the variable is true, or if it has any content in it, it will return 1 for true.

“With respect to bash, what is “seq” and how is it used?”
seq just prints a range or sequence of numbers. For example “seq 1 10” prints 1..10. or just “seq 10”.

When is it good to run a script with exec, why?
exec is best used when you need to run a script within a script because it closes the shell once it’s done executing.

Write out all of the commands needed to write and execute a for loop script.
vi myscript.sh

#! /bin/bash

for num in $(seq 10);
do
echo $num
done

chmod u+x myscript.sh

./myscript.sh

What does SQL stand for?
structured query language

List 4 possible SQL implementations and their descriptions
mysql – the original mysql now owned by oracle
mariadb – a fork of mysql, open source
postgresql – a bsd alternative to mysql
sqllite – a lightweight SQL database

What is another name for the rows in an SQL table?
TUPLE

What is another name for a column in an SQL table?
attribute

What is another name for type of info in an SQL attribute?
data type/ data domain

How would you login to the local SQL database as root?
mysql -u root -p

What follows every sql command? A
semicolon.

In SQL, what command will select the database MYDB? Type an example.
use MYDB;

What SQL command will list all available databases? Type out an example.
show databases;

In SQL, what command will show all tables in a database? Type it out.
show tables;

How would you create a table called mytable with 2 columns in SQL? Type an example.
create table mytable (name varchar(10), lastname varchar(10));

How would you insert a first and last name, into the table ‘mytable’ with 2 attributes of firstname and lastname? Type it out.
insert into mytable values(‘firstname’,’lastname’);

In SQL, how would you view all values from all attributes from the table mytable? Type it out.
select * from mytable;

In SQL, how would you view only the firstname, lastname attributes from mytable, type it out.
select firstname, lastname from mytable;

“In SQL, how would you select only the rows in ‘mytable’ that have a firstname of “victor”? type it out.”
select * from mytable where firsname=’victor’;

In SQL, how would you delete the table ‘mytable’? Type it out.
drop mytable;

In SQL, how would you delete every row where the attribute firstname equals victor (in a table called mytable)? Type it out.
delete from mytable where firstname=’victor’;

What is the order of preference that hosts.allow and host.deny is checked?
Hosts.allow is checked first, so any allow rule supercedes any deny rules.

What mail emulator program do most distros expect to see installed?
sendmail

Name 4 mail servers (MTA)
sendmail ( the original)
Qmail (not open source, public domain)
Exim
Postfix (most used)

What file can you edit to dictate where accounts or services forward their mail to?
/etc/aliases

When done editing the /etc/aliases file, what command do you need to run?
newaliases

What command can you use to check the mail queue?
mailq

What command can you use to check your user’s mail?
mail -u user

“What command can you use to send an email to the user “bob” from the command line?”
mail bob

Are linux accounts case-sensitive?
Yes

What file lists groups and their membership?
/etc/group

What file lists users, their userID, their primary group, and their home directory path?
/etc/passwd

What command would you use to create the user bob?
useradd bob

What command would you use to set the user bob’s password ?
passwd bob

“What does “passwd testuser -l” do?”
Locks the account

“What does “passwd testuser -u” do?
” Unlocks the account

“What does “passwd testuser -d” do?
” Removes the password on the account.

“What does “passwd testuser -S” do?
” displays info about the account

How would you rename a user? usermod -l new old

What command will change a user’s home directory and move files? Ex: move bob’s files to bob2
usermod -m -d bob /home/bob2

How do we set a bob’s account to expire on 1/1/2018 ?
chage -E 1/1/2018 bob

What command remove’s bob user account along with his home directory?
usedel -r bob

“What command create’s the group “friends” ?”
groupadd friends

“What command deletes the group “friends” ?”
groupdel friends

What command lists all the groups the user bob is a part of?
groups bob

How do we check the systemlog with systemd?
journalctl

Where are linux log files generally stored?
/var/log

List 4 syslog systems for linux.
syslogd
rsyslogd
syslog-ng
journalctl

What is the format of the syslog config in syslog.conf?
facilities.priority action

What are the valid priorities or log levels as it relates to syslog? Lowest to highest priority.
debug
informational
notification
warning
error
critical
alert
emergency

What command can we use to manually generate the log “this is a test”
“logger “this is a test”

How do we set the linux software clock to push it’s time to the hardware clock?
hwclock –systohc

How do we display the hardware clock? sudo hwclock or sudo hwclock -r

What is NTP stratum?
Stratum means how many NTP server hops away we are from the ultimate time source.

Where is the NTP config for linux?
/etc/ntp.conf

How do you list all ntp peers? ntpq -p or –peers

What three ways can we schedule jobs in linux?
1. Using the “at” command
2. Using cronjobs
3. Using Batch (runs jobs when system load average is low)

What two sub types of cron jobs exist?
1. system cron jobs
2. user cron jobs

How do we edit the user cronjobs?
crontab -e

How do we edit SYSTEM cron jobs?
vi /etc/crontab

“How do we schedule a cronjob to run the command “ls” once every day at 7 AM ?”
* 7 * * * ls

When writing cronjobs, what is the meaning of the 5 asterisk fields?
1.minute
2.hour
3.day of month
4. month
5. day of week

“How would you schedule the command “ls” at 1 PM with “at” ?”
at 1300
ls
(press ctrl d)

What command can you use to check the at queue? atq

What command can you use to remove scheduled AT commands? atrm

What file would you edit to set manual host to IP mappings in Linux? Add an entry for myserver at 10.0.0.10
vi /etc/hosts
10.0.0.10 myserver

What file can you edit to configure the interface eth0?
/etc/sysconfig/network-scripts/ifcfg-eth0

What file would you edit to manually set your DNS servers in linux?
/etc/resolv.conf

How would you enable IP forwarding in linux?
Edit the 0 to 1 in /proc/sys/net/ipv4/ip_forward

What file can you edit to manually set a hostname in linux permanently?
/etc/hostname

List two ways to print the route table in Linux.
1. route
2. netstat -r

What global login script gets executed when a user logins?
/etc/profile

name the two major font type technologies
Bitmap fonts – older fonts quick required multiple files, didnt scale well
outline fonts – newer fonts that scaled well, one file, took more cpu to process

Name the two subtypes of Outline fonts
adobe post script type 1, truetype

What file must be edited to add XFT fonts, then what program must you run ?
edit /etc/fonts/local.conf

run
sudo fc-cache

Write a bash script function below called ‘listfunction’ which changes directories and lists all of the files.
listfunction() {
cd /
ls
}

In Bash scripting what does the command ‘$’? tell you?
It tells you the exit code of the last executed command:
0 for success
1 for failure

in SQL, how would you update all objects ‘cost’ to 10 where their attribute ‘clothing’ is ‘shirt’ (in the table mytable)?
update mytable set cost=10 where clothing=’shirt’;

In SQL, we have a table called names, with attributes for firstname and lastname, how would you count all people with the same last name and display them in groups together?
select lastname, count(*) from names group by lastname;

What can you or a local user edit in their home directory to forward their mail?
~/.forward

What file can you edit to configure the systemd-journald daemon?
/etc/systemd/journald.conf

What does Linux utilize to rotate logs? How does it run? Where is it’s config file? What else does it do?
“Linux utilizes the “logrotate” program.This program runs via cron jobs. It’s config is in /etc/logrotate.conf. It deletes, and compresses old logs in /var/log”

In Linux, what network ports are priveleged and what ports are unpriveleged? What does that mean?
Priveleged ports are 1-1023 and unpriveleged are ports 1024-65k
This means to start programs listening on ports 1-1023, you must be root.

What fields must be present in ifcfg-eth0; for a static iP (list all)?
device=name
bootproto=static
onboot=yes
ipaddr=192.168.1.10
netmask=255.255.255.0
gateway=192.168.1.1
network=192.168.1.0
broadcast=192.168.1.255

What fields must be present in ifcfg-eth0 for a DHCP IP (list all)?
device=’name’
bootproto=’dhcp’
onboot=’yes’

What is the /etc/services file for?
Translates names to ports/protocol for programs.

With ifconfig, how would you assign eth0 an ip of 192.168.1.55/24
ifconfig eth0 192.168.1.55 netmask 255.255.255.0

With ifconfig, how would you bring the interface eth0 up or down?
ifconfig eth0 up
ifup eth0

ifconfig eth0 down
ifdown eth0

What is LSOF? What parameter lets you check the network aspect of it?
LSOF is a tool to list open files, however when you add the -i parameter it lists programs and their listening ports.

What is the format of entries in resolv.conf ? What else can be in there?
Entries of nameservers must be like this

nameserver 8.8.8.8

you may also include your default domain in there, like so

domain lab.local

What can you edit to make the Linux system consult DNS before /etc/hosts? What do you set?
Edit /etc/nsswitch.conf
and set
hosts: dns files

What command will list the limitations each user has on core file sizes, cpu time, max processes, and open files?
ulimit -a

What is a group password, how would you set it, and how would you use it?
“A group password is a password for a group
You set it by using “gpasswd mygroup” (you will be prompted for a pass)
You would use it by using “newgrp groupname” to switch groups but you will be prompted for the password

Leave a comment

Exit mobile version