Ten Good Unix Habits

IBM’s DeveloperWorks has 10 Good Unix Habits, which apply to GNU/Linux at least as much as to Unix.

I would expect that most experienced admins can second-guess the content to 5-7 of these 10 points, just from the title (for example, item 1 is a reference to “mkdir -p”, plus another related syntax available to Bash users). I would be surprised if you knew all ten:

1. Make directory trees in a single swipe.
2. Change the path; do not move the archive.
3. Combine your commands with control operators.
4. Quote variables with caution.
5. Use escape sequences to manage long input.
6. Group your commands together in a list.
7. Use xargs outside of find .
8. Know when grep should do the counting — and when it should step aside.
9. Match certain fields in output, not just lines.
10. Stop piping cats.

How many did you get?

3 Responses to Ten Good Unix Habits

  1. cusco says:

    1. mkdir -p

    2. wget -O /path ??

    3. echo “insert into bla (bla,bla) Values (bla,bla);|mysql && echo “select bla from bla;”|mysql

    4. echo “$var” ?? in bash set vars with lowcase

    5. echo -e “line 1\nline2\n”

    6. ??? ls /usr/local/bin

    7. deborphan|xargs apt-get remove –purge -y

    8. grep -c bla file

    9. ???

    10. Use grep instead of cat|grep ??

  2. kcoder24 says:

    I don’t get the meaning in several, can you explain how to implement every one? Here are the ones that I understand

    1 mkdir -p
    2 ?
    3 ?
    4 Use doble quotes only when it´s really needed?
    5 Mmmmh I understand use \n instead the enter itself, but why? what’s the difference?
    6 Group… in a file and execute? or maybe use pipes?
    7 Why use xargs instead find -exec
    8 Detect when is usefull grep and when “grep -c”
    9 awk ‘$2~/RegExp/’ instead grep “RegExp”
    10 That’s classic stop using cat to pipe the output to another command

  3. unixshell says:

    The explanations are in the IBM article; for example, 2 is about the “tar -C /path” syntax…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: