Here are some bash tips that might be useful to you for a better and more efficient use of the bash shell.
The variable CDPATH
This variable expands the scope of the cd command.
By default, cd looks for a possible subdirectory in the current working directory.
Let us take an example :
fool@localhost:~$ cd cron
If CDPATH is not set, cd will look for a subdirectory named cron. If it does not exist, cd will look through the directories added to CDPATH. As we want to display the content of the directory /var/spool/cron, here is what we have to do :
fool@localhost:~$ export CDPATH=/var/spool/cron
Then, cd cron will work well and the current working directory will be /var/spool/cron
The bash builtin fc
fc displays a list of all the latest commands typed. It is like the command history.
To list the 16 lastest commands typed :
fool@localhost:~$ fc -l
To list a range of commands typed :
fool@localhost:~$ fc -l 495 501
The numbers 495 and 501 refers to the lines numbers displayed by the command history.
To reexecute the command number 495
fool@localhost:~$ fc -s 495
There is a package, named fortunes-debian-hints, which brings you known or unkown tips (depends on you) about using Debian in a more efficient way.
To install it :
root@localhost:~# apt-get install fortunes-debian-hints
To test it, please put the following links in your .bashrc :
if [ -x /usr/games/fortune ]; then
More information on the Debian official wiki :
The first way to search for a file in all a filesystem is to use the command locate
With Debian, locate is no more included in the package findutils.
You must install the package locate which provides the commands locate and updatedb.
As root :
root@localhost:~#apt-get install locate
Then, issue the following command to check whether the commands locate and updatedb are available :
The command locate looks through an index for searching a file.
This index is built after issuing the command updatedb as root :
The more recent the index is, the more efficient is the search through locate.
Make sure that the index is rebuilt on a regular basis. This point is all the more crucial since there are a lot of files creation/deletion. The index could be outdated very quickly.
There are two main ways to add more swap space to your current one : creating a new swap partition or creating a new swap file
The first method
Supposing you still have some remaining space on your SCSI hard drive,
->Create your partition with fdisk
->Format it : mkswap /dev/sda1
->Activate the new swap partition : swapon /dev/sda1
The second method
->Create a new file with the command dd :
dd if=/dev/zero of=/path_of_your_new_swap_file bs=1M count=100
We have just created a 100Mo file
->Then, format this file : mkswap /path_of_your_new_swap_file
->Activate the new swap file : swapon /path_of_your_new_swap_file
The total amount of available swap space can be checked with the two following commands :