Vous êtes sur la page 1sur 7

Manual pages

http://linuxmanpages.com

man <command>
man <section> <command>

man uses the less pager

Space
Esc + V
/
Q

one page forward


one page backward
search
quit

Manual sections
1
2
3
4
5
6
7
8
9

Excutable programs
System calls
Library calls
Device files
File formats
Games
Miscellaneous
System administration commands
Kernel routines

passwd command
section 1
man passwd
man 5 passwd

/etc/passwd file
section 5

Basic file management


Linux treats almost everything as a file
regular files, directories, devices, sockets, pipes

touch, vi, nano, mkdir


Create / Modify

rm, rmdir

gzip, gunzip,
bzip2

tar, cpio

Delete

find, locate

Locate

Compress

View

Archive

Copy

less, ls

cp, dd

Move
Rename

mv
Create a backup copy of the MBR
$ dd if=/dev/sda of=mbrsave bs=512 count=1

General notions
Linux is case sensitive
Filename.txt <> filename.txt
Filenames can contain any character.
Filenames can be 255 characters long.
filesystem dependent

Special filenames
.
current directory
.. parent directory

Filenames should never contain


wildcards: * ? \
quotations:
$ touch fileone filetwo
path separator: / $ touch file*

$
$
$
$
$
$

cd /usr/bin
pwd
cd .
pwd
cd ..
pwd

$ rm file*

A wildcard stands in place of a group of characters


Wildcards
Wildcard expansion = file globbing
*
zero or more characters
?
only one character
Replacing an wildcard with chars to obtain
[] character set
file names in the current directory

Linux shell
Shell implementations
Bourne Again Shell
bash
bsh
most common Bourne Shell
In linux

tcsh

C Shell

Korn Shell

Z Shell

csh

ksh

zsh

/bin/sh symbolic link to the default shell

$ ls l /bin/sh
$ ls l /bin/*sh

some can also be external commands


Internal commands
cd <directory> change directory
cd ~

ls
echo <string>
env

pwd print working directory

replaces the shell


exec <program>

time <command>

export
clear clear screen

set

logout

exit

Linux shell
Command Completion TAB

$ less ~/.bash_history

~/.bash_history
History Search

Command History
UpArrow

Ctrl + P

DownArrow

Ctrl + N

history
history c

Ctrl + R reverse search


Ctrl + S forward search
Ctrl + G terminate search

display all history


clear history

Line editing
move

Ctrl+A

Ctrl+E

a command line in the shell


delete

Ctrl+X; Bksp

Del

move by one word


Ctrl+Left Ctrl+Right

Ctrl+K

Bash configuration: /etc/profile ~/.bash_profile

Environment variables
means of passing named data
set a variable
$ export HOSTNAME=lpic.credis.ro
$ HOSTNAME=lpic.credis.ro

$ env

set local variable


export to the environment

displays all environment variables

Launch a shell with a


modified environment

SHELL

$ env
copy

ENV

read a variable
$ echo $HOSTNAME

$ export HOSTNAME

ENV

When retrieving the value of a variable precede


the variable name with a '$' character

launch

CHILD
SHELL

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

Streams, pipes & redirection


$ cat <<!
Some simple text
!

append

here-is document
<>
<

<< Standard Input


stdin

Standard Output
stdout

program

stderr
Standard Error
Discard errors

$ command 2> /dev/null

tee [options] [files]


-a, --append

Writes input to stdout and files

send output of program1 to input of program2


program1

program2

pipe

>

>>

&>
2>

2>>