159
What are some of your most useful or favorite terminal commands?
(piefed.social)
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
(Fixed the bolding issue)
From a file I keep since I started using Linux near 5 years ago:
Display the RAM usage:
watch -n 5 free -mUseful if you open way too much stuff and/or you're running on budget processing power, and don't want your computer freezing from 3 hours.
Also useful if you use KDE's Konsole integrated into the Dolphin file manager and you must for some reason not close the Dolphin window. You'd just need to open Dolphin's integrated Konsole (F4), run the command and without closing it, press F4 again to hide the Konsole.
Terminal-based file browser that sorts by total size:
ncduwhy is the cache folder 50 GB big?
Mass-check MD5 hashes for all files in the path, including subfolders:
find -type f \( -not -name "md5sum.txt" \) -exec md5sum '{}' \; > md5sum.txtChange
md5sum(and optionally the output file's name) for your favorite/needed hash calculator command.For mounting ISOs and similar formats:
sudo mount -o loop path/to/iso/file/YOUR_ISO_FILE.ISO /mnt/isoAnd unmounting the file:
sudo umount /mnt/isoBeware there's no N in the umount command
For creating an ISO from a mounted disc:
dd if=/dev/cdrom of=image_name.isoAnd for a folder and its files and subfolders:
mkisofs -o /path/to/output/disc.iso /path/from/input/folderCompress and split files:
7z -v100m a output_base_file.7z input_file_or_folderChanges the capslock key into shiftlock on Linux Mint (not tested in other distros):
setxkbmap -option caps:shiftlockWas useful when the shift key from a previous computer broke and I didn't have a spare keyboard.
If you want to run Japanese programs on Wine, you can use:
LC_ALL=ja_JP wine /path/to/the/executable.exeThere are other options but this is one that worked the better for me so I kinda forgor to take note of them.
List all files in a given path and its subfolders:
find path_to_check -type fTip: add
> output.txtor>> output.txtif you'd rather have the list in a TXT file.Running a program in Wine in a virtual desktop:
wine explorer /desktop=session_name,screen_size /path/to/the/executable.exeE.g.:
wine explorer /desktop=MyDesktop,1920x1080 Game.exeUseful if you don't want to use the whole screen, there are integration issues between Linux, Wine and the program, or the program itself has issues when alt-tabbing or similar (looking at you, 2000's Windows games)
Download package installers from with all their dependencies:
apt download package_nameAsks for sudo password even when not running as sudo. Downloaded files come with normal user permissions thankfully. Also comes with an installation script but if you want to run it offline, iirc you need to change
apt installin the script fordpkg -i.If you use a program you'd rather not connect to the internet but without killing the whole system's connection, try:
firejail --net=none the_command_you_want_to_runOr if you want to run an appimage:
firejail --net=none --appimage the_command_you_want_to_runIf you want to make aliases (similar to commands from Windows' PATH) and your system uses bash, edit the file $HOME/.bashrc (e.g. with Nano) and make the system use the updated file by either logging out and in, or running
. ~/.bashrcPython/Pip have some nifty tools, like Cutlet (outputs Japanese text as Romaji), gogrepoc (for downloading stuff from your account using GOG's API), itch-dl (same as gogrepoc but for Itch.io), etc. If you lack the coding skills and doesn't mind using LLMs, you could even ask one to make some simpler Python scripts (key word though: simpler).
If you want to run a video whose codec isn't supported by your system (e.g. Raspberrian which only supports H.264, up to 1080p):
ffmpeg -i input_video.mkv -map 0 -c:v libx264 -preset medium -crf 23 -vf scale=1920:1080 -c:a copy -c:s copy output_video.mkv