Tag Archives: file

linux – file commands

 diff <file1> <file2> compare files
 rm -rf <dir> force delete of <dir>
 touch -r <ref_file> <file> matches timestamp <file> to <ref_file>
 touch -t <YYYYMMDDHHSS> <file> set <file> timestamp
 sudo fdisk -i list connected drives
 file <file> determine file type info
 mount /dev/sda# /mnt/usbdrive mount usb drive
 echo -n “<string>” | md5sum generate md5 hash for <string>
 md5sum -t <file> generate md5 hash for <file>
 echo -n “<string>” | sha1sum generate sha1 hash for <string>
 sha1sum <file> generate sha1 hash for <file>
 sort -u <file> sort unique lines in <file>
 grep -c “<string>” <file> count lines with <string> in <file>
 shred -f -u <file>overwrite / delete files
 dos2unix <file> convert <file> to unix format
 find -iname “*<string>*” find files with <string> in the filename
 find / -perm -4000 -o -perm -2000 find suid and gid files
 split -b <size> <file> split <file> in <size> blocks
 awk ‘sub(“$”, “\r”)’ <file_input> > <file_output> convert <file_input> to windows format
 dd skip=1000 count=2000 bs=8 if=<file> of=<file> cut block 1K-3K from <file>
 chattr <+/->i <file> set / unset immutable bit
tail -f * find modified files in current dir
FacebookTwitterGoogle+Share