sudo !!
to rerun last command as sudo.
history
can be paired with !5
to run the fifth command listed in history.
sudo !!
to rerun last command as sudo.
history
can be paired with !5
to run the fifth command listed in history.
cd
then ls
then cd
then ls
maybe I’ll throw a ls -a
I use -A instead, which doesn't show "." and ".."
tldr
because I am too impatient to read through man pages or google the exact syntax for what I want to do.
There are exactly three kinds of manpages:
I will take 1 any day over 2 or 3. Sometimes I even need 1, so I'm grateful for them.
But holy goddamn is it awful when I just want to use a command for aguably its most common use case and the flag or option for that is lost in a crowd of 30 other switches or buried under some modal subcommand. grep
helps if you already know the switch, which isn't always.
You could argue commands like this don't have "arguably most common usecases", so manpages should be completely neutral on singling out examples. But I think the existence of tl;dr is the counterargument.
Tangent complaint: I thought the Unix philosophy was "do one thing, and do it well"? Why then do so many of these shell commands have a billion options? Mostly /s but sometimes it's flustering.
I went a little overboard and wrote a one-liner to accurately answer this question
history|cut -d " " -f 5|sort|uniq -c|sort -nr|head -5
Note: history
displays like this for me
20622 2023-02-18 16:41:23 ls
I don't know if that's because I set HISTTIMEFORMAT='%F %T '
in .bashrc, or if it's like that for everyone.
If it's different for you change -f 5
to target the command. Use -f 5-7
to include flags and arguments.
My top 5 (since last install)
2002 ls
1296 cd
455 hx
427 g
316 find
g
is an alias for gitui. When I include flags and arguments most of the top commands are aliases, often shortcuts to a project directory.
Not to ramble, but after doing this I figured I should alias the longest, most-used commands (even aliasing ls
to l
could have saved 2002 keystrokes :P) So I wrote another one-liner to check for available single characters to alias with:
for c in a b c d e f g h i j k l m n o p q r s t u v w x y z; do [[ ! $(command -v $c) ]] && echo $c; done
In .bash_aliases I've added alias b='hx ${HOME}/.bash_aliases'
to quickly edit aliases and alias r='source ${HOME}/.bashrc'
to reload them.
tldr
is great. Basically a crowd-sourced alternative to man
with much more concise entries. Example:
$ tldr dhcpcd
DHCP client.
More information: <https://roy.marples.name/projects/dhcpcd>.
Release all address leases:
sudo dhcpcd --release
Request the DHCP server for new leases:
sudo dhcpcd --rebind
control+R
in bash, it lets you quickly search for previously executed commands.
its very useful and makes things much quicker, i recommend you give it a try.
Sudo !!
It reruns the last command as sudo.
Pretty useful since I'm always forgetting.
Since nobody has said yet, I use screen pretty heavily. Want to run a long running task, starting it from your phone? Run screen to create a detachable session then the long running command. You can then safely close out of your terminal or detach with ctrl a, d and continue in your terminal doing something else. screen -r to get back to it.
clear
because apparently I am too scatterbrained to comprehend more than one full page of text in the terminal
Not a specific command, but I learned recently you can just dump any executable script into ~/bin and run it from the terminal.
I suffer greatly from analysis paralysis, I have a very hard time making decisions especially if there's many options. So I wrote a script that reads a text file full of tasks and just picks one. It took me like ten minutes to write and now I spend far more time doing stuff instead of doing nothing and feeling badly that I can't decide what to do.
This is because $HOME/bin
is in your $PATH
environment variable. You can add more paths that you'd like to execute scripts from, like a personal git repo that contains your scripts.
I think the standard is ~/.local/bin, for the people that like standards.
After using too much WINE,
I type pwd
, whoami
clear
. Constantly, and for no reason.
Ctrl-L
Oh. I know. But you don't understand - I'm compelled to type it out. I must.
pv (Pipe Viewer) is a command line tool to view verbose information about data streamed/piped through it. The data can be of any source like files, block devices, network streams etc. It shows the amount of data passed through, time running, progress bar, percentage and the estimated completion time.
As primarily a Windows admin (Yes, we exist on Lemmy ;) ) here are few I use often.
Enter-PSSesion
Get-ADUser
(also group and computer)CLS
(aka the superior clear
)ii .
(short for Invoke-Item .
which runs the selected object using the default method. For paths (like .
) the default is explorer, so ii .
opens the current directory using explorer.)ft
(short for Format-Table
formats piped input as a table.)fl
(short for format-like
. Used like ft
but for lists.)Where-Object
Select-Object
CTR + u will delete the whole command. I use that a lot so I don't have to backspace. It's saved me a ton of time
Related: Alt + .
, to cycle through arguments used in previous commands
xdg-open FILE
- opens a file with the default GUI app. I use it for example to open PDFs and PNG. I have a one letter alias for that. It can also open a file explorer in the current directory xdg-open .
. Should work on any compliant desktop environment (gnome/kde).
sudo
Make me a sandwich.
sudo rm -rf /
Very powerful yet helpful command :-)
Someone has to say this. Don't do it anyone
Agree. Don’t just copy and paste CLI commands you find on the internet, suggested by a stranger
The most deceptive joke I've seen on this is
sudo rm -fr /
to remove the French language pack
On my desktop:
df -h
to check disk usage
htop
to see resource usage
ll
list directory contents
I recently learned to use a for loop on the command line to organize hundreds of files in a few seconds.
A loosely moderated place to ask open-ended questions
If your post meets the following criteria, it's welcome here!
Looking for support?
Looking for a community?
~Icon~ ~by~ ~@Double_A@discuss.tchncs.de~