Erodov.com Forums | India's Top Technology forum.
Loading

navigation start navigation end
Go Back   Erodov.com Forums | India's Top Technology forum. > Software Zone > Open Source
Register Forgot Password?

 
 
Thread Tools Search this Thread
Old 06-05-10   #1
Cyanogenmod 6.0-N1
Pr[e]f[e]rr[e]d M[e]mb[e]r
work, work and more work :(
 
 
blufox's Avatar
Rig Gallery
Icon14 Linux/Unix Lesser Known Tips and Tricks


Hi,

Purpose of this thread : To put up lesser knows tricks which are difficult to find.

Let me start off with a lame tip -

If you are using any application which needs to be run with different variables on input conditions at times, you can write a script which can do this for you according to some predefined rules.

e.g on my work laptop if I launch chrome( or chromium), it fails to browse any http sites except internal ones.

So this is what I did -

Code:
[pradeeps@archlinux ~]$ which chromium
/usr/bin/chromium
[pradeeps@archlinux ~]$ file /usr/bin/chromium 
/usr/bin/chromium: POSIX shell script text executable
[pradeeps@archlinux ~]$ cat /usr/bin/chromium 
#!/bin/sh
export CHROME_WRAPPER=/usr/lib/chromium/chromium
export CHROME_DESKTOP=chromium.desktop
exec /usr/lib/chromium/chromium $@

Since I know this is a script which invokes a binary in /usr/lib/chromium/chromium , let us fix things for chrome.

The reason it is unable to browse is because I am behind a proxy, so let us do some very simple customization to this script to ease our life -
I replaced "exec /usr/lib/chromium/chromium $@" with

Code:
env  http_proxy=http://proxy-xyz.com:3128 https_proxy=http://xyz.com:3128 no_proxy="localhost, *.internal.xyz.com, mywebserver, 127.0.0.1 192.168.1.0/24" /usr/lib/chromium/chromium $@
Next time I launch chromium ( or Google chrome), everything works fine. Heck I do not even have to change anything at home. There is no proxy at home and it will work straight since I have put my home subnet in no_proxy range.

Same thing can be extended to any application on Unix. This is not restricted to browsers.
I can launch gcc with different options while compiling kernel code and with different options while compiling userspace code and with different options while compiling multithreaded programs which use posix thread library.

I hope this helps someone who is banging his head figuring things out.

keep adding yours.
__________________
School has a definition of intelligence that fights creativity

/Steve Wozniak
blufox is offline   Reply With Quote
Old 06-05-10   #2
teh spamm[E]R!
[E]onian
trolling around
 
 
baba doga's Avatar

 
Join Date: Nov 2008
Posts: 10,854
baba doga is Notable
Re: Linux/Unix Lesser Known Tips and Tricks

bookmarked.

and rated.

Last edited by baba doga; 06-05-10 at 04:36 PM.
baba doga is offline   Reply With Quote
Old 06-05-10   #3
teh zeuS!
[E]onian
Alls well that ends in hell
 
 
montylee's Avatar

 
Join Date: Aug 2007
Location: Saddi Dilli
Posts: 4,527
montylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirable
Re: Linux/Unix Lesser Known Tips and Tricks

nice post. I don't know if this is lesser known or not but here it is:

"To clear the screen on a terminal, you generally use the "clear" command, instead press Ctrl+L".

It's very handy and don't use the clear command anymore.
__________________
--------------------------------------------------
"May the Source be with You"

montylee is offline   Reply With Quote
Old 06-05-10   #4
teh geeK!
[E]onian
I havent set my status yet.
 
 
sahilm's Avatar

 
Join Date: Mar 2008
Location: Noida
Posts: 1,210
sahilm is highly Admirablesahilm is highly Admirablesahilm is highly Admirablesahilm is highly Admirablesahilm is highly Admirablesahilm is highly Admirablesahilm is highly Admirable
Re: Linux/Unix Lesser Known Tips and Tricks

Originally Posted by montylee View Post
nice post. I don't know if this is lesser known or not but here it is:

"To clear the screen on a terminal, you generally use the "clear" command, instead press Ctrl+L".

It's very handy and don't use the clear command anymore.
Nice. I had it aliased as 'c'. Guess I need one less alias now. Thanks.
__________________
Originally Posted by stonedsurd View Post
Freakin genius mate. Of course, it's also common sense...
Originally Posted by SignOps View Post
These days, Common sense = freaking genius.
sahilm is offline   Reply With Quote
Old 07-05-10   #5
teh zeuS!
[E]onian
Milk provides nutritions!!!
 
 
initpidzero's Avatar
Rig Gallery
 
Join Date: Feb 2009
Location: !(The Kapitol)
Posts: 4,779
initpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Great
Re: Linux/Unix Lesser Known Tips and Tricks

some from my side
I use alias:
alias vi vim
alias ll ls -l

then you can use !### command to execute previous command
for example
#history
1. ls
2.clear
3. gcc hell.c
4. ./a.out
5. blah blah

so if you want to execute "clear again"
just do
#!2

and reverse search is very common way of finding something on prompt:
just do "ctlr+r" and type keyword, u can see previous command matching the string on display, which can be used by pressing "Enter"
__________________
<rob89> windows is being a bit*h >_<
<Trinexx> Install Linux.
<rob89> no. i use windows for all my work
<Trinexx> Linux would be better for that.
<rob89> besides, i like being able to play a game or two
<Trinexx> Linux has games.
<rob89> im not getting linux. windows has great support, ill have this fixed in no time
<Trinexx> Linux has better support.
<rob89> if you say "linux" one more time, im gonna send you a virus
<Trinexx> Good *ucking luck. I'm on Linux.
initpidzero is offline   Reply With Quote
Old 07-05-10   #6
teh zeuS!
[E]onian
Alls well that ends in hell
 
 
montylee's Avatar

 
Join Date: Aug 2007
Location: Saddi Dilli
Posts: 4,527
montylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirable
Re: Linux/Unix Lesser Known Tips and Tricks

Originally Posted by initpidzero View Post
some from my side
I use alias:
alias vi vim
alias ll ls -l

then you can use !### command to execute previous command
for example
#history
1. ls
2.clear
3. gcc hell.c
4. ./a.out
5. blah blah

so if you want to execute "clear again"
just do
#!2

and reverse search is very common way of finding something on prompt:
just do "ctlr+r" and type keyword, u can see previous command matching the string on display, which can be used by pressing "Enter"
thanks for the ctrl+r tip, i have seen ppl use it but never cared to ask them the shortcut. So, i do ctrl+r and i see only 1 match . Is there a way to switch among possible matches?

Also, for executing previous command, u can also use this:
1. ls
2.clear
3. gcc hell.c
4. ./a.out
5. blah blah


so, to execute clear, so u can do:
# !c

So, just use ! and then either enter the first few characters of the command or the command number from history.
montylee is offline   Reply With Quote
Old 07-05-10   #7
teh zeuS!
[E]onian
Milk provides nutritions!!!
 
 
initpidzero's Avatar
Rig Gallery
 
Join Date: Feb 2009
Location: !(The Kapitol)
Posts: 4,779
initpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Great
Re: Linux/Unix Lesser Known Tips and Tricks

no montee, u use the command number. let me give a practical demo:
#history

977 vi server.c
978 gcc -o server server.c
979 ./server 8990
980 ./client
981 ./client 127.0.0.1 8990
982 ./client 127.0.0.1 8999
983 vi client.c
984 ./client 127.0.0.1 8999
985 ./sample
986 vi client.c
987 ls
988 vi client.c
989 vi server.c
990 gcc server.c -o server
991 ./server 8990
992 vi server.c
993 ll -l /
994 ll -ld /
995 man git-ignore
996 history

#!987
ls
....
....
.....

for ctrl+r to work effectively, u have to smart search:
(reverse-i-search)`ls': ls -l /tmp/
and if u want to see what all matches, press "ctrl+r" repeatedly until u get the command you are looking for.
Bash sometimes behave abnormally, so even if its in history, u may not be able to find that command a few times.
initpidzero is offline   Reply With Quote
Old 07-05-10   #8
teh zeuS!
[E]onian
Alls well that ends in hell
 
 
montylee's Avatar

 
Join Date: Aug 2007
Location: Saddi Dilli
Posts: 4,527
montylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirablemontylee is highly Admirable
Re: Linux/Unix Lesser Known Tips and Tricks

okie dokie...so press Ctrl+R again to see the next match
BTW, i do use the command number with history, i was just telling about another use i.e. u can use exclamation sign and the first few characters of the command too (instead of command number), don't u know abt it? Lemme elaborate it a bit:

$ history

1 ls
2 clear
3 cp -r doodle /mnt/usb/


So, to run cp again, just do:
$ !c
or
$ !cp

Sometimes, you'll get an error that the command is ambiguous, then u need to specify more characters of the command to make it unique.
montylee is offline   Reply With Quote
Old 10-05-10   #9
teh zeuS!
[E]onian
Milk provides nutritions!!!
 
 
initpidzero's Avatar
Rig Gallery
 
Join Date: Feb 2009
Location: !(The Kapitol)
Posts: 4,779
initpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Greatinitpidzero is simply Great
Re: Linux/Unix Lesser Known Tips and Tricks

^interesting
initpidzero is offline   Reply With Quote
Old 15-05-10   #10
teh nuB!
I havent set my status yet.
 

 
Join Date: May 2010
Location: L.A.
Posts: 3
lamdacore is Mysterious
Re: Linux/Unix Lesser Known Tips and Tricks

Well from the above mention of using "!" to get a history of earlier commands, I don't know if this is obvious or well known but you can do this:
Code:
/~/  rm Downloads/lost/
rm: cannot remove `Downloads/lost/': Is a directory
/~/ !! -r
rm Downloads/lost/ -r
/~/
also "sudo !!"
we all forget the sudo sometimes.
lamdacore is offline   Reply With Quote
Old 15-05-10   #11
teh spamm[E]R!
[E]onian
I havent set my status yet.
 
Rig Gallery
 
Join Date: Jul 2008
Posts: 22,817
stonedsurd is extremely Renowned
stonedsurd is extremely Renownedstonedsurd is extremely Renownedstonedsurd is extremely Renowned
Re: Linux/Unix Lesser Known Tips and Tricks

Originally Posted by lamdacore View Post
Well from the above mention of using "!" to get a history of earlier commands, I don't know if this is obvious or well known but you can do this:
Code:
/~/  rm Downloads/lost/
rm: cannot remove `Downloads/lost/': Is a directory
/~/ !! -r
rm Downloads/lost/ -r
/~/
also "sudo !!"
we all forget the sudo sometimes.
Hello Kaus
stonedsurd is offline   Reply With Quote
Old 16-05-10   #12
teh zeuS!
Pr[e]f[e]rr[e]d M[e]mb[e]r
..I..
 
 
Dark Star's Avatar
Rig Gallery
 
Join Date: May 2007
Location: /var/temp
Posts: 2,502
Dark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly Famed
Re: Linux/Unix Lesser Known Tips and Tricks

Code:
shashwat@shashwat-desktop:~$ whereis firefox
firefox: /usr/bin/firefox /etc/firefox /usr/lib/firefox /usr/lib64/firefox /usr/share/firefox
Create swap if you have forgotten to create while partitioning .


1. Make an empty partition using fdisk

Code:
fdisk /dev/sda
Press n to create a new partition, then press Enter so that fdisk choose the defaul cylender from where the disk is empty, once done you can enter size like 4096M for 4gb and so on.

Then change the partition created to swap by pressing t and then enter partition number and then 82 for linux-swap. Write all the changes by pressing w.

Code:
partprobe #To invoke new partition table w/o restarting the pc
Once done. Make that partition swap using

Code:
mkswap /dev/sdaX
Where X is the partition number to which you want to create a swap partition.

Code:
 swapoff #To switch the swap off
swapon #To switch the swap on



Check the swap by
Code:
free -m
__________________

Dark Star is offline   Reply With Quote
Old 16-05-10   #13
Cyanogenmod 6.0-N1
Pr[e]f[e]rr[e]d M[e]mb[e]r
work, work and more work :(
 
 
blufox's Avatar
Rig Gallery
 
Join Date: Jun 2008
Location: Bangalore
Posts: 5,443
blufox is extremely Renowned
blufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renowned
Re: Linux/Unix Lesser Known Tips and Tricks

^^^ Good to see Darky after a looooong time.
Nice tips. I was unaware of partprobe thing, thanks for brining it up.
Just to add to what Darky suggested. You can also use a file to be used as a swap instead of partition, if you do not want to alter your partition table.

Just make a raw file using dd as per your requirements.
dd if=/dev/urandom of=/opt/swapfile1 bs=N count=sizerequired/N

do a mkswap /opt/swapfile1

and finally -

swapon /opt/swapfile1

Done.
blufox is offline   Reply With Quote
Old 16-05-10   #14
teh zeuS!
Pr[e]f[e]rr[e]d M[e]mb[e]r
..I..
 
 
Dark Star's Avatar
Rig Gallery
 
Join Date: May 2007
Location: /var/temp
Posts: 2,502
Dark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly FamedDark Star is highly Famed
Re: Linux/Unix Lesser Known Tips and Tricks

^^Why fill some partition instead make use /dev/null for better results.
Dark Star is offline   Reply With Quote
Old 16-05-10   #15
Cyanogenmod 6.0-N1
Pr[e]f[e]rr[e]d M[e]mb[e]r
work, work and more work :(
 
 
blufox's Avatar
Rig Gallery
 
Join Date: Jun 2008
Location: Bangalore
Posts: 5,443
blufox is extremely Renowned
blufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renownedblufox is extremely Renowned
Re: Linux/Unix Lesser Known Tips and Tricks

^^^ errr is there a harm?
Anyway you are going to allocate, irrespective of whether you use it with null, zeros or urandom?
So what is the harm?

This ain't lazy allocation but reservation of blocks for a swapfile. Doesn't matter in the end I hope.
blufox is offline   Reply With Quote
Post New Thread  Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seven Tips and Tricks for Windows 7 Nocturnal Tip and Tricks :) 11 07-07-16 01:05 PM
Unix Gurus: COme help me vasishta.sushant Programming 7 03-12-09 02:41 PM
Super Advanced tips for Linux Users. SignOps Open Source 7 03-03-09 03:43 PM
UNIX: Need help in few things. Who can help? vasishta.sushant Programming 14 07-01-09 07:23 AM
WTB:AMD X2 4200+ or lesser Khimera Closed/Completed Deals 8 17-09-07 07:46 PM


Tags
lesser, linux, linux or unix, tips, tricks
All times are GMT +5.5. The time now is 01:37 AM.
Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 PL2 ©2011, Crawlability, Inc.