Wednesday, September 8, 2010

Linux Commands I Use Daily

sudo su

This command will allow you to become root. I know, I know. Im not supposed to become root for any reason, but it’s just easier to become root if you have to string a lot of sudo.

pgrep NameOfApplication | xargs sudo kill 9


I use this command when I want to kill a misbehaving app. It may look like a long command and a waste of time, but its pretty easy to type and saves a lot of time if the app is not killed with the first try. Just "UpArrow Enter" as many times as you like.

This command uses:
pgrep – gets process id. Sort of like if you did `ps | grep` but much faster.
xargs – gets the input from the pipe and uses each to execute the next command.
kill 9 – kill forcefully.
sudo – super user do.

So if you have 5 instances of Firefox open just

pgrep firefox | xargs sudo kill 9

All instances will be killed. Do they not die?!?! Do a barrage of Up-Arrow Enter to completely obliterate all instances!!! Take that undead/zombie Firefox.

grep

I use this a lot. Who doesn't?. How do you use this little pearl?
dmesg | grep wireless
ls –A | grep *.pdf


I use this on anything with too much text that I need to search through.

mail

I used this for my work to create reports and send myself reminders on gmail. I used it as follows in the command line.

mail -s ”This is the subject line” myemail@some_mail.com << EOF
This is the body
EOF
#(no space between "<< EOF")

Did I mention that it's very useful for generating reports.

So what commands do you guys use daily?

1 comment:

  1. Wow... this the most uninteresting blog out there, yeah have fun programming the rest of us will enjoy life.

    ReplyDelete