Linux File Commands Flashcards
Compare files
diff file1 file2
Force delete of
rm -rf
Overite/delete file
shred -f -u
Matches ref_file timestamp
touch -r
Set file timestap
touch -t YYYMMDDHHSS
List connected drives
sudo fdisk -l
Mount USB key
mount /dev/sda# /mnt/usbkey
Compute md5 hash
md5sum -t file
Generate md5 hash
echo -n “str” | md5sum
SHA1 hash of file
sha1sum file
Sort/show unique lines
sort -u
Count lines w/ “str”
grep -c “str” file
Create .tar from file
tar cf file.tar files
Extract .tar
tar xf file.tar
Create .tar.gz
tar czf file.tar.gz files
Extract .tar.gz
tar xzf file.tar.gz
Create .tar.bz2
tar cjf file.tar.bz2 files
Extract .tar.bz2
tar xjf file.tar.bz2
Compress/rename file
gzip file
Decompress file.gz
gzip -d file.gz
UPX packs orig.exe
upx -9 -o out.exe orig.exe
Create zip
zip -r \Directory*
Cut block 1K-3K from file
dd skip=1000 count=2000 bs=8 if=file of=file
Split file into 9K chunks
split -b 9K \
Win compatible txt file
awk ‘sub(“$”.”\r”)’ unix.txt > win.txt
Find PDF files
find -i -name -type *.pdf
Search for setuid files
find / -perm -4000 -o -perm -2000 -exec ls -ldb {} \;
Convert to *nix format
dos2unix
Determine file type/info
file
Set/Unset immutable bit
chattr (+/-)i