There are many ways to list directories and sort the results by size. I have just found another way. Use the ls command with the -S parameter. This sorts files by size. Very useful way to get the largest files in a certain directory. Linux has so many varied methods of listing files, it is hard to keep up with how many there are. Even using echo * | tr " " "\n"
is useful for this. But the ls command is more verbose than echo.
List the top 10 largest files in a certain directory.
ason@Yog-Sothoth » Documents » $ ls -hula -S | head -n 10 total 19M -rw-r--rw- 1 jason jason 512M Feb 16 13:18 myimage.img -rw-rw-r-- 1 jason jason 4.3M Jan 23 11:26 zsh-5.4.2.tar.gz -rw------- 1 jason jason 2.2M Jun 7 09:45 ubuntupocketguide-v1-1.pdf -rw-rw-r-- 1 jason jason 1.9M Jun 7 09:45 hell.jpg -rw-r--rw- 1 jason jason 1.7M Mar 21 10:29 directory.miff -rw-r--r-- 1 jason jason 1.4M Jan 23 11:12 RAIDInteractiveSimulator4.exe -rw-rw-r-- 1 jason jason 556K Mar 26 09:51 pg768.txt -rwxrwxrwx 1 jason jason 477K May 8 09:05 registration.js -rw-rw-r-- 1 jason jason 459K Mar 23 14:06 NRB_458574869EDR_F0390444NCAM00295M_.JPG
Listing the first 10 files in a directory with the built-in bash echo command.
jason@Yog-Sothoth » Documents » $ echo * | tr " " "\n" | head -n 10 1434065177594.jpg 1434065201125.jpg 1434065287849.jpg 1434065333771.jpg 1434065359757.jpg 1434065384104.jpg 6thRBAnnex-and-Invade.Altis 70 altis_patrol_ops_nato.Altis ammo_box
Print a file listing using printf() instead of ls.
jason@Yog-Sothoth » Documents » $ printf '%s\n' * | head -n 10 1434065177594.jpg 1434065201125.jpg 1434065287849.jpg 1434065333771.jpg 1434065359757.jpg 1434065384104.jpg 6thRBAnnex-and-Invade.Altis 70 altis_patrol_ops_nato.Altis ammo_box
List all pending upgrades if there are any.
ason@Yog-Sothoth » Documents » $ apt list --upgradeable Listing... Done
List a directory using find instead of ls.
jason@Yog-Sothoth » Documents » $ find . -maxdepth 1 -type f | head -n 20 ./setup-ad-server.ps1 ./70 ./hello.txt ./back10.png ./missilethumb.jpg ./ver.pl ./zsh-5.4.2.tar.gz ./config.cpp ./root.jpeg ./back9.xcf ./warn.c ./1434065333771.jpg ./1434065384104.jpg ./registration.js ./flip ./RAIDInteractiveSimulator4.exe ./missilebig.jpg ./index.html?lang=en-pl ./out.txt ./hell.jpg
List only subdirectories in a folder that match a certain name.
jason@Yog-Sothoth » share » $ find mate* -maxdepth 0 | head -n 20 mate mate-about mate-applets mate-background-properties mate-calc mate-control-center mate-dict mate-dictionary mate-disk-usage-analyzer mate-eiciel mate-media mate-menu mate-menus mate-notification-daemon mate-panel mate-power-manager mate-screensaver mate-screenshot mate-sensors-applet mate-session-manager
The -maxdepth 0
parameter to find will only search for directories and not files. Very useful for searching a system for a certain sub-directory in a certain Linux directory. Very useful if there are a lot of them, and finding just one is desired.
Get information about a certain apt package. This is very useful to ensure the user is installing the right one for the job.
jason@Yog-Sothoth » share » $ apt show mc Package: mc Version: 3:4.8.19-1 Priority: optional Section: universe/utils Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian MC Packaging Group <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1,487 kB Provides: mcedit Depends: e2fslibs (>= 1.37), libc6 (>= 2.15), libglib2.0-0 (>= 2.35.9), libgpm2 (>= 1.20.4), libslang2 (>= 2.2.4), libssh2-1 (>= 1.2.8), mc-data (= 3:4.8.19-1) Recommends: mime-support, perl, unzip Suggests: arj, bzip2, catdvi | texlive-binaries, dbview, djvulibre-bin, file, genisoimage, gv, imagemagick, libaspell-dev, links | w3m | lynx, odt2txt, poppler-utils, python, python-boto, python-tz, xpdf | pdf-viewer, zip Homepage: https://www.midnight-commander.org Download-Size: 474 kB APT-Manual-Installed: yes APT-Sources: http://au.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages Description: Midnight Commander - a powerful file manager GNU Midnight Commander is a text-mode full-screen file manager. It uses a two panel interface and a subshell for command execution. It includes an internal editor with syntax highlighting and an internal viewer with support for binary files. Also included is Virtual Filesystem (VFS), that allows files on remote systems (e.g. FTP, SSH servers) and files inside archives to be manipulated like real files.
List gnome packages available for the system.
jason@Yog-Sothoth » share » $ apt list gnome-* Listing... Done gnome-bluetooth/bionic,now 3.28.0-2 amd64 [installed,automatic] gnome-control-center/bionic-updates,now 1:3.28.1-0ubuntu1.18.04.1 amd64 [installed,automatic] gnome-mahjongg/bionic,now 1:3.22.0-3 amd64 [installed,automatic] gnome-mines/bionic,now 1:3.28.0-1 amd64 [installed,automatic] gnome-panel/bionic 1:3.26.0-1ubuntu5 amd64 gnome-session/bionic-updates,now 3.28.1-0ubuntu3 amd64 [installed,automatic] gnome-settings-daemon/bionic,now 3.28.1-0ubuntu1 amd64 [installed,automatic] gnome-shell/bionic,now 3.28.1-0ubuntu2 amd64 [installed,automatic] gnome-software/bionic-updates,now 3.28.1-0ubuntu4.18.04.1 amd64 [installed,automatic] gnome-sudoku/bionic,now 1:3.28.0-1 amd64 [installed,automatic] gnome-system-tools/bionic,now 3.0.0-6ubuntu1 amd64 [installed] gnome-todo/bionic,now 3.28.1-1 amd64 [installed,automatic] gnome-tweaks/bionic,bionic,now 3.28.1-1 all [installed] gnome-video-effects/bionic,bionic,now 0.4.3-1ubuntu1 all [installed]
Another way to get status information on an installed package.
jason@Yog-Sothoth » share » $ dpkg --status mc
List all packages that were ever removed with apt.
jason@Yog-Sothoth » share » $ grep remove /var/log/dpkg.log*