Sunday, October 25, 2009

Linux CLI - Remove/Delete



1. To remove files
rm


2. To remove empty directory
rmdir 


3. To remove a directory along with all of its contents, type:
rm -fr

*use this with caution as there is no undelete.


4. To uninstall packages
apt-get remove  

Linux CLI - How to clear history

For fast clearing just type 'history -c' command that will clears the terminal history.

Another alternative by googling..

 1. Just put this command in your .bashrc file

a. If you don't even want to keep on in the first place
export HISTSIZE=0

b. Prevent less from creating a history file.
export LESSHISTFILE="-"

c.Prevent a bash history file from ever being saved.
unset HISTFILE


2. Your history will be available in ram for each bash session, but will be gone once you log out

rm -fr ~/.bash_history

ln -s /dev/null ~/.bash_history


3. You could add the following line to the end of your .bash_logout file:

rm -f .bash_history


Test it!!!

Linux CLI - Check size of Directory and sub-directories

1. Display free disk space

df --


2. Display disk usage statistics

du --


Example:


1. Check disk total free space
df -h


2. Check size of directory by list down all the contents
du -ah /path/to/dir



3. Only display total directory size
du -sh /path/to/dir



p/s - normally I only use du -sh & df -h

This Week [44] Motivation

Stop fooling around..
Just do it!