sudo !!to rerun last command as sudo.historycan be paired with!5to run the fifth command listed in history.Fifth as in fifth most recent command or fifth oldest?
I believe it’s the fifth oldest - I think
!-5will get you the fifth impost recent, but I was shown that and haven’t put it into practice.The most common usecase I do is something like
history | grep dockerto find docker commands I’ve ran, then use!followed by the number associated with the command I want to run in history.
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 -5Note:
historydisplays like this for me20622 2023-02-18 16:41:23 lsI don’t know if that’s because I setHISTTIMEFORMAT='%F %T 'in .bashrc, or if it’s like that for everyone. If it’s different for you change-f 5to target the command. Use-f 5-7to include flags and arguments.My top 5 (since last install)
2002 ls 1296 cd 455 hx 427 g 316 findgis 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
lstolcould 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; doneIn .bash_aliases I’ve added
alias b='hx ${HOME}/.bash_aliases'to quickly edit aliases andalias r='source ${HOME}/.bashrc'to reload them.deleted by creator
history -i
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.
I recently switched to tmux and boy, it’s way better. I basically use only tmux now anymore. Creating panes to have two processes in one glance, multiple windows, awesome. Plus all the benefits of screen.
Maybe someone reading wants to now about
prefix+s. This doubles your excitement.Try zellij. Not as popular as tmux, but very intuitive to use.
In a similar vein,
nohuplets you send tasks to the background and seems to be everywhere.Also, screen can connect to an UART device or serial or anything that offers up a TTY
Don’t use
screen, but I do usetmuxpretty heavily.I Always forget to run screen first, so I just rely heavily on dtach
Simply change your terminal command to execute the terminal multiplexer of your choice.
man terminal_of_choice, look for (start) command.No thanks, I’m good
How does screen / tmux work when detached from a session, how does it keep the session alive (both when running locally, and while ssh:ing to a server)? Is there a daemon involved?
You can find out by running screen and executing pstree, that way you can see how the screen process is run.
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.
I think the standard is ~/.local/bin, for the people that like standards.
or add it to path
deleted by creator
I use this constantly
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.
Uhhh…
sudo suDon’t be like me
sudo -i
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.
i’d like to introduce you to your new best friend: reset… it doesn’t everything clear does and a LOT more
haha, I can relate to that :). formerly I had the compulsion to execute sync frequently. Now my compulsion is to push Ctrl-C like 4 times every time I need it. I read somewhere that’s common because of ^C has a lack of feedback to the user, so, a script showing an alert that the clipboard received some information helped with this compulsion.
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
For reference: https://en.m.wikipedia.org/wiki/Rm_(Unix)
The rm -rf / variant of the command, if run by a superuser, would cause every file accessible from the present file system to be deleted from the machine.
The most deceptive joke I’ve seen on this is
sudo rm -fr /to remove the French language pack
I did this on my personal computer just to prove a point.
As primarily a Windows admin (Yes, we exist on Lemmy ;) ) here are few I use often.
Enter-PSSesionGet-ADUser(also group and computer)CLS(aka the superiorclear)ii .(short forInvoke-Item .which runs the selected object using the default method. For paths (like.) the default is explorer, soii .opens the current directory using explorer.)ft(short forFormat-Tableformats piped input as a table.)fl(short forformat-like. Used likeftbut for lists.)Where-ObjectSelect-Object

Fucking hell Lol 😂
ls and cd
I sometimes hit ls and then need to type dir.
The amount of times i tried to dir in linux and ls in windows is mire than I like to admit
slChoo choo!
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 directoryxdg-open .. Should work on any compliant desktop environment (gnome/kde).cdevery single day.ll
df -h
du -sch
Ctrl+r
ll
Is an alias for
ls -alyea?
I have it as
ls -alFh















