5 quick and dirty Linux tips you may not know

Share Button

Remember that day you were sitting at a friendly bash$ prompt and discovered tab completion? It was like a choir of angels came down from the heavens and sang Hallelujah, the Shell Hath Come (yes, that’s a bourne again reference). While these 5 tips may not be that monumental, they are still things I wouldn’t be able to do without… perhaps they will help you as well.

1. Grep without the grep

I frequently see a lot of people running grep commands like this: ps -ef | grep pmon | grep -v grep

Since the ‘ps’ command is a process list, it unfortunately will not only return the pmon process you are looking for but the ‘grep pmon’ command you just ran.

It is obnoxious, but easy to workaround. However, the ‘grep -v’ command is the long way. Here is the short way around the issue:

ps -ef | grep [p]mon

Simply wrap the first character of the search term in square brackets, and you are good to go.

2. Kill them all

Have you ever needed to, say, kill all LOCAL=NO processes on an Oracle server? Yeah, me neither. But if you did, not saying that I have, this is the kind of command I would use:


3. Space hogs

This one is probably a little better known, but if you need to find the top space users in a directory just run the following command:

du -k | sort -n

Note that the output number will be in kilobytes.

4. Getting the magic back

Does your job or client require you to use sudo in order to log into a database server as Oracle? Depending on the way you get X Windows going, that may have caused you grief in the past (particularly with installing Oracle). But you can easily grab your auth data and transfer it when you sudo to a new user like so:

And you get the clock, right? But you need to be oracle to do an install. Before you do that sudo command, type xauth list

When I sudo to oracle, notice xclock doesn’t work:

But I can add back my authorization by using xauth add and pasting the entire line from the xauth list output.

Doing so will make X it work once again, but now as the oracle user.

5. Screen your sessions

This one was a godsend. Have you ever been working on a long running operation and you lost your connection to Oracle, or had to go home, or god knows what else? It is a horrible pain and one that really messes up a lot if it gets you at the wrong time. That should be a thing of the past if you use screen.

Screen is a multiplexed terminal, allowing you to spawn multiple terminals in a single terminal session. Opening a new ‘screen’ is simple; simply type the word screen at a Linux command line:

Notice your terminal clears and you start at a new prompt. Now I will go ahead and make it wait for input.

If I press CTRL+A, then CTRL+D, my screen will detach, putting me back on the ‘parent’ terminal session:

If I want to get back to the child screen, I can type screen -rx to re-attach. Or start a new terminal with a fresh ‘screen’ command. You can even detach from multiple terminals and connect to the one of your choosing:

But wait, there’s more! If you and a buddy, coworker, consultant, engineer, parole officer, etc. want to share the same screen, you can login as the same user via SSH and then both type screen -rx. You will both join the multiplexed session (screen) and be able to type and see what each other is typing. It is awesome for following along, mentoring, etc.


Good luck with these, and don’t do anything dangerous on production. If you have any of your own tips to share, feel free to leave a comment!

Share Button


  1. I cannot count how many expensive consultants I have had to teach how to use xauth add.

    screen is priceless when logged in from home on a VPN with a timeout.

    Nice post!

  2. Re. Space hogs:

    (1) ‘du -sk | sort -nr | head’ gives you the Top 10 space hogs with the biggest ones first.

    (2) ‘du -sk *| sort -nr | head -25’ limits ‘du’ to the visible files/ directories and in this example gives you the top 25 entries of the results.

  3. I use “tmux” instead of “screen”. It is lighter, faster, has better support for resizeable panes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.