Suramya's Blog : Welcome to my crazy life…

August 4, 2012

Reinstalled system after accidental removal of KDE. Pleasantly surprised by ease of configuration

Filed under: Computer Tips,Knowledgebase,Linux/Unix Related,Tech Related — Suramya @ 11:19 PM

Last night I was trying out stuff on my computer and decided to install virtual box on the system to allow me to install Windows in a virtual environment. I ran the command to install virtual box and then said ok without paying too much attention to what it was doing. As a punishment for that, the apt-get program proceeded to uninstall most of the KDE environment on the system leaving me with Gnome as my primary desktop (and there is no way I am using Gnome as my primary desktop). I could have fixed it by reinstalling KDE but since I had been thinking about removing the 32 bit Debian and installing the 64 bit version I decided to use this opportunity to do so and downloaded the 64 bit version from the Debian site, put it on a USB drive and proceeded with the install which took about an hour to complete.

After the install completed, I upgraded the system to the latest ‘Unstable’ build (Debian Unstable has the latest software packages so I prefer using it as opposed to Stable which is rock solid but has fairly dated software versions.) which took most of the night thanks to the no of packages to download and install. Once everything was upgraded I started customizing my setup and initially was dreading the amount of time it would take to get both my monitors working (based on previous experience) but surprisingly this time I didn’t have to do a lot to get both the monitor’s working.

If you remember, the last time I tried enabling the second monitor I hit a lot of hurdles mostly thanks to the mess I had made with my previous meddling and experimentation but this time it was fairly simple. I thought that I would follow the same steps I had the last time I installed the monitor so I started by installing the fglrx driver but the latest version of the driver no longer supports my chipset (ATI RS880 [Radeon HD 4250]) and the installer told me to install the free Radeon driver in the package xserver-xorg-video-radeon instead. So I did that after purging the fglrx driver (See here for instructions). I also had to install the Firmware for the Radeon card which I did by issuing the following command:

apt-get install firmware-linux-nonfree

After the driver was installed I rebooted (to make sure all systems started up clean) and setup my dual monitors by following these steps:

  • Click on Start -> System Settings
  • Click on ‘Display and Monitor’ under Hardware.
  • Under ‘Size & Orientation’ change the ‘Position’ dropdown to ‘Left Of’ the first (If your second monitor is to the left of the first one)
  • Set the Primary output to the monitor where you want the Task bar etc to show up. If you don’t know which monitor is which, click on the identify Outputs button.
  • Once you are done, Click on ‘Apply’ and if all looks good you can set it as default by clicking on the ‘Save as Default button’.

If you are ok with the resolutions available to you in the dropdowns above then you are done and you can skip the steps below.

Unfortunately for me I wanted a resolution of 1440×900 as the default instead of 1600×900 which was too small & the fonts looked pretty bad at that resolution and the 1280×1024 which was the next available size looked worse because my of my monitor shape (16:9 resolution as opposed to 4:3). So I had to do a bit more work to fix the problem.

First I tried manually setting the mode to 1440×900 using xrandr but I got an error message that “xrandr ‘cannot find mode'”. So I did a little Google search and found a forum post where another person was having the same issue. That link told me how to add a custom mode to my system which I did using the following steps:

First we need to figure out if our configuration will support the mode we are trying to use and if so get the modeline we need for the new config, so we run this command:

cvt 1440 900

If the system can support the resolution specified (1440×900 in the above example) it will return a line that looks something like:

# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
Modeline "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync

Luckily for us my system can support the resolution so we then need to tell xrandr about the new mode using the following command:

xrandr --newmode "1440x900"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync 

Where the first paramter (“1440×900” in this case) is an identifier and the rest is the information returned by cvt. (If successful the command will return no output.)

Then we need to tell the system that both the displays (called DVI-0 and VGA-0 on my system) should use the new mode which is accomplished using the following commands:

xrandr --addmode VGA-0  "1440x900"
xrandr --output VGA-0 --mode 1440x900
xrandr --addmode DVI-0  "1440x900"
xrandr --output DVI-0 --mode 1440x900

If the commands were successful then your screen should resize and start using the new resolution. Now that this is done we want this to happen everytime we log in without having to run the commands manually.

When you click on the ‘Save as Default’ button in the ‘Size & Orientation’ dialog box, KDE saves your settings in a file at the following location: ~/.kde/share/config/krandrrc that is executed everytime you log in to KDE. So to make the changes permanent we have to modify the file with the new settings.

The file contains the following lines right at the top:

[Display]
ApplyOnStartup=true
StartupCommands= 

We need to modify the StartupCommands= line to use our new settings. Basically it should contain all the commands we used above in a single line delimited by \n. On my system the file looks like the following after I updated it:

[Display]
ApplyOnStartup=true
StartupCommands=xrandr --newmode "1440x900"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync\nxrandr --addmode DVI-0  "1440x900"\nxrandr --addmode VGA-0
  "1440x900"\nxrandr --output VGA-0 --pos 1450x0 --mode 1440x900 --refresh 59.9782\nxrandr --output DVI-0 --pos 0x0 --mode 1440x900 --refresh 59.9782\nxrandr 
--output DVI-0 --primary

Once you make the change, save the file and log out. After loging out I usually restart X to make sure everything came up cleanly and then if all went well then the changes should take effect after you log in.

Hope others find this useful when configuring their systems.

– Suramya

PS: The best part is that after re-formating and using the Opensource version of the display driver instead of the proprietary one, my average memory usage went down from about 3GB about 1GB with all the same programs running in the background. 🙂

January 3, 2012

Working without Free diskspace in Linux

Filed under: Computer Tips,Linux/Unix Related,Tech Related — Suramya @ 5:52 AM

On linux machines you can fill your root partition to 100% utilization and the system would still continue to function giving you a chance to free up space without downtime, but on Windows machines the same is not possible and if you have managed to fill your C:\ to 100% then the system will go down (Know this for sure for Windows versions up to Vista, not sure about Win7) hard. This is something that has puzzled me a lot over the years but didn’t know how it worked, but now I finally have an explanation:

When you format a partition in Linux , 5% of the total space gets reserved for privileged processes, by default. This is done so that system processes continue to function correctly ,if the filesystem gets full. This is useful for your ‘root’ partition.

The really interesting part is that you can configure this to reduce the percentage of the reserved space using the tune2fs command. e.g. if you wanted to reduce the reserved space for /dev/sda1 to 1% of the total space then issue the following command as root:

tune2fs -m 1  /dev/sda1

Source: Flossstuff’s Blog

Enjoy.

– Suramya

September 18, 2011

How to set different backgrounds for each desktop in KDE 4.6.5

Filed under: Computer Tips,Linux/Unix Related,Tech Related — Suramya @ 11:59 PM

I have talked about How to set different backgrounds for each desktop in KDE4 in a previous post. However in KDE 4.6.5 the previous steps no longer work, so posting the new steps to get different backgrounds in KDE:

  • Click on the ‘Start Menu’ (The K at the bottom Right of the screen)
  • Click on ‘System Settings’ under the Settings menu
  • Double Click on the ‘Workspace Behavior’ under the “Workspace Appearance and Behavior” section
  • Check the “Different widgets for each desktop”
  • Click Apply

That’s it. Now you can change the wallpaper by Right clicking on the desktop and selecting ‘Desktop Settings’. Its good to know that the KDE Developers paid attention to complaints that the users made about their software and addressed it.

– Suramya

May 18, 2010

Boot From a USB Drive even when your BIOS Won’t Let You

Filed under: Computer Software,Computer Tips,Tech Related — Suramya @ 11:37 PM

If you are like me then you have gotten into the habit of carrying a Live Linux CD with you at times, I keep mine in my Laptop bag so its there when I need it. However CD’s have a lot of inherent problems like, an inability to update the version without burning a new disk and a susceptibility to scratches.

Having a Bootable USB drive with the latest version of Linux solves all these problems. USB drives are quite cheap now and it makes sense to have one available loaded with the latest diagnostic tools. But till date I didn’t carry a bootable USB drive with me because a lot of the systems I encountered didn’t allow me to boot from USB which made the bootable drive pretty much useless. Now, there is a way to fix the problem. What you need is a Blank CD and the latest version of PLoP.

PLoP is a Bootmanager that allows you to create a boot CD that will enable the system to boot from a USB drive even when that option is not supported by the BIOS. You can download PLoP from here. Installing it is quite easy. You just need to extract the .ZIP file that you downloaded and burn the .iso image to a CD. There are two ISO images on the CD and you can use either one of them, however according to the readme file plpbtnoemul.iso should work “everywhere” so if you have some doubt use that image.

Once you burn the image to the CD, reboot the system and configure it to boot off the CD. When the system boots up you will get a boot menu that will allow you to choose USB as the device to boot from. Once you do that the system will boot off the USB drive as normal and you can proceed from there.

Hope you find this as helpful as I am going to.

– Suramya

Source: Boot From a USB Drive Even if your BIOS Won’t Let You – How-To Geek.

September 3, 2009

Sort a file list by Date in Linux (Including Subdirectories)

Filed under: Computer Tips,Linux/Unix Related,Tech Related — Suramya @ 7:35 PM

I use Amarok to play music and I really like it, however my Playlist was created in Winamp/XMMS which I initially thought that Amarok couldn’t read. So all the new music I got since I switched to Amarok was no longer being added to a playlist, I just added the new songs manually then used the select 50 random songs option to play music.

Yesterday I figured out that Amarok does indeed read .m3u files (Winamp Play lists) so I wanted to add all the new music I have to the top of the old playlist. So basically I needed a list of all music in my system sorted by date. If you have been using Linux and are reasonably familiar with it then I think the first thing that came to your mind must have been: “Why can’t we just use ls -lRrt”? That’s pretty much what I thought. But unfortunately this command doesn’t work very well for what I wanted to do.

After playing around for a while I finally managed to get the system to show me a list of all music files in my system sorted in reverse chronological order. The command I used for this is:

find -name "*.mp3" -print0 | xargs -0 stat --format '%Y %n'|sort -r

Now the explanation:

  • find -name “*.mp3” : returns a list of all mp3 files in the current directory and any subdirectory under it.
  • -print0: This tells find to use the ASCII NUL character instead of space to separate the filenames. If we don’t use this then xargs chokes on the spaces in file names.
  • xargs -0: This tells xargs to use the ASCII NUL character instead of space to separate the filenames.
  • stat –format ‘%Y %n’: This runs the stat command on every file returned by find. This command returns the Time of last modification as seconds since Epoch followed by the name of the file.

    e.g.

    suramya@Wyrm:~$ stat --format '%Y %n' unison.log
    1251802152 unison.log

  • sort -r: sorts the list using the first column (the creation time) and displays the result.

——-

Example execution result in my Scripts directory:

suramya@Wyrm:~/bin$ ls -l
total 2648
-rwx------ 1 suramya suramya      77 2009-01-10 04:30 bookfixer.sh
-rwx------ 1 suramya suramya      76 2009-01-10 04:30 cardDesigner.sh
-rwx------ 1 suramya suramya     548 2009-01-10 04:30 change_wan.sh
-rwx------ 1 suramya suramya     478 2009-01-10 04:30 compare_entire_dir.sh
-rwx------ 1 suramya suramya    3462 2009-01-10 04:30 delay.pl
-rwx------ 1 suramya suramya      66 2009-01-10 04:30 EditPlus
-rwx------ 1 suramya suramya      88 2009-01-10 04:30 export_xterm
-rwx------ 1 suramya suramya     203 2009-01-30 04:29 extract.sh
-rwx------ 1 suramya suramya   82558 2009-01-10 04:30 lit2html
-rwx------ 1 suramya suramya     320 2009-01-10 04:30 makedir.sh
-rwx------ 1 suramya suramya      49 2009-01-10 04:30 mapsql
-rwx------ 1 suramya suramya     369 2009-01-15 02:11 MuteUnmute.sh
-rwx------ 1 suramya suramya 2350194 2009-01-10 04:30 pdftohtml
drwx------ 2 suramya suramya    4096 2009-01-10 04:30 Poet
drwx------ 2 suramya suramya    4096 2009-01-10 04:30 Remote
-rwx------ 1 suramya suramya     109 2009-02-08 19:47 resize.sh
-rwx------ 1 suramya suramya      48 2009-01-10 04:30 rootscan
-rwx------ 1 suramya suramya     397 2009-01-10 04:30 S41firewall
-rwx------ 1 suramya suramya     111 2009-02-21 20:15 sync_website.sh
-rwx------ 1 suramya suramya     116 2009-01-10 04:30 text2img
-rwx------ 1 suramya suramya     122 2009-01-10 04:30 uncompress.sh
-rwx------ 1 suramya suramya  180580 2009-01-10 04:30 vcdgear


suramya@Wyrm:~/bin$ find -name "*" -print0 | xargs -0 stat --format '%Y %n'|sort -r
1235227520 ./sync_website.sh
1235227520 .
1234102660 ./resize.sh
1233269990 ./extract.sh
1231965676 ./MuteUnmute.sh
1231542033 ./vcdgear
1231542033 ./uncompress.sh
1231542033 ./text2img
1231542033 ./S41firewall
1231542033 ./rootscan
1231542033 ./Remote/StarFlight
1231542033 ./Remote/Firestorm
1231542033 ./Remote/CyberNibble
1231542033 ./Remote
1231542033 ./Poet/poet.tar.gz
1231542033 ./Poet
1231542033 ./pdftohtml
1231542033 ./mapsql
1231542033 ./makedir.sh
1231542033 ./lit2html
1231542033 ./export_xterm
1231542033 ./EditPlus
1231542033 ./delay.pl
1231542033 ./compare_entire_dir.sh
1231542033 ./change_wan.sh
1231542033 ./cardDesigner.sh
1231542033 ./bookfixer.sh

As you can see, the ‘sync_website.sh’ script is the latest script in that directory.

Hope you find it useful.

– Suramya

April 21, 2008

Getting my wireless card working in Debian

Filed under: Computer Tips,Knowledgebase,Linux/Unix Related,Tech Related — Suramya @ 2:03 AM

As promised here are the steps that I followed to get my wireless card working on my Comaq Presario V3000 in Debian:

1. Install ndiswrapper

In my case I allready had the ndis wrapper installed. If thats not the case with your system run the following command as root to install it:

apt-get install ndiswrapper-common ndiswrapper-utils ndisgtk

2. Disable the “bcm43xx” driver on your system

Run the following command at a command prompt as root :

echo 'blacklist bcm43xx' | sudo tee -a /etc/modprobe.d/blacklist

3. Download the Windows driver for your card

My system uses the Broadcom Corporation BCM4310 card and I had to download the Windows driver for it from the Dell site. For some reason the driver I found at the Compaq site refused to work. You can download it from here.

Save this in the /tmp directory cd into the /tmp directory, and unzip the Windows driver package:

cd /tmp
unzip R123456.EXE (or whatever the name of the download is)

4. Install the Windows driver with ndiswrapper

To load the driver you need to run the following command as root:

ndiswrapper -i /tmp/DRIVER/bcmwl5.inf

The you should verify that the driver has been successfully loaded

ndiswrapper -l

The output of this command should look like the following if it is loaded correctly

Installed ndis drivers:
{name of driver} driver present, hardware present

or

{name of driver} : driver installed
device ({Chipset ID}) present

5. Load the ndiswrapper module

You now need to load the ndiswrapper module. Run the following steps at a command prompt as root:

depmod -a
modprobe ndiswrapper

if the above commands don’t give any errors then the drivers have been successfully installed.

6. Configure the wireless card

I have found the ‘netcardconfig’ command the easiest to use when configuring a new card. Run it as root and answer the questions it asks and it will configure the card for you.

7. Set the ndiswrapper module to automatically load at boot

ndiswrapper is not started by default when the system starts up so you must configure your system to load the ndiswrapper module at system startup. To do this, edit /etc/modules file as root to add an entry for ndiswrapper at the end of the file.

vi /etc/modules

Add ‘ndiswrapper’ (without the quotes) to the end of the file in a new line. Save and exit.

Now the module will be loaded when the system next starts up.
—-

A special thanks to JamesGu from the UbuntuForums for figuring out the solution and posting it there.

Hope you find this useful. I certainly did. 😉

Will post about my sound card next.

– Suramya

February 12, 2008

Regular Expressions Cheat Sheet

Filed under: Computer Tips,Knowledgebase,Tech Related — Suramya @ 9:52 PM

The Regular Expressions cheat sheet is designed to be printed on an A4 sheet of paper and live by a designer or developer’s desk, to make life a bit easier.

regular_expressions_cheat_sheet.png
Regular Expressions Cheat Sheet

Check out this post for a description of what is on the cheat sheet.

– Suramya

October 3, 2007

Automatic session logging/monitoring with GNU screen

Filed under: Computer Security,Computer Tips,Security Tutorials,Tech Related — Suramya @ 11:10 PM

Found this good article on how to setup screen on Linux/Unix so that it automatically logs all activity made in the session. Screen is a utility that I use very often on my Linux box. Basically its a program that you start and it attaches to a specific console and if you ever get disconnected you don’t loose your work/position, all you have to do is log back in and reconnect to that screen. You can also connect to a system via ssh/telnet and start a program then disconnect from ssh then move to another location and reconnect to server and join the same session from there. I use it all the time when compiling stuff or downloading large files.

The main issue I had with screen was that it would only keep 20-30 lines in the history so if you wanted to scroll up to read the previous logs you couldn’t. Now this article explains how to set up logging so that you can do that. For the impatient here’s how you do it:

I wanted to automattically launch a screen session when somone logged in so if I happened to be on the server I could monitor them in real time. I also wanted a log of the session in case I wanted to look over it later or if I was not able to monitor the session live.

I ended up adding the following to my .bashrc

# — if $STARTED_SCREEN is set, don’t try it again, to avoid looping
# if screen fails for some reason.
if [[ “$PS1″ && “${STARTED_SCREEN:-No}” = No && “${SSH_TTY:-No}” != No ]]; then
STARTED_SCREEN=1 ; export STARTED_SCREEN
if [ -d $HOME/log/screen-logs ]; then
sleep 1
screen -RR && exit 0
# normally, execution of this rc script ends here…
echo “Screen failed! continuing with normal bash startup”
else
mkdir -p $HOME/log/screen-logs
fi
# [end of auto-screen snippet]

and add the following to your .screenrc

# support color X terminals
termcap xterm ‘XT:AF=E[3%dm:AB=E[4%dm:AX’
terminfo xterm ‘XT:AF=E[3%p1%dm:AB=E[4%p1%dm:AX’
termcapinfo xterm ‘XT:AF=E[3%p1%dm:AB=E[4%p1%dm:AX:hs:ts=E]2;:fs=07:ds=E]2;screen07′
termcap xtermc ‘XT:AF=E[3%dm:AB=E[4%dm:AX’
terminfo xtermc ‘XT:AF=E[3%p1%dm:AB=E[4%p1%dm:AX’
termcapinfo xtermc ‘XT:AF=E[3%p1%dm:AB=E[4%p1%dm:AX:hs:ts=E]2;:fs=07:ds=E]2;screen07′

# detach on hangup
autodetach on
# no startup msg
startup_message off
# always use a login shell
shell -$SHELL

# auto-log
logfile $HOME/log/screen-logs/%Y%m%d-%n.log
deflog on

Keep in mind that this is not a very secure setup. Anyone with any technical knowledge can edit the logs as they are located in the user’s home directory and are editable by them. So don’t rely on it extensively to keep a system secure.

Complete article is available here: Automatic session logging and monitoring with GNU screen for the paranoid.

Thanks,
Suramya

July 6, 2007

Allow passwordless access to a subfolder of a password protected directory

Filed under: Computer Tips,Knowledgebase — Suramya @ 2:22 PM

Hey,
We have a directory on the server thats password protected and we needed to give access to a subdirectory of that folder to everyone (Without having them enter a password). Turns out it is possible to do so using .htaccess

Create a .htaccess file in the subfolder that you want to give full access to with the following content:

AuthType none
Satisfy any

Save and exit. This overrides the password protection of the parent folder and gives anonymous access to the folder.

Thanks to Vinit for the tip.

– Suramya

June 24, 2007

Getting a 404 error in asp.net when the file exists on the server

Filed under: Computer Software,Computer Tips,Knowledgebase,Tech Related — Suramya @ 1:25 PM

Hit this issue recently on a web server that I was setting up on Windows 2003 server using IIS. Now everything was installed correctly and I had copied all the files to the server, then I created a virtual directory for my asp.net application and when I went to http://localhost/Test it would show me the directory listing (Yes I had enabled that so that I could debug). However when I clicked on the service.asmx file it would tell me that the file didn’t exist and I would get a 404 error. Now I knew that the file was there and I could see it in the directory listing but for some reason the IIS refused to show it.

The problem was caused because the server was running the 64 bit version of ASP.NET 2.0 while we were expecting the 32 bit version. Yes, it took me a couple of hours to figure that out. To fix it basically what you have to do is tell IIS that you want to use the 32 bit version for this particular Virtual Directory by changing the Script Map. The steps to change this are:

  • Open the IIS management console.
  • Expand the local computer node, expand Web Sites, and then expand Default Web Server.
  • Right-click the folder for the application, and then click Properties.
  • On the Directory tab, click Configuration.
  • The Application Configuration dialog box appears.
    On the Mappings tab, select an ASP.NET application extension, such as .asmx or .aspx.

    The Executable Path column of the dialog box lists the path to the ASP.NET ISAPI extension used by the application. By default, the ASP.NET ISAPI extension is installed in the following location:

    %system root%\Microsoft.NET\Framework\versionNumber. Browse to the appropriate directory and select the aspnet_isapi.dll file.

  • Click Ok and exit
  • Finally Stop and Start the webserver for the changes to take effect.

Now you should be able to access the files on the server without issues.

BTW, also make sure that the user IIS is running as also has permissions to read files and execute scripts in the directory where you have copied your files.

Hope fully you found this helpful.

Source for the steps to change the mapping: How to: Configure ASP.NET Applications for an ASP.NET Version

Thanks,
Suramya

« Newer PostsOlder Posts »

Powered by WordPress