Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, August 9, 2011

Changing display resolution on Ubuntu when the resolution option doesn't show up

It is very annoying when you have a good monitor (an NEC MultiSync LCD1970NX in my case), capable of supporting 1280x1024 or some such high resolution, whereas Ubuntu simply cannot see beyond 832x624.

Earlier versions of Ubuntu had the xorg.conf file which is no longer present, although if you craft it by hand it is still going to be used. That seems like a dangerous proposition, though - a simple mistake could screw up at least something that is working.

I found the savior in the command xrandr, thanks to X/Config/Resolution page on the ubuntu wiki. And here is what I have done so far:

1. I first ran the command xrandr to make sure that the VGA1 indeed existed. As it turns out, that command can also tell you what is the highest resolution your monitor can support:
sudipta@Springfield:~$ xrandr
Screen 0: minimum 320 x 200, current 832 x 624, maximum 4096 x 4096
VGA1 connected 832x624+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0 +   75.0 
   1280x960       60.0 
   1152x864       75.0 
   1024x768       75.1     70.1     60.0 
   832x624        74.6*
   800x600        72.2     75.0     60.3     56.2 
   640x480        72.8     75.0     66.7     60.0 
   720x400        70.1 
LVDS1 connected 832x624+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1280x720       60.0 +
   832x624        74.6*
   800x600        85.1     72.2     75.0     60.3     56.2 
   640x480        85.0     72.8     75.0     59.9 
   720x400        85.0 
   640x400        85.1 
   640x350        85.1 
See that 1280x1024 at the top of the list? That is how high my monitor could go. And see that line in the middle with a * at the end (832x624        74.6* in my case) - that one is what I am currently running. And strangely enough, although xrandr knew the highest possible on available, the monitor options only showed 832x624 to be the highest:

So all I had to do to rectify the situation was to open up the gnome terminal and run
xrandr --output VGA1 --mode 1280x1024
which was the highest one supported by my monitor, as mentioned above. Note that I did not specify a refresh rate (using --rate 75 or 60): I let the computer decide for itself. And voila! I had a 1280x1024 screen on my monitor!

I will post an update about how to make the change permanent as well, although the wiki already mentions some options.

Thursday, July 7, 2011

ln -sf gives ?[01;32mFILENAME?[0m

So I was trying to link to a few files from a script and it kept getting me these strange links instead of the actual file name. This is what I had in my shell prompt:

for i in `ls /var/www | grep FILENAME`; do ln -sf $i .; done

[The grep is there because of multiple files which began by the same name]. But then what I got instead in the folder where I was running this script was this:

sudipta@Hogwarts:~/html$ ls -l
total 156
lrwxrwxrwx 1 sudipta sudipta     25 2011-07-06 23:08 ?[01;32mFILENAME?[0m -> ?[01;32mFILENAME?[0m

lrwxrwxrwx 1 sudipta sudipta     34 2011-07-06 23:08 FILENAME.txt -> FILENAME.txt

I had no idea where this strange file was from or why it was here. Also, only a few files were getting affected by this. A simple "ls -l" showed that this was happening only to those files which had the executable file set

After some time, I realized that this was a permissions problem. I gave the local directory write permission by www-data, and then sudo-ed myself into www-data and re-executed my script again.

sudipta@dev:~/html$ rm -f FILENAME*sudipta@dev:~/html$ chmod a+w .
sudipta@dev:~/html$ sudo su www-data
[sudo] password for sudipta:
$
for i in `ls /var/www | grep FILENAME`; do ln -sf $i .; done
$^D
And that did it! All I needed was to run the thing as www-data with write permission in my current directory.
sudipta@Hogwarts:~/html$ ls -l
total 156
lrwxrwxrwx 1 sudipta sudipta     25 2011-07-06 23:08 FILENAME -> FILENAME

lrwxrwxrwx 1 sudipta sudipta     34 2011-07-06 23:08 FILENAME.txt -> FILENAME.txt

Friday, October 22, 2010

StrongSwan: we have no ipsecN interface for either end of this connection

I installed a new NIC card on one of my PCs where IPSec was already set up through StrongSwan and configured NAT-ing through iptables. Afterward, when I tried to do "ipsec up myconnection" I got this error:
we have no ipsecN interface for either end of this connection
The reason, it turns out, is that if the ipsec services were started before all the network interfaces came up, it is confused about which egress route to take. As I found on the Layer9 blog (and translated from German to English via Babelfish), it turns out you need to make sure that ipsec starts after the network has come up. The quick fix was just an IPSec restart:
sudo /etc/init.d/ipsec restart

And the long-term fix was definitely to just delay the ipsec a little. Add this to your /etc/rc.local file:
/etc/init.d/ipsec stopsleep 5/etc/init.d/ipsec start

Thursday, October 7, 2010

Strongswan: ike alg: unable to locate my private key

If you are using StrongSwan to establish an IPSec connection and you encounter this error:
root@crackjack:~# ipsec up conn-to-td
002 "conn-to-td" #2: initiating Main Mode
002 "conn-to-td" #2: ike alg: unable to locate my private key
002 "conn-to-td" #2: ike alg: unable to locate my private key
003 "conn-to-td" #2: empty ISAKMP SA proposal to send (no algorithms for ike selection?)

Then I have found the way to solve the first part of your problem - the private key part. Basically, after FreeSwan became OpenSwan and then finally StrongSwan, they created a directory for each individual part under /etc/ipsec.d. So for example the CA certs are stored in the folder /etc/ipsec.d/cacerts, or the certs you got are stored in /etc/ipsec.d/certs. Similarly, you are supposed to store your private key at /etc/ipsec.d/private. What you have probably done is that in /etc/ipsec.conf you wrote down
leftcert=/etc/ipsec.d/private/my_private_key.pem
When in fact you should have your /etc/ipsec.conf as the following:

# ipsec.conf - strongSwan IPsec configuration file

# basic configuration

config setup
    plutodebug=all
    plutostderrlog=/var/log/pluto.log
    charonstart=yes
    plutostart=yes


conn host-to-host
      left=
      leftcert=my_cert.pem
      leftid=my_private_key.pem
      right=
      rightid=
      auto=start
      pfs=no
      rekey=no
      keyingtries=3
After this, you can do the faithful /etc/init.d/ipsec restart and the private key problem will disappear

Wednesday, May 26, 2010

Upgrading Fedora from the command line

I have a Fedora box running and I sort of screwed up the GDM so I was left without a display. Since the Fedora 13 (Goddard) was released recently, I decided to upgrade, from the command line. It kept giving me the error that complained, "Can't open display".

I finally figured out that I needed preupgrade-cli, as specified here: http://fedoraproject.org/wiki/PreUpgrade

The syntax, from the command line is this (as root):
preupgrade-cli "Fedora 13 (Goddard)"

Note the quotes surrounding the argument - you need those to specify the string for the version you want to upgrade to.

Sunday, May 9, 2010

Road rash on Linux using wine

For a lot of us, Roadrash is a game that is going to remain close to our hearts forever! Countless hours spent in front of the PC while kicking and punching others, or even on the LAN fending off your room-mate. For a lot of us, this has been THE introduction to computer video games.

Downloading the game is pretty easy, actually. I got mine at http://www.download-full-games.com/pc/sports/road_rash.html

The tricky part is to get to run it on Linux. In my case, Ubuntu Linux is the only operating system I have: I honestly don't need Windows for much. This game, however, runs only on Windows and so the quintessential wine came to the rescue. So then I unzipped the file and from the command prompt typed:

sudipta@Hogwarts:~/roadrash$ wine ROADRASH.EXE

This unfortunately leads to the "CD-Rom not found" error. The fix to this, as we all know, is to have the registry edited. There is a SETREG.EXE which you can run, but then the state is not persistent. As in, if you run

sudipta@Hogwarts:~/roadrash$ wine SETREG.EXE
sudipta@Hogwarts:~/roadrash$ wine ROADRASH.EXE

Then the registry was just altered when the last wine command was run, not this time. So I opened up the RASH.REG file and found that it contained:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts\RoadRash 95]
@=""
"Path"="D:\\"
"CheckDialup"=hex:00
"ChatState"=hex:02
"MiniDash"=hex:00
"OpponentList"=hex:01 

Which basically means that the above Windows registry value needed editing. This in turn led me back to the .wine folder in my home directory. Lo and behold, there was a system.reg file with lots of Registry-like entries.

sudipta@Hogwarts:~/.wine$ gedit  system.reg

So I simply added a section right on top that said:

[SOFTWARE\\Electronic Arts\\RoadRash 95]
@=""
"Path"="D:\\"
"CheckDialup"=hex:00
"ChatState"=hex:02
"MiniDash"=hex:00
"OpponentList"=hex:01 

This was because there was an entry right on top that said, ";; All keys are relative to \\Machine". And now when I run


sudipta@Hogwarts:~/roadrash$ wine ROADRASH.EXE

I get







Viola! Ah the joys of kicking the next guy off the road... :D

Thursday, June 4, 2009

Migrate or roll back an entire svn repository

If you have suddenly been stuck doing a stupid commit to svn and don't know how to just get back, here is a quick hack which I found at http://stackoverflow.com/questions/402159/roll-back-or-revert-entire-svn-repository-to-an-older-revision.


svnadmin create --fs-type fsfs /svnroot/<repo>.fixed
svnadmin dump -r 1:24 /svnroot/<repo> --incremental > dump.svn 
svnadmin load /svnroot/<repo>.fixed < dump.svn
 
The next step, as you might have guessed, is to move the repo.fixed to . This way, you can also copy a repository as it is to someplace else by just doing the load into some other server somewhere.

Friday, May 15, 2009

Boost your volume on toshiba laptops running ubuntu

If you have a Toshiba Satellite laptop and run ubuntu, then you probably hate the fact that you cannot hear the sound as loud as you would want it to be. Doing a
sudo apt-get install gnome-alsamixergui
will not help too much as well, since it will still show only Master and Capture in the alsamixergui under Applications -> Sound and Video -> Alsa Mixer

So here is what you need to do: you need to install alsa from source. First, download the latest ones from here: http://www.alsa-project.org/main/index.php/Download. The volume control is under Utilities, but you will also need the Library to install that stuff.

So first, install the library:
tar -xvjf alsa-lib-1.0.20.tar.bz2
cd alsa-lib-1.0.20
./configure
make
sudo make install

Then install the utilities:
tar -xvjf alsa-utils-1.0.20.tar.bz2
cd alsa-utils-1.0.20
./configure
sudo make install
NOTE - there is no make step here - direct make install!

If you get an error that says "`t-ja.gmo': No such file or directory" then you need to install gettext.
sudo apt-get install gettext

After that, once your utils are fully installed, go ahead and see the alsa in full glory: open Applications -> Sound and Video -> Alsa Mixer Gui and increase the Master, Head and Front volumes to full! Yennjoy!

Thursday, April 9, 2009

Cygwin ls command not found

If you are a linux enthusiast and really miss those greps and sed/awks on the windows box, you've probably installed cygwin. You tried running it either by double-clicking the cygwin icon on your desktop or the cygwin.bat file in your "C:\cygwin" directory and got the bash-3.X$ prompt. However, although the pwd or cd commands work, if you try ls, it says:"ls: command not found".

Here is what you need to do to fix it:
  1. Right click on "My Computer" -> Properties -> Advanced -> Environment Variables
  2. Add a new environment variable, called CYGWIN_HOME and set its value to C:\cygwin
  3. Edit the PATH environment variable and add C:\cygwin\bin to it (usually separated by a ';').
  4. Just click okay, exit any command prompts or bash shells (over cygwin) you may have open, and open it again - it'll work!
Note: this assumes that you have installed cygwin at C:\cygwin. If you've kept it someplace else, please modify the above accordingly.

Sunday, February 22, 2009

Automatic mail notification from gmail

On Ubuntu or any gnome desktop that you're using, simply put the command "mail-notification" in your .bash_profile and sync it up with your gmail/yahoo mailboxes. Every time a new message comes, you can see a small popup on the right. No new tools to install for each website, no thousands of things to consider.

If you want to just give it a try, go via Applications->Internet->Mail Notification and give it a shot.