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