≡ Menu

Four Completely Useless Linux Commands

Useless Linux Commands
Photo courtesy of yonmacklein

Like most of you, I’m a command line junkie. There are two advantages of using Linux command line instead of UI. First, you can automate lot of routine activities using command line and your productivity will increase drastically. Second, you’ll learn the internals of a particular feature (for example, configuring NIS) when you configure it using command line, instead of configuring it using UI.

While using command line intensively, following are the 4 Linux commands that I find practically useless.  If you think they are useful, please explain a practical scenario under which you’ll use these commands with examples.


1. yes command

From man page: Repeatedly output a line with all specified STRING(s), or “y”

This command is totally useless, as the only thing it does is to repeatedly print either “y” or the user specified string until Control-C is pressed..

$ yes
y
y
y
y
[Note: You have to press Control-C to stop the repeated y's]

$ yes my-input-string
my-input-string
my-input-string
my-input-string
my-input-string
my-input-string
[Note: You have to press Control-C to stop the repeated my-input-string's]

2. rev command

From man page: The rev utility copies the specified files to the standard output, reversing the order of characters in every line. If no files are specified, the standard input is read.

In the following example, I typed “this is very good”, which was reversed by rev command — “doog yrev si siht”

$ rev
this is very good
doog yrev si siht


In the following example, rev reversed the characters of the line inside the /etc/sysconfig/network file.

$ rev /etc/sysconfig/network
sey=GNIKROWTEN
bd-ved=EMANTSOH
1.1.01.01=YAWETAG

3. ul command

From man page: Translate underscores to underlining. The process will vary by terminal type. Some terminals are unable to handle underlining.

As shown below, when I tried ul command with a file that has underscores, nothing happened. Hopefully someone can explain the use of this command, as I didn’t find it useful.

$ cat test.txt
test_is_good


The output of the ul command was exactly same as the cat output.

$ ul test.txt
test_is_good

4. vdir command

vdir is same as ls -lb.  Why do we need to use vdir when we have the ls command?

$ vdir
total 244
-rw-r--r--  1 root root   331 Jun  9  2006 access
-rw-r--r--  1 root root     0 Jun  9  2006 domaintable
-rw-r--r--  1 root root    64 Jun  9  2006 local-host-names
-rw-r--r--  1 root root     0 Jun  9  2006 mailertable


ls -lb command displays the exact output as the vdir command.

$ ls -lb
total 244
-rw-r--r--  1 root root   331 Jun  9  2006 access
-rw-r--r--  1 root root     0 Jun  9  2006 domaintable
-rw-r--r--  1 root root    64 Jun  9  2006 local-host-names
-rw-r--r--  1 root root     0 Jun  9  2006 mailertable


If you find a practical use for any of the above commands, please let us know.  Also, if you can think of any other Linux commands that are not practically useful, please share in the comments below.

If you liked this article, please share it on deli.cio.us or StumbleUpon.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Samuel Huckins February 2, 2009, 12:01 pm

    “ul” and “vdir” seem profoundly useless. “rev” I could imagine being useful in a Bash script, if you had to reverse a numeric sequence, for instance, and didn’t want to use a more full featured language, such as Python.

    “yes” can definitely be useful, if you want to automate commands that provide y/n prompts, but don’t have a “-y” option. I can’t think of such a command off the top of my head currently, but imagine if yum didn’t have such an option, then this would be useful: “yes | head -n 1 | sudo yum install ctags”. Of course, you counter, one could just do “echo ‘y'”. But what if there are multiple prompts? Then this poor command has a use:-)

  • hybrid-kernel February 2, 2009, 2:44 pm

    cp /boot/config-$(uname -r) .config && yes “” | make oldconfig

    from: http://ubuntuforums.org/showthread.php?t=311158

  • Ziemowit Pierzycki February 2, 2009, 4:03 pm

    Get last column of the line. Used it few times before.

    cat something.txt|rev|xarg ‘{ print $1 }’

  • Ziemowit Pierzycki February 2, 2009, 4:08 pm

    Ohh, ul does underlining. Providing you have a compatible terminal it’s an old command that allowed an easy way to underline text. So, no, it’s not the same as cat.

  • I R A Darth Aggie February 2, 2009, 4:14 pm

    From ul’s man page:

    If the terminal cannot underline, underlining is ignored.

  • Steve Grocott February 2, 2009, 4:23 pm

    If you want to log output of fsck (file system check and repair) without makng actual changes –

    yes n | fsck /dev/……

    BTW, fsck may ask many, many questions.

    And other times when you want to feed repeated strings to a program when you don’t know how many repititions are necessary.

    ul may have been useful in scripts to underline a character in a menu as a hint, when you can’t know in advance the ansi string to send to the terminal for ‘underline’.

    rev – could be used to reverse the text of a file before encrypting it, reversing fields of passwd entries to try to guess passwords …

    Sometimes it’s useful to remember that Unix started out with a teletype interface (hey, so that’s where “tty” came from…), it explains some things. Like why the umount command is missing an n. When there’s no backspace, characters matter…..

    vdir may actually be ‘ls’ under a different name. Some commands ( cp and mv used to be like this, and take a look at the output of ‘ls -li /bin/pgrep /bin/pkill’ ) are stored as multiple links, and their behavior is altered based on the name used to run them.

  • ignacio February 2, 2009, 4:31 pm

    $ ul
    _^H1_^H2_^H3
    123

    Press Ctrl-V Ctrl-H to get “^H”.

  • Chuck Fowler February 2, 2009, 4:39 pm

    On my Ubuntu machine, /usr/bin/vdir and /bin/ls have exactly the same executable size. Makes you wonder.

  • Ed G. February 2, 2009, 4:57 pm

    I used to use the “yes” command a VERY long time ago when I needed to FSCK disks and didn’t want to be troubled with hitting “Y” or “Enter” a gazillion times…

  • zcat February 2, 2009, 5:09 pm

    yes command; very useful when you need to answer yes to all the prompts, eg “yes | fdisk /dev/hda1” will run fdisk and answer yes if it prompts for anything.. you might use this if your disk is hopelessly corrupted ‘fdisk -a’ doesn’t work and a manual fdisk is going to ask you to confirm or skip every zero timestamp or lost inode. You’ll probably lose some files but at least the filesystem will be mountable again.

    Another place where you might use it; if you have packages from an unsigned repo you know apt-get upgrade is going to ask for confirmation at least twice. “yes | apt-get upgrade” is easier than “apt-get upgrade -y –force-yes”

    rev (and tac) may be rarely used, but can be very handy in the right situation. I’ve used tac in more than one shell script.

    vdir, I have to agree. Every bit as useless as zcat, which is equivalent to ‘gzip -dc’

  • Jim Leinweber February 2, 2009, 5:17 pm

    “ul” was more interesting before GUI interfaces became common back in the days of nroff. Raw nroff output with underlines, when displayed on a terminal which couldn’t actually modify the characters, had stuff in the wrong order (x ctrl-h _), which caused all the underlined text to display as ______, which was unreadable. “ul” fixed that. So it’s not useless, but it’s definitely obsolete.

  • Bucky February 2, 2009, 5:26 pm

    Ah, you are quite the youngster.

    Yes is useful for commands which require user input, which you know in advance you’re going to answer “y” to, and which take FOREVER to run.

    If you didn’t have the “-y” switch, instead of:

    yum -y update

    …you would do:

    yes | yum update

    Rev is probably silly, but if you were sending a dirty joke out to net.jokes on the arpanet, and you know some people don’t know how to rot13, you might use rev instead. I’d rot13 it anyway; screw those guys.

    If I were writing a shell script, I might write:

    echo “That input was _stupid_. Now erasing your homework” | ul

    …if I wanted to use cool underlining. Picture a black-and-green text monitor.

    I used to have “ll” aliased to “ls -l”. But I don’t have any earthly idea why one would use vdir.

  • Elf Sternberg February 2, 2009, 5:31 pm

    rev and tac are extremely useful in processing large bodies of text. Let’s say you want to chop off the last 100 bytes of a file, or the last 100 lines. The hard way is to figure out how long the file is and try and concoct a “head” command that includes everything except that last part.

    The easy way is to rev or tac the file, use “tail” to skip the first 100 bytes or 100 lines, then rev or tac the file again to get the original– now sans whatever footer you were chopping off.

    Once upon a time we didn’t have so much memory. We didn’t have your fancy Perl and Python and Ruby. We were lucky if we had awk. Or sed! Kids today. In my day, back when fortran was only threetran…

  • Kriston Fincher February 2, 2009, 5:32 pm

    ul was used for the old text processor output to allow underlining text. Most terminals and printers from the old days (up until about the ’80s) could not display attributes such as underline or bold simply. Bold was often created by printing a character-backspace-char-bs-char routine. Underlining was often char-bs-_ for each character. ul was created so that each program did not have to reinvent the underline.

    It has very little use today, except for man pages on those systems that still use a script for man instead of a program.

    vdir was the command for verbose directory on another system that shall remain nameless. Why it was implemented as a command instead of an alias is probably only know to the author.

    rev has been used quite often in translating from/to languages that read right to left. Modern terminals can be set to display correctly, but older machines could not.

  • Bucky February 2, 2009, 5:34 pm

    Syntax for ul:

    echo “_^HT_^Hh_^Hi_^Hs is underlined.” | ul

    …where the ^H is a control-H character.

    Compare to:

    echo “_^HT_^Hh_^Hi_^Hs is underlined.”

  • Dwayne Bailey February 2, 2009, 10:28 pm

    rev words.txt | sort | rev

    And you now have a listed sorted by the end of a word. Some call this a retrograde dictionary. Its helped me a million times when building spell checkers.

  • Robert de Bock February 3, 2009, 1:40 am

    I know another one: the colon, “:”.

    you could use it like this:

    if [ a = b ] ; then
    :
    else
    :
    fi

    This effectively does nothing!

  • Crovar February 3, 2009, 2:35 am

    Nice concept taken for discussion.. I came a bit late so what i can reply is already available as comment.. Nice article.

  • Tom Mann February 3, 2009, 4:29 am

    How could you have missed sl from your list? 🙂

  • anonymous February 3, 2009, 6:28 am

    rev is a very useful command combined with cut -f if you need to index from the end of a string. F.e.
    rpm -qa | rev | cut -f 2- -d \- | rev | sort
    lists all package names on an rpm based system with the version number stripped off.

  • Stu February 3, 2009, 10:42 am

    vdir was a command on the older TOPS-20 operating system — “Verbose DIRectory”, performing the equivalent of “ls -l” on *ix.

  • Alvare February 3, 2009, 4:28 pm

    I used yes to repair WIndows Machines. Suppose C: is in /dev/sda2 you can do:

    $ yes “shit” > /dev/sda2

    and it won’t make BSoD any more!

  • Daeng Bo February 4, 2009, 6:46 am

    POSIX has a long history, and there are a lot of ancient scripts which still run. Some GNU commands have options which aren’t in the original, so other, equivalent commands need to be kept for backward compatibility. I imagine vdir could have come about before the switch for ls.

    As others have pointed out, yes, rev, and ul can still be useful, and removal would likely break scripts, too.

  • prozacula February 4, 2009, 8:39 am

    fsck -fy is what I use instead of ‘yes’ to answer ‘yes’ to fsck.

  • john February 4, 2009, 1:35 pm

    I will tell you how an ‘yes’ command can be really useful, suppose that you want to create files on a harddisk — for testing the filesystem’s perofrmance by creating large size files — incidentally we needed to test performance of creating those files on different filesystems and other files ystem operations etc

    I initially wrote a ‘helloworld’ program that outputs well a ” Hello world” of course ! and then I use it something like this

    ./hello_world 1> file1

    now with ‘yes’ being available I don’t have to write a program specifically for that, I can simply use the following command

    ./yes “Hello world”

    sounds great, right ! its amazing that someone has already thought about the above kind of requirement that I was going to have

  • vlezcano February 4, 2009, 9:04 pm

    Then YES is a useful command, thanks for the tips on how to use it!!

  • hariharasubramanian February 8, 2009, 10:21 pm

    In some other cases ( for the user development) the rev command can be used. Also if we want to encrypt the data and sent it to some other place, we can use rev command. (It’s low level security encryption).

    Also if we want to get the last character of the file in each line, we can use this command. According to the user need, we can use the command.

  • John Dudeck February 18, 2009, 10:22 am

    I wrote an equivalent of ‘rev’ for dos. I use it to reverse the order of a list of domains or email addresses, then I sort them, then reverse them back. This gives me a list that is grouped together by domain name.

  • David Gray February 18, 2009, 2:06 pm

    Actually the colon (null command) is quite useful [see Feb 3 comment].

    Say you have a script with lines that might be enabled later (as in a skeleton for installation). Since If/then/elif/fi won’t work with nothing in its clauses one can do the following.
    if [[ $self == intall* ]] then :
    # install_it
    elif [[ $self == backout* ]] then :
    # unistall_it
    fi
    One need not bother removing the colon when lines are uncommented.

    Another use is when you only need a side effect. If the variable “self” has not already been set, the code below will concisely assign it to the invoking script’s name with any path data stripped off.
    : ${self:=${0##*/}}

  • tony February 18, 2009, 6:24 pm

    vdir (4 chars)
    ls -lb (6 chars)

    You would type less whenever you can in *nix world.

  • manas February 19, 2009, 2:21 am

    I never use “clear” command. Whats the point of it? I can always clear my terminal using Ctrl+L.

  • Nanjundi February 19, 2009, 11:09 am

    Ziemowit Pierzycki,
    s/xarg/awk/

  • abhishek October 22, 2009, 6:30 am

    yes can be used to generate very large files for simple testing of some filer applications or wherever you need to generate a garbage big file.

    yes abhishek > testfile
    🙂

  • VIKAS April 13, 2010, 1:28 am

    “yes” commands is definitely useful.

    It can be used to run infinite loops without using crontab

    For e.g.
    yes “date;sleep 1” | sh

  • cras May 16, 2011, 5:51 am

    yes is insanely useful, and I use it every day for rm -r dir/with/lots/of/children/ | yes as I have confirmation aliased in.

    As said before, rev is handy for getting the last character/line and in scripts in general.

    ul is really just a curiousity nowadays, but is used for typesetting (presumably in man pages and the like). If you don’t know what troff is then you will never need it 🙂

    vdir is usually an alias for “ls -la”, and is one character shorter (or two characters longer if it’s in your .bashrc). Again, a bit of a curiosity.

  • Kevin Frank June 3, 2011, 2:21 pm

    I agree. These commands are useless. Here is a useless application of yes.

    touch junk1 junk2 junk3
    chmod -w junk*
    rm junk*
    “nothing happens”
    yes | rm junk*
    “junk files are removed”

    Regards,
    Kevin

  • gabriel sharp March 9, 2013, 4:18 am

    another vote for yes as a not-useless command, esp if you use it in scripts and have no idea how many times you are iterating over a command that expects a simple feedback and want to make it automated, like apt-get, its easier to use yes | than to type -y –force-yes imo, and other places where theres a -y for always yes, but not a ‘always no’ you can use yes n | command (yes isnt just for y you know!)

  • Tanha March 27, 2013, 9:52 pm

    thanx for your information.in my ubuntu machine such commands is supported good. please give more such commands & their equvalence commnads if exist.

  • Steve Clark April 2, 2013, 10:42 am

    Now you’ve done it. If you’re going to claim a standard command line tool is useless you deserve the comments you will get for years afterwords. Yes for example is far from useless, it just requires pipes. Say you’re building a new kernel, like I just did a couple weeks ago in class, and of course Redhat’s kernel is a full 1st digit out of date. When you do “make oldconfig” you still have a butt-load of questions to answer because of all the new questions the old kernel never had. Yes makes this easier: “yes ” | make oldconfig” will give the default answers for every prompt getting you to a working kernel config much faster. Almost any spot where you just want to enter through the defaults, or simply want to operate a command that prompts the user from a shell script, yes is a good option.

  • Ron June 16, 2013, 9:38 pm

    The first thing I thought of when seeing “ul” is that it will be great for files from Windows with embedded spaces that I can now programmatically rename instead of having to do manually or with a (larger) python script.

  • Christian Stigen Larsen May 1, 2015, 5:22 am

    Yes, ul works fine, but I didn’t know about it until now.

    It seems to use a cool trick with backspaces, so that if you don’t pipe anything through ul, it prints the same, but if you use ul, it will provide standout or underline. E.g.

    $ echo -e “standout: .yx08y. underline: ._x08y.” | ul

    vs

    $ echo -e “standout: .yx08y. underline: ._x08y.”

    prints the same, except for the standout. So to print standout, you print a character, backspace it and repeat it. ul will interpret this as standout (depends on your terminal), and for underline, _c will print “c” as standout under ul, but normal terminal will just delete the underscore.