DECK 1 Flashcards
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)
-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
touch file{1..10} creates?
ls -d /dir/a*
ls -d /dir/*a
ls -d /dir/a???
ls -d /dir/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
which looks for binaries in….
sudo chvt 3
find / -name “host” 2>/dev/null
something
$PATH
-switches to tty3
looks for “host” on whole system, sends errors to null
looks for object CONTAINING “something”
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
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
find /dir/ -name “*” -type f | xargs grep “127.0.0.1”
mount /dev/devicename/directory
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
findmnt shows all currently mounted devices and their
shows devices not mounted
umount /mnt
-place in filesystem
-lsblk
-unmounts a device
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….
ln -s
-hard link deleted
-change to one is change to the other
ls -il /etc/hosts
ln /dir/file anotherfile
adding text to a symbolic link will change info in target (hard link) and original
show inode# (i) of file
format for create a hard link. The two files will have same inode#
tar -cvf my_archive.tar /home /etc
tar -tvf=
tar -xvf=
-creates tar (my_archive.tar) of /home and /etc directories
shows contents of an archive
extracts. -c switches output
tar -czvf /tmp/archive.tgz /home /etc. What’s with the tgz?
tar -cjvf with .bz2 means
tar -cJxvf with .xz means
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
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
shows last 3 lines of /etc/passwd, pipes output of that to head to show only ONE line
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
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”
grep ‘^l’ /dir/file
grep ‘l$’ /dir/file
grep ‘anna\b’ /dir/file
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
grep ‘b. *t’ /dir/file
awk -F : ‘{ print $4 } ‘ /etc/passwd
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
sed searches and transforms text
sed -i s/oldword/newword/g /dir/file
what does g mean in the above command?
subs “oldword” with “newword” in /dir/file
-global= subs instance EVERYWHERE
sed -i -e ‘10d’ /dir/file
sudo pkill -u username
/etc/sudoers file only editable through visudo
-i = interactive/happens immediately, -e (just there?), ‘10d’ = line 10 is DELETED, /dir/file = where it’s happening
logs out a user
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?
/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!
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
allows Lisa to add folks (useradd) and change passwords (passwd)
! /usr/bin/passwd root
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
connects as a specified user
users with /sbin/nologin in their path cannot…
use command | –help to get
useradd lori -u 2000 -s /sbin/nologin
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)
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
-rf forces user off and deletes them
-password min/max days and warn age. basically password parameters
usermod -L locks accounts, usermod -U= unlocks
usermod -e 2032-01-01 user does what?
usermod -s /sbin/nologin user
-expires the users account (-e)
-sets user’s shell to no login
/etc/passwd contains primary group info
secondary group info is in…
lid -g groupname
groupmod -U user group
/etc/groups
list all users in a group
adds a user to a group (-U unlocks them if needed)
chage user
touch /etc/skel/file
-changes password AGE for a user
-creates a file in /etc/skel. That file is copied to a user’s home directory.
Awk ‘{print $4}’ file and cut -d’ ‘ -f4 file do same thing. What?
-return 4th field of a file containing on space between fields