this post was submitted on 16 Dec 2025
165 points (98.2% liked)

Linux

61465 readers
397 users here now

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.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

I've been setting up a new Proxmox server and messing around with VMs, and wanted to know what kind of useful commands I'm missing out on. Bonus points for a little explainer.

Journalctl | grep -C 10 'foo' was useful for me when I needed to troubleshoot some fstab mount fuckery on boot. It pipes Journalctl (boot logs) into grep to find 'foo', and prints 10 lines before and after each instance of 'foo'.

(page 2) 50 comments
sorted by: hot top controversial new old
[–] Auster@thebrainbin.org 3 points 1 month ago

(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 -m
Useful 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:
ncdu
why 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.txt
Change 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/iso

And unmounting the file:
sudo umount /mnt/iso
Beware there's no N in the umount command

For creating an ISO from a mounted disc:
dd if=/dev/cdrom of=image_name.iso

And for a folder and its files and subfolders:
mkisofs -o /path/to/output/disc.iso /path/from/input/folder

Compress and split files:
7z -v100m a output_base_file.7z input_file_or_folder

Changes the capslock key into shiftlock on Linux Mint (not tested in other distros):
setxkbmap -option caps:shiftlock
Was 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.exe
There 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 f
Tip: add > output.txt or >> output.txt if 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.exe

E.g.:
wine explorer /desktop=MyDesktop,1920x1080 Game.exe

Useful 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_name
Asks 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 install in the script for dpkg -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_run

Or if you want to run an appimage:
firejail --net=none --appimage the_command_you_want_to_run

If 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 . ~/.bashrc

Python/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

[–] crispycone@lemmy.zip 2 points 1 month ago* (last edited 1 month ago) (1 children)

Deleted comment.

I double posted as Mlem didn’t show my initial comment after posting for some reason.

(Edit)

[–] Magister@lemmy.world 2 points 1 month ago* (last edited 1 month ago) (2 children)
alias cd..='cd ..'
alias ll='LC_COLLATE=C ls -alFh'
alias ls='ls --color=auto'
load more comments (2 replies)
[–] hades@feddit.uk 2 points 1 month ago

Number one will forever and ever be strace

[–] roran@sh.itjust.works 2 points 1 month ago
cd `pwd`

for when you want to stay in a dìr that gets deleted and recreated.

cat /proc/foo/exe > program
cat /proc/foo/fd/bar > file

to undelete still-running programs and files still opened in running programs

[–] marcie@lemmy.ml 2 points 1 month ago

rpm-ostree status

rpm-ostree reset

rpm-ostree rebase

idk i love rpm-ostree man

[–] gangrif@social.undrground.org 2 points 1 month ago

@marighost I dont use Prox, but for various random linux commands.. ive got a wealth. :D in the journalctl vein.

journalctl -xeu \<service name\>

ex: journalctl -xeu httpd

Gives you the specific journal output for the given service. In this example. httpd.

Also, journalctl is more than boot logs, its all of your logs from anything controlled by systemd. Mounts, services, timers, even sockets.

For example. On my system, i have /var/home as a mount. systemctl and journalctl can give me info on it with:

systemctl status var-home.mount
journalctl -xeu var-home.mount

You can see all of the mounts with.
systemctl list-units --type=mount

Or, see all of your services with
systemctl list-units --type=service

Or all of your timers with
systemctl list-timers

We do a weekly show on getting into linux terminals, commands, tricks, and share our experience.. It's called Into the Terminal. on the Red Hat Enterprise Linux youtube channel. I'll send you a link if you're interested.

[–] mr_right@lemmy.dbzer0.com 2 points 1 month ago (1 children)

i do not know if this counts as a command but you might want to check Atuin, what it does is help you find, manage and edit the commands you used in your shell history saves you a lot of time

[–] 87Six@lemmy.zip 2 points 1 month ago

Interesting.

I use FZF myself and set my history size to 99999

[–] jim3692@discuss.online 2 points 1 month ago (1 children)

docker run --rm -it --privileged --pid=host debian:12 nsenter -a -t1 "$(which bash)"

If your user is in the docker group, and you are not running rootless Docker, this command opens a bash shell as root.

How it works:

  • docker run --rm -it creates a temporary container and attaches it to the running terminal
  • --privileged disables some of the container's protections
  • --pid=host attaches the container to the host's PID namespace, allowing it to access all running processes
  • debian:12 uses the Debian 12 image
  • nsenter -a -t1 enters all the namespaces of the process with PID 1, which is the host's init since we use --pid=host
  • "$(which bash)" finds the path of the host's bash and runs it inside the namespaces (plain bash may not work on NixOS hosts)
[–] noughtnaut@lemmy.world 2 points 1 month ago (1 children)

So you're running bash "as if you're on the host systen". What's the benefit?

load more comments (1 replies)
[–] netvor@lemmy.world 2 points 1 month ago (1 children)

I think vipe is underrated; it takes whatever is on its stdin, shoves it in a temp file, opens your favorite text editor (EDITOR environment variable) and waits in the background until you finish editing the file and close it. Then it outputs the edited text to its stdout.

It's useful in all kinds of pipes, but personally I use it tons of times a day in combination with xclip, in something like this:

xclip -o -selection primary | vipe | xclip -i -selection clipboard

(I actually have a bit fancier version of this pipe wrapped in a Bash function named xvxx.)

On my setup, this takes my current text selection, opens it in vim, and lets me edit it before it sends it to the "traditional" Ctrl+C clipboard. It's super handy for editing comments like this one.

If you often find yourself writing complex Bash pipelines involving generating some output and then running set of commands per line (perhaps in a while loop), sometimes replacing the "selection part" with vipe can be easier than coming up with right filter.

find_or_ls_or_grep_something | vipe | for while read -r foo; do some_action "$foo"; done

And if you are really confident with Bash, you can go even a step further and do:

you might find something like this useful sometimes:

find_or_ls_or_grep_something | vipe | bash

and just create a large dumb one-off script, manually curating what's exactly done. Remember that editing large lists in vim can be made much easier by utilizing vim's ability to invoke unix filter commands (those greps and uniqs and seds et al.) on the buffer, and /or block editing mode using Ctrl+V (that last one method goes really well with column -t).

[–] brainwashed@feddit.org 3 points 1 month ago

Neat! FYI for anoyone else who does not find this, it is part of moreutils.

[–] HakunaHafada@lemmy.dbzer0.com 2 points 1 month ago* (last edited 1 month ago)

redshift -O 5000: 'redshift' is a utility that adjusts the color temperature of your display, '-O' allows you to set a specific temperature, and '5000' is what I like.

Edit: I also like xkill. xkill lets you click on a window or program and kills it. I need to do this frequently every time exit Kodi; the program stops, but the window is still there.

[–] Theoriginalthon@lemmy.world 2 points 1 month ago

Absolute favourite is | the pipe command.

[–] Geodes_n_Gems@lemmy.ml 1 points 1 month ago

Running Wine is the command I've used the most probs, you can tell I haven't touched the thing in months.

load more comments
view more: ‹ prev next ›