Some interesting Linux Tools:
1) Backing up ‘/’ “root partition” in Linux:
It may happen that we run out of memory in the ‘/’ (i.e. root partition). As all the packages are stored in the root partition only it is not possible to directly delete the file(s). An alternative to this is resizing the partition with some Partition Editor program like ‘GParted’. But as the program also suggests it may lead to loss of data (and the whole partition may be needed to be reformatted leading to entire loss of data).
In such and many more cases we may perform a total backup of the ‘/’ root partition by writing some commands in the Terminal. In this case we make a ‘tar’ backup of the whole root partition which we may restore in case of data loss.
COMMANDS WHILE CREATING BACKUP#
cd / ### Change current directory to ‘/’ root
tar -cvpzf backup.tar.gz –exclude=backup.tar.gz –exclude=/media –exclude=/proc –exclude=/lost+found –exclude=/sys –exclude=/mnt –exclude=/dev –exclude=/home
# ‘–exclude=/home’ only when ‘/home’ folder is on other separate partition.
# To know more about why ‘-cvpzf’ is used, try “man tar” in the Terminal.
# Note that we are using the root directory itself to store the backup (…. -cvpzf backup.tar.gz …). We may also use any suitable location to store it. (Say for example /home/test/backup.tar.gz)
# Create the backup and specify the parameters. The ‘–exclude’ flags are used for the locations which are not to be included in the backup. First ‘–exclude’ for the backup file itself as we don’t want to make a backup of the backup file itself (which will lead to error). Second ‘–exclude’ to avoid the ‘/media’ folder which is the mount point for all the other partitions. The other ‘–exclude’s for /proc, /lost+found, /sys, /mnt and /dev are due to the fact that they are not needed in the backup and can be restored automatically. The ‘–exclude’ for /home is optional and is to be used only when there is separate partition for the ‘/home’
COMMANDS WHILE RESTORING BACKUP#
tar –xvpzf /home/test/backup.tar.gz -C / # assuming that the backup file is stored in the directory ‘/home/test/’
mkdir /media
mkdir /proc
mkdir /lost+found
mkdir /sys
mkdir /mnt
mkdir /dev
mkdir /home ### Only if excluded while creating Backup
# Recreate the directories not included in the backup by using ‘mkdir’ from the Commands List.
# Refer to the commands list for more general commands.
If still by any chance after you restore the backup the GRUB menu does not show up or shows “grub rescue>” follow the commands give at ‘Tackling GRUB Rescue by the chroot method‘.
Note that if you have to, by any chance, reinstall the GRUB Bootloader, you will need a LiveOS installed on a USB stick or a Live CD/DVD.
2) How to change the display in Terminal:
Bored by looking the mylongusername@my-another-long-pc-name:$ in the Terminal, then you can change the display by just using two commands.
a=PS1
PS1=:
Using these two commands, we can change the display to only a ‘:’.
Other characters or words may be used by replacing the ‘:’ in the command by the required keyword.
To restore it just close the Terminal and open a new one. All changes are undone.