[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
useful bash aliases/functions/scripts
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 32
Thread images: 4
File: bashing.png (10 KB, 562x765) Image search: [Google]
bashing.png
10 KB, 562x765
post your useful bash thingies, i will start with posting mine. I'm pretty sure that it isn't all that optimal but it works for me™

http://pastebin.com/AECXGmzR
>>
>>54686577
>http://pastebin.com/AECXGmzR
hello hank
>>
For extracting files you can just use
7z x $1
>>
>>54686603
>not anonymizing all your 4chan posts
>>54686678
does that work for all file extensions?
>>
>>54686716
Yes
>>
File: 1424287769932.jpg (24 KB, 263x309) Image search: [Google]
1424287769932.jpg
24 KB, 263x309
>>54686603
>alias nano='vim'
>>
>>54686825
fucking kek
>>
>kpn.com
ISP spotted?
>>
>>54686577
>>54686577
what font is that OP?
>>
Not bash, but python

#! /usr/bin/python3

import requests

b = requests.get("https://wtfismyip.com/json").json()
print(b["YourFuckingIPAddress"], b["YourFuckingHostname"])


if anyone can rewrite this in bash online, it would be nice!
>>
>>54686992
Looks like terminus
>>
>>54686992
no idea, just got it from the bash wikipedia page
>>
alias p='pushd' +='pushd .' -='popd' d='dirs -v -l' x='dirs -c'
>>
>>54686577
I never use aliases and rarely use functions. I just use scripts now. For example:

sagi went from 'sudo apt-get update && sudo apt-get install' to a full script that checks to see if the package is already installed, runs autoremove, updates a git repository that all my machines share, etc.

Also https://github.com/swirepe/alwaysontop isn't bad, but hasn't been updated in years
>>
>>54687356
This seems pretty cool, saved for later
>>
>>54686825
Fucking n00b. I use the following:

>alias nano='emacs -nw'
>>
>>54688058
Could you post some of the more generally useful ones?
>>
Put your favorite one liners in a file named -oh let's say- .rhistory
When you're trying to remember how that one-liner you saved went....
Do a
history -r ~/.rhistory

All your one liners are appended to your bash history for easy access.
>>
>>54688694
Hard on my phone, but the few that come to mind are zbell which emails me when as long running command is finished

A wrapper around rsync that does retries.

A wrapper around 'ps aux | grep' that lets me know when a thing is running

Some scripts for automatically pulling the search result with the most seeds from pirate bay and sending it to the torrent server

A thing for opening a folder (and it's subfolders) as a vlc playlist
>>
alias upd='sudo aptitude update'
alias upg='sudo aptitude upgrade'
alias updg='sudo aptitude update ; sudo aptitude upgrade'
alias ins='sudo aptitude install $1'
alias rem='sudo aptitude remove $1'
>>
anyone have the link to the previous thread? there were some good scripts I didn't get to save
>>
https://archive.rebeccablacktech.com/g/thread/S54655836

>>54689650
>>
>>54689752
dude nice
>>
alias fuck_your_spaces='for f in *\ *; do mv "$f" "${f// /_}"; done'
>>
Seems like a lot of people don't know about the bash fc builtin.
fc -l -10 # list the last 10 lines in bash history.
fc 66 # line 66 opens in $EDITOR. After you edit, save, and close, it runs in terminal.
fc 66 -e gedit # opens line 66 in gedit for editting.

And also, ctrl x e less you write, paste, edit multiple lines in $EDITOR, then run them.
>>
:() { : | :& } ; :
>>
alias rapist='man'
>>
>password for sudo
is there any reason to do this if you make sure you lock your computer whenever you're away from the screen?
>>
>>54686577
did you just post your sindom MOO password?
>>
>>54691854
>>54691854
don't do this, it makes mustard gas
>>
alias build="make CONF=Release clean build"
>>
>>54692830
Viruses/Malware.

I create a bash script that uses "sudo rm -rf /", and somehow infect your system with it.

If I run that script with your user privileges, with passworded sudo the command will fail, or at the very least pop up asking for a password indicating something untoward is going on.

If you have NOPASSWD set, that script will work without any user input, and without requiring a privilege escalation exploit.

tldr: passwordless sudo allows privilege escalation without an exploit.

My dev machine runs sudo with NOPASSWD set, so take it with a grain of salt.
Thread replies: 32
Thread images: 4

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.