Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am taking a test soon and I would like to know useful commands on Linux for a programmer. Some examples are string, strace, top, free, df, mount, cat, head, tail, whoami, touch. What are others?

I am a complete novice. Those are all the commands I know along with groupadd, useradd, chmod, chown, ls, rm, mkdir and echo. That is all I know.

share|improve this question

migrated from stackoverflow.com Sep 17 '09 at 20:32

This question came from our site for professional and enthusiast programmers.

19 Answers 19

lsof

It lists open files, including network sockets. It can very useful when debugging.

share|improve this answer

Asking for useful commands will help you expand your knowledge for real world applications. But it won't help too much for an upcoming test. A well designed test will likely explore the nuances that only experience can tell you.

Example: if you need to use strace, then you probably know most of the other commands that would appear on this list. If you don't, but still need strace, then what you really need is someone else to help you disect the strace output.

share|improve this answer
  • Study the man page for your shell. Read it repeatedly.
  • Learn awk for quick text processing tasks.
  • Nobody has mentioned sort yet.
  • Get comfortable in a text editor (Vim/Emacs)
  • Learn a scripting language (Ruby/Python/Perl are the usual suspects)
share|improve this answer

I once used pmap to locate a nasty memory leak I couldn't find with valgrind.

share|improve this answer

If you like to learn from other people's source code, learn more about svn, git.

share|improve this answer

Well, I checked the history of my commands, and here is what I found:

=> sed 's/[;|][[:space:]]*/\n/g' .bash_history | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 20
   1725 ssh
   1480 ls
   1125 cd
    494 vim
    471 grep
    425 cat
    378 mplayer
    294 sudo
    285 rm
    241 psql
    230 perl
    175 scp
    171 svn
    148 /sbin/ifconfig
    133 man
    121 bc
    120
    118 find
    110 ps
    109 sort

Some of these are work oriented (perl, psql), or environment oriented (sudo, mplayer).

As for "programmer" commands, the list that I would recommend to master is:

  • awk
  • cat
  • cut
  • find
  • grep
  • head
  • nc
  • nl
  • ps
  • sed
  • sort
  • strace
  • tac
  • tail
  • tcpdump
  • uniq

If you're working in a Unix environment, then learning ssh is definitely a good idea (i.e. it doesn't end up as only "ssh somewhere" or "ssh somewhere some_command", learn about port (or net) forwarding and most importantly: keys and ssh-agent).

share|improve this answer

These aren't really specific to Linux/Unix anymore, but I wonder how I lived without:

  • sed
  • grep
  • perl (for more complex automated editing)
  • less
  • tail (looking at log files as they are added to)
share|improve this answer

sed and awk and also, ctrl+r to reverse look up past commands.

share|improve this answer
  • apt-get : to install development packages
  • tail : to inspect /var/log files
  • fuser : to get mapping between a process and a port (easier to kill zombies)

etc.

share|improve this answer

Commands I use daily are:

  • grep
  • find
  • chmod
  • chown
  • man

There's also a few apps you should know in case there's no GUI:

  • vi
  • ssh
share|improve this answer

The first one you must master is man, and learn "man -k *keyword*" to find relevant man pages.

A few years ago, I wrote up a simple guided path Learning Linux/Unix with man(1) for a few people working for me who were new to Linux. You might also find this helpful.

share|improve this answer
1  
man -k ?= apropos, does anyone use apropos anymore? –  KFro Sep 17 '09 at 21:48

Here is a pretty big list of commands with short description.

share|improve this answer

These are important to me:

  • grep, to look for code
  • sed, to replace stuff
  • diff and patch

For checking & stripping symbols:

  • nm
  • strip
share|improve this answer
  • du - disk usage
  • !grep - will look for and execute grep in bash history (you can change for any string searched)
  • slocate / locate - quick find file or directory
  • editor: joe, nano or others
share|improve this answer

That depends on the type of programmer you are.

For C/C++:

nm, ar, objdump, ranlib, ld, ldd, readelf, elfcmp

For Bash/SH:

awk, sed, grep (or ack), find, xargs, test

For most languages:

diff, patch

But a couple people have well stated that man and apropos are truly useful.

share|improve this answer

If you are serious about programming, I would recommend learning a version-control system. Which version-control system is a whole other Holy War but the basic concepts are transferable between them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.