≡ Menu

Linux command – finding and running commands

Q. I am new to Linux. How do I find and run commands under Linux?

A. Linux comes with lots of commands. But don’t worry it offers commands to find them. Try following commands
ls -l

Task: locate the binary, source, and manual page files for a command

whereis locates source/binary and manuals sections for specified files. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext, for example, .c. Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in a list of standard Linux places. For example find out where is ls command?
$ whereis ls

ls: /bin/ls /usr/share/man/man1/ls.1.gz

Task: Display short descriptions about command

Each manual page has a short description available within it. whatis searches the manual page names and displays the manual page descriptions of any name matched.
$ whatis ls

ls (1)               - list directory contents

Task: Locate a command with which command

which command returns the pathnames of the files which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX conformant shell. It does this by searching the PATH for executable files matching the names of the arguments.
$ which ls
$ which -a date

Task: search the manual page names and descriptions for commands using apropos command

Each manual page has a short description available within it. apropos searches the descriptions for instances of keyword. This is useful to find out command according to task. For example display command that deletes a user, use
$ apropos 'delete a user'

userdel (8)          - Delete a user account and related files

Other examples
$ apropos 'delete'
$ apropos 'icmp'

Task: list files in databases using locate command

Use to find out location of file. If you forget location of file called httpd, use locate as follows:
$ locate httpd.conf


Task: find command & files using ‘find’ command

=> See this previous article about find command examples.

Task: ls -l command

ls -l command provides detailed information about file. See this article [Find out information about my file – explaining ls command] for more information.

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 0 comments… add one }
Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: