Not a command but bang expansions. For example
!?
is the args of last command useful for stuff likemkdir foo ; cd !?
https://www.redhat.com/sysadmin/bash-bang-commands learn these. you suck at using your computer if you don’t know them.
Is there something similar in fish shell?
sudo
doas
nmtui. But that’s because my router is trash.
I really like that
cd
command. :PYou’ll love
zoxide
then.deleted by creator
When you set it up you tell it which command you want. Default is “cdi” but I changed it to “cd” immediately.
The command is ‘z’
deleted by creator
It’s in the official docs for zoxide, you are supposed to use the z alias, and many distros just set it up directly like that. I love doing
z notes
from wherever I am.That doesn’t require a separate package, especially one which uses eval on every new shell. And isn’t messing with my distros or personal aliases (and doesn’t introduce cargo-packaging).
Simply adding one to two (you get the gist) directories and a keybind for
cd ..
is more slick. There are cases where you might usepushd .
but even then other tooling should already cover your needs.It’s also so easy that you can temporarly append to
$CDPATH
for a specific session. But again, then a second pane or pushd is already available.Now downvote me, lemmy.
You have to enable it in your shell config. For bash it’s
eval "$(zoxide init bash)"
That will give you the
z
command.https://github.com/ajeetdsouza/zoxide?tab=readme-ov-file#installation
On arch the command is just
z
A command is anything you execute in the shell.
cd
is just a built-in command
I recently learned to use a for loop on the command line to organize hundreds of files in a few seconds.
Example of said Black Magik?
Let’s say, for example, you have a directory of files named x01-001; x01-002; x02-001; x02-002; x03-001… and so on.
I want to create subdirectories for each ‘x’ iteration and move each set to the corresponding subdirectory. My loop would look like this:
for i in {1…3}; do mkdir Data_x0$i && mv x0$i* Data_x0$i; done
I’ve also been using it if I need to rename large batches of files quickly.
Check out
rename
$ touch foo{1..5}.txt $ rename -v 's/foo/bar/' foo* foo1.txt renamed as bar1.txt foo2.txt renamed as bar2.txt foo3.txt renamed as bar3.txt foo4.txt renamed as bar4.txt foo5.txt renamed as bar5.txt $ rename -v 's/\.txt/.text/' *.txt bar1.txt renamed as bar1.text bar2.txt renamed as bar2.text bar3.txt renamed as bar3.text bar4.txt renamed as bar4.text bar5.txt renamed as bar5.text $ rename -v 's/(.*)\.text/1234-$1.txt/' *.text bar1.text renamed as 1234-bar1.txt bar2.text renamed as 1234-bar2.txt bar3.text renamed as 1234-bar3.txt bar4.text renamed as 1234-bar4.txt bar5.text renamed as 1234-bar5.txt
In your second example, it looks like you have an escape character before the first ‘dot’, but not the second one. Is this a typo, or am I misunderstanding the command?
It’s not a typo. The first section of the regex is a matching section, where a dot means “match any character”, and an escaped dot is a literal dot character. The second section is the replacement section, and you don’t have to escape the dot there because that section isn’t matching anything. You can escape it though if it makes the code easier to read.
rename
is written in Perl so all Perl regular expression syntaxes are valid.However, your comment did make me realize that I hadn’t escaped a dot in the third example! So I fixed that.
xargs
is also fun, and assuming your for loop doesn’t update anything out of the loop, is highly parallelizableThe equivalent of the same command, that handles 10 tasks concurrently, using
%%
as a variable placeholder.seq 1 100 | xargs -I'%%' -P 10 sh -c 'mkdir Data_X0%% && mv x0%%* Data_X0%%;'
But for mass renaming files,
dired
along with rectangle-select and multicursors within Emacs is my goto.
Even better when
cd
automatically invokespushd
.what’s your alias?
cd -
undoes the last cd. Not quite push/popd but still useful. Pro tip, works also: git checkout -Hell yeah. Every one of these threads makes me more inclined to read man pages
You should. These are the actually sources to learn.
On my desktop:
df -h
to check disk usagehtop
to see resource usagell
list directory contentsI recently found btop and am trying to use that instead of htop.
looks up btop ooooo
ll
df -h
du -sch
Ctrl+r
ll
Is an alias for
ls -al
yea?
I have it as
ls -alFh
I set mine to
ls -lAh
After using too much WINE, I type
pwd
,whoami
touch
😏I remember
touch
Make me a sandwich.
LambdaRX is not in the sudoers file. This incident will be reported
Eh, guess I won’t get anything for christmas.
sudo rm -rf /
Very powerful yet helpful command :-)
I did this on my personal computer just to prove a point.
Someone has to say this. Don’t do it anyone
Instructions unclear, dick now stuck in computer.
Lp0 on fire
doesnt actually do anything on gnu rm, and hasnt in like a decade. but yeah, dont do it.
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.
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
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.
Also, screen can connect to an UART device or serial or anything that offers up a TTY
I would know this as tmux, is there a difference?
no, tmux is a newer screen. some of us havent switched cos we’re too lazy i guess? i think the common wisdom is that it’s better. i havent tried cos i already know enough of screen and it’s fine for me
Or you can learn both and spend the rest of your life trying screen commands in tmux and vice versa.
mmmmmm <3
gnu screen is just a different program than tmux. they do the same thing though
Don’t use
screen
, but I do usetmux
pretty heavily.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.
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
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,
nohup
lets you send tasks to the background and seems to be everywhere.You can’t mention
nohup
without at least mentioningkill -9
orpkill
to slay the monster you created you madmanNo hate! Just need to make sure people know so they don’t create a bazillion threads without realizing it, or how to stop them effectively
Sometimes I’ll just reboot the entire damn machine just to be safe ;)
shutdown -r now
I do love
fuck
.And you mistype it as fsck
sudo udevadm monitor
Figuring out which usb device went on holiday.
Wow, super useful command. Starring this comment