Archives for October, 2010
Posted by Derek@TheDailyLinux »
1 Comment »
I enjoyed this little tip from linuxjournal.com on how to convert filenames to lowercase recursively. Here’s an example of the command:
for x in `ls path/to/directory`; do if [ ! -f $x ]; then continue; fi; lc=`echo $x | tr '[A-Z]' '[a-z]'`; if [ $lc != $x ]; then mv -i $x $lc; fi; done
In my case, I wanted to find all files with a particular string in them and then convert to lowercase. This is what I used:
for x in `find path/to/directory -name "*theString*"`; do if [ ! -f $x ]; then continue; fi; lc=`echo $x | tr '[A-Z]' '[a-z]'`; if [ $lc != $x ]; then mv -i $x $lc; fi; done
Posted by Derek@TheDailyLinux »
Add Comment »
Mercurial is yet another open source code management system in the sea of SCM systems like CVS, SVN, or GIT. Honestly, I don’t know much about it to dive into details on setup and capabilities, but it’s something to push onto my plate for a little digestion and might be for you as well. Be sure to take a look at the main homepage to find out more: http://mercurial.selenic.com/
One capability that it has, which the others probably do as well, is that it has a fairly nice and clean looking web interface which can be hosted on your development PC or server for working with your code. I also know that in order to interact with the Mercurial SCM, you use the command ‘hg’, which is the element symbol for mercury. Clever, no? See the man pages here: http://linux.die.net/man/1/hg
Posted by Derek@TheDailyLinux »
Add Comment »
This was one of those “Hey! I didn’t know that!” moments when I found out that you can actually telnet to an SMTP server. This allows you to test the server as well as do other cool things such as send and receive email. By no means is it the most conventional way of sending and receiving email, but does help you flex your geek muscles a bit more. Since this is already a topic that is covered rather well by the community, I’m just going to refer you to the following article to give it a whirl:
http://www.yuki-onna.co.uk/email/smtp.html
Also, it appears that Google will allow you to do this with your gmail account (see the last answer):
http://mail.google.com/support/bin/answer.py?hl=en&answer=78775
What do ya know? It seems that there’s a similar thing for POP3 accounts as well:
http://techhelp.santovec.us/pop3telnet.htm
Have fun!
Posted by Derek@TheDailyLinux »
Add Comment »
Here is an example of how to backup a MySQL database to a dump:
mysqldump -u username -h hostname -p password db_name > dump.sql
Here is an example of how to restore a MySQL database from a dump:
mysql -u username -h hostname -p password db_name < dump.sql
You can also pass in a blank value for the password option and it will prompt you for it when you run the command rather than typing it out in plain text for all to see. Food for thought.
As always, be sure to check out the man pages for mysql and mysqldump.
Posted by Derek@TheDailyLinux »
Add Comment »
You can prevent the Gnome Display Manager (GDM), or the login screen, from loading on system startup by using the following command (run with root privileges):
sudo update-rc.d -f gdm remove
You can reverse this step by using the following command to restore GDM to defaults:
sudo update-rc.d gdm defaults 13 01
Posted by Derek@TheDailyLinux »
Add Comment »
Use the dmidecode utility to get information about the underlying hardware of your system including motherboard, memory, processor, and much more. Here’s an example of running the command (need root privileges):
sudo dmidecode | more
As always, be sure to check out the man pages for dmidecode.
Posted by Derek@TheDailyLinux »
Add Comment »
You can configure the kernel with the “CONFIG_KALLSYMS” option for more useful output when a kernel oops is encountered. The description is “Load all symbols for debugging/ksymoops”. You can find more information about the option here: http://cateee.net/lkddb/web-lkddb/KALLSYMS.html. Below, you’ll find “before and after” results:
Before
[ 1.120000] Backtrace:
[ 1.120000] Function entered at [<c0026a68>] from [<c0026b60>]
[ 1.120000] Function entered at [<c0026afc>] from [<c00afdcc>]
[ 1.120000] r6:00000004 r5:00000004 r4:00000000
[ 1.120000] Function entered at [<c00af964>] from [<c00b0110>]
[ 1.120000] Function entered at [<c00b0058>] from [<c00de8f0>]
[ 1.120000] Function entered at [<c00de8d0>] from [<c006ad9c>]
[ 1.120000] Function entered at [<c006ac5c>] from [<c006ae7c>]
[ 1.120000] Function entered at [<c006ae4c>] from [<c0064de0>]
[ 1.120000] Function entered at [<c0064c1c>] from [<c00755e4>]
[ 1.120000] Function entered at [<c0075590>] from [<c0076fa4>]
[ 1.120000] Function entered at [<c0076d4c>] from [<c002617c>]
[ 1.120000] Function entered at [<c00260a4>] from [<c002028c>]
[ 1.120000] Function entered at [<c002024c>] from [<c0020d44>]
After
[ 1.110000] Backtrace:
[ 1.110000] [<c0026a80>] (__flush_dcache_page+0x0/0x34) from [<c0026bc0>] (flush_dcache_page+0x64/0x138)
[ 1.110000] [<c0026b5c>] (flush_dcache_page+0x0/0x138) from [<c00b17a8>] (do_mpage_readpage+0x468/0x684)
[ 1.110000] r6:00000004 r5:00000004 r4:00000000
[ 1.110000] [<c00b1340>] (do_mpage_readpage+0x0/0x684) from [<c00b1aec>] (mpage_readpages+0xb8/0x10c)
[ 1.110000] [<c00b1a34>] (mpage_readpages+0x0/0x10c) from [<c00e035c>] (ext2_readpages+0x20/0x28)
[ 1.110000] [<c00e033c>] (ext2_readpages+0x0/0x28) from [<c006c734>] (__do_page_cache_readahead+0x140/0x1f0)
[ 1.110000] [<c006c5f4>] (__do_page_cache_readahead+0x0/0x1f0) from [<c006c814>] (ra_submit+0x30/0x34)
[ 1.110000] [<c006c7e4>] (ra_submit+0x0/0x34) from [<c0066778>] (filemap_fault+0x1c4/0x3a4)
[ 1.110000] [<c00665b4>] (filemap_fault+0x0/0x3a4) from [<c0076f7c>] (__do_fault+0x54/0x3d0)
[ 1.110000] [<c0076f28>] (__do_fault+0x0/0x3d0) from [<c0078978>] (handle_mm_fault+0x258/0x364)
[ 1.110000] [<c0078720>] (handle_mm_fault+0x0/0x364) from [<c00261dc>] (do_page_fault+0xd8/0x1c0)
[ 1.110000] [<c0026104>] (do_page_fault+0x0/0x1c0) from [<c002028c>] (do_DataAbort+0x40/0xa4)
[ 1.110000] [<c002024c>] (do_DataAbort+0x0/0xa4) from [<c0020d44>] (ret_from_exception+0x0/0x10)
Posted by Derek@TheDailyLinux »
2 Comments »
If you’re a programmer, you might be interested in taking advantage of the ctags utility to quickly navigate through your source code in a text editor such as VIM.
Ctags is a utility or program that creates an index (aka tag) file of names found in source and header files of various programming languages. This index includes things such as functions, variables, class members, macros, etc. This is great because vim can take advantage of this index and you can more quickly navigate through source files. For more information, wikipedia has a nice article on it here.
To start using ctags, you must first have the ctags utility. A quick check would be to just type ctags --version in the terminal:
thelinuxdaily@localhost> ctags --version
ctags (GNU Emacs 23.1)
Copyright (C) 2009 Free Software Foundation, Inc.
This program is distributed under the terms in ETAGS.README
If you have it, then we can immediately start using it. First, build the index by running in the directory where you keep the source code:
ctags source.c
If you’d like to be able to recursively scan all of your source files, you must insure that you’re using the exuberant ctags utility. In a Debian based system, this is simply done with:
sudo apt-get install exuberant-ctags
sudo update-alternatives –config ctags
Then, open the source in vim and use ctrl ] to jump into the tag and ctrl t to jump out of the tag.
There’s quite a bit of information available out there on using these tools together. I would recommend taking a look around. Here are a few that I found:
Stackoverflow: Vim and Ctags tips and tricks
Linux.byexamples: Vim with Ctags
Posted by Derek@TheDailyLinux »
Add Comment »
Aliases are great and can make your life in the terminal easy. They give you a way to shorten multi-part or long commands into a single command. For example, if you’re always navigating to a certain directory like /home/username/this/directory, then you can more quickly chance to that directory by using a single command. Here’s what the alias for that would look like:
alias mydir='cd /home/username/this/directory/'
Now, whenever you type mydir, it will take you to /home/username/this/directory.
When you no longer need or want an alias, you can remove it using unalias. Here’s how to remove the example we just made above:
unalias mydir
As always, for more information on aliases refer to the man pages: alias, unalias.