What Linux/Unix commands are outdated and have powerful alternatives?

Today I discovered you can make less act like tail -f.

less filename, then press Shift-F to start follow mode.

Just like tail, but you have all the added features of less - like scrolling, searching, and the highlighting of search hits.

I've been watching log files with tail for years.

This just made me ponder: are there other commands that are outdated and have powerful alternatives?

Please share the bliss - a single command per post.


I like to point to my ack, an alternative to grep for programmers.


I'm surprised people (including me) have lived with cobbled-together aliases and shell scripts with find & xargs for so long.

Try htop -- top on steroids.

Try multitail -- tail on steroids.

The most obvious:

less is more.

Not exactly replacements for anything, but moreutils is a collection of small Unixy tools, which are basically meant to fill holes in the *nix toolbox.

Since, you only wanted one command per post, I guess I'll have to choose sponge, which allows you to save the output of a pipe to one of the files used as input. IOW, it allows you to modify files in-place, without having to worry about temporary files.

For example, if you do:

grep 'something' somefile.txt > somefile.txt

somefile.txt will end up empty. So, you could use sponge:

grep 'something' somefile.txt | sponge somefile.txt

Rsync replaces/complements most file transfer methods (scp, rcp, piped tar commands etc, and even cp in many cases) in an efficient and powerful way.

Due to its versatility, it has a lot of options. But I really recommend to learn at least the basics of rsync.

mtr is a traceroute replacement (it is a combination ping and traceroute).

Unlike traceroute, it finds the route almost immediately (since it doesn't wait for a response before moving to the next hop).

The command line version is installed by default in Debian (package mtr-tiny).

Context sensitive autocompletion.

Well, I know, it's not a command and it's unlikely to be found on many Unices, but Linux. In my Ubuntu Hardy, bash_completion is already configured very well, and that means not only for files and direcotires! For example if I type

svn pr<TAB><TAB>

I get:

praise    propdel   propedit  propget   proplist  propset

And even

svn propget svn:k<TAB>

I get automaticaly

svn propget svn:keywords

It works also for ant and make automatically reading the default files or the ones specified on the commandline! That's a real time saver!

rsh/rexec/rcp/etc. have been supplanted by ssh/scp/etc.

The question and tags are contradictory. Linux isn't Unix (stupid Open Group), and most "real" Unix boxes don't have anywhere close to the software that Linux does. As an example, on a fairly plain AIX 5.3pl6 install:

$ less
ksh: less:  not found.

And yes, I admin these systems, but we've agreed to not load non-core components in most cases since we need them to match the deployed systems in the field.

It's great to have the newer tools in your toolbox, but if you don't know the "old school" way then you're going to be in a world of hurt if you're ever on a AIX/Solaris/HP-UX/etc system which doesn't have the newer tools (and may not even have bash).

Note, on our development VM I do have as many modern tools installed as I can find, simply because while I can work in a more plain environment, it doesn't mean that I enjoy it. And I do as much work as possible on our Linux (CentOS 5) system, simply because the tools on it are still newer than anything I can find readily packaged for AIX (Solaris is somewhat better; HP-UX is infinitely worse).

netcat should be universally replaced by socat.

It's worth having a look at the GNU versions of some commonplace commands, since they've quietly acquired useful refinements beyond the standard (XPG4, etc.) versions.

For example, recursive grep is much nicer than find | xargs grep.

Also, find ... -print0 | xargs -0 ... handles the long-standing horrible quoting problem that makes xargs fail to handle funky space-filled filenames properly.

GNU tar takes 'j' and 'z' flags to handle bzipped and gzipped archives directly.

And bash's $() alternative to backticks makes the occasional nested backquoted expression easier to read and write.

On Linux, ip (from the iproute2 package) behaves more predictably and gives easier-to-parse output than ifconfig/route.

pax is a replacement for tar and cpio, with a sane set of command-line options: -r to read from an archive, -w to write to an archive, -rw to do tree-to-tree copies. It also provides a -s option to allow you to perform substitutions on filenames before reading/writing a file from/to an archive. :-)

Edit: Mark Baker makes an interesting point (in comments) that I should clarify. pax makes pax archives (which are an extension of ustar, and can be unpacked by most tar programs) by default. But, with the -x option, it can be made to create cpio archives and ustar archives (these two are guaranteed by the standard). Some implementations, such as the BSD one, support creating even more types, such as old-style (pre-ustar) tar archives.

One might say that awk has been completely obsoleted by perl.

However, since I was using awk since before perl existed, I still use it; as for more serious scripts, I use python instead of perl.

atool: handling archives without headaches

Some examples:

  • aunpack archive.tgz Unpacks all the files in the archive. If the author of the archive was so inconsiderate as to put multiple files in the archive‚Äôs root, the command automatically creates a directory and moves the files inside.
  • aunpack -e archive1.tgz archive2.zip Unpacks each archive.
  • apack archive.tar.bz2 *.txt Creates a new compressed archive containing all text files in the current working directory.
  • als archive.rar Shows the names of the files contained in the archive.

Examples are from: http://debaday.debian.net/2008/12/28/atool-handling-archives-without-headaches/

dig is a better alternative to nslookup.

'rename' is a good alternative to the long oneliners one writes to change name to a bunch of files.

Not really a replacement for an outdated command per se, but screen is a great alternative to opening multiple terminal windows and/or using bg, etc.

If you're on a GNU system, don't use sed '1!G;h;$!d'; instead, use tac.

bm (link), instead of popd and pushd or creating temporary aliases, is really useful.

To add a directory to be called with tag

bm -a /path/to/a/dir tag

To go to this directory

cdbm tag

Wherever glibc is installed, you can getent passwd foo instead of grep foo /etc/passwd (similarly for aliases ethers group hosts netgroup networks protocols rpc services shadow) -- it even Does The Right Thing(TM) in an NIS setup.

Why bother typing gzip -dc foo.tar.gz | tar xf - when tar xzf foo.tar.gz will spawn the decompressor for you?

Going even further... why bother typing tar xzf foo.tar.gz or tar xjf foo.tar.bz2 when GNUtar will automatically detect compression? tar xf foo.tar.(gz|bz2) just magically works.

I'm not sure if this should be an answer or merely an edit to the question.

Before using less as a tail replacement, you can search for something "/search_string" and THEN invoke the Follow command (shift-F). Now any "search_strings" that scroll by will be highlighted. This is useful for when you're scanning a bunch of program output or logs and are looking for a particular string or pattern.

Don't forget that you can use regular expressions, too!

cfdisk is an easy-to-use upgrade of the command-line drive partitioning utility fdisk.

ifconfig and iwconfig are deprecated in favor of ip which is a extremely powerful tool to show / manipulate routing, devices, policy routing and tunnels.

I really like locate as a substitute for find - much easier to use "locate filepattern" than "find / -name filepattern -print", and more efficient because it uses an index database.

You have to have the updatedb command run on a schedule to update the locate database; check your distro's man page for details.

echo might still only be used with trivial arguments otherwise, its behavior might be unpredictable. For all other purposes (control characters, new line suppression, formatting), it has been obsoleted by the much powerful and consistent printf command.

I find that wcalc is a nice replacement for bc

tmux over screen. tmux is so much easier to configure, it's not even funny.

The Perl Pie: perl -pi -e 's/foo/bar/' instead of sed 's/foo/bar/', with the much more powerful perlre syntax. (It's not quite a drop-in replacement, since Perl regexes use, for example, ? instead of \?.)

Need Your Help

Algorithm to find next greater permutation of a given string


I want an efficient algorithm to find the next greater permutation of the given string.