Posts Tagged ‘commandline’

GNU/Linux includes many utilities for working with text files through the shell. In this post we take a quick look at accessing and manipulating text files in a “column-wise” mode. Suppose you have the following two files, each with two columns separated by the TAB character. $cat file1 Alice   Paris Bob     Tokyo Mary    London John    New York $cat file2 [...]

Monday, October 17th, 2011 at 17:02 | 0 comments
Categories: Linux

Sed can be used to strip out all HTML or XML tags from a file and get the plain text version. Suppose you have file gnulinux.html with the following contents: <p>The combination of <a href=“/gnu/linux-and-gnu.html“>GNU and Linux</a> is the <strong>GNU/Linux operating system</strong>, now used by millions and sometimes incorrectly called simply “Linux“.</p> Tempting but incorrect [...]

Monday, October 17th, 2011 at 12:16 | 0 comments
Categories: Linux

Here’s a quick way to remove empty lines from a file using the Linux command line: cat file1 | sed /^$/d > file2 Where file1 is the input file containing empty lines and file2 is a newly created file with empty lines removed.

Wednesday, September 22nd, 2010 at 16:50 | 0 comments
Categories: Linux

Changing the port number of SSH daemon is a quick way of reducing the number of SSH brute force attacks your server might face (check the file /var/log/auth.log to see if there are many failed SSH login attempts). Just to be on the safe side, create a backup copy of the SSH daemon config file. [...]

Friday, September 3rd, 2010 at 08:56 | 0 comments
Categories: Linux

Good article on Tuxradar with some clever command line hacks: Command line tricks for smart geeks

Wednesday, December 16th, 2009 at 13:46 | 0 comments
Categories: Linux

Here’s how to find the version of your CentOS system from the command line: more /etc/redhat-release

Wednesday, November 18th, 2009 at 17:58 | 0 comments
Categories: Linux

This post is about how to change the resolution (i.e. font size) of virtual terminals or “tty” in Linux. Virtual terminal is the basic command line interface which you see when you press <Ctrl><Alt><F1> (note: to get back to your existing Gnome or KDE session press <Alt><F7>). This is different from the Terminal emulator, such [...]

Monday, September 21st, 2009 at 05:28 | 0 comments
Categories: Linux

Sometimes it is necessary to split a large file into several smaller ones, for example so that they fit on a CD or USB disk or can be attached to email. It’s very easy to do this from command line. Suppose you have a file of 500 MiB called “large_file” and to split it into [...]

Friday, September 18th, 2009 at 14:33 | 0 comments
Categories: Linux

Nautilus and Thunar sometimes refuse to mount NTFS disk (e.g. a USB hard drive) when it was previously not unmounted cleanly from Windows. It is still possible to mount it from terminal shell by using the following command: sudo mount -t ntfs-3g -o force /dev/sdc1 /media/myntfsdisk Where /dev/sdc1 is the device you want to mount [...]

Sunday, June 7th, 2009 at 15:56 | 0 comments
Categories: Linux

To check for installed packages from the command line, use the dpkg command with the –get-selections option. This returns all packages installed on your system (most likely a lot!). So it is best to use grep to narrow down the search results. For example, the following command lists all packages with “fire” in the package [...]

Thursday, May 28th, 2009 at 13:31 | 0 comments
Categories: Linux