Post your Command line tricks

Forum rules
Share your brain ;)
User avatar
z3bra
Window Manager
Posts: 53
Joined: Fri Jun 27, 2014 8:34 am
Location: France
Contact:

Re: Post your Command line tricks

Unread post by z3bra » Tue Feb 09, 2016 12:01 pm

The meme version:

Code: Select all

curl -s icanhazip.com
BANGARANG, MOTHERFUCKER.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Post your Command line tricks

Unread post by franksinistra » Tue Feb 09, 2016 12:18 pm

^ nice one
rice no more.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Tue Feb 23, 2016 11:43 am

ooh nice one Zeebs. Didn't see that one.

Code: Select all

 nmap -sP 192.168.1.0/23
find out what is on your local (area) network.
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Tue Feb 23, 2016 12:59 pm

arp-scan --local

probably does the same with 23.5MB less dependency bloat :D (no idea really, I just use this to show other computers in the local network)
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Tue Feb 23, 2016 1:22 pm

^ that works too.
or in fact - for no bloat at all (assuming net-tools is installed):

Code: Select all

arp -a 
:)
not so 'live' though
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Tue Feb 23, 2016 3:11 pm

^ yeah, though net-tools is also an external package, at least not a base package in BBQ releases, so -- as bloated as arp-scan ;)
..gnutella..

User avatar
doubledutch
killall X
Posts: 163
Joined: Sun Aug 10, 2014 1:25 pm

Re: Post your Command line tricks

Unread post by doubledutch » Tue Feb 23, 2016 3:42 pm

I use netdiscover a lot. It's a kind of crutch. Need to use tools with more expressive syntactical features like these. Thanks.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: Post your Command line tricks

Unread post by ivanovnegro » Thu Mar 17, 2016 11:05 pm

This looks fancy:

Code: Select all

 sudo apt edit-sources

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/vim.basic
  4. /usr/bin/vim.tiny

Choose 1-4 [2]: 
This exists since apt 1.0.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Post your Command line tricks

Unread post by GekkoP » Fri Mar 18, 2016 9:22 am

^ That's really cool and of course I knew nothing about it.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: Post your Command line tricks

Unread post by ivanovnegro » Mon Mar 21, 2016 12:44 am

Watch your sensors in real time:

Code: Select all

watch sensors
or

Code: Select all

watch -d sensors
Of course you need lm-sensors installed and probably configured.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Tue Apr 05, 2016 7:42 am

^ 'watch' is cool as hell, in lieu of using 'pv' to see if something's copying progress, I often run a watch on a du -sh /path/to/copy/

I wanted to do this typo as an April Fool's:

Code: Select all

mkdior 
freshens up the directory.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
linuxbbq
Oyster-Slurper
Posts: 27
Joined: Thu Aug 28, 2014 10:03 am

Re: Post your Command line tricks

Unread post by linuxbbq » Tue Apr 05, 2016 11:13 am

^ I know at least two people who tried it...
Trailing whitespace? Give me a fucking break, and save me from "experts" and "C-language lawyers."

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Fri May 20, 2016 2:01 pm

Code: Select all

 while true; do while [[ $(ps aux | grep -c [s]tupid.php) -gt 9 ]]; do ps -eo user,pid,cmd,etime | grep [u]ser | grep "php /home/user/stupid.php" | tail -n1 | kill $(cut -d " " -f5) ;sleep 10s ; echo "killed one"; done ;done 
not too proud - but it did the job (of keeping only 9 silly php scripts running, by killing the newest one) and saved the day
note the gorgeous 'while true' loop wrapping the 'while' loop..
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Post your Command line tricks

Unread post by dkeg » Fri May 20, 2016 2:56 pm

*did the job

Work hard; Complain less

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: Post your Command line tricks

Unread post by ivanovnegro » Fri May 20, 2016 3:09 pm

Playing with systemd a bit and still trying to learn some important commands to enable/disable services.

To see what is already running:

Code: Select all

systemctl list-unit-files --type=service | grep enabled
Now, let's trim down some shit as root:

Code: Select all

systemctl stop *unneeded.service*

Code: Select all

systemctl disable *unneeded.service* 
Used it to disable mpd from running at boot as a service after a fresh install. Finally I know how to use systemd properly and with my preferred music application mpd. Because I was still using sysvinit commands.

Code: Select all

systemctl status *unneeded.service*
tells you if it worked.

You probably know all that but as we say, it did the job for me.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Fri Mar 10, 2017 2:33 pm

i still use sysv init commands :P
muscle memory...

So this is funny, when it's sunny, turn my dark screen into a bright white sunshine proof screen!

Code: Select all

xcalib -invert -alter
or even

Code: Select all

xcalib -i -a
then use a broweser plugin to invert the screen colours and there we are. :)
I bound it to the think launcher. as it wasn't doing anything else.
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Sun Mar 12, 2017 8:16 am

^ there might even be a way of automatically changing it, if the box has the ambient light sensor. Well, laziness :D
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Mon Mar 13, 2017 9:07 am

^ there is/was a project which has that idea.
otherwise it's xbacklight bound to the original keys for lighting
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Mon Mar 13, 2017 4:57 pm

^ overkill it: get the weather stats from an API every 10 minutes, and as soon as it's "Sunny" make the screen inverted :D
a bit like redshift huh
..gnutella..

User avatar
z3bra
Window Manager
Posts: 53
Joined: Fri Jun 27, 2014 8:34 am
Location: France
Contact:

Re: Post your Command line tricks

Unread post by z3bra » Wed Jun 14, 2017 10:45 pm

You guys should certainly check this: http://www.tedunangst.com/flak/post/sct ... emperature
A simple way to update you screen color to the time of day.

Now to get back to the topic of cool CLI tricks:

Code: Select all

echo 'main(){printf("hello, world!\n"); return 0}' > hello.c
cc -static hello.c -o hello
mkdir /ns/handcraft && cp hello /ns/handcraft/
ip netns add handcraft
ip netns exec handcraft unshare -fpium --mount-proc env -i container=handcraft PATH=. chroot /ns/handcraft hello
And you've just made the smallest linux container in the world!

Another really neat trick to try out C code:

Code: Select all

$ echo '#include "/dev/stdin"' > pgm.c
$ cc pgm.c
int main() {
    printf("Compile time code!\n");
    return 0;
}
^D
$ ./a.out
Compile time code!
Useless, but cool as shit right?
BANGARANG, MOTHERFUCKER.

Post Reply