Basic Commands

From Schmid.wiki
Jump to: navigation, search

Contents

Command List

command purpose example usage
$ help display shell internal commands
$ man display manual for command $ man cp
$ cd change directory $ cd ~/tmp
$ ls dir $ ls /var/log
$ ls -a dir all $ ls -a ~
$ cp copy $ cp /home/user/file.txt .
$ mv move / rename $ mv oldname newname
$ rm delete
$ rm -r delete (also subdirectories)
$ nano simple editor
$ vim cool (though initially confusing) editor $ vim ~/.bashrc
$ emacs big and annoying editor (Ctrl+x, Ctrl+c to quit)

Getting Help

How do you get help for the syntax of a command in linux? It depends on the command. If it is an internal shell-command, 'help' is used. If not, 'man' or the '--help' option is used.

Internal Shell Commands

The internal commands are part of the shell you are using (e.g. bash). try these examples:

Display a list of the internal commands:

$ help
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
...
$ help for     display the syntax for using the 'for' command
for: for NAME [in WORDS ... ;] do COMMANDS; done
    The `for' loop executes a sequence of commands for each member in a
    list of items.  If `in WORDS ...;' is not present, then `in "$@"' is
    ...

Other Commands

the rest of the commands are located as files on the computer.

$ man cp         display the manpage for 'cp'
...
$ cp --help      display short information for 'cp'
Usage: cp [OPTION]... SOURCE DEST
  or:  cp [OPTION]... SOURCE... DIRECTORY
  or:  cp [OPTION]... --target-directory=DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
  -a, --archive                same as -dpR
      --backup[=CONTROL]       make a backup of each existing destination file
...
$ which cp       show the location of the program 'cp'
/bin/cp
Personal tools