Archive for 'Linux CLI'

/dev/null does not exist

Lost your /dev/null by accidently shoving a file there as root? Use the following to recreate:

rm /dev/null; mknod -m 666 /dev/null c 1 3

  • Share/Bookmark

find – what you’re looking for and more

Using find on the command line as su is a great way to remove spent sessions from your /tmp directory for instance.

find -user theusersname -delete

Will remove all instances of that users files. A great quick way to clean up after a rogue application in development.

  • Share/Bookmark

Change word in all files in directory (+recursively)

These commands will replace all instances of ‘foo’ with ‘bar’ in all files in the current working directory and any sub-directories.

Current Directory:
sed -i s/foo/bar/g *

Recursively:
find * -type f -exec sed -i s/foo/bar/g {} \;

  • Share/Bookmark