Showing posts with label Size. Show all posts
Showing posts with label Size. Show all posts

20 March 2026

How to find the most largest 10 files on Ubuntu?

To find the largest 10 files in a directory recursively on Ubuntu, use a combination of the
find, du, sort, and head commands.
Command to find the 10 largest files (human-readable format)
Run the following command in your terminal. Replace . with the specific directory path if you want to search a different location:
bash
find . -type f -exec du -Sh {} + | sort -rh | head -n 10
Explanation of the Command
Here is a breakdown of the commands and options used:
  • find .: Starts the search from the current directory (.) and traverses all subdirectories recursively.
  • -type f: Restricts the search to regular files only, ignoring directories, links, etc..
  • -exec du -Sh {} +: Executes the du command on the found files.
    • du: Estimates file space usage.
    • -S: Reports the size of individual files, not including the size of subdirectories (important for listing individual files correctly).
    • -h: Displays sizes in a human-readable format (e.g., 10MB, 2G).
    • {} and +: These are used by find to pass multiple filenames to a single du command efficiently.
  • |: Pipes the output of the find command to the sort command.
  • sort -rh: Sorts the output lines.
    • -r: Reverses the sort order, placing the largest files at the top.
    • -h: Compares human-readable numbers correctly (e.g., understands that 2G is larger than 10M).
  • | head -n 10: Displays only the first 10 lines of the sorted output (the top 10 largest files).
Alternative: Using Bytes for Precise Sorting
If you need a very precise numeric sort (e.g., if the human-readable sorting behaves unexpectedly on non-GNU systems), you can print sizes in bytes:
bash
find . -type f -printf "%s %p\n" | sort -nr | head -n 10
This command prints the size in bytes (%s) followed by the file path (%p), sorts numerically (-n) in reverse order (-r), and shows the top 10 results.
Interactive Method (GUI/TUI)
For an interactive, user-friendly experience, you can use the ncdu tool, which is available in the Ubuntu package manager.
  1. Install ncdu: sudo apt install ncdu.
  2. Run in the directory: ncdu . (or a specific path, e.g., ncdu /var/log). This provides an interactive interface to navigate directories and see the largest files and folders.

23 February 2026

How to shrink file size of a pdf file?

sudo apt update
sudo apt install ghostscript

The Compression Command
Use the following command to compress the PDF to a "screen" quality, which is usually sufficient for viewing on monitors or emailing and will easily bring a 3MB file below 2MB:
bash
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
  • input.pdf: Replace with your original file name.
  • output.pdf: The name of the new compressed file.
Alternative: Better Quality (eBook)
If the /screen setting makes the text look too blurry, try /ebook (150 dpi), which balances good quality with a smaller file size:
bash
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Other Options
  • -dPDFSETTINGS=/screen: 72 dpi, lowest quality, smallest size (best for >2MB requirement).
  • -dPDFSETTINGS=/ebook: 150 dpi, medium quality, better for reading.
  • -dPDFSETTINGS=/printer: 300 dpi, high quality, likely to keep the file over 2MB.
Note: If the PDF contains text only, the file size reduction may be limited.


16 February 2022

29 June 2021

CSS for 5 Typical Media Query Break Points (Device Screen Sizes)

CSS for 5 Typical Media Query Break Points (Device Screen Sizes)


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>

/* Typical device breakpoints - 5 groups */

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
  [class*="col-"] {width: 100%; }
}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
  .col-min600-1 {width: 8.33%;}
  .col-min600-2 {width: 16.66%;}
  .col-min600-3 {width: 25%;}
  .col-min600-4 {width: 33.33%;}
  .col-min600-5 {width: 41.66%;}
  .col-min600-6 {width: 50%;}
  .col-min600-7 {width: 58.33%;}
  .col-min600-8 {width: 66.66%;}
  .col-min600-9 {width: 75%;}
  .col-min600-10 {width: 83.33%;}
  .col-min600-11 {width: 91.66%;}
  .col-min600-12 {width: 100%;}
}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
  .col-min768-1 {width: 8.33%;}
  .col-min768-2 {width: 16.66%;}
  .col-min768-3 {width: 25%;}
  .col-min768-4 {width: 33.33%;}
  .col-min768-5 {width: 41.66%;}
  .col-min768-6 {width: 50%;}
  .col-min768-7 {width: 58.33%;}
  .col-min768-8 {width: 66.66%;}
  .col-min768-9 {width: 75%;}
  .col-min768-10 {width: 83.33%;}
  .col-min768-11 {width: 91.66%;}
  .col-min768-12 {width: 100%;}
}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
  .col-min992-1 {width: 8.33%;}
  .col-min992-2 {width: 16.66%;}
  .col-min992-3 {width: 25%;}
  .col-min992-4 {width: 33.33%;}
  .col-min992-5 {width: 41.66%;}
  .col-min992-6 {width: 50%;}
  .col-min992-7 {width: 58.33%;}
  .col-min992-8 {width: 66.66%;}
  .col-min992-9 {width: 75%;}
  .col-min992-10 {width: 83.33%;}
  .col-min992-11 {width: 91.66%;}
  .col-min992-12 {width: 100%;}
}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
  .col-min1200-1 {width: 8.33%;}
  .col-min1200-2 {width: 16.66%;}
  .col-min1200-3 {width: 25%;}
  .col-min1200-4 {width: 33.33%;}
  .col-min1200-5 {width: 41.66%;}
  .col-min1200-6 {width: 50%;}
  .col-min1200-7 {width: 58.33%;}
  .col-min1200-8 {width: 66.66%;}
  .col-min1200-9 {width: 75%;}
  .col-min1200-10 {width: 83.33%;}
  .col-min1200-11 {width: 91.66%;}
  .col-min1200-12 {width: 100%;}
}

</style>
</head>

<body>

</body>

</html>

20 June 2021

How to list all html files in a directory recursively sorted by file size?

 How to list all html files in a directory recursively sorted by file size?

$du -a -h | sort -nr | grep 'html' | less

Note:

1. '-a' means all files and directories, not just directories.

2. '-h' means human readable.

3. '-n' means numeric sort.

4. '-r' means recursive.

24 March 2021

How can I scale the content of an iFrame?

How can I scale the content of an iFrame?


<iframe src="https://xxx.html" style="border:none; overflow: hidden; position: relative; width: 1044px; height: 1730px; -ms-zoom: 0.5; -moz-transform: scale(0.5); -moz-transform-origin: 0px 0; -o-transform: scale(0.5); -o-transform-origin: 0 0; -webkit-transform: scale(0.5); -webkit-transform-origin: 0 0;" title="xxx"></iframe>

27 July 2016

How to shrink (reduce the size of) a PDF file?

How to shrink (reduce the size of) a PDF file?

Opened the large PDF file with Adobe Reader.

File | Print.

In Printer selection box, choose 'Adobe PDF'.

Click Properties.

Click 'Paper/Quality' tab.

Click 'Advanced'. Look for 'Graphic'/'Print Quality'. Change it into a smaller number pdi. 300pdi is usually OK.

OK | OK | Print.