r/LinuxTeck • u/Candid_Athlete_8317 • 18d 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!
62
Upvotes
12
u/StupidIsIfYouDontAsk 17d ago
sudo !!runs your previous command again with sudo11
u/blobCabbage 17d ago
batwhich is likecat, but with syntax highlighting.8
u/radialis99 17d ago
man. The man command lists the manual pages for most linux commands.
apropos. Apropos lets you search the manual pages.
7
u/bannedfromdevnull 18d ago
alias.
6
u/sqeeezy 18d 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
5
u/Lonely-Scarcity-3387 17d ago edited 17d ago
CTRL+R in the terminal to see your command history.
4
u/Deep_Mood_7668 18d ago
dmesg -w
3
u/Background-Train-104 18d ago
wall "Anyone using this machine now?"
3
u/diegotbn 17d ago
xargs,head,tail,touch,cat,sedfindis incredibly useful, probably the most useful on a daily basis out of any of these hereAnd of course there's all the basic file and directory operations-
cp,mv,mkdir,rmThe obvious
sudoandsuand of coursechmodAlso
alias,gzip,tar,lsblk,ipaddress,fdiskandgdiskI don't use it every day, but
ddis beautifully simple and dangerous but if you're careful you don't need any other tool for cloning and wiping drives/partitions3
u/opensourcedev 14d ago
cal and cal -y
2
u/recursion_is_love 17d ago
ls/findpipe toxargs2
u/tuxsmouf 17d ago
It's not a builtin command : fping -qa -g xxx.xxx.xxx.xxx/xx
2
u/leobult 17d 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 17d 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.
2
u/Only-Stable3973 17d ago
Probably when using cd then using the back command...etc. cd .., cd -, and cd ~
2
u/Fun_Tune5669 17d 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/Due-Result7928 17d ago
poweroff
1
u/MrWoland74 17d ago
wl-copy
1
u/leobult 17d ago
Curl ip.me
1
u/ftranschel 17d ago
emerge 🫠
1
u/Current_Laugh4767 17d ago
inxi
1
u/Pitiful_Noise_1127 17d ago
History
1
u/williamt31 17d 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.
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 17d ago
Pushd and popd
Awk
1
u/lyidaValkris 17d ago
cat- though really well known, beginners might open everything innanoor a GUI text editor instead of a simple output in the terminal.catcan also be used to quickly create and paste text into a file in one step.batis even better, allowing a more formatted output for ease of reading.1
u/Optimal-Savings-4505 17d ago
Multiplexing your terminal with r/tmux and similar solutions. It offers a subset of
emacsfunctionality that is very useful for daily tasks. There are many other solutions, so this is a conceptual thing, really.1
u/hexdump74 17d 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 17d ago
sudo sv restart sddm
1
u/CardOk755 17d 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 17d ago
topgrade: One command to upgrade everything.
1
u/Dev-in-the-Bm 17d ago
opencodeAlias is
oc1
u/camachorod 17d ago
realpath, pwd, du -sh
1
u/Radiant64 17d ago
tree
1
u/SoggyWalrus7893 17d ago
!su or anything "!" when a bit of up arrow on the mouse doesn't find it
cal
1
u/knuthf 17d ago
Whois TLD
1
u/Corn_Flake_76 17d ago
whoami - especially after a night of hard drinking.
1
u/n3vim 17d ago
"fuck" but it does not come preinstalled
1
u/TipAppropriate1384 17d ago
Ctrl -r
1
u/lwj15 17d 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/xpusostomos 16d ago
rg
1
u/BarkingSpider5 16d 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- 16d 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 16d ago
Screen -S session_name, screen -r -d session_name
1
u/Leolo_ 16d ago
Two things to make you powerful on the CLI: mastering
xargsand redirection to multiple pipes.1
u/michaelpaoli 16d 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 16d ago
ps -aux | grep xxx
kill 1232141
1
u/PossibilityOrganic 16d 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/ThimMerrilyn 16d ago
History
1
u/CorporateDirtbag 15d ago
claude --dangerously-skip-permissions
1
u/HowCanIChangeMyName1 15d ago
What do you need "sort | uniq" for that "sort -u" doesn't do?
1
u/Free_Somewhere4715 15d ago
OSC52
1
u/clawsoon 15d ago
awk for anything structured like a log file, config file, or simple CSV. It's too flexible to give a single one-liner, but I'll make some things up and hopefully you'll get the idea:
awk '$1 == "Oct" && $2 == "25" {print $5}' /var/log/messages
Or for a CSV, set the field separator to a comma:
awk -F, '$3 == "Sell" {x=x+$4} END {print x}' transactions.csv
Let's extract the "default" section from an inf-style config file:
awk '/^\[/ {defaultsection=0} /^\[defaults\]/ {defaultsection=1} defaultsection==1 {print $0}' /etc/mke2fs.conf
It's a full-fledged programming language which was a big inspiration for Perl, Python, and Javascript, so you can do a lot more with it than what I'm doing here. The biggest thing it lacks compared to those languages is locally-scoped variables, which is why it's mostly best for one-liners.
1
u/Wisdom_Wizard_Waldo 15d ago
I don't?...
If i'm using a command every day, chances are i'll just stick it in a daemon so it does it automatically
1
u/ofnuts 15d ago
Perl rename (which is plain
renamein my distro).And outside of the command line,
kdiff3andfilelightare very useful.1
u/natnit555 15d ago
1.Practical way to share file/directory with peers (not secure)
python -m http.server
Then your peer can access the files/dirs from http://<ip addr>:8000
2. Saves your output to file for later inspection while at the same time you can watch it as well.
<arbitrary commands> | tee output.log
3. Script/record/document your steps/work - not one liner actually
screen
https://devhints.io/screen
1
u/ivovis 14d ago
I don't no if I'd call it overlooked, but I use journalctl -r to see how long I slept.
1
u/ChillingChasuble 14d ago
lsusb to show USB devices that are connected to
1
u/ohlaph 14d ago
cd
1
u/Bamseg 14d ago
My most used command is "just" (a command runner - https://github.com/casey/just ) it deeply integrated in my nixos workflow -> herdr, fishshell, starship
It save to me tons of time and nervous.
1
u/SewNgP2206 14d ago
alias k=kubectl
1
u/Bamseg 14d ago edited 14d ago
My most used command is just. It allow create
justfile(per project or global) with complex recipe's and run these recipes as>just recipe_nameThere is snip-off my nixos maintenance justfile:~/.../homelab/.justfile
Then i run in my config folder root where .justfile is:
$> just updateand it call my update recipe to update my flake inputs. Then$> just switchand my new system generation become active. The recipe can be bash or wherever you want (python, etc.. use shebang in recipe)1
u/solslost 13d ago
History
1
u/modsiw_agnarr 13d ago edited 13d ago
sponge
Almost every use is due to a bad habit / anti-pattern, but old habits die hard.
1
u/Squirrel525 12d ago
clear
1
u/jimirs 12d ago
CTRL+E to go the end of the terminal "strings"; CTRL+A beginning; CTRL+D deletes word backward; ALT+D deletes the word forward;
history | grep "something"
find . -type f -name "something*" (-type d for dirs)
nc -zv 192.168.1.X 22 (check connectivity with some host, specific port)
ss -tulpn (check ports listening to something)
cat > file.txt <<'EOF'
write stuff here, or paste
EOF
1
u/AlmosNotquite 11d ago
'grep' is the answer to everything. It is like the 42 of Linux.
1
u/StrawberryFederal709 11d ago
shutdown -h now
1
u/Due-Celebration-5435 11d ago
sudo apt update
1
u/jmakov 11d ago
byobu restore tiles
1
u/roywill2 11d ago
pushdso you can flip between directories1
u/Pretend-Chart-6323 11d ago
tree
0
u/Mr_Boltistran 18d ago
tmux -CC
0
u/WhyFlip 17d ago
ls
1
u/randygeneric 16d ago
history | grep -i <> | grep -iv <>
ps
killall
, )
1
u/[deleted] 14d ago
[removed] — view removed comment