Tips & Tricks

OpenSource For You - - Contents - —Ab­hishek Gupta, aizaak93.gupta@gmail.com The joy of us­ing open source soft­ware is in find­ing ways to get around prob­lems—take them head on, de­feat them! We in­vite you to share your tips and tricks with us for pub­li­ca­tion in OSFY so that they can reach a

Us­ing the Linux process task man­ager

When­ever the sys­tem hangs and we can­not do any­thing about it, we can kill that process by us­ing the ter­mi­nal and re­sume our work as be­fore so that we don’t need to restart our sys­tem. To do this, we must open the ter­mi­nal by press­ing Ctrl + alt + T.

Now, in the ter­mi­nal, type the top com­mand, which will show you all the run­ning pro­cesses. From the out­put of the top com­mand, note the PID (process ID num­ber) that you want to kill. Let’s sup­pose my Chrome browser is us­ing up all the mem­ory or CPU re­sources, forc­ing my com­puter to hang, and its PID is 1309.

$top Press q to exit the top com­mand: kill -9 <YOUR PID> $kill -9 1309 This will kill the process that is run­ning on PID 1309. —Dhavalku­mar Pra­jap­ati, dhaval.dai­ict@gmail.com

Change the last mod­i­fied/cre­ated date of a file

Ever won­dered if you could change the last mod­i­fied/ cre­ated date of a file? Well, you can!

Con­sider the sam­ple file as shown be­low, which was cre­ated on some ar­bi­trary day:

-rw-rw-r-- 1 ec2-user ec2-user 52 Dec 17 07:37 sam­ple Now, cre­ate a new file with a touch/vim: $touch new-file

The files in the direc­tory will now look like what’s shown be­low: -rw-r--r-- 1 root root 0 Jan 14 05:05 new-file -rw-rw-r-- 1 ec2-user ec2-user 52 Dec 17 07:37 sam­ple

Next, as­sign the last mod­i­fied date of the sam­ple to new­file: $touch -r sam­ple new-file

Voila! The date of the new file is now the same as the sam­ple file!

-rw-r--r-- 1 root root 0 Dec 17 07:37 new-file -rw-rw-r-- 1 ec2-user ec2-user 52 Dec 17 07:37 sam­ple

This pre­serves the con­tents of new­file but only changes the last mod­i­fied date.

—Dheeraj Tri­pathi, dheer­a­j007tri­pathi@gmail.com

An in­ter­est­ing com­mand in Ubuntu

Ap­ti­tude is a text based in­ter­face based on the Ad­vanced Pack­ag­ing Tool (APT) sys­tem. Many of the com­mon pack­age man­age­ment func­tions, such as in­stal­la­tion, re­moval and up­grade, can be per­formed in Ap­ti­tude with sin­gle-key com­mands, which are typ­i­cally lower case let­ters. It can be in­stalled by us­ing the fol­low­ing com­mand:

$sudo apt-get in­stall ap­ti­tude To ver­ify, use the fol­low­ing: $ap­ti­tude

Ap­ti­tude will ac­cept the moo as a pa­ram­e­ter, which ex­e­cutes the fol­low­ing funny words as an out­put. Shown be­low is an ex­am­ple of the same:

$ap­ti­tude -v moo

There re­ally are no Easter Eggs in this pro­gram.

$ap­ti­tude -vv moo

Didn't I al­ready tell you that there are no Easter Eggs in this pro­gram?

$ap­ti­tude -vvv moo Stop it!

$ap­ti­tude -vvvv moo

Okay, okay, if I give you an Easter Egg, will you go away?

$ap­ti­tude -vvvvv moo All right, you win.

/----\

-------/ \

/ \

/ | -----------------/ --------\ ---------------------------------------------$ap­ti­tude

-vvvvvv moo

What is it? It's an ele­phant be­ing eaten by a snake, of course.

Here, ‘v’ is a ‘ver­bose file’. —Ram­prakash S, ram­kee­lai@gmail.com

An exit short­cut

We use var­i­ous ter­mi­nal com­mands that are in­ter­preter based. To come out of these, just press Ctrl+D. This short­cut works for the Linux, Python, ssh, sftp and MySQL ter­mi­nals.

—Tushar Kute, tushar@tusharkute.com

Print a dis­tinct ex­ten­sion in a folder

To print dis­tinct ex­ten­sions in a given folder, use the fol­low­ing com­mand:

find /path/to/your/direc­tory -type f | awk -F. '!ar­ray[$NF]++{print $NF}'

This com­mand will cap­ture the ex­ten­sions in a given folder by sep­a­rat­ing the field names with a pe­riod (‘.’) and print­ing the last en­try, i.e., the ex­ten­sion. For reg­u­lar files that don't have any ex­ten­sion, the ab­so­lute path of the file gets printed.

—Madhu Babu, mad­hu­mad­hana93@gmail.com

Run as the su­per user us­ing 'nau­tilus'

In­stead of work­ing from the ter­mi­nal us­ing sudo ev­ery time, type the fol­low­ing com­mand on the ter­mi­nal: $sudo nau­tilus

As soon as you run this com­mand, a file ex­plorer will be opened. All ac­tions that you wanted to do on the ter­mi­nal us­ing the sudo per­mis­sion can now be done in this file ex­plorer’s GUI.

—Anirudh k, anirudh.3194@gmail.com

Re­move un­wanted and du­pli­cate files us­ing FSlint

With time, we start keep­ing the same files with the same name (or a dif­fer­ent name) on var­i­ous fold­ers in our sys­tem, ei­ther know­ingly or un­know­ingly.

Here is an easy way of get­ting rid of du­pli­cate and un­wanted files present any­where in your com­puter. FSlint is open source soft­ware for Linux sys­tems. It can be used on both the com­mand line and GUI modes. First, you need to in­stall it to start us­ing it.

So type the fol­low­ing com­mands in the ter­mi­nal:

sudo apt-get up­date sudo apt-get in­stall fslint

Af­ter suc­cess­ful in­stal­la­tion, you can use FSlint by search­ing for it in the Ubuntu dash­board.

—Akhilesh Pandey, akhilesh.ss­sihl@gmail.com

Run a com­mand and come back to the cur­rent work­ing direc­tory im­me­di­ately

You can run a com­mand in Linux and im­me­di­ately come back to the cur­rent direc­tory. All you need to do is to run the com­mand in paren­the­ses.

$(cd /home/ab­hishek/Doc­u­ments/ && ls)

The above com­mand will list all the files in the direc­tory Doc­u­ments and come back to the present direc­tory im­me­di­ately.

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.