p1 working with the command line

7
Manual pages http://linuxmanpages.com man <command> man <section> <command> man uses the less pager Space one page forward Esc + V one page backward / search Q quit Manual sections 1 Excutable programs 2 System calls 3 Library calls 4 Device files 5 File formats 6 Games 7 Miscellaneous 8 System administration commands 9 Kernel routines man passwd man 5 passwd passwd command section 1 /etc/passwd file section 5

Upload: george-florea

Post on 09-Nov-2015

222 views

Category:

Documents


3 download

DESCRIPTION

Python Working With the Command Line

TRANSCRIPT

  • Manual pageshttp://linuxmanpages.com

    man

    man

    man uses the less pager

    Space one page forwardEsc + V one page backward/ searchQ quit

    Manual sections

    1 Excutable programs2 System calls3 Library calls4 Device files5 File formats6 Games7 Miscellaneous8 System administration commands9 Kernel routines

    man passwd

    man 5 passwd

    passwd commandsection 1

    /etc/passwd filesection 5

  • Create / Modify

    Locate

    View

    Copy

    Move

    Rename

    Archive

    Compress

    Delete

    Linux treats almost everything as a file

    regular files, directories, devices, sockets, pipes

    touch, vi, nano, mkdir

    less, ls

    cp, dd

    mv

    tar, cpio

    gzip, gunzip,bzip2

    rm, rmdir find, locate

    Basic file management

    $ dd if=/dev/sda of=mbrsave bs=512 count=1

    Create a backup copy of the MBR

  • General notions

    Linux is case sensitive

    Filename.txt filename.txt Special filenames. current directory.. parent directory

    Filenames can contain any character.Filenames can be 255 characters long.

    Wildcards* zero or more characters? only one character[] character set

    Wildcard expansion = file globbing

    Filenames should never contain wildcards: * ? \quotations: path separator: /

    $ cd /usr/bin

    $ pwd

    $ cd .

    $ pwd

    $ cd ..

    $ pwd

    filesystem dependent

    $ touch fileone filetwo

    $ touch file*

    $ rm file*

    A wildcard stands in place of a group of characters

    Replacing an wildcard with chars to obtainfile names in the current directory

  • Shell implementations

    bash bsh tcsh csh ksh zsh

    Bourne Again Shell

    Bourne Shell

    C Shell Korn Shell Z Shell

    /bin/sh symbolic link to the default shell

    Linux shell

    Internal commands

    echo

    exec

    time

    exitlogout

    cd cd ~

    change directory

    pwd print working directory

    clear clear screen

    replaces the shell

    set

    env export

    ls

    most common In linux

    $ ls l /bin/sh

    $ ls l /bin/*sh

    some can also be external commands

  • Linux shell

    Command Completion TAB

    Command History

    Ctrl + P

    Ctrl + N

    UpArrow

    DownArrow

    Ctrl + R reverse searchCtrl + S forward searchCtrl + G terminate search

    History Search

    ~/.bash_history

    history display all historyhistory c clear history

    Bash configuration: /etc/profile ~/.bash_profile

    Line editing

    a command line in the shell

    Ctrl+KDelCtrl+X; Bkspdelete

    move Ctrl+ECtrl+Amove by one word

    Ctrl+Left Ctrl+Right

    $ less ~/.bash_history

  • read a variable

    $ echo $HOSTNAME

    $ env

    displays all environment variables

    set a variable

    $ export HOSTNAME=lpic.credis.ro

    set local variableexport to the environment

    $ HOSTNAME=lpic.credis.ro

    $ export HOSTNAME

    When retrieving the value of a variable precede the variable name with a '$' character

    Common environment variables: USER/USERNAME - Username of current user SHELL - Path to the current command shell PWD - Present Working Directory HOSTNAME - TCP/IP name of the computer HOME - Home directory of current user PATH - List of directories where executables are found PS1 - Default prompt in bash DISPLAY - The display used by X (:0.0) EDITOR - The default text editor

    SHELLENV

    CHILD SHELL

    ENV

    launchcopy

    $ env

    Launch a shell with a modified environment

    Environment variablesmeans of passing named data

  • Streams, pipes & redirection

    program stdin stdout

    stderr

    Standard Input Standard Output

    Standard Error

    < >>

    2> 2>>

    &>

    here-is document

    Discard errors $ command 2> /dev/null

    tee [options] [files] Writes input to stdout and files-a, --append

    program1 | program2

    pipe

    send output of program1 to input of program2

    append

    $ cat Some simple text

    !