Posts Tagged ‘command-line’

Tip for the day – Fix your terminal displaying junk characters

August 24, 2013 Leave a comment

Sometimes when reading a binary file your terminal font may be set to junk values and whatever you type will appear as junk. This may happen when reading a binary file through cat command, opening the raw device files like /dev/random /dev/urandom, or reading  /proc/kcore memory file. Below screen shot shows how terminal looks when this happens,

Terminal displaying all characters as garbage after reading a binary fileWhen you are working in GUI environment within a terminal emulator this may not be a problem as you can close and reopen a new terminal. But this is a problem when you’re working in text environment.

There is an easy way to fix this problem by resetting the terminal. Yes typing reset command in the terminal will reset your terminal back to normal state.


Recover files from your drive even if the drive file system is corrupt

April 8, 2010 1 comment

Most files can be recovered from storage drives even it is deleted , but in some rare cases where the file system of the drive itself  is corrupt then the data recovery becomes very difficult but not impossible .Consider a situation in which the memory card of your digital camera is corrupt and is unusable without being formatted , but if formatted all the precious pictures in it will be lost.In such extreme cases a little command line tool in Linux called magicrescue can be used. magicrescue can be used in cases where the drive’s filesystem or partition is completely corrupt or unusable and it can only be used to restore known file types such as images, mp3 etc .

If you are using ubuntu or any debian based Linux distribution ,install magicrescue by typing the following in terminal:

sudo apt-get install magicrescue

or else install it by using the distibution’s package manager.

After installing magicrescue connect your corrupted flash drive or memory card to the system , chances are that they do not get mounted due to corrupted filesystem . Find the hardware address of the drive ,for example if it is a flash drive the hardware address might be /dev/sdb or if it is a memory card you can find it in /dev/disk/by-id/ and will contain usb-card-reader or something like that, be careful not to select the wrong device.

magicrescue requires two mandatory options -d and -r. -d for specifying the output directory and -r to specify the recipe or the type of file to extract ,if multiple file types are to be extracted -r can be used successively.

For example if you want to extract jpeg files from the drive sdb ,the command to be used is:

sudo magicrescue -d ./Pictures/ -r jpeg-jfif -r jpeg-exif /dev/sdb

sudo is necessary because ordinary user cannot access the drive hardware directly and ./Pictures/ is the output directory and jpeg-jfif and jpeg-exif are jpeg filetypes and /dev/sdb is the drive from which the images are to be extracted.

Improve your productivity in linux with these little tricks

January 7, 2010 Leave a comment

your productivity in linux can multiplied with these simple tricks that most new users do not even know of its existence.Some of those lesser known tricks are given here:

  • All linux distributions support an extra method of copy/paste by using the middle(scroll) button of your mouse.One drawback of this method is that it only supports copying text.You can use this method by selecting the text you want to copy and by middle clicking where you want it to be pasted.The text can be pasted as many times  as long as the original text remains selected.This method would be helpful if you want to paste the same text multiple times and could be more useful inside the terminal.For example,when you look for solutions to your problem about linux most of them deals with command line, you could just select the commands given and middle click in the terminal.The text can also be copied using ctrl+c and can be paste by clicking the scroll button in your mouse.
  • The nautilus file browser can be opened from the desktop by simply pressing “/” (forward slash) key and pressing the enter key.You can also type the path of the folder where the nautilus should be opened.For example to browse /etc folder just press / and type etc,the nautilus will open the etc folder for you.
  • Desktop background can be set in linux distributions using gnome desktops such as ubuntu by dragging and dropping the picture in the desktop with the middle mouse button and selecting set as background from the menu that appears.
  • Instead of typing the entire path of the file in the terminal window you could just drag and drop the file into the terminal window and the terminal will complete the path name of the file for you.
  • TAB key can be used inside the terminal for auto completion of commands.For example to open Firefox from terminal, type fir and press TAB key the terminal will auto complete the remaining for you,this applies to pathnames and filenames.If there is more than one match for what you typed in the terminal, the TAB key displays nothing and when you press the TAB key again it displays a list of possible matches for what you have typed.

Hope this would be useful for most new users out there.If there is something other you want to know just let me know in the comments.

Split and join large files in GNU/Linux just using command-line

February 7, 2009 20 comments

To split a large file into smaller ones:

Lets say you have to send your personal video file of size 100MB to your friend through Gmail but gmail has a maximum file upload limit of size 20MB.So you have to split it into 5 smaller files of size 20MB and upload it.For this you have to go to the directory where the file is stored and use the following command in the terminal:

$ split –b20m Largefilename Smallfilename

where 20m is the size of output file in MB,to split in KB put k instead of m.various other options are also available to split command,to know them just type

$ split --help

To join smaller files into a larger one:

These days most files hosted at major file hosting sites are split into smaller files such as *.001…009 or *.part01…*.part09 etc.To join these files you don’t have to search for any external softwares,you just have the commands built into every GNU/Linux system.

To join the part files open up the terminal and navigate to the directory where the files are placed and execute the command:

$ cat partfilename* > outputfilename

For example if the file names are



video.avi.03 etc.use

$ cat video.avi.* > video1.avi

Categories: linux tips Tags: , ,