r/linuxquestions • • Oct 29 '26

What’s one Linux command you wish someone had explained to you sooner?

[removed]

353 Upvotes

316 comments sorted by

67

u/Fazaman Oct 29 '26 • Bravo

sshfs

You can mount a remote machine's filesystem (or parts of it) to yours simply over ssh.

Have two remote machines that can't reach each other for various reasons, but you need to copy something from one to another? Well, you could copy from one to local and then from local to the other, or you could sshfs them both to your machine and then just rsync from one directly to the other. Sure, you're still the middle-man, network-wise, but you don't need that two-step process!

I've known about it for a long time, but never really started using it until a couple years ago.

14

u/FxChiP Oct 29 '26

Protip: rsync will also work over ssh directly if you -e ssh.

15

u/Fazaman Oct 30 '26

rsync works over ssh by default and has for a very long time. No need to specify -e ssh.

I usually do
rsync -Pav /this user@server:/there

My point is that rsync can't do remote to remote. One end of the transfer must be local, but if you use sshfs, they can both be remote.

6

u/Jean_Luc_Lesmouches Mint/Cinnamon Oct 29 '26

https://manpage.me/?q=rsync

Rsync copies files either to or from a remote host, or locally on the current host (it does not support copying files between two remote hosts).

→ More replies (1)

5

u/Sad-Cod-9584 Oct 30 '26

it's how I use my NAS :D

sshfs is great. only need one port open and can use standard ssh auth, like pubkeys.

4

u/JamesZeroZone Oct 31 '26

Combine it with the 'autofs' to auto-mount when accessing the dir

3

u/DubInflux Oct 29 '26

This will truly save me time and rely less on “tailscale file”, or having both an ssh & SFTP session open

2

u/Langdon_St_Ives Oct 30 '26

Or for one offs you could simply `ssh host-a "cd src && tar cvfjl - ." | ssh host-b "cd dst && tar xfjp -"`

→ More replies (2)
→ More replies (2)

82

u/jondaley Oct 29 '26

I was going to say "rm -rf /", but when I learned about clusterssh, that was a great day, since I administer lots of systems.

I once had a customer who was trying to learn DOS, so bought a DOS for Dummies book and tried out all the commands alphabetically. I got a call to fix the system after he had run fdisk *and* format. The fdisk command succeeded but it was cached so didn't kill off the system until he ran the format.

I said, "so when it said, 'this command will erase all content on your system, do you want to continue?', you chose 'yes'?" He said, yup, that's what the book said it would do...

9

u/StevenJOwens Oct 29 '26

For a long time, the very first thing I taught people about Unix (and later Linux) was "rm -rf /", and then tell them to never do it!

→ More replies (3)

6

u/Ikor147 Oct 29 '26

Seems dumb, but at least they tried learning something which is more than most people. 

3

u/Commercial_Poem_9214 Oct 29 '26

This took me back. Thanks for sharing!

3

u/stormdelta Gentoo Oct 29 '26

If you administer many systems it's almost always better to use a tool meant for that though, e.g. Ansible / Salt / etc.

Even those are less common these days in favor of more config-driven setups that don't rely on long-lived system state.

2

u/HotBunniee Oct 30 '26

that DOS story is a good reminder how easy it is to ignore the warnings when you're just following a book step by step

3

u/statichum Oct 30 '26

Now we can pass commands form Ai to do that and jot even have to do the reading part! Yay!!

49

u/Munalo5 Test Oct 29 '26

Not a command but putting a single space before the command to keep it off the bash history log. Keeps the log from getting clogged with junk.

14

u/Zedboy19752019 Oct 29 '26

Say what?? I had no clue.

12

u/dorfsmay Oct 29 '26

This is no longer the default behaviour, it only works if HISTCONTROL=ignorespace or HISTCONTROL=ignoreboth is defined in the environment.

→ More replies (1)

13

u/TuxTool Oct 29 '26

WHAT? This thread is making me feel like a newvie.. lol

2

u/papajan78 Oct 31 '26

haha me too: )

→ More replies (3)

20

u/WetMogwai Oct 29 '26

I found find to be intimidating for over 25 years. Now I use it constantly. It would have made so many things so much easier if I had bothered to learn it earlier.

5

u/frankensteinsKITTEN Oct 29 '26

Imagine the collective man hours saved if find just processed arguments like everything else!

9

u/TapEarlyTapOften Oct 29 '26

Check out fd find - threaded find, so way faster.

→ More replies (3)

19

u/ricperry1 Oct 29 '26

`git`. I know it’s not technically a “Linux command”, but I still struggle to understand what’s what. And I need to use it often.

5

u/CaptainEdMercer Oct 29 '26

Look up "The Git Parable". All of that made Git finally click for me.

→ More replies (1)

33

u/Joker-Smurf Oct 29 '26

I have been using fish shell for a few months now, but still learning little shortcuts.

Like Alt+s (which prepends sudo to the current line, or if the line is empty, adds sudo to the previous command just like `sudo !!` In bash)

And `cd -` which is the fish equivalent of `cd ~-`

6

u/smackells Oct 29 '26

man alt+s would have been useful to know, I just added !! back into fish

4

u/xchino Oct 29 '26

I've been using fish for over a decade and didn't know about Alt+s, solid tip!

66

u/Ori_553 Oct 29 '26

Those are all elementary, but they made me like Linux years ago:

history | grep "any substring i can remember from that one-liner i used a week ago" (searches historical commands)

Tab key -> autocomplete (folder names, files, binaries, etc)

bb (bonus, if you know, you know)

69

u/Joker-Smurf Oct 29 '26

Ctrl+r then start typing part of the string from a week ago…

25

u/mp_matthew Oct 29 '26

This with the zsh fzf extension is actually crazy useful

4

u/Dry_Calendar_8627 Oct 29 '26

zsh4humans enables that and also enables a similar feature for location history. Hit alt+r, it pipes your location history through fzf, so you can search for a folder you've been in recently. Hit enter and you're teleported there. Now I seldom use cd

3

u/NoRacistRedditor Oct 29 '26

I'd like to throw atuin in the ring as well

→ More replies (1)

9

u/dorfsmay Oct 29 '26

Or "ESC" "/" in vi mode (set -o vi).

Ctrl R works because bash and bash like shells default to emacs mode. Nothing wrong with that, but if vi/vim is your thing, please give "set -o vi" a try!!

3

u/spryfigure Oct 29 '26

I'm ashamed. I use vi mode for years and never used this, despite it being so much easier to type than Ctrl-R.

→ More replies (3)

6

u/Lammtarra95 Oct 29 '26

Or Esc / to search if you have your shell in vi mode rather than the default emacs mode.

2

u/trannus_aran Oct 29 '26

And putting an easily searchable # comment after commands you wanna remember

→ More replies (5)

16

u/TapEarlyTapOften Oct 29 '26

You know, if you want to leave notes to yourself in the bash history, comments are a thing.

6

u/Graymouzer Oct 29 '26

Over thirty years of using Linux and the thought never occurred to me. Clever.

8

u/coastalrocket Oct 29 '26

Using aliases has been a favourite of mine. Turning history | grep into 'wot' has made my life a little sunnier. That and adding a temp route to a vpn. It's the little things.

→ More replies (2)

2

u/TrekkiMonstr Oct 29 '26

Atuin is great for this

2

u/Phyrexiah Oct 29 '26

I would suggest to add the timestamps and command id's to the history and just:
history | less
then /pattern
this approach will give you more context

2

u/alanwazoo Oct 29 '26

I give up, what's 'bb'? IYDKYDK

2

u/kjoonlee Oct 29 '26

3

u/alanwazoo Oct 30 '26 edited Oct 30 '26

Wow, ASCII art takes me back to early BSD Unix, those brain cells have been dormant for a while. Did those on the Teletype ASR-33 so it's been a while ;-) Was blazing at 110 baud.

Obligatory Linux command...

The 'find' command is one of the most versatile and powerful, worth the effort to learn. Where else could you do something like this that finds SUID and big files'''

find / \(-perm 4000 -fprintf /root/suid.txt '%p\n'\) , \(-size +100M -fprintf /root/big.txt '%p\n'\)

→ More replies (2)

14

u/0dev0100 Oct 29 '26

htop

Tells me what's using which resources

15

u/Joker-Smurf Oct 29 '26

btop, same but pretty

4

u/Shoddy-Tutor9563 Oct 29 '26

ttop, little less pretty, but with history

→ More replies (4)

57

u/TomDuhamel Oct 29 '26

man

Someone should really have told you about to this one, so you shouldn't be intimidated by commands you don't know.

11

u/GameDestiny2 Oct 29 '26

So much better than the help command

5

u/BonsaiWeed Oct 29 '26

I might be misremembering things, but I think the two work on different levels?

help <command> lists shell commands, i.e. stuff tied to BASH. Whereas man <command> lists the other stuff. Practically a text manual for installed programs and whatnot.

→ More replies (2)

8

u/ResponsibilityBig343 Oct 29 '26

man touch

21

u/Joker-Smurf Oct 29 '26

man touch; finger; mount; fsck; umount

7

u/skyfishgoo Oct 29 '26

if you really want a kick in the balls

man bash

4

u/Mithrandir2k16 Oct 29 '26

and tldr or even better tealdeer.

2

u/Bob_12_Pack Oct 29 '26

I think this was one of the first I learned

→ More replies (5)

13

u/MasterGeekMX Mexican Linux nerd trying to be helpful Oct 29 '26

For me it was something more meta: that commands are in fact programs you have installed, not a set of orders the terminal knows.

4

u/cujojojo Oct 29 '26

Especially the fact that ‘[‘ itself is a command, not a special shell character/syntax!

4

u/Dilyn Oct 29 '26

And sometimes the programs are actually shell-builtins and may actually operate differently so when someone specifies /usr/bin/printf they may have a very specific reason :v

→ More replies (2)

2

u/LFK1236 Oct 29 '26

Good point! I've written my own version of ls a couple times because I didn't like how the standard one worked.

In PowerShell you can even override cd, since POSIX commands are all aliases there.

→ More replies (1)

12

u/ResponsibilityBig343 Oct 29 '26

Not commands but this one senior taught me how to reverse search using ctrl+r

3

u/dk1988 Oct 29 '26

Incredibly useful! There's not a day of work that I don't use that.

9

u/neckyo Oct 29 '26

Awk

It took me a couple of years and seeing someone else using it ti start processing logs and command output with 9ne liners

4

u/Shaosil Oct 29 '26

I probably overuse awk but it's just so flexible

4

u/TuxTool Oct 29 '26

Awk + sed is God mode for file processing

9

u/Schaex Oct 29 '26

I am a very big advocate for tldr, which is a very useful tool that gives you examples of how to use a specific command. I often use it because I just cannot remember where to put the file/directory name when calling grep or find for example.

Just enter tldr grep and it will pull the examples and display them :D

Other than that, sed and xargs are incredibly useful, but not used enough imo :D

→ More replies (4)

8

u/bbbourq Oct 29 '26

For me it was the `rsync` command with ssh vs. `scp`:

rsync -avPzhe ssh /path/to/local_dir username@remote_server:/path/to/remote_dir/

→ More replies (4)

8

u/vilari-mickopf Oct 29 '26

`parallel` for spawning multiple processes, `nohup` if you are not using tmux and want to detach processes from current session (allowing procceses to continue to run after for example ssh session is closed). Also `rg` instead of `grep -R`, it's waaaaay faster.

→ More replies (3)

7

u/absnotkinkyreggae Oct 29 '26

i hope i dont start a debate but:

systemctl edit <service name>

will open your text editor with the default service file all commented out and you can create your own override file, which then is inserted within /etc/systemd/system/<service name>.d/override.conf

pretty handy.

→ More replies (2)

7

u/frankensteinsKITTEN Oct 29 '26

xargs. It's one of those commands that I just couldn't get my head around until I started proper shell scripting and learnt about the difference between piping to stdin and processing arguments. It's a very simple tool, but often comes in handy.

3

u/serafean Oct 30 '26

the `-0` argument made me immensely more powerful with xargs. Combined with `find -print0` parallel processing of files is one pipe away. And I understood what IFS is and how arguments are processed ( the exec() function's arguments finally made sense)

6

u/MyNameIsRichardCS54 Oct 29 '26

Not a command, but I wish someone had told me about LVM much sooner than I learnt about it. It's not as scary as I thought.

6

u/GimmieTheRoot Oct 29 '26

cat instead of dd

You can properly cat iso files to usb sticks faster than DD can write them. Blew my mind.

3

u/MyNameIsRichardCS54 Oct 29 '26

TIL - Mind appropriately blown.

2

u/brettsparetime Oct 29 '26

Hmm, I suspect that if you set your block size appropriately for the target device, dd will still be faster.

→ More replies (3)

1

u/TuxTool Oct 29 '26

What? I've been using Linux for 30 years.. and... Wait, what?

3

u/henrytsai20 Oct 29 '26

Even cp works, since block devices are just files after all.

→ More replies (1)
→ More replies (2)
→ More replies (9)

5

u/elijuicyjones Oct 29 '26

GREP is what made my work easy back in the 90s when everyone else was using GUI tools that were woefully inadequate.

2

u/dorfsmay Oct 29 '26

And rg / rigpgrep these days.

5

u/pa5hk1n Oct 29 '26

strace. When a program fails with some useless error message, it can show exactly which files it tried to open and what went wrong. Saved me from a lot of guesswork.

strace -f -e trace=%file ./your_program

5

u/Soakitincider Oct 29 '26

I like sudo !!

If you do a command and it doesn’t work, you can type sudo !! and it will run the command again but as sudo.

2

u/RSkyhawk172 Oct 30 '26

WHAT thank you that's incredibly helpful!!

2

u/Sad-Cod-9584 Oct 30 '26

it goes further, ! is just your history, so !! is last command, !4 is the fourth-last command and so on.

Edit: no it's not, it's the fourth command in your history. just type history, check the number and type !<Number> to fetch it.

→ More replies (1)

4

u/asrma7 Oct 29 '26

Definitely awk. Filtering, extracting columns, pulling useful information from huge log files, you name it.

4

u/funny_perovskite Oct 29 '26

awk. other than printing a field

4

u/das_menschy Oct 29 '26

CTRL + R to search in your shell history. 

3

u/OldAgeGeek62 Oct 29 '26

tldr for any command you can't remember the syntax.

3

u/MouseJiggler Oct 29 '26

A command is never on its own, it is always a part of a system. Don't think in terms of a single command - think how a particular tool fits in a workflow. That is the thing I wish I understood early on.

3

u/doodlehip Oct 29 '26

There are so many things, but one nifty little trick I tend to use a lot is Ctrl+T Which swaps the character under the cursor with the one to the left.

3

u/ATF_OFFlClAL Oct 29 '26

Use "old somefile.xyz" to rename it to "somefile.xyz.old"

3

u/Dr_CLI Oct 30 '26

This may start a heated discussion about editors but I say to take time to learn vi. The reason I say this is because vi is on every Unix based system. Nano may be available on most Linux districts but not all (it may be available but not installed). If you ever have to troubleshooting a system that won't boot and only has vi available you will be glade you took the time.

I'm not going to sugar coat it for you, vi has a very steep learning curve and not at all friendly or forgiving for new users. It is very different from most any other editor you have ever used. Start simple with just the i command. Then learn a, ... Keep adding commands to your knowledge. The more you learn it the more you will not want to use other editors. There are plenty of online tutorials and other reference materials.

3

u/enRchi Oct 31 '26

or if vim is installed on your computer, just run "vimtutor" and you will learn a lot.

2

u/_Lost-In-The-Weeds_ Oct 29 '26

TLDR / TealDeer

Example based "man pages"

2

u/Jan1north Oct 29 '26

vi - baptism by fire!

3

u/Lammtarra95 Oct 29 '26

vi is a simple editor with two or three modes and a straightforward grammar. Unfortunately it is usually taught as a series of unrelated magic incantations.

2

u/Jan1north Oct 29 '26

So true. I've stumbled through it... and now, somewhat perversely it has become a favorite to this touch typist!

→ More replies (1)

2

u/zed_patrol Oct 29 '26

sl

1

u/scaredycrow87 Oct 29 '26

Scrolled all the way to find this one!

2

u/Vk2djt Oct 29 '26

sed. Still yet to deal with that beast.

2

u/john_flutemaker Oct 29 '26

Sed in detail.

2

u/mglepd Oct 29 '26

tldr for people like me who are too lazy for man. Seriously useful for beginners

2

u/grantrules Oct 29 '26

Screen or tmux

2

u/time-always-passes Oct 29 '26

You can go a really long way with just five:

xargs

find

echo

cut

grep

Learn everything you can about how those can work with piping.

And then add in

ssh

nc

With these last two you can do all sorts of network magic, as well as remote execution.

2

u/MartinUK_Mendip Oct 29 '26

Putting a hash in front of any lengthy command line I'm constructing so hitting 'enter' doesn't run it.
Asides from that 'find' and realising you can run another -exec after the first -exec

→ More replies (1)

2

u/other-brother-darryl Nov 03 '26

fc

If you type a massively long command (like a docker run sequence) and realize you made a typo after hitting enter, you don't need to pull it back up and use the arrow keys to slowly go back to fix it.

Just type fc and hit Enter. It opens your previous command in your default text editor. Once you fix the typo, save and exit, the corrected command will execute automatically.

I use it the most when I know I'm going to write a long command. I type fc, erase whatever is in nano and type out my command; this gives me much more space and I can move around more freely as I "craft" my command, then save, exit and off it goes.

spong would be a close second for me. It's basically a smarter replacement for '>' because it "soaks up" all the input entirely before opening the output file.

This: sort data.txt > data.txt will erase data.txt

While this: sort data.txt | sponge data.txt will do what you actually wanted.

2

u/TapEarlyTapOften Oct 29 '26

When people refer to things like this, they're often interpreting "learn Linux" as "learn bash." To thst end I would recommend you read the bash users guide. After that, I would recommend reading the GNU C library reference. 

2

u/granadesnhorseshoes Oct 29 '26

Not even bash specifically just the general shell as a concept. 90% of what anyone uses day to day and in documentation is /bin/sh compatible so it works anywhere from bash to fish.

So many people, even fellow linux "admins" have absolutely no concept of how a command is composed in a shell. Just "These magic words do this." I don't judge you because you didn't know specifically which command to use to do even basic specific things. I judge you super hard if i have to tell you where the spaces go.

To that end and to genuinely answer the question posed: shopt

→ More replies (1)

2

u/forestbeasts Oct 29 '26

...are you a bot again, OP?

Again, sorry if not, but... smells fishy.

(Different OP this time though. If you're wondering what I'm on about with the 'again', I just ran across another question that just had... the too-perfect sheen of slop all over it.)

→ More replies (2)

2

u/GruesomeJeans Oct 29 '26

The command of unplug it and plug it back in.. my Logitech keyboard has white LEDs in it and for some reason on occasion when I reboot Zorin my lights are off by default and the keyboard FN buttons don't turn them on. At first I was using a mix of some commands to get them back one when I discovered I can just unplug the USB and plug it back in and they turn back on fine...

1

u/iwouldbeatgoku Oct 29 '26

I have a similar issue with a corsair mouse, occasionally when I turn on the computer it will be off until it gets unplugged and replugged, and I have no idea why.

My keyboard doesn't do this though, so when it happens I just run a script to reset every USB port instead of reaching to the back of the computer or rebooting.

→ More replies (5)
→ More replies (2)

1

u/OutrageousCrab9224 Oct 29 '26

tee

Cuz i rewrote it, then found it

1

u/schnarfler Oct 29 '26

stow for dotfiles / config files (with a git repo)

1

u/cad_nova Oct 29 '26

That's a good question 'man'

1

u/ctesibius Oct 29 '26

Not as useful as it was, but telnet. It was very useful for debugging servers with text-based prototols (http, imap, smtp etc.). So you could do something like telnet 80 example.com and interact with the server as though you were the client, seeing all the responses and error messages.

I'm putting that in the past tense as there's not much use of unencrypted servers now and you would use things like openssl and curl these days.

2

u/USofYayDJ Oct 30 '26

openssl s_client -connect server:port for telnrt to https,, I maps, etc

→ More replies (1)
→ More replies (1)

1

u/Steerable-Octopus Oct 29 '26

strace, it's glazed like it's the best thing since sliced bread but I think it's too noisy to be useful.

1

u/vinzz73 Oct 29 '26
  1. less -> shift-f
  2. ctrl-r

1

u/ianwilloughby Oct 29 '26

Either watch or 2>&1 | tee fubar. I ran a lot of Apache spark using scala. The Java output is maddeningly voluminous

1

u/das_menschy Oct 29 '26

To search for a file named "somefile.txt":  find . -type f -name somefile.txt 2>/dev/null 

To search for a file containing the text "sometext":  grep -rnw "sometext" . 2>/dev/null 

1

u/muffinChicken Oct 29 '26

I have my system setup so I can write Arabic directly into the terminal thus giving me the feeling of aladin

1

u/Few_Research3589 Oct 29 '26

It is -- at least for me -- more a question of the main ideas and commands clustered around each of them:: ssh, rclone, timeshift, borg, cron, vim, rofi, tint2, diff, ffmpeg, etc.; and of course, python has a special place among them

I am not an IT spcialist, I am just ready to put quite a lot of time and effort into saving some time and effort :-) just because I can.

You can (and I did) pursue similar approach in windows, as far as I can remember, but it was much harder and less satisfying than in linux

1

u/LokiAstaris Oct 29 '26

jq

The ability to search large JSON objects and strip out the parts I want.

1

u/roywill2 Oct 29 '26

Not a command but connector the pipe | symbol. Just magic "cat file | sort | uniq "

1

u/abyssea Oct 29 '26

Chmod calculations

1

u/vanderaj Oct 29 '26

It’s comm for me. It helps find things that are the same or different in two or three files. I exceptionally handy and stops you writing a quick and dirty script for the same thing.

1

u/rndrboi Oct 29 '26

I feel like awk, sed and grep really improved my Linux experience. Not on the daily but every now and then you have to something that I'm grateful I took time to learn those commands well

1

u/Pretty-Driver9444 Oct 29 '26

Ik vraag het meestal aan chatGPT of een andere AI. Die hebben het ook wel eens mis maar vaak heb ik er wat aan.

1

u/Jew-zilla Oct 29 '26

All of them. Just started using it a few years ago. Now I have a Kali box as a daily driver, a machine from 2011 with Armbian running Tailscale and Pi-Hole, and a third running Mint. The last one was a fun project. It was a Windows 8 early ultrabook, but the display went weird when the adhesive behind the screen leaked. I put Mint on it and removed the display. I always wanted a Commodore64, now I have my own custom slabtop.

1

u/OkYogurtcloset4980 Oct 29 '26

grep with -B (before) and -A (after). Just gives you the block of lines around its find

1

u/mnlg Oct 29 '26

Not really a programme/command that made me click with linux, just one I was surprised to find: strings. It looks for printable strings within binaries.

strings /bin/ls

1

u/skantrall1433 Oct 29 '26

What made me want to try Linux was tab completion in bash. DOS didn't have it then.

As for commands, egrep / grep -E is something I use daily, also awk is amazing.

But I still don't know how to use tee.

1

u/Jean_Luc_Lesmouches Mint/Cinnamon Oct 30 '26

open opens a file with the associated program as it you double clicked on it. With a URL it opens the web browser. open . opens your gui file manager in the current dir. It works with sudo to open as root.

1

u/swstlk Oct 30 '26

e2image and losetup -- I use them for recovery/backups..

1

u/theNbomr Oct 30 '26

Not so much a command as a concept: the concept of standard IO, and the related concept of 'everything is a file'. This gains the best advantage when you understand the basic semantics of file access: open, read, write, seek, close.

With these concepts understood, the whole benefit of IO redirection and the elegance of treating everything as a file, and how it makes many separate small tools work together so easily.

1

u/kj1352 Oct 30 '26

Using tabs for auto complete.

1

u/h0dgep0dge Oct 30 '26

pv, socat, nmap/nping, tcpdump

1

u/2eanimation Oct 30 '26 edited Oct 30 '26

!!

Expands to the last command you typed.

E.g. if your command needs root permission and you forgot sudo, type in sudo !!

Edit: there’s a whole can to open with the exclamation mark! !n expands to the nth command in history(so !1 would be the first). Works with negative indices, !-2 expands to the second to last command. !pattern if you don’t know the number. !grep expands to the last grep command you typed. !$ expands to the last file-path. Let’s say you used less ./some-path/text.txt and now want to edit it, type vim !$. !*, same spiel for arguments.

1

u/stianhoiland Oct 30 '26

`sh` is air, `sed` is water, `fzy` is honey.

1

u/DadsVacation Oct 30 '26

Piping less into a large terminal output to easily read and search contents

Alias for combining mkdir and cd together

sudo dd if=/path/to/linux.iso of=/dev/sdX bs=4M status=progress conv=fsync

Instead of using image writers to write os images to usbs

1

u/HoodoftheMountain Oct 30 '26

recently `parallel`, instead of inputting a file each time the command is run or running a shell script, just batch it all together if the names are similar enough. Useful for when I have to re-encode a list of things in ffmpeg.

1

u/SigmaxAlpha Oct 30 '26

No se. llegue a Linux ya sabiendo programar, asi que si tengo una tarea repetitiva, simplemente abro mi IDE y escribo un programa que la haga, asi que no toco mucho la terminal mas alla de para usar apt o iniciar los graficos.

1

u/Champboyriley Oct 30 '26

Lots of good suggestions ...

I find locate and updatedb (commands must work in a pair) to be very usefull when looking for files but are not sure where they might be. Locate is like a find command but is almost instant even on fairly large systems.

1

u/VeryPogi Oct 30 '26

sed and awk are important Linux commands because they allow you to automatically search, filter, extract, and manipulate text from files and command output. They are especially useful for system administration, log analysis, configuration management, and shell scripting.

→ More replies (1)

1

u/maartenyh Oct 30 '26

》apt update

Error: no root permissions

》sudo !!

Updating...

'!!' Appends your last command to your newest command

1

u/Mister_Magister Oct 30 '26

I'm too deep to think of any at this point but i'd like to understand lsof

also people need to have explained what is dd and why they're using it wrong

1

u/Sad-Cod-9584 Oct 30 '26

lots of good stuff in here already, but I just want to add that vim accepts stdin, so you can do for example sudo dmesg | vim -

1

u/Dr_CLI Oct 30 '26

A lot of good command references here. If you are going to really use the command line then you need to spend time to really learn Bash (or whatever shell you use). Learning the shell will provide a great base for interactive command line use as well as shell script writing.

After you have a good understanding of Linux and are using pipes to write complex command strings, then study up on the xargs command. A fairly obscure command with power for dealing with huge amounts of arguments. Can breakup long lists in into workable units.

1

u/m1L35dY50N Oct 30 '26

!! in Bash.

Ever typed a long-ass command, hit Enter, and realized you forgot sudo ?

Instead of typing the whole thing again, just use sudo !! and Bash will rerun your previous command with sudo front of it.

Such a tiny feature, but it's saved me an embarrassing amount of typing over the years.

Just don't blindly use it if you're not sure what your last command was.

In that case check with history.

Also pushd and popd were massive eye-openers. Being able to jump between directories and return to where you were without constantly typing out paths is ridiculously convenient.

1

u/Relevant-Educator587 Oct 31 '26

CTRL+R has increased my work speed of 10000%

1

u/frasnian Oct 31 '26

If you have to use telnet a lot for management interfaces, rlwrap is fantastic.

1

u/Ok_Enthusiasm8135 Oct 31 '26

Screen or tmux

1

u/neopaf Oct 31 '26

tac (reverse cat)

1

u/neopaf Oct 31 '26

alt+. (add last command last argument here)
esc+. (Ditto)

1

u/Unable_Fun_1074 Oct 31 '26

fg, sin duda.

1

u/daninlakewood Oct 31 '26

I was going to say grep and then I thought, I wish someone would explain grep to me now.

1

u/ecce_mono Oct 31 '26

I noticed a lot of 'cut' commands in my predecessor's scripts at an old job. Still one of my go-tos for quick n dirty one-liners. Also second place goes to the combo of sort & uniq

1

u/Whyte_Wolf Oct 31 '26

../../ when using cd

1

u/vphan13_nope Oct 31 '26

cd - to go back to the last PWD, ctrl-r to search previous commands

1

u/tekchip Nov 02 '26

history and !xxx

Lets you see all your prior command and you can re-run a command by typing ! followed by it's number.

As someone else points out you can combine history with grep to narrow down which command you're looking for.

1

u/plugs3501 Nov 02 '26

sudo !! Has saved me more times

1

u/UseTheTerminal Nov 03 '26

poweroff

Alternative to shutdown, literally just turns off your computer. but not all distros have it.

1

u/LawElectrical2434 23d ago

Well... That you can reap zombies of other processes with waitpid. I learned that today. Also, turns out, it was a redditor full of shit, you cannot do that if they don't belong to your process... But still, something I learned today, just something that wasn't true. 

1

u/wehaveYummiTummies 20d ago

Not a command, but the thing that I find myself constantly referencing over the >10 years I've been using linux is the shell parameter expansions page of the bash manual (idk about compatibility with other shells).

  • ${var##something*else} will remove the longest substring matching the pattern something*else starting from the left (see shell pattern matching for info about the patterns). Useful for extensions: var=filename.ext; echo ${var##*.} will return ext.
  • ${var#something*else} removes the shortest substring, from the left. IF you have filename.ext1.ext2 and want to get ext1.ext2, use this one, because filename. is the shortest pattern that matches *..
  • ${var%%something*else} will remove the longest substring from the right. So instead of *., you would use .*: var=filename.ext; echo ${var%%.*}; would give you filename instead of ext.
  • ${var%something*else} matches the shortest pattern from the right.

Those are the ones I use the most. There's more that are also helpful, like find/replace, and some that deal with arrays.

1

u/Sahkopi4 15d ago

What is a pipe and how to use grep

1

u/mdins1980 Oct 29 '26

One for me was SSH. I had been using Linux for years before I even knew SSH existed, but once I discovered it, I couldn't imagine living without it. Another was tab completion. For the longest time, I had no idea I could just press Tab to autocomplete commands.

4

u/TapEarlyTapOften Oct 29 '26

Wait until you learn about tmux.

2

u/mdins1980 Oct 29 '26

lol nice! I already rock tmux daily, but I will admit I discovered it later than I should have.

→ More replies (1)
→ More replies (1)

1

u/ReasonableTreeStump Oct 29 '26 edited Oct 29 '26

Sudo lol. Sudo everything. Break sudo? Repair or revert and sudo properly. If it is your personal machine, don’t be afraid to break it and reload.

That brings me to rsync. Not exactly linux but one of the best part about linux

Edit: oh also chmod -x or +x

Edit 2: i just realized that I have been using Linux straight for over a year now, without dualbooting windows. I have a macbook air for travel/work etc. But yeah, it took me a bit to actually understand what was going on.

Before I started using linux full-time, I would use command prompt on windows but only if I was following a guide.

Now I feel a little more confident just trying and seeing what happens, knowing just enough to know I can explain it to some LLM (claude or chatgpt) and they can point out the idiotic thing I did, and I can go DOH and fix it. Also, I feel like I have somewhat of a grasp to know when an LLM is being stupid and giving me a dumb linux or software related answer.

And I don’t work in tech anything. Legal/policy. So, honestly, anyone wondering about linux. It might seem intimidating, but it is not difficult.

I use Ubuntu. it works for me.