Are you making most out of the Linux? There are lots of helpful features which appears to be Tips and Tricks for many of Linux Users. Sometimes Tips and Tricks become the need. It helps you get productive with the same set of commands yet with enhanced functionality.
1. To audit the commands we’d run in past, we use history command. Here is a sample output of history command.
history
Obvious from output, the history command do not output the time stamp with the log of last executed commands. Any solution for this? Yeah! Run the below command.
HISTTIMEFORMAT="%d/%m/%y %T "
history
If you want to permanently append this change, add the below line to ~/.bashrc.
export HISTTIMEFORMAT="%d/%m/%y %T "
export HISTTIMEFORMAT="%F %T "
#you can also use that
2. The next gem in the list is – how to check disk write speed? Well one liner dd command script serves the purpose.
dd if=/dev/zero of=/tmp/output.img bs=8k count=128k conv=fdatasync
rm -rf /tmp/output.img
3. How will you check the top six files that are eating out your space? A simple one liner script made from du command, which is primarily used as file space usages.
du -hsx * | sort -rh | head -6
Explanation of commands and switches.
du – Estimate file space usages
-hsx – (-h) Human Readable Format, (-s) Summaries Output, (-x) One File Format, skip directories on other file format.
sort – Sort text file lines
-rh – (-r) Reverse the result of comparison, (-h) for compare human readable format.
head – output first n lines of file.
4. The next step involves statistics in terminal of a file of every kind. We can output the statistics related to a file with the help of stat (output file/fileSystem status) command.
stat filename_ext (viz., stat abc.pdf)
dd – Convert and Copy a file
if=/dev/zero – Read the file and not stdin
of=/tmp/output.img – Write to file and not stdout
bs – Read and Write maximum upto M bytes, at one time
count – Copy N input block
conv – Convert the file as per comma separated symbol list.
rm – Removes files and folder
-rf – (-r) removes directories and contents recursively and (-f) Force the removal without prompt.
5.man command
#man ls
manual of the given command
Credit:
https://www.tecmint.com