Recently I had to edit the sudoers file and I learnt that a dedicated editor for this task exists. The editor is called visudo. On Fedora Core 7 I found it at /usr/sbin/visudo .
Got the job done but am wondering now if there is something like emacssudo. Hmmm !!!
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Friday, December 12, 2008
Friday, October 17, 2008
Minimize all open windows simultaneously in Linux
How do I simultaneously minimize all open windows in Linux ?
What is the Linux equivalent of WindowsKey+D in Linux ?
In Gnome its Ctrl+Atl+D.
Source is from this page :D
I would have found this out had I checked
that was the path at least on Fedora Core 7 .
What is the Linux equivalent of WindowsKey+D in Linux ?
In Gnome its Ctrl+Atl+D.
Source is from this page :D
I would have found this out had I checked
System > Preferences > Personal > Keyboard Shortcuts
that was the path at least on Fedora Core 7 .
Saturday, October 4, 2008
rename files with same first name but different extentions
The scenario is this. You have a folder/directory with the following files:
basically the ${file##*.} extracts the extensions of the file. On the same note ${file%*.} will extract the first names of the files.
got it from this page :)
a.txt, a.ps, a.pdfand you want to change the file names to
b.txt, b.ps, b.pdfHere is how to do it.
for file in `ls a.*`
do
mv $file b.${file##*.}
done
basically the ${file##*.} extracts the extensions of the file. On the same note ${file%*.} will extract the first names of the files.
got it from this page :)
Thursday, September 25, 2008
ssh'ing to a GNU/Linux machine from WindowsXP
I frequently SSH to a GNU/Linux ( Fedora Core 7 ) machine from a WindowsXP system. I have Xming to import remote display to local system, while I use putty to SSH to the Linux system. Since some days I was facing this strange problem. I could ssh to the linux system fine but could not import the display while launching any gui on the remote system. I got the following error
It turns out that this was occuring because of a corrupt /etc/hosts file on the Linux system. In fact the /etc/hosts file read as below:
God only knows why that was the case. Anyways I fixed the /etc/hosts file to read as below:
127.0.0.1 localhost.localdomain localhost
And wallah it worked fine as before !
I googled for a solution and found on this page. This post did the trick for me. Thanks tomrosenfeld :D
_X11TransSocketINETConnect() can't get address for localhost:6010: Name or service not known
Display localhost:10.0 unavailable, simulating -nw
It turns out that this was occuring because of a corrupt /etc/hosts file on the Linux system. In fact the /etc/hosts file read as below:
::1 localhost6.localdomain6 localhost6
God only knows why that was the case. Anyways I fixed the /etc/hosts file to read as below:
127.0.0.1 localhost.localdomain localhost
And wallah it worked fine as before !
I googled for a solution and found on this page. This post did the trick for me. Thanks tomrosenfeld :D
Tuesday, July 29, 2008
glibc detected double free or corruption
While segmentation fault is the most common error that C/C++ face another one that has been harassing me for some time is as follows ::
glibc detected double free or corruption
This occurs when one tries to release memory that has already been deallocated. One quick and dirty way to get rid of it is as follows :
( thats a zero at the right side of the equal to sign )
and now run the executable, it should run without a problem.
However I am not too sure if this will cause unreliable results or any other sort of problems later. I guess its best to check the code to find out and remedy the error causing this.
Could the following be of any use ?
http://valgrind.org/
See this page to understand how valgrind can help you.
glibc detected double free or corruption
This occurs when one tries to release memory that has already been deallocated. One quick and dirty way to get rid of it is as follows :
$export MALLOC_CHECK_=0
( thats a zero at the right side of the equal to sign )
and now run the executable, it should run without a problem.
However I am not too sure if this will cause unreliable results or any other sort of problems later. I guess its best to check the code to find out and remedy the error causing this.
Could the following be of any use ?
http://valgrind.org/
See this page to understand how valgrind can help you.
Friday, July 25, 2008
#define main
I have two files and the contents are as follows :
lines
#ifndef main
#define main
If I change it to
#ifndef Main
#define Main
or
#ifndef MAIN
#define MAIN
etc.
the program compiles.
Turns out that the line
#define main
actually defines the macro ``main" with an empty value. When the preprocessor works on the code it replaces all instances of the word main with an empty string resulting in the compile time error as posted above.
To find out the error just see the effect of preprocessor on the code before and after changing the macro name from main to Main or MAIN or whatever.
The effect of the preprocessor can be seen with the following command :
g++ -E main.cpp
Mind you that the above command will produce lots and lots of code ( in my case about 30000 lines of code). So this is what you can do
First with the erroneous header file ::
g++ -E main.cpp > outputA
and then with the fixed header file ::
g++ -E main.cpp > outputB
now compare the files outputA and outputB with the diff utility.
diff outputA outputB
You will find that the preprocessor working on the erroneous code produces
int (void)
while the preprocessor working on the correct code produces
int main(void)
Thanks to the gurus at gnu.g++.help I could understand the error I was making !
The thread can be found here.
p.s. I work on GNU/Linux with the gcc compiler.
file :: main.h
-------------------------------------
#ifndef main
#define main
#endif
--------------------------------------
and
file :: main.cpp
-------------------------------------
#include "main.h"
int main(void)
{
return 0 ;
}
------------------------------------
This program does not compile and the error message that I get is ::
expected unqualified-id before ‘void’
expected `)' before ‘void’
lines
#ifndef main
#define main
If I change it to
#ifndef Main
#define Main
or
#ifndef MAIN
#define MAIN
etc.
the program compiles.
Turns out that the line
#define main
actually defines the macro ``main" with an empty value. When the preprocessor works on the code it replaces all instances of the word main with an empty string resulting in the compile time error as posted above.
To find out the error just see the effect of preprocessor on the code before and after changing the macro name from main to Main or MAIN or whatever.
The effect of the preprocessor can be seen with the following command :
g++ -E main.cpp
Mind you that the above command will produce lots and lots of code ( in my case about 30000 lines of code). So this is what you can do
First with the erroneous header file ::
g++ -E main.cpp > outputA
and then with the fixed header file ::
g++ -E main.cpp > outputB
now compare the files outputA and outputB with the diff utility.
diff outputA outputB
You will find that the preprocessor working on the erroneous code produces
int (void)
while the preprocessor working on the correct code produces
int main(void)
Thanks to the gurus at gnu.g++.help I could understand the error I was making !
The thread can be found here.
p.s. I work on GNU/Linux with the gcc compiler.
Subscribe to:
Posts (Atom)