Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Apr 232010
 

How to avoid command being saved to shell history

Answer:

Firstly, you need to set the Bash shell environment variable to tell the shell to ignore the history if the command is starting with a particular character, e.g. a space in our case below.

# export HISTIGNORE="&:[ ]*"

Then, type the command start with a space

# who

And verify using the history command

# history

Apr 212010
 

Best way to kill all child processes forked by a given program

Answer:

Firstly, find the process group leader (i.e. master process that forked other processes) of the program, e.g. apache2

# sudo ps x -o  "%p %r %y %x %c " | grep apache2 

14787 14787 ?        00:00:00 apache2

To verify if it is the process leader.

# pgrep apache2 | sort -n | head -n1 
14787 

To issue kill to all the members in the process group

# kill -9 -14787

Apr 212010
 

Add a user that can gain root privileges in Ubuntu

Answer:

You have created a user, and now you want to make this user (e.g. peter as an example) can gain root privileges.

Firstly, check your /etc/sudoers file

# sudo cat /etc/sudoers

You might found the following lines

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
john ALL=(ALL) ALL

Method 1

If you have the line %admin ALL=(ALL) ALL, then you can add the user (e.g peter) to the admin group using the command:

# sudo usermod -g admin peter

Method 2

Or you can edit the file /etc/sudoers to add your account manually

# sudo visudo

Append peter ALL=(ALL) ALL at the end..

%admin ALL=(ALL) ALL
john ALL=(ALL) ALL
peter ALL=(ALL) ALL
Apr 202010
 

Are there any Linux equivalent of the Mac OS X "open" command?

Answer:

The Mac OSX's open command is a very handy tool for opening file, without the need to sepcify the program name.

In Linux, you have two choices:

1. xdg-open

# xdg-open test.html

2. see

# see test.html

Both command will open the file by your default web browser.