DECK 1 Flashcards

1
Q

ffind / -name passwd -exec cp {} /mnt/copy \; to move
find / -name “passwd” -exec cp {} /mnt/copy \; to move
find / -name “passwd
” -exec cp {} /mnt/copy \; to move

man mandb updates?

man -k something?

rmdir only removes EMPTY directories. Need -r to remove directory with shit (can also add f too)

A

-looks for passwd
-looks for beginning with “passwd”
-looks for ending with “passwd”

-man pages

searches man pages for an expression, like “print”, “user” etc

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

touch file{1..10} creates?

ls -d /dir/a*

ls -d /dir/*a

ls -d /dir/a???

ls -d /dir/a???*

A

-file1-file10

-shows files that begin with a in a directory

-ending in a

-files starting with a but has 3 characters

-starting with a but has 3 OR MORE characters

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

which looks for binaries in….

sudo chvt 3

find / -name “host” 2>/dev/null

something

A

$PATH

-switches to tty3

looks for “host” on whole system, sends errors to null

looks for object CONTAINING “something”

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

find / -type f -size +100M 2>/dev/null

find /etc -size +1k -exec grep -l student {} \; 2>/dev/null

\; seperates commands

mkdir -p creates parent directories if they don’t exist

A

looks (-l) for files with a size bigger than 100MBS and sends errors to null

looks (-l) in etc with a size over 1mb, looks for “student” and sends errors to null

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

find /dir/ -name “*” -type f | xargs grep “127.0.0.1”

mount /dev/devicename/directory

A

finds files (-f) in a dir with ANY name (*). xargs passes command to grep to find 127.0.0.1

mounts a device and give it a directory

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

findmnt shows all currently mounted devices and their

shows devices not mounted

umount /mnt

A

-place in filesystem

-lsblk

-unmounts a device

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

ln creates a hard link, …creates a soft link

symbolic links points to hard links. Symbolic links become invalid if…

files with hard links are deleted only when ALL hard links are deleted

hard links and the original share same inode, meaning….

A

ln -s

-hard link deleted

-change to one is change to the other

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

ls -il /etc/hosts

ln /dir/file anotherfile

adding text to a symbolic link will change info in target (hard link) and original

A

show inode# (i) of file

format for create a hard link. The two files will have same inode#

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

tar -cvf my_archive.tar /home /etc
tar -tvf=
tar -xvf=

A

-creates tar (my_archive.tar) of /home and /etc directories
shows contents of an archive
extracts. -c switches output

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

tar -czvf /tmp/archive.tgz /home /etc. What’s with the tgz?

tar -cjvf with .bz2 means

tar -cJxvf with .xz means

A

creates a compressed file with gzip (-z) of /home and /etc. ‘tgz’ is a good way of specifiying file was compressed with gzip

file compressed with bzip

file compressed with xz compression. Smallest of compressors but slowest

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

head= shows first 10 lines
tail= shows last 10
-n= specifiy number of lines

tail -3 /etc/passwd | head -n 1

cat -A= shows all non-printable characters

A

shows last 3 lines of /etc/passwd, pipes output of that to head to show only ONE line

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

cut -d : -f 1 /etc/passwd | sort

grep -v something = excludes a word from results

ps aux | grep ssh | grep -v grep

grep -i = case insensitive

A

cuts out (cut) stuff, with : as the delimiter and shows field 1 of /etc/passwd, pipes that output to sort

-shows processes, pipes output to grep to show only ssh, pipes again to grep -v to exclude “grep”

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

grep ‘^l’ /dir/file

grep ‘l$’ /dir/file

grep ‘anna\b’ /dir/file

A

looks for starting with (^l) the letter l

looks for ending with ($l) the letter l

searches for the word “anna” in the users file

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

grep ‘b. *t’ /dir/file

awk -F : ‘{ print $4 } ‘ /etc/passwd

A

looks for shit starting with b, followed by any character (.) and then followed by a t (*t) in /dir/file

awk -F : (field separator at :), ‘{ print $4 } ‘ = takes fourth field from each line, /etc/passwd = where this is happening

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

sed searches and transforms text

sed -i s/oldword/newword/g /dir/file

what does g mean in the above command?

A

subs “oldword” with “newword” in /dir/file

-global= subs instance EVERYWHERE

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

sed -i -e ‘10d’ /dir/file

sudo pkill -u username

/etc/sudoers file only editable through visudo

A

-i = interactive/happens immediately, -e (just there?), ‘10d’ = line 10 is DELETED, /dir/file = where it’s happening

logs out a user

17
Q

instead of editing /etc/sudoers, create drop-in files in..

wheel members get full sudo access

%wheel ALL=(ALL) ALL in /etc/sudoers gives

usermod -aG wheel myuser

NEVER add NOPASSWD: ALL to end of wheel line. WHY?

A

/etc/sudoers.d

full sudo access to a user

adds (-aG) to the wheel group a user (myuser)

because sudo usrs won’t be asked for a password!

18
Q

the drop in file lisa ALL= /usr/sbin/useradd, /usr/bin/passwd does what?

if you’ve given a user rights to change a passwd, what like should you add at end to STOP them from changing root passwd?

by default, ssh is always on and active and allowed through firewall.

can check status of any service with systemctl status service

A

allows Lisa to add folks (useradd) and change passwords (passwd)

! /usr/bin/passwd root

19
Q

use ssh and an ip address to connect

ssh user xxx.xxx.xxx.xxx =

ROOT ACCESS TO SSH IS DISABLED BY DEFAULT ON RHEL 9!

user properties are managed in /etc/passwd

A

connects as a specified user

20
Q

users with /sbin/nologin in their path cannot…

use command | –help to get

useradd lori -u 2000 -s /sbin/nologin

A

login. EVER

better output for a command

adds a user named lori, sets uid to 2000 (-u 2000) and sets shell to no login (-s /sbin/nologin)

21
Q

userdel -rf username

/etc/login.defs contains UMASK, GID/UID limits, and…

by default in RHEL, users get a home directory. home directories are added to /etc/skel

A

-rf forces user off and deletes them

-password min/max days and warn age. basically password parameters

22
Q

usermod -L locks accounts, usermod -U= unlocks

usermod -e 2032-01-01 user does what?

usermod -s /sbin/nologin user

A

-expires the users account (-e)

-sets user’s shell to no login

23
Q

/etc/passwd contains primary group info

secondary group info is in…

lid -g groupname

groupmod -U user group

A

/etc/groups

list all users in a group

adds a user to a group (-U unlocks them if needed)

24
Q

chage user

touch /etc/skel/file

A

-changes password AGE for a user

-creates a file in /etc/skel. That file is copied to a user’s home directory.

25
Q

Awk ‘{print $4}’ file and cut -d’ ‘ -f4 file do same thing. What?

A

-return 4th field of a file containing on space between fields