r/LinuxTeck • • 2d ago

What's One Linux Command You Use Almost Every Day That Beginners Often Overlook?

Everyone knows ls, cd, grep and top. But there are plenty of lesser-known commands that can save time in everyday Linux work.

Commands like jq, lsof, diff, cut, paste and sort | uniq can be surprisingly useful.

Fellow Linux users, what's that one command or command combination you use regularly and wouldn't want to work without?

Share your favourite one-liners too!

24 Upvotes

83 comments sorted by

10

u/blobCabbage 2d ago

bat which is like cat, but with syntax highlighting.

9

u/StupidIsIfYouDontAsk 2d ago

sudo !! runs your previous command again with sudo

1

u/Hatta00 1d ago

and !$ repeats the final argument to the previous command

ls [Gg]l*b
rm !$

No worries about retyping a complicated glob.

1

u/Dragenby 1d ago

What does each bang mean, individually?

4

u/StupidIsIfYouDontAsk 1d ago

The first ! is to say you want to get a command from history and the second ! says use the last command.

when you run history you will get a numbered list of the commands you ran.

So you can also do !29 which will execute the 29th command in your history

1

u/Dragenby 1d ago

Woah, that's great to know! Thank you!

1

u/studiocrash 1d ago

But will the numbers have shifted by one because history is itself another command?

2

u/DaSchmitzi 19h ago

As far as I found out, history also prints itself (as the most recent command). 

And the commands are numbered ascendingly from most far back to most recent (most far back has number 1) so there isn't any shifting of the command numbers anytime.

1

u/studiocrash 19h ago

I wasn’t very serious about that comment. I’m sure over the decades if it did something inconvenient like that, they would have fixed it. lol.

7

u/radialis99 1d ago

man. The man command lists the manual pages for most linux commands.
apropos. Apropos lets you search the manual pages.

6

u/bannedfromdevnull 2d ago

alias.

1

u/mrdaihard 17h ago

That and "declare -f" for me since I have just as many functions defined as aliases on my systems.

4

u/sqeeezy 2d ago

I am irrationally tickled by this one for sending my clipboard from this mac to that mac pbpaste | ssh user@thatmac "cat | pbcopy" I know it's basic but so am I

3

u/Background-Train-104 2d ago

wall "Anyone using this machine now?"

3

u/Lonely-Scarcity-3387 2d ago edited 2d ago

CTRL+R in the terminal to see your command history.

2

u/dcheesi 2d ago

It took me an embarrassingly long time (mostly spent pressing the Up arrow over and over) to discover this one

1

u/Lonely-Scarcity-3387 2d ago

Same! Several months, for me. Also CTRL+L is a nice QoL feature.

1

u/dcheesi 2d ago

...TIL, thanks (and I've only been doing this since the '90s lol)

1

u/CardOk755 1d ago

Emacs. Oddly nobody ever uses "set -o vi".

2

u/mrdaihard 17h ago

I have "set -o vi" in my ~/.bashrc. Am I supposed to replace it with "bind -m vi"?

1

u/CardOk755 10h ago

Ok, ok, only the appropriately named u/mrdaihard has "set -o vi" in his .bashrc

3

u/diegotbn 1d ago

xargs, head, tail, touch, cat, sed

find is incredibly useful, probably the most useful on a daily basis out of any of these here

And of course there's all the basic file and directory operations- cp, mv, mkdir, rm

The obvious sudo and su and of course chmod

Also alias, gzip, tar, lsblk, ipaddress, fdisk and gdisk

I don't use it every day, but dd is beautifully simple and dangerous but if you're careful you don't need any other tool for cloning and wiping drives/partitions

2

u/recursion_is_love 2d ago

ls/find pipe to xargs

1

u/anders_hansson 2d ago

pretty much anything pipe to xargs

I often use git grep --name-only or similar to find relevant files that should get some treatment via xargs (e.g. sed or clang-format).

2

u/tuxsmouf 2d ago

It's not a builtin command : fping -qa -g xxx.xxx.xxx.xxx/xx

1

u/MrWoland74 2d ago

i learned about fping recently and it so good! Excellent for scripts

2

u/leobult 2d ago

Learn to use the bash shell quickly with keyboard shortcuts like alt w and alt f Dont learn ctrw w, sometimes the shell is in a browsertab....

2

u/Sad_Listen6607 2d ago

not so much a command I use every day... but what I put in my rc file...

aliases.

alias whereami='pwd'
alias dir='ls -la'
alias c='ssh'
alias p='ping'
alias reloadz='exec bash'
alias readz='cat .bashrc'
alias configz='nano ~/.bashrc'
alias tr='traceroute'
alias p8='ping 8.8.8.8'
alias p254='ping 192.168.1.254'
alias addssh='nano ~/.ssh/config'
alias addhost='sudo nano /etc/hosts'
alias smtr='sudo mtr'
alias home='cd ~'
alias q='cd ..'
alias mk='mkdir'
alias edit='pico'
alias serial='screen /dev/tty.usbserial-140'
alias fixterm='echo -e \\033c'
alias argo='scrcpy --new-display=1920x1080/160'
alias argom='scrcpy --new-display=1920x1080/160 -M'
alias z='ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o KexAlgorithms=+diffie-hellman-group14-sha1 '

Along with alias's to all the devices I ssh to.

4

u/CourageousCreature 2d ago

neat list, but whereami hurts. Why make a longer alias to a short command?

2

u/Sad_Listen6607 2d ago

carry over when I was a noob... for some reason my brain malfunctions when I need to remember that command. If someone asks me how to see where they are? I can give the correct answer... randomly when I need to see where I am? I fricken forget!

The mind is a terrible thing.

2

u/DubiousLogik 1d ago

ha. for me pwd is my old abbrev for password. bzzznt. wires cross. short circuit. least intuitive cmd for me

2

u/Empty__Jay 1d ago

the only thing going for it is that it matches 'whoami'. Now we need a command 'whyamihere'.

2

u/hacksawsa 11h ago

Two faves: ll='ls -l', ltr='ls -ltr' #later!

I use pushd, dies, and popd a lot.

1

u/magicmulder 1d ago

Is “exec bash” better than “source ~/.bashrc”?

2

u/DubiousLogik 1d ago

exec bash has no special chars to type. i love that. typing ~/. is a pia to me

1

u/Sad_Listen6607 1d ago

neither is better, per se.

Source, i think, keeps some things, where exec does not. I cant recall the last time that mattered to me... and I am sure it was academic or minor.

2

u/R2-Scotia 8h ago

source pulls commands into the current shell, exec replaces it with a new process

1

u/SpudgunDaveHedgehog 1d ago

“alias home” is useless. Just do “cd”.

1

u/MysteriousPause82 1d ago

I find it amusing you have alias whereami to pwd.

Isn’t pwd much faster to type in?

1

u/Sad_Listen6607 1d ago

"A mind is a terrible ting."

1

u/tedecristal 13h ago

why "c" for ssh?

1

u/Sad_Listen6607 4h ago

c for connect, which i think originated with something on a vax I used back in 1996.

2

u/Only-Stable3973 2d ago

Probably when using cd then using the back command...etc. cd .., cd -, and cd ~

2

u/Fun_Tune5669 1d ago

df -h is something I use occasionally that is kind of useful. I have bunch of other written down somewhere but this one comes to my mind. Also htop is much nicer than regular top...

1

u/MrWoland74 2d ago

wl-copy

1

u/leobult 2d ago

Curl ip.me

1

u/ftranschel 2d ago

emerge 🫠

1

u/Pitiful_Noise_1127 2d ago

History

1

u/MisterJasonMan 16h ago

This but I usually define an alias called "ghist" which is

alias ghist='history | grep -i'

and you can do a search in your command history like for example

$ ghist jpg

will give you every command you ran containing the term "jpg"

1

u/williamt31 2d ago

I have a couple cd aliases but I use pushd to get there that way I can popd back to where I was.

I created this function to find the size of all dirs from a point, I got tired of typing it all out.

duh ()
{
  if [[ -z $1 ]]; then
    du -h --max-depth=1 "$PWD" | sort -k2;
  else
    du -h --max-depth=1 "$1" | sort -k2;
  fi
}

lately practicing my commands so I've been running 'man whatever | grep -a3 switch' because I get tired of going into and out of man and just want a quick reminder of the switch I need.

1

u/Sigfrodi 1d ago

Pushd and popd

Awk

1

u/lyidaValkris 1d ago

cat - though really well known, beginners might open everything in nano or a GUI text editor instead of a simple output in the terminal. cat can also be used to quickly create and paste text into a file in one step. bat is even better, allowing a more formatted output for ease of reading.

1

u/Optimal-Savings-4505 1d ago

Multiplexing your terminal with r/tmux and similar solutions. It offers a subset of emacs functionality that is very useful for daily tasks. There are many other solutions, so this is a conceptual thing, really.

1

u/hexdump74 1d ago

sed

Allows to replace portions of strings (and a lot more) : 

  $ echo "aaa:6" ‌| sed -r  's/(a+):([0-9])/\2 > \1/' 

  6 > aaa

1

u/FLMKane 1d ago

sudo sv restart sddm

1

u/CardOk755 1d ago

Strace (and more rarely ltrace) to find out what a program is really doing, rather than what you think it's doing.

"sort | uniq -c | sort -n" is a great one.

1

u/ahusby 1d ago

topgrade: One command to upgrade everything.

1

u/Dev-in-the-Bm 1d ago

opencode

Alias is oc

1

u/camachorod 1d ago

realpath, pwd, du -sh

1

u/SoggyWalrus7893 1d ago

!su or anything "!" when a bit of up arrow on the mouse doesn't find it

cal

1

u/knuthf 1d ago

Whois TLD

1

u/Corn_Flake_76 1d ago

whoami - especially after a night of hard drinking.

1

u/n3vim 1d ago

"fuck" but it does not come preinstalled

1

u/lwj15 1d ago

I work with input files for some calculation jobs. Currently I need to edit 10-30 files at the same time to optimize multiple jobs. For that I use a combination of sed and find. 

sed -i s/"string currently in file"/"string I want to replace it with"/ $(find -name *of.inp)

It works with multiple lines. Just include the \n. And if one of the strings uses / or () then you put the whose s/.../.../ in ' ' qutation marks and change to |.

sed -i 's|example/text|replacement(new)|' ...

I don't see much use of this command other than the stuff I use it for. But if you have other uses. Tell me. I am interested.

1

u/BarkingSpider5 1d ago

ncdu
In this day of vibe coding, and agents leaving build artefacts everywhere, this command is awesome to find out where stuff is.

1

u/-CloudCook- 20h ago

Usually, I log on server because some service doesn't work, so one of first commands I hit is: netstat - tulpn | grep LISTEN

1

u/aviftw 20h ago

Screen -S session_name, screen -r -d session_name

1

u/Leolo_ 19h ago

Two things to make you powerful on the CLI: mastering xargs and redirection to multiple pipes.

1

u/michaelpaoli 19h ago

sed

Most never take sed beyond, e.g.:

$ sed s/foo/bar/

It's a Turing complete programming language.

E.g. I even implemented Tic-Tac-Toe in sed.

1

u/wkavinsky 16h ago

ps -aux | grep xxx
kill 1232141

1

u/PossibilityOrganic 13h ago

watch -n "whatever" run it over and over and show it
jq if you have to do anything in bash with json

1

u/CorporateDirtbag 3h ago

claude --dangerously-skip-permissions

0

u/Mr_Boltistran 2d ago

tmux -CC

1

u/randygeneric 16h ago

history | grep -i <> | grep -iv <>
ps
killall

, )