Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Detailed Articles

Page Tree
root

...

@self

General Search

...

Useful One Off Recipes

Disk Management

List directories from largest to smallest at the top level only. On older system h will not work and you must use k.

Code Block
languagebash
finddu / -namesh [filename] -print # find a file
find / -size +51024 -print     # where 51024 is in Kilobytes which is approximately 5MB

Search Inside of Files

...

* | sort

Long Running Processes

Look for long running processes,

Warning

To write.

Information

Last

Last searches back through the file /var/log/wtmp  (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. 

Lastb

Lastb is the same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad login attempts.

Quck String Manipulation

Quick reference of manipulating standout,

...

Code Block
languagebash
find [folder] -type f | xargs -I {} grep -li "text" {}

find [folder] -type f                  # search the specified folder for all files, returns full path of each file
    | xargs -I {} grep -li "[text]" {} # piped into xargs to grep for all files containing specified text ignoring case

Search & Replace Inside of Files

echo "some_file_name.txt" | tr "_" " " # result will be "some file name.txt"
paste oldName.txt newName.txt > runMe.txt # connects line by line to contents of both files together

 

Integrity Checking

MD5

Check if a file is corrupt,

Code Block
languagebash
find# [folder] -type f | xargs -I {} grep -li "text" {} | xargs perl -pi -e 's/[text_to_search_for]/[text_to_search_for]/g'

find [folder] -type f                  # search the specified folder for all files, returns full path of each file
    | xargs -I {} grep -li "[text]" {} # piped into xargs with to grep for all files containing specified text ignoring case
    | xargs perl -pi -e 's/[text_to_search_for]/[text_to_replace_with]/g' # pipe list of files and using perl search and replace with specified text

Disk Management

List directories from largest to smallest at the top level only. On older system h will not work and you must use k.

Code Block
languagebash
du -sh * | sort

Long Running Processes

Warning

To write.

Other Useful Commands

Code Block
languagebash
On Ubuntu
md5sum /path/to/file

# On Solaris
digest -a md5 -v /path/to/file