Tip #201 Store a directory name to come back to
Put the following alias in your profile to store a directory name to use later on:Read more »
Tip #197 Zero files
Zero out files leaving directory and file sets in place - used for archival purposes.Read more »
Tip #196 Manipulate Bash sockets using /dev/tcp
Don't have telnet or netcat handy for making a socket connection? Most Linux distros - not likely Debian - have this functionality built directly into Bash. The following will pull my site's index source on port 80, replace with any URL.Read more »
- TAGS:
- bash
Tip #195 Bash
These handy one-liners are used to perform the famous Caesar cipher encryption where letters of the alphabet are shifted by differing margins. The same tr command can be used to encrypt and decrypt encoded files/strings.Rot-13 encryption:
(file)
Read more »
- TAGS:
- bash
Tip #194 Fix the previous command
If, like me, you often make mistakes on the command line, try using the history shortcut '^^' to repeat the last command with changes.For example:
Read more »
Tip #185 CDPATH
This is a little known and very underrated shell variable. CDPATH does for the cd built-in what PATH does for executables. By setting this wisely, you can cut down on the number of key-strokes you enter per day.For example:
Read more »
- TAGS:
- bash
Tip #181 Remove empty directories
To remove empty directories (even if filenames or dirnames contain spaces or weird characters) from a tree you can do:Read more »
Tip #180 Permanent bash history
Often I find myself using Ctrl-R in Bash to get an old command, only to find that too many days have passed and it's no longer in the .bash_history file.It is possible to increase the number of lines in the history file, but there can always be a moment when you'll need a long command from many months ago. The solution below uses the PROMPT_COMMAND variable, a command that bash executes before showing each prompt. Here are the two lines to add to your profile:
Read more »
- TAGS:
- history
- bash
- redirection
Tip #179 Disable bash history
Disable history for a particular account in bash with:(in home dir)
Read more »
- TAGS:
- history
- bash
- redirection
Tip #165 Directories and its size
which directories and trees take up all the diskspace?du -sm $(find /start/dir/* -type d -maxdepth 1 -xdev) | sort -g
If you want more human readable output try:
du -ha /var | sort -n -r | head -n 10
you want to see ALL directories in the tree
find $1 -type d | xargs du -sm | sort -g
To show all directories size including sub directories, type
du -h
To calculate the current directory size you are in (-s stand for summary)
du -sh
To show all the 1 level sub directories size (which you are not interested at sub sub directories.)
du -sh *
To show the size of specific directory
du -sh /home
To show the size of all sub directories of a specific directory
du -sh /home/* Read more »
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs