Sunday 24 August 2014

Find large sized files

For example, find files of more than 100MB in size
cd /
find . -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' 


Find latest modified files in current directory and subdirectories
find . -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head

The following command will provide top 20 files of the above command, (useful when there is long unnecessay list)
find . -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n20
notice the -n20 at the end of the command

Find file by name
find / -name filename

Find size of a directory (including all sub contents)
du -hsc /directory/


Compress directory / Uncompress
tar -cvzf filename.tar.gz folderToCompress 
#change the -c to -x to above to extract
Note: this compressing command does not make any change in the source folder 
(leaves unchanged)
to uncompressed the above mentioned compressed folder
tar -xvzf filename.tar.gz 
# This command does not make any change to the compressed gz file (leaves unchanged). It extracts the directory/files in the current directory


How to run a service in background
service-command > /dev/null 2>&1 &


How to find system CPU information
#lscpu



How to download youtube videos on linux computer

Downloading playlist
example
youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)s" https://www.youtube.com/playlist?list=PLhDZ7rwW_JLXzDe8GCIuPcsZxYohZNRT3