command line
Reclaiming disk space on Ubuntu server
Here are a few command lines to help reclaim disk space:
this one displays folders off the root larger than 1 gigabyte
sudo du -h --max-depth=1 / | grep '[0-9]G\>'Same thing but inside the /var folder
sudo du -h --max-depth=1 /var | grep '[0-9]G\>'THis one will monitor disk space in a term window while you work in another
clear;watch df -hthis command will remove old packages you dont need, and free up a few hundred megs. a good move to instantly get some space, but just not very much.
sudo apt-get autoremove
Quickly fixing SSH when the remote key changes!
So, you cloned your virtual machine and made sure it has the same MAC addresses so that it would pull the same IP from the DHCP server lease. but the next time you click on your SSH icon, it fails.
Does this look familiar?
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!Well this is the magic line:
Offending key in /home/someuser/.ssh/known_hosts:19
Easy batch renaming in Ubuntu (and other debian systems)
Ever want to rename 300 .foo files to .bar? wish you could do this:
mv *.foo *.barHere is the answer: Debian Rename included in ubuntu.
this example renames all .php5 files to .php
rename ‘s/\.php5/.php/’ *.php5
Recursive search for files with specific content using GREP
So you know that somewhere in your source folder (/source) that there is a script that uses the foo() function but you cant remember which one and there are thousands of files, what do you do?
You grep them!
grep -R -i -n 'foo()' *
Lets break it down, first we are grepping files, the -R indicates to search recursively, -i indicates we want to ignore case, and -n indicates we want to know which line of the file grep finds our search string on. then the search string in single quotes and lastly, a finame wildcard, in this case, search through every file.
Popular content