Shared Flashcard Set

Details

Linux Administrator Exam Prep LFCSA v2.16
Linux Administrator Exam Prep LFCSA v2.16 skills nessesary to pass LFCSA
100
Computer Science
Professional
10/04/2016

Additional Computer Science Flashcards

 


 

Cards

Term
Utility and useful options for listing active processes. (2 options)
Definition

PS

 

aux

#shows all running proccess

 

au jf  

#shows running procces and tree

Term

How do you change the full name of the user?

(2 ways)

Definition

1. edit the /etc/passwd and manually enter

2. use the chfn (no options if current user)

Term
How do you change the shell for a user?
Definition
chsh
Term
As root, list 2 ways to prevent a user from logging in.
Definition

chsh user

change the shell to /usr/sbin/nologin

or change the shell to 

/bin/false

The second way prevents login period, the first way states that the account is currently not available.

Term
To add a user what command an options could you use to easily setup the username with it's home directory and specify the shell?
Definition
useradd username -m -s /bin/bash
Term
What command with options could you use to add a user to a user group?
Definition

usermod -aG

-a = append

-G = groups (can change multiple)

Term
How can you check to see what groups a user belongs to?
Definition
cat /etc/groups | grep "username"
Term
Parameter used to clear iptables
Definition
iptables --flush
Term
Which firewall command would you use for centOS and which would you use for Ubuntu?
Definition

centOS = firewalld

Ubuntu = iptables

Term
Which command do you use to check the ipforwarding?
Definition
iptables -L
Term
How can you identify which version of Linux you are using from the command line? How can you find the Kernal information?
Definition

cat /etc/lsb-release

cat /etc/debian_version

 

uname -a

Term
What is the location for the iptables config file?
Definition
/etc/sysconfig/iptables-config
Term
How would you reset the iptables settings to default?
Definition
iptables --flush
Term
When scripting using the shell what command can you set so that the script will exit as soon as it executes an error?
Definition
set -e
Term
What are 3 commands for inserting and appending files in VI or VIM?
Definition

1. I for insert

2. A for append and insert on the current line

3. O for append and insert on the next line

Term
Explain how you copy and paste in VI or VIM..
Definition

yy - yank the entire current line

 

p - paste after the cursor

P - paste before the cursor

Term
How do you undo a command in VI or VIM?
Definition

u - undoes any change made

U - undoes a change made to the current line

Term
How would you search for the term "test" in VI or VIM? Then how would you locate the next "test" in the file?
Definition

/test

 

Retype /test

Term
How
Definition
Term
How could you replace all the words Brat with amoeba in the text file red.txt and then output that to the file red2.txt?
Definition
sed 's/Brat/amoeba/g' red.txt > red2.txt
Term
How could you replace all the words Brat with amoeba in the text file red.txt?
Definition
sed 's/Brat/amoeba/g' red.txt
Term
What command & syntax would you use to sort a txt file reverse alphabetically?
Definition
sort -r file.txt
Term
What command would you use to list a txt file by number lines?
Definition
nl file.txt
Term
How would you remove ";"s from a txt file?
Definition
cut -d ';' file.txt
Term

How would you search your whole Linux file system to find the file ping.txt?

 

How would you ignore the case of the letters in the search?

 

Which variable could you use to list every file except ping.txt?

Definition

find / -name "ping.txt"

 

use -iname

 

add -not

Term
How can you use the find command to search for directories?
Definition
add the variable -type d
Term
How can you locate files modified less than a day ago and greater than a day ago?
Definition

find / -mtime -1

 

or 1 for greater than a day ago

Term
How can you search for files by user?
Definition
find / -user user
Term

What does this function do?

 

cp -rf .. .

Definition

Creates a copy of all the conents in a folder one tree up into the current folder.

 

cp = Copy

-recursive

-force

Term

What would this command do?

tar -cvzf data_backup.tar.gz data

Definition

Tar = tape backup

-c compress

-v verbose

-z zip

-f files

data = destination directory

Term
How would you view files in a tar backup?
Definition

tar tvf file

 

t = list

v = verbose

f = file

Term
How would you unzip a tar compressed archive?
Definition

tar zxvf ../file /destination

 

z - uncompress

x - extract

v - verbose

f - file

Term
How do you add a new user?
Definition
useradd username
Term
What command edits file attributes?
Definition
chmod
Term
How do you quit a terminal SSH session?
Definition
exit
Term
What command do you use to list special file attributes?
Definition
lsattr
Term

How would you set a file to be immutable?

How would you set a file to only allow users to append it?

Definition

chattr +i file

chattr +a file

Term
How can you find out what user you are?
Definition
whoami
Term
How can you print the current directory path?
Definition
pwd
Term
What is a useful command to see your real IP address?
Definition
curl ipinfo.io/ip
Term
Explain how you would transfer a file from one linux terminal to another.
Definition
scp -v /sender machine full path user@54.285.11.1:/receiver dir path
Term
What are commands to view what process are using processing and memory resources?
Definition

TOP - shows all running and sleeping processes

HTOP - Better and needs to be installed

use to add to yum library yum install epel-release

free - shows free memory add -m for

df -h   //  Shows Mounted drives

df -hTi  // Shows Inode information

du -sch /var/* - Useful for finding directories that are using too much space

 

 

 

 

Term
What command can you use to see system device configurations?
Definition
dmesg
Term
What directory contains the system logs?
Definition
/var/log
Term
What is the command to do a search with YUM for applications?
Definition
yum search app
Term
What modifier would you add to yum install to skip verification prompts?
Definition
yum install -y app
Term
How would you download just the package (.rpm) file to a your system in RHEL/CentOS?
Definition

yum install -y yum-utils

yumdownloader appname

Term
How would you find out what you have installed on a RHEL/Centos system?
Definition
yum list installed | more
Term
How do you determine if you need to run an update on your applications (RHEL/CentOS)?
Definition
yum check-update
Term
What does this command do? yum grouplist | more?
Definition
This will tell you what groups of applications and libraries are available.
Term

What does this command do?

yum repolist all

 

What does this command do?

yum --enablerepo= install debuginfo

Definition

Lists enabled and disabled repositories install on your system.

 

Would install the debug repository and enable it.

Term
How would you find out what you have done with the yum command?
Definition
yum history
Term
How do you clean your yum
Definition
yum clean all
Term

How do you list the PATH and how would you add a directory to the PATH?

 

Then how to you save your changes so that they work in your next terminal session?

Definition

env | grep PATH

 

export PATH=$PATH:/dir/dir

 

add your PATH=$PATH:/dir/dir:/dir/dir to either

.bashrc or .profile in your ~ directory

Term

How do you create a new user with proper regular syntax?

What are two required steps after that?

Definition

useradd -d /home/user/testuser testuser

You must then Manually create the home directory

mkdir /home/user/testuser

chown testuser:testuser testuser

(from /home)

Term
What is another method to add a new user other than useradd? Why is this method better?
Definition

adduser testuser

Adds the home dir with the appropriate group

Term
How do you remove a user? What should you do next?
Definition

userdel testuser

Remove the user's home directory

 

Term
How do you list the user groups?
Definition
cat /etc/groups
Term
How do you remove a directory and all sub directories?
Definition
rm -rf (Directory)
Term

How do you add a user group?

(3 ways)

Definition

addgroup test1

groupadd test1

vim /etc/groups

Term
How do you temporarily change your user group?
Definition
newgrp usergroup
Term
How do you set a group password?
Definition
gpasswd testgroup
Term
how do you change a file's group ownership?
Definition
chgrp testgroup testfile.txt
Term
How do you add sudo privileges to a user?
Definition

visudo

Then duplicate the root user line with the username instead of root.

Term
Where are passwords stored in modern distributions?
Definition
/etc/shadow
Term
What is the location of the passwd file?
Definition
/etc/passwd
Term

If you wanted to place a system wide variable or script available for all users what file would you place it in?

(ubuntu, centos)

Definition

Ubuntu

/etc/bash.bashrc

Centos

/etc/bashrc

Term
What directory and file would you modify to add items to the startup for each user when they login?
Definition
/etc/skel/.bash_profile
Term

What steps do you need to take to add a new user manually?

5 steps

Definition

Add the user to VIPW

Add the new user's group with VIGR

Create the home directory & set the file permissions for the new user

Copy the skel directory to the new user's directory.

Set the user passwd

Term
How do you remove a folder/contents and all it's sub folders?
Definition
rm -r dir
Term
How do you list the current directory and all sub directories with files?
Definition
add -R to ls
Term
How do you see what processes are currently running for the current user?
Definition
ps
Term
What are 2 applications for viewing what processes are currently running?
Definition
top
htop
Term
How can you list all processes running on your system? How about in tree view?
Definition
ps aux
ps axjf
Term
How can you find the process command id number for a process? What is another way?
Definition
pgrep process id
ps aux | grep id#
Term
How do you kill a process? How do you kill a process that won't kill?
Definition
kill process id#

add -KILL
Term
How do you start and restart a process?
Definition
kill -HUP process id #
Term
How can you raise or lower a processes priority?
Definition
renice -10to10 process id
Term
What does this program do? chfn
Definition
Changes the user's full name and info.
Term
Can you gain access to root with sudo privileges without the root password?
Definition
Yup!
Term
How do you fix the iptables file back to the default values?
Definition
iptables --flush
Term
How would you drop or reject your machine's ability to ping?
Definition
iptables -A INPUT --protocol icmp --in-interface interfaceID -j DROP or REJECT
Term
How do you list your iptables status?
Definition
iptables -L
Term
How do you check the status of your firewall on centOS?
Definition
systemctrl status firewalld
Term
How do you view the IP routing table?
Definition
netstat -rn
Term
Where can you edit properties on iptables that control when table changes are saved?
Definition
/etc/sysconfig/iptables.config
Term
What is a nice GUI partition editor you can install for Linux?
Definition
gparted
Term
How would you list your partitions from the command line?
Definition
df -h
-h prints in powers of 1000
Term
How do you list the physical disks on your system?
Definition
fdisk -l
Term
How do you append and set variables?
Definition

Append

PATH=$PATH:/home/user/

 

Set

PATH=/home/user/

Term
How do you make a variable available for all users? Would this change be permanent after reboot? How would you make that variable permanent for all users?
Definition

export VARIABLE

 

no

 

add the variable to:

/etc/profile

 

 

 

Term
What is the difference between and interactive and non-interactive shell?
Definition
You can interact with and interactive shell, where as a non-interactive shell runs in the background and you cannot issue commands.
Term

Explain this command:

 

ls f[igh][lfz]e*.???

Definition

This command prints the current directory list:

starting with the letter f,

the second character being either i,g, or h

the 3rd character being either l, f, or z

the 4th character being e

the 5th+ characters being anything

and the file extension being exactly 3 digits of anything character

 

*remember that all of this is case sensitive*

*remember you can use [A-Z] to search for characters in a range*

Term
Explain the difference between using single quotes and double quotes in Linux...
Definition
Double quotes will use fetch and use variables and commands where using single quotes preserves the literal meaning of each character and will NOT fetch variables and commands.
Term

How can you ignore a variable in a string that uses a $?

 

For example

 

echo "The cheeseburger is going to cost you $5.00"

Definition

Use a \ in front of $

 

for example

 

echo "The cheeseburger is going to cost you \$5.00"

Term
Explain command options and arguments..
Definition

a command contains a

1. command

 

and then you can add:

 

2. options ie -L  which tells the command how to do something

 

3. arguments which tells the command how to do it

 

ie find -iname "profile.bash"

Term
How do you change the Root password if you forgot it and you have Su privaleges?
Definition

sudo su

 

You then change the Root password and you may then login.

Term
What is a good application for locating .bin sources?
Definition

whereis passwd

 

for the application passwd

Term
How do you ignore case with the grep command?
Definition
grep -i
Term
When using various searches IE the less command how do you navigate between multiple results?
Definition

n for next

N for previous

Supporting users have an ad free experience!