Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

A shell is a UNIX system command processor. It's Basically, it is a command language to tell the system what to do. There are two major shell (command interpreter) families: 
    Bourne, Korn, Bash Shell
    C Shell
   
The syntax of shell commands can vary from one shell to another.
At UQAM we use the Bourne Again Shell (bash) for the environment but often Korn Shell (ksh) for scripting. Therefore all commands below are bash commands.

...


Syntax of a shell

...

command

        command-name [ -option(s) filename(s) or arguments ]

...

The first word of the command line is usually the command name. This is followed by the options/keys, if any, then the file and/or directory names. Options are usually preceded by a single or double dash, '-' or '--', and you –'.  One may use more than one option per command which usually can get combined. For example:

      You can also most of the time combine options:     $  ls -l -t -r
is the same as
    $        ls -lrt

In case you have a file name or an argument starting with a '-' you can use '--'. The command will NOT interpret anything following a '--' as an option/key.
For example if you are using 'grep' to look for '-a' in a file you could type:
    $  grep -iw -- -a filename

For more detailed explanations about Program Argument Syntax Conventions, please click on the here.

The examples on this reference card use bold case for command names and options and italics for arguments and filenames.

Documentation of specific commands

      whatis command    - displays whatis command - display a one-line summary about command
      man command         - display displays on-line manual pages about command

'man' can be use on almost all of the shell commands listed below.

Important note about shell commands

...

Shell commands are case sensitive

. Type commands exactly as shown; most shell commands are lower case. File and directory names can be lower, upper, or mixed case but must be typed exactly as listed.

...

Most important shell commands

Quota and disk space usage

On most systems your home quota (the amount of data you can keep under your home) is limited. The following commands help to check quotas and sizes of directories and file systems:

quota -v display your disk quota and usage.
There are quotas on several of our file systems. You might want to check them once in a while.
du -sdisplay your total disk usagedu -sc shc *display the size of all files and folders in current directory.
Very useful if you need to do a clean up because your quota is exceeded!
df -hcheck if the file systems are full - Do NOT do this on guillimin!
echo $PATHinspect your search path

List Files and Directories

Check where you are

      pwd : display the name of present working directory - tells you where you are

      present working directory
true_path directory-name : display the "true" name of directory-name, not the links. This command is a local add-on.

List Files and Directories

      ls directory/file-name(s) : list contents of directory

Here are some of the options I find most useful options of the 'ls' command:

    -alist all files including invisible files (starting with '.')

-llong list - shows ownership, permission, and links

-hlist size in human readable format (k-, M-, GBytes)

-tlist files chronologically

-rreverse order of listing

-ddo not display directory contents but only the directory itself

-Slist in order of size (helps to find the largest files)

...

See 'chmod' below about how to change the permissions.

Change

...

Directory

cd : to change to your home directory
cd directory-name : to change to another directory
cd - : to change back to the previous directory

...