Linux tips

Clear recently used history from the system.
Gnome save history in recently used history in the ~/.local/share/recently-used.xbel, to clear the history permanently install this:
apt install bleachbit
Conigure belachbit to clear the history, this is a bash script clearing the gnome history:
#!/bin/bash
if cat /dev/null > ~/.local/share/recently-used.xbel
then
echo "history cleared"
else
echo "cleaning failed"
fi
Find and delete a file in linux.
The code below find the file "ALL-PC.eml" and in the "/" and delete them:
find / -name ALL-PC.eml -type f -print0 | xargs -0 /bin/rm -f
Top
Compress, archive ,zip and password protect a folder in linux command.
The better compression tools is p7zip to use with tar archiver install this package:
apt install p7zip-rar
To compress a folder run the commmand:
tar cf - directory | 7za a -si directory.tar.7z
To decompress run this command:
7za x -so directory.tar.7z | tar xf - -C target_dir
To compress files with tar and bzip2 run the command:
tar cvfj archive_name.tar.bz2 dirname/
To add files to an existing archive, use `--append' (`-r'). The command `tar --append --file=afiles.tar arbalest' would add the file `arbalest' to the existing archive `afiles.tar'. The archive must already exist in order to use `--append' (`-r'):
tar -rj
To zip and password protect a folder run this command:
zip -9 -r -e <new_zip_folder_name> <folder_to_zip>
In above command the -9 is for best compression the -r is for folder and -e is for password.
exttarct archives
Extrract all bzipped tar archives from one folder to another folder:
for a in from_folder/*.bz2
do
    tar -xjvf "$a" -C to_folder
done
View the *.tar.bz2 file content without extracting using option tvjf:
tar tvfj archive_name.tar.bz2
Can pipe the output to the less command to view the files one by one.
Top
How to make a hard disk zero or create fix images with dd.
If a hard disk have some data or file system that cannot be overwritten or deleted by the ordinary partitions tools then use the dd command to wipe all data and make the hard disk zero:
dd if=/dev/zero of=/dev/sdc iflag=nocache oflag=direct bs=4096
When finished you will get the message "dd: writing ‘/dev/sdc’: No space left on device".
To create the images use the G for GB and M for mb and K for kilo bytes, open the device and then run the command below:
dd if=/dev/urandom of=image_name bs=1 count=5G
Top
How to emty trah folder from all drives or permanantly delte a file or folder with right click.
Linux have trash for each partiton, when you delete a file or folder going to the trash, to emyty all trashes with one command install the:
apt install trash-cli
Then in terminal as root run the command:
trash-empty
To delete the files and folders from nautilus permanently open the preferences then behavior tab and check the "Include a delete command that bypasses trash" now when right click any file or folder you will see the delte command that permanently will delete that one.
Top


<< Previous Next >>