Announcement

Collapse
No announcement yet.

The single most useful Linux command is ...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    The single most useful Linux command is ...

    "man", which is short for "manual". To find out how to use man open a Konsole and issue:
    man man
    which will give you:
    NAME
    man - an interface to the on-line reference manuals

    SYNOPSIS
    man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale]
    [-m system[,...]] [-M path] [-S list] [-e extension]
    [-i|-I] [--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager]
    [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification] [-p string]
    [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...
    man -k [apropos options] regexp ...
    man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
    man -f [whatis options] page ...
    man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale]
    [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]] [-H[browser]]
    [-X[dpi]] [-Z] file ...
    man -w|-W [-C file] [-d] [-D] page ...
    man -c [-C file] [-d] [-D] page ...
    man [-hV]

    DESCRIPTION
    man is the system's manual pager. Each page argument given to man is normally
    the name of a program, utility or function. The manual page associated with each
    of these arguments is then found and displayed. A section, if provided, will direct man
    to look only in that section of the manual. The default action is to search in all of the
    available sections, following a pre-defined order and to show only the first page found,
    even if page exists in several sections.

    The table below shows the section numbers of the manual followed by the types of
    pages they contain.

    1 Executable programs or shell commands
    2 System calls (functions provided by the kernel)
    3 Library calls (functions within program libraries)
    4 Special files (usually found in /dev)
    5 File formats and conventions eg /etc/passwd
    6 Games
    7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
    8 System administration commands (usually only for root)
    9 Kernel routines [Non standard]
    What follows is an "overview", examples, options, etc...

    Many times a man page will end with suggestions for further reading, as does "man man":
    SEE ALSO
    mandb( 8 ), manpath(1), manpath(5), apropos(1), whatis(1), catman(8 ), less(1),
    nroff(1), troff(1), groff(1), zsoelim(1), setlocale(3), man(7), ascii(7), latin1(7), the
    man-db package manual, FSSTND.
    The numbers in the parentheses refer to the section that a particular manual is located.
    Hence, "less(1)" is found in section 1 of the man pages, "Executable programs or shell
    commands".

    Often you want to use a console command but you can't remember its specific spelling,
    or its necessary parameters or options. Say you have a CDROM that you want to
    unmount. You try
    unmount /mnt/cdrom
    but you get an error message with some suggestions, two of which are umount(2)
    and umount( 8 ). You try "man umount(2)" but get an error:
    bash: syntax error near unexpected token `('
    So, you try "man umount" along and get a manual page that begins with "umount(8 )".
    UMOUNT( 8 ) Linux Programmer's Manual UMOUNT(8 )

    NAME
    umount - unmount file systems

    SYNOPSIS
    umount [-hV]

    umount -a [-dflnrv] [-t vfstype] [-O options]
    umount [-dflnrv] {dir|device}...

    DESCRIPTION
    The umount command detaches the file system(s) mentioned from the file hierarchy.
    A file system is specified by giving the directory where it has been mounted. Giving the
    special device on which the file system lives may also work, but is obsolete, mainly
    because it will fail in case this device was mounted on more than one directory.

    Note that a file system cannot be unmounted when it is `busy' - for example, when
    there are open files on it, or when some process has its working directory there, or when a
    swap file on it is in use. The offending process could even be umount itself - it opens libc,
    and libc in its turn may open for example locale files. A lazy unmount avoids this problem.

    Options for the umount command:

    -V Print version and exit.

    -h Print help message and exit.

    -v Verbose mode.

    -n Unmount without writing in /etc/mtab.

    -r In case unmounting fails, try to remount read-only.

    -d In case the unmounted device was a loop device, also free this loop device.

    -i Don't call the /sbin/umount.<filesystem> helper even if it exists.
    By default /sbin/umount. filesystem> helper is called if one exists.

    -a All of the file systems described in /etc/mtab are unmounted. (With umount
    version 2.7 and later: the proc filesystem is not unmounted.)
    Is that the one you want? It may be the same as "umount(2)" but at this point you have
    no way of knowing. One is from section 2, related to function calls by the kernel, the
    other from section 8, commands used by system administrators. Consulting the man pages
    of man you learn that a parameter, "-D", followed by the section number tells the man
    command which section to look into. It will look in that section and return the first
    "umount" command it encounters.
    So, you issue:
    man -D 2 umount
    and your efforts returns this page:
    UMOUNT(2) Linux Programmer's Manual UMOUNT(2)

    NAME
    umount, umount2 - unmount file system

    SYNOPSIS
    #include <sys/mount.h>

    int umount(const char *target);

    int umount2(const char *target, int flags);

    DESCRIPTION
    umount() and umount2() remove the attachment of the (topmost) file system mounted
    on target.

    Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required to unmount
    file systems.

    Linux 2.1.116 added the umount2() system call, which, like umount(), unmounts a
    target, but allows additional flags controlling the behavior of the operation:

    MNT_FORCE (since Linux 2.1.116)
    Force unmount even if busy. This can cause data loss. (Only for NFS mounts.)

    MNT_DETACH (since Linux 2.4.11)
    Perform a lazy unmount: make the mount point unavailable for new accesses,
    and actually perform the unmount when the mount point ceases to be busy.

    MNT_EXPIRE (since Linux 2.6.8 )
    Mark the mount point as expired. If a mount point is not currently in use, then an
    initial call to umount2() with this flag fails with the error EAGAIN, but marks the
    mount point as expired. The mount point remains expired as long as it isn't
    accessed by any process. A second umount2() call specifying MNT_EXPIRE unmounts
    an expired mount point. This flag cannot be specified with either MNT_FORCE
    or MNT_DETACH.

    RETURN VALUE
    On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
    ....
    mmmm....... "umount(2)" looks like coding descriptions for a programmer who may want
    to write code calling the umount command. That's now what you wanted, so umount(8 ),
    the default returned from the "man umount" request is the correct page. Generally speaking,
    the default pages returned from a man request is usually the information the typical user is
    asking for.

    But, what if you not only don't know how to spell a specific command, you don't even know
    the name of a command or even if it exists in the file hierarchy? All you remember is that it
    is a command that mounts MSDOS file systems. This is where another valuable Linux
    command comes into play. It is called "apropos". You issue
    apropos mount
    in a Konsole, and here is what is returned:
    fdlist (1) - Floppy disk mount utility
    fdmount (1) - Floppy disk mount utility
    fdmountd (1) - Floppy disk mount utility
    fdumount (1) - Floppy disk mount utility
    fdutilsconfig ( 8 ) - configure the suid bit of fdmount
    filesystem (7) - event signalling that filesystems have been mounted
    free (1) - Display amount of free and used memory in the system
    fusermount (1) - mount FUSE filesystems
    Gnome2::VFS::Monitor (3pm) - Monitors volume mounts and unmounts
    Gnome2::VFS::Monitor::Handle (3pm) - Monitors volume mounts and unmounts
    Gnome2::VFS::Volume (3pm) - Abstraction for a mounted file system or a network location
    Gnome2::VFS::VolumeMonitor (3pm) - Monitors volume mounts and unmounts
    ifuse (1) - Mount filesystem of an iPhone/iPod Touch.
    local-filesystems (7) - event signalling that local filesystems have been mounted
    mdu (1) - display the amount of space occupied by an MSDOS directory
    mklost+found ( 8 ) - create a lost+found directory on a mounted Linux second extended file...
    mmount (1) - mount an MSDOS disk
    mount (2) - mount file system
    mount ( 8 ) - mount a filesystem
    mount.fuse.ntfs ( 8 ) - Read/Write userspace NTFS driver.
    mount.ntfs ( 8 ) - Third Generation Read/Write NTFS Driver
    mount.ntfs-3g ( 8 ) - Third Generation Read/Write NTFS Driver
    mount.ntfs-fuse ( 8 ) - Read/Write userspace NTFS driver.
    mountall ( 8 ) - Mount filesystems during boot
    mounted (7) - event signalling that a filesystem has been mounted
    mounting (7) - event signalling that a filesystem is mounting
    mountpoint (1) - see if a directory is a mountpoint
    ntfs-3g.probe ( 8 ) - Probe an NTFS volume mountability
    ntfsmount ( 8 ) - Read/Write userspace NTFS driver.
    remote-filesystems (7) - event signalling that remote filesystems have been mounted
    setup (2) - setup devices and file systems, mount root file system
    sleep (1) - delay for a specified amount of time
    switch_root ( 8 ) - switch to another filesystem as the root of the mount tree.
    umount (2) - unmount file system
    umount ( 8 ) - unmount file systems
    umount2 (2) - unmount file system
    virtual-filesystems (7) - event signalling that virtual filesystems have been mounted
    and, right in the center of the listing, is the command "mmount".
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    #2
    Re: The single most useful Linux command is ...

    sudo apt-

    woodsmoke

    Comment


      #3
      Re: The single most useful Linux command is ...

      The single most useful Linux command is ...
      sudo init 0

      When enough is enough...

      Seriously, though, man is a mixed bag. Some man pages read like a text book, and are so well written that even in a state of maddened frustration, one can figure out how to do things. The rsync man page is an example of this. Other man pages -- well, as someone said, "written by engineers, for engineers," and unless you happen to be one, forget it. Find is an example of that, regex is another. Part of the problem is that these are old commands, inherited from unix, and there are so many options that it's impossible to write a condensed manual and cover the whole of what they do.

      And then there are my favorites -- the ones that say, "This man page written to accompany the command xxx", and that's it.

      +1 on apropos, especially for those of us who tend to remember, "That was update- something..."

      Another trick with apropos is to type the first couple of letters and hit the TAB key twice; then bash will give you a list of all the command alternatives that match.
      We only have to look at ourselves to see how intelligent life might develop into something we wouldn't want to meet. -- Stephen Hawking

      Comment


        #4
        Re: The single most useful Linux command is ...

        Browsing the man, info & help pages with the Konqueror & Rekonq

        [img width=400 height=264]http://img718.imageshack.us/img718/8278/konquerorandrekonq.jpg[/img]

        KIO
        > KDE Glossary KIO:
        KDE Input/Output framework provides a single API for operating on files, whether local or on a remote server. Additionally, KIO Slaves provide support for individual protocols. Some particularly useful ones are http, ftp, sftp, smb, nfs, ssh (fish), man, tar and zip.
        Konqueror
        > KDE Userbase Konqueror:
        Format a man page for easy reading

        Type in
        man:rsync
        to get the whole information about using rsync, in a form that's easy on the eye and better for printing, too.
        Rekonq
        > KDE Userbase Rekonq:
        rekonq supports KIO services, including cookies, cache, proxies and network settings. KIO-slaves like file:/, ftp:/, man:/, help:/, info:/ etc will work in rekonq, too.

        More
        > A Quick and Easy Guide to KDE KIO slaves
        > Printpage: HOWTO find Kubuntu's manual / reference / guide / documentation / help

        A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
        Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

        Comment


          #5
          Re: The single most useful Linux command is ...

          Thanks, Rog!

          I wasn't aware of what Konq could do with "manxx".

          Old dogs do learn new tricks! 8)

          Out of curiosity I tried FireFox with "man:umount" and it worked too!
          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
          – John F. Kennedy, February 26, 1962.

          Comment


            #6
            Re: The single most useful Linux command is ...

            Lets not forget:

            sudo mkfs.ext4 /dev/sda1

            where /dev/sda1 = a partition with windows on it...

            Please Read Me

            Comment


              #7
              Re: The single most useful Linux command is ...

              Originally posted by oshunluvr

              where /dev/sda1 = a partition with windows on it...

              Comment


                #8
                Re: The single most useful Linux command is ...

                how about 'sudo rm -rf /'? That should do something...

                Comment


                  #9
                  Re: The single most useful Linux command is ...

                  Originally posted by TheBigAmbulance
                  how about 'sudo rm -rf /'? That should do something...
                  Yeah -- it will provide an opportunity to do something different with your computer. :P

                  Comment


                    #10
                    Re: The single most useful Linux command is ...

                    I had a linux instructor tell me that if you are ever stupid enough to use the 'rm -rf' command, PLEASE make sure you put the full path in. This is the easiest way to bork your entire system.

                    Comment


                      #11
                      Re: The single most useful Linux command is ...

                      WARNING

                      For the uninitiated and those very new to Linux, the following is provided.

                      The cited command: rm -rf / is the most dangerous command you can ever type! It will, without any prompting, erase your entire system.

                      WARNING
                      Windows no longer obstructs my view.
                      Using Kubuntu Linux since March 23, 2007.
                      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                      Comment


                        #12
                        Re: The single most useful Linux command is ...

                        Sorry about making you type that Snowhog... Just kidding around. Thanks for the disclaimer.

                        Comment


                          #13
                          Re: The single most useful Linux command is ...

                          Now we have to wonder how many noobs tried it out, not knowing what it would do, and are now staring at an empty screen when they crashed or rebooted? We'll soon find out!
                          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                          – John F. Kennedy, February 26, 1962.

                          Comment


                            #14
                            Re: The single most useful Linux command is ...

                            Sorry guys, that was not an intelligent thing to actually write down, much less place it in a location where good people are coming for help on a daily basis...

                            Comment


                              #15
                              Re: The single most useful Linux command is ...

                              TheBigAmbulance@

                              No problem, and no harm done. I knew what you were 'trying' to say, and I know that you intended no harm to anyone.
                              Windows no longer obstructs my view.
                              Using Kubuntu Linux since March 23, 2007.
                              "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                              Comment

                              Working...
                              X