Índice
São descritas ferramentas e dicas para gerir dados binários e de texto no sistema Debian.
![]() |
Atenção |
---|---|
The uncoordinated write access to actively accessed devices and files from
multiple processes must not be done to avoid the race condition. File locking mechanisms using
|
A segurança dos dados e a sua partilha controlada têm vários aspectos.
Estas podem ser realizadas usando a combinação de algumas ferramentas
Aqui está um sumário das ferramentas de arquivo e compressão disponíveis no sistema Debian.
Tabela 10.1. Lista de ferramentas de arquivo e compressão
pacote | popcon | tamanho | comando | extensão | comentário |
---|---|---|---|---|---|
tar
*
|
V:61, I:99 | 2660 |
tar (1)
|
.tar
|
o arquivador standard (de facto standard) |
cpio
*
|
V:41, I:99 | 920 |
cpio (1)
|
.cpio
|
arquivador estilo Unix System V, usar com o find (1)
|
binutils *
|
V:58, I:74 | 11996 |
ar (1)
|
.ar
|
arquivador para a criação de bibliotecas estáticas |
fastjar *
|
V:7, I:31 | 216 |
fastjar (1)
|
.jar
|
arquivador para Java (estilo zip) |
pax
*
|
V:1.5, I:6 | 172 |
pax (1)
|
.pax
|
new POSIX standard archiver, compromise between tar and
cpio
|
afio
*
|
V:0.3, I:1.7 | 240 |
afio (1)
|
.afio
|
cpio extenso com compressão por ficheiro etc.
|
gzip
*
|
V:91, I:99 | 284 |
gzip (1), zcat (1), …
|
.gz
|
GNU LZ77 compression utility (de facto standard) |
bzip2
*
|
V:51, I:79 | 132 |
bzip2 (1), bzcat (1), …
|
.bz2
|
Burrows-Wheeler
block-sorting compression utility with higher compression ratio than
gzip (1) (slower than gzip with similar
syntax)
|
lzma
*
|
V:8, I:80 | 172 |
lzma (1)
|
.lzma
|
LZMA compression utility with higher compression
ratio than gzip (1) (deprecated)
|
xz-utils *
|
V:5, I:26 | 460 |
xz (1), xzdec (1), …
|
.xz
|
XZ compression utility with higher compression
ratio than bzip2 (1) (slower than gzip
but faster than bzip2 ; replacement for LZMA compression utility)
|
p7zip
*
|
V:2, I:23 | 1052 |
7zr (1), p7zip (1)
|
.7z
|
7-Zip file archiver with high compression ratio (LZMA compression) |
p7zip-full *
|
V:14, I:26 | 3612 |
7z (1), 7za (1)
|
.7z
|
7-Zip file archiver with high compression ratio (LZMA compression and others) |
lzop
*
|
V:0.7, I:6 | 144 |
lzop (1)
|
.lzo
|
LZO compression utility with higher compression
and decompression speed than gzip (1) (lower compression
ratio than gzip with similar syntax)
|
zip
*
|
V:8, I:52 | 632 |
zip (1)
|
.zip
|
InfoZIP: ferramenta de compressão e arquivo do DOS |
unzip
*
|
V:24, I:69 | 408 |
unzip (1)
|
.zip
|
InfoZIP: DOS unarchive and decompression tool |
![]() |
Atenção |
---|---|
Do not set the " |
![]() |
Nota |
---|---|
The gzipped |
![]() |
Nota |
---|---|
The xz-compressed |
![]() |
Nota |
---|---|
Popular compression method in FOSS tools such as
|
![]() |
Nota |
---|---|
|
![]() |
Nota |
---|---|
|
![]() |
Nota |
---|---|
|
![]() |
Nota |
---|---|
Internal structure of OpenOffice data files are " |
Aqui está um sumário de ferramentas de cópia simples e salvaguarda disponíveis no sistema Debian.
Tabela 10.2. Lista de ferramentas de cópia e sincronização
pacote | popcon | tamanho | ferramenta | função |
---|---|---|---|---|
coreutils *
|
V:92, I:99 | 13828 | GNU cp | copia localmente ficheiros e directórios ("-a" para ser recursivo) |
openssh-client *
|
V:52, I:99 | 2104 | scp |
copia remotamente ficheiros e directórios (cliente, "-r "
para ser recursivo)
|
openssh-server *
|
V:70, I:83 | 700 | sshd | copia ficheiros e directórios remotamente (servidor remoto) |
rsync
*
|
V:19, I:52 | 704 | - | sincronização remota a salvaguarda de 1 via |
unison *
|
V:0.9, I:3 | 1816 | - | sincronização remota a salvaguarda de 2 vias |
Copying files with rsync
(8) offers richer features than
others.
--exclude
" and "--exclude-from
"
options similar to tar
(1)
![]() |
Dica |
---|---|
Execution of the |
![]() |
Dica |
---|---|
Version control system (VCS) tools in Tabela 10.16, “lista de ferramentas de sistemas de controle de versão” can function as the multi-way copy and synchronization tools. |
Here are several ways to archive and unarchive the entire content of the
directory "./source
" using different tools.
GNU tar
(1):
$ tar cvzf archive.tar.gz ./source $ tar xvzf archive.tar.gz
cpio
(1):
$ find ./source -xdev -print0 | cpio -ov --null > archive.cpio; gzip archive.cpio $ zcat archive.cpio.gz | cpio -i
afio
(1):
$ find ./source -xdev -print0 | afio -ovZ0 archive.afio $ afio -ivZ archive.afio
Aqui estão algumas maneiras de copiar o conteúdo inteiro do directório
"./source
" usando diferentes ferramentas.
./source
" directory →
"/dest
" directory
./source
" directory at local host →
"/dest
" directory at "user@host.dom
"
host
rsync
(8):
# cd ./source; rsync -av . /dest # cd ./source; rsync -av . user@host.dom:/dest
You can alternatively use "a trailing slash on the source directory" syntax.
# rsync -av ./source/ /dest # rsync -av ./source/ user@host.dom:/dest
cp
(1) de GNU e scp
(1) de openSSH:
# cd ./source; cp -a . /dest # cd ./source; scp -pr . user@host.dom:/dest
GNU tar
(1):
# (cd ./source && tar cf - . ) | (cd /dest && tar xvfp - ) # (cd ./source && tar cf - . ) | ssh user@host.dom '(cd /dest && tar xvfp - )'
cpio
(1):
# cd ./source; find . -print0 | cpio -pvdm --null --sparse /dest
afio
(1):
# cd ./source; find . -print0 | afio -pv0a /dest
You can substitude ".
" with "foo
" for
all examples containing ".
" to copy files from
"./source/foo
" directory to
"/dest/foo
" directory.
You can substitude ".
" with the absolute path
"/path/to/source/foo
" for all examples containing
".
" to drop "cd ./source;
". These
copy files to different locations depending on tools used as follows.
/dest/foo
": rsync
(8), GNU
cp
(1), and scp
(1)
/dest/path/to/source/foo
": GNU
tar
(1), cpio
(1), and
afio
(1)
![]() |
Dica |
---|---|
|
find
(1) is used to select files for archive and copy
commands (see Secção 10.1.3, “Idiomas para o arquivo” and Secção 10.1.4, “Idiomas para a cópia”) or for xargs
(1) (see
Secção 9.5.9, “Repeating a command looping over files”). This can be
enhanced by using its command arguments.
A sintaxe básica de find
(1) pode ser sumariada no
seguinte.
-o
" between conditionals) has lower precedence than
"logical AND" (specified by
"-a
" or nothing between conditionals).
!
" before a conditional) has higher precedence than
"logical AND".
-prune
" always returns logical TRUE and, if it is a directory, searching of file
is stopped beyond this point.
-name
" matches the base of the filename with shell glob
(see Secção 1.5.6, “Glob da shell”) but it also matches its initial
".
" with metacharacters such as "*
"
and "?
". (New POSIX feature)
-regex
" matches the full path with emacs style BRE (see Secção 1.6.2, “Expressões regulares”) as
default.
-size
" matches the file based on the file size (value
precedented with "+
" for larger, precedented with
"-
" for smaller)
-newer
" matches the file newer than the one specified in
its argument.
-print0
" always returns logical TRUE and print the full filename (null terminated) on the standard output.
find
(1) is often used with an idiomatic style as the
following.
# procura /caminho/para \ -xdev -regextype posix-extended \ -type f -regex ".*\.afio|.*~" -prune -o \ -type d -regex ".*/\.git" -prune -o \ -type f -size +99M -prune -o \ -type f -newer /path/to/timestamp -print0
This means to do following actions.
/path/to
"
.*\.afio
" or
".*~
" from search by stop processing
.*/\.git
" from
search by stop processing
/path/to/timestamp
"
Please note the idiomatic use of "-prune -o
" to exclude
files in the above example.
![]() |
Nota |
---|---|
For non-Debian Unix-like system, some
options may not be supported by |
We all know that computers fail sometime or human errors cause system and data damages. Backup and recovery operations are the essential part of successful system administration. All possible failure modes hit you some day.
![]() |
Dica |
---|---|
Keep your backup system simple and backup your system often. Having backup data is more important than how technically good your backup method is. |
Existem 3 factores chave que determinam a política actual de salvaguarda e recuperação.
Saber o que salvaguardar e recuperar.
~/
"
/var/
" (except "/var/cache/
",
"/var/run/
", and "/var/tmp/
")
/etc/
"
/usr/local/
" or
"/opt/
"
Saber como salvaguardar e recuperar
Avaliar os riscos e custos envolvidos.
As for secure storage of data, data should be at least on different disk partitions preferably on different disks and machines to withstand the filesystem corruption. Important data are best stored on a write-once media such as CD/DVD-R to prevent overwrite accidents. (See Secção 10.3, “Os dados binários” for how to write to the storage media from the shell commandline. GNOME desktop GUI environment gives you easy access via menu: "Places→CD/DVD Creator".)
![]() |
Nota |
---|---|
You may wish to stop some application daemons such as MTA (see Secção 6.3, “Agente de transporte de mail (MTA)”) while backing up data. |
![]() |
Nota |
---|---|
You should pay extra care to the backup and restoration of identity related
data files such as " |
![]() |
Nota |
---|---|
If you run a cron job as a user process, you must restore files in
" |
Here is a select list of notable backup utility suites available on the Debian system.
Tabela 10.3. Lista de suites utilitárias de salvaguarda
pacote | popcon | tamanho | descrição |
---|---|---|---|
rdiff-backup *
|
V:1.4, I:3 | 804 | salvaguarda incremental (remoto) |
dump
*
|
V:0.4, I:1.5 | 716 |
4.4 BSD dump (8) and
restore (8) for ext2/ext3 filesystems
|
xfsdump *
|
V:0.3, I:1.9 | 628 |
dump and restore with xfsdump (8) and
xfsrestore (8) for XFS
filesystem on GNU/Linux and IRIX
|
backupninja *
|
V:0.5, I:0.6 | 452 | lightweight, extensible meta-backup system |
mondo
*
|
V:0.11, I:0.5 | 1168 | Mondo Rescue: disaster recovery backup suite |
sbackup *
|
V:0.05, I:0.16 | 488 | suite de salvaguarda simples para o ambiente GNOME |
keep
*
|
V:0.13, I:0.3 | 1232 | sistema de salvaguarda para o KDE |
bacula-common *
|
V:1.3, I:2 | 1404 | Bacula: salvaguarda, recuperação e verificação em rede - ficheiros de suporte comum |
bacula-client *
|
I:0.9 | 84 | Bacula: salvaguarda, recuperação e verificação em rede - meta-pacote cliente |
bacula-console *
|
V:0.3, I:1.2 | 184 | Bacula: salvaguarda, recuperação e verificação em rede - consola de texto |
bacula-server *
|
I:0.5 | 84 | Bacula: salvaguarda, recuperação e verificação em rede - meta-pacote servidor |
amanda-common *
|
V:0.4, I:0.8 | 6924 | Amanda: Advanced Maryland Automatic Network Disk Archiver (Bibliotecas) |
amanda-client *
|
V:0.4, I:0.8 | 748 | Amanda: Advanced Maryland Automatic Network Disk Archiver (Cliente) |
amanda-server *
|
V:0.11, I:0.3 | 916 | Amanda: Advanced Maryland Automatic Network Disk Archiver (Servidor) |
backuppc *
|
V:0.8, I:1.0 | 2460 | BackupPC é um sistema de grau empresarial de alta performance para fazer salvaguardas a PCs (baseado em disco) |
backup-manager *
|
V:0.4, I:0.6 | 672 | ferramenta de salvaguarda de linha de comandos |
backup2l *
|
V:0.2, I:0.3 | 152 | ferramenta de baixa manutenção para salvaguarda/restauro para medias montáveis (baseado em disco) |
As ferramentas de salvaguarda têm os seus objectivos especializados.
sbackup
and keep
packages provide easy
GUI frontend for desktop users to make regular backups of user data. An
equivalent function can be realized by a simple script (Secção 10.1.8, “Um script de exemplo para salvaguarda ao sistema”) and
cron
(8).
Basic tools described in Secção 10.1.1, “Ferramentas de arquivo e compressão” and Secção 10.1.2, “Ferramentas de cópia de sincronização” can be used to facilitate system backup via custom scripts. Such script can be enhanced by the following.
rdiff-backup
permite salvaguardas incrementais
(remotas).
dump
ajuda a arquivar e restaurar o sistema de
ficheiros completo de modo incremental e eficiente.
![]() |
Dica |
---|---|
Veja os ficheiros em " |
For a personal Debian desktop system running unstable
suite, I only need to protect personal and critical data. I reinstall
system once a year anyway. Thus I see no reason to backup the whole system
or to install a full featured backup utility.
Eu uso um script simples para fazer um arquivo salvaguarda e gravá-lo em CD/DVD usando uma GUI. Aqui está um script exemplo para tal.
#!/bin/sh -e # Copyright (C) 2007-2008 Osamu Aoki <osamu@debian.org>, Public Domain BUUID=1000; USER=osamu # UID and name of a user who accesses backup files BUDIR="/var/backups" XDIR0=".+/Mail|.+/Desktop" XDIR1=".+/\.thumbnails|.+/\.?Trash|.+/\.?[cC]ache|.+/\.gvfs|.+/sessions" XDIR2=".+/CVS|.+/\.git|.+/\.svn|.+/Downloads|.+/Archive|.+/Checkout|.+/tmp" XSFX=".+\.iso|.+\.tgz|.+\.tar\.gz|.+\.tar\.bz2|.+\.afio|.+\.tmp|.+\.swp|.+~" SIZE="+99M" DATE=$(date --utc +"%Y%m%d-%H%M") [ -d "$BUDIR" ] || mkdir -p "BUDIR" umask 077 dpkg --get-selections \* > /var/lib/dpkg/dpkg-selections.list debconf-get-selections > /var/cache/debconf/debconf-selections { find /etc /usr/local /opt /var/lib/dpkg/dpkg-selections.list \ /var/cache/debconf/debconf-selections -xdev -print0 find /home/$USER /root -xdev -regextype posix-extended \ -type d -regex "$XDIR0|$XDIR1" -prune -o -type f -regex "$XSFX" -prune -o \ -type f -size "$SIZE" -prune -o -print0 find /home/$USER/Mail/Inbox /home/$USER/Mail/Outbox -print0 find /home/$USER/Desktop -xdev -regextype posix-extended \ -type d -regex "$XDIR2" -prune -o -type f -regex "$XSFX" -prune -o \ -type f -size "$SIZE" -prune -o -print0 } | cpio -ov --null -O $BUDIR/BU$DATE.cpio chown $BUUID $BUDIR/BU$DATE.cpio touch $BUDIR/backup.stamp
Este é suposto ser um script de exemplo executado pelo root.
Eu espero que você altere e execute isto como o seguinte.
find … -print0
" por "find … -newer
$BUDIR/backup.stamp -print0
" para fazer uma salvaguarda
incremental.
scp
(1) or
rsync
(1) or burn them to CD/DVD for extra data security.
(I use GNOME desktop GUI for burning CD/DVD. See Secção 12.1.8, “Shell script example with zenity” for extra redundancy.)
Mantenha a coisa simples!
![]() |
Dica |
---|---|
You can recover debconf configuration data with
" |
For the set of data under a directory tree, the copy with "cp
-a
" provides the normal backup.
For the set of large non-overwritten static data under a directory tree such
as the one under the "/var/cache/apt/packages/
"
directory, hardlinks with "cp -al
" provide an alternative
to the normal backup with efficient use of the disk space.
Here is a copy script, which I named as bkup
, for the
data backup. This script copies all (non-VCS) files under the current
directory to the dated directory on the parent directory or on a remote
host.
#!/bin/sh -e # Copyright (C) 2007-2008 Osamu Aoki <osamu@debian.org>, Public Domain fdot(){ find . -type d \( -iname ".?*" -o -iname "CVS" \) -prune -o -print0;} fall(){ find . -print0;} mkdircd(){ mkdir -p "$1";chmod 700 "$1";cd "$1">/dev/null;} FIND="fdot";OPT="-a";MODE="CPIOP";HOST="localhost";EXTP="$(hostname -f)" BKUP="$(basename $(pwd)).bkup";TIME="$(date +%Y%m%d-%H%M%S)";BU="$BKUP/$TIME" while getopts gcCsStrlLaAxe:h:T f; do case $f in g) MODE="GNUCP";; # cp (GNU) c) MODE="CPIOP";; # cpio -p C) MODE="CPIOI";; # cpio -i s) MODE="CPIOSSH";; # cpio/ssh S) MODE="AFIOSSH";; # afio/ssh t) MODE="TARSSH";; # tar/ssh r) MODE="RSYNCSSH";; # rsync/ssh l) OPT="-alv";; # hardlink (GNU cp) L) OPT="-av";; # copy (GNU cp) a) FIND="fall";; # find all A) FIND="fdot";; # find non CVS/ .???/ x) set -x;; # trace e) EXTP="${OPTARG}";; # hostname -f h) HOST="${OPTARG}";; # user@remotehost.example.com T) MODE="TEST";; # test find mode \?) echo "use -x for trace." esac; done shift $(expr $OPTIND - 1) if [ $# -gt 0 ]; then for x in $@; do cp $OPT $x $x.$TIME; done elif [ $MODE = GNUCP ]; then mkdir -p "../$BU";chmod 700 "../$BU";cp $OPT . "../$BU/" elif [ $MODE = CPIOP ]; then mkdir -p "../$BU";chmod 700 "../$BU" $FIND|cpio --null --sparse -pvd ../$BU elif [ $MODE = CPIOI ]; then $FIND|cpio -ov --null | ( mkdircd "../$BU"&&cpio -i ) elif [ $MODE = CPIOSSH ]; then $FIND|cpio -ov --null|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&&cpio -i )" elif [ $MODE = AFIOSSH ]; then $FIND|afio -ov -0 -|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&&afio -i - )" elif [ $MODE = TARSSH ]; then (tar cvf - . )|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&& tar xvfp - )" elif [ $MODE = RSYNCSSH ]; then rsync -rlpt ./ "${HOST}:${EXTP}-${BKUP}-${TIME}" else echo "Any other idea to backup?" $FIND |xargs -0 -n 1 echo fi
Isto é suposto ser exemplos de comandos. Por favor, leia o script e edite-o à sua necessidade antes de o usar.
![]() |
Dica |
---|---|
I keep this |
![]() |
Dica |
---|---|
For making snapshot history of a source file tree or a configuration file
tree, it is easier and space efficient to use |
Dispositivos de armazenamento amovível podem ser qualquer um dos seguintes.
These removable storage devices can be automatically mounted as a user under
modern desktop environment, such as GNOME using
gnome-mount
(1).
Mount point under GNOME is chosen as
"/media/<disk_label>
" which can be customized by
the following.
mlabel
(1) para o sistema de ficheiros FAT
genisoimage
(1) com a opção "-V
" para o
sistema de ficheiros ISO9660
tune2fs
(1) with "-L
" option for
ext2/ext3 filesystem
![]() |
Nota |
---|---|
A auto-montagem em ambientes de trabalho modernos apenas acontece quando
esses dispositivos amovíveis não estão listados em
" |
![]() |
Dica |
---|---|
When providing wrong mount option causes problem, erase its corresponding
setting under " |
Tabela 10.4. Lista de pacotes que permitem aos utilizadores normais montarem dispositivos
amovíveis sem uma entrada correspondente no "/etc/fstab
"
pacote | popcon | tamanho | descrição |
---|---|---|---|
gnome-mount *
|
V:15, I:28 | NOT_FOUND | wrapper para (des)montar e ejectar dispositivos de armazenamento (usado pelo GNOME) |
pmount *
|
V:4, I:19 | 548 | montar dispositivos amovíveis como utilizador normal (usado pelo KDE) |
cryptmount *
|
V:0.2, I:0.5 | 360 | Gestão e montagem em modo de utilizador de sistemas de ficheiros encriptados |
usbmount *
|
V:0.4, I:1.4 | 112 | montar e desmontar automaticamente dispositivos de armazenamento USB |
Quando partilha dados com outros sistemas via dispositivos de armazenamento amovível, você deve formatá-lo num sistema de ficheiros comum que seja suportado pelos dois sistemas. Aqui está uma lista de escolhas de sistemas de ficheiros.
Tabela 10.5. Lista de hipóteses de sistemas de ficheiros para dispositivos de armazenamento amovíveis com cenários de utilização típica
sistema de ficheiros | descrição do cenário de utilização típico |
---|---|
FAT12 | partilha de dados em várias plataformas em disquetes (<32MiB) |
FAT16 | partilha de dados em várias plataformas em dispositivos como pequenos discos rijos (<2GiB) |
FAT32 | partilha de dados em várias plataformas em dispositivos como grandes discos rijos (<8TiB, suportado por mais recente que MS Windows95 OSR2) |
NTFS | partilha de dados em várias plataformas em dispositivos como grandes discos rijos (suportado nativamente no MS Windows NT e versões posteriores, e suportado pelo NTFS-3G via FUSE em Linux) |
ISO9660 | partilha de dados estáticos em várias plataformas em CD-R e DVD+/-R |
UDF | escrita de dados incremental em CD-R e DVD+/-R (novo) |
sistema de ficheiros MINIX | armazenamento de dados em ficheiros unix eficiente em espaço em disquetes |
sistema de ficheiros ext2 | partilha de dados em dispositivos tipo disco rijo com sistemas Linux mais antigos |
sistema de ficheiros ext3 | partilha de dados em dispositivos tipo disco rijo com sistemas Linux actuais (sistema de ficheiros com journal) |
![]() |
Dica |
---|---|
Veja Secção 9.4.1, “Encriptação de discos amovíveis com dm-crypt/LUKS” para partilha de dados em várias plataformas usando encriptação ao nível do dispositivo. |
O sistema de ficheiros FAT é suportado pela maioria dos sistemas operativos modernos e é bastante útil para objectivos de trocas de dados via dispositivos tipo disco rijo.
When formatting removable hard disk like devices for cross platform sharing of data with the FAT filesystem, the following should be safe choices.
Partitioning them with fdisk
(8),
cfdisk
(8) or parted
(8) (see Secção 9.3.1, “Configuração das partições do disco”) into a single primary partition
and to mark it as the following.
Formatar a partição primária com o mkfs.vfat
(8) com o
seguinte.
/dev/sda1
" para
FAT16
-F 32
/dev/sda1
" for FAT32
Quando se usa sistemas de ficheiros FAT ou ISO9660 para partilhar dados, as considerações de segurança deverão ser as seguintes.
tar
(1),
cpio
(1), or afio
(1) to retain the long
filename, the symbolic link, the original Unix file permission and the owner
information.
split
(1) command to protect it from the file size
limitation.
![]() |
Nota |
---|---|
For FAT filesystems by its design, the maximum file size is |
![]() |
Nota |
---|---|
Microsoft itself does not recommend to use FAT for drives or partitions of over 200 MB. Microsoft highlights its short comings such as inefficient disk space usage in their "Overview of FAT, HPFS, and NTFS File Systems". Of course, we should normally use the ext3 filesystem for Linux. |
![]() |
Dica |
---|---|
Para mais sistemas de ficheiros e acesso a sistemas de ficheiros, por favor leia "HOWTO dos Sistemas de Ficheiros". |
Quando se partilha dados com outro sistema via rede, você deve usar serviços comuns. Aqui estão algumas dicas.
Tabela 10.6. Lista de serviços de rede para escolher com o cenário de utilização típico
serviço de rede | descrição do cenário de utilização típico |
---|---|
SMB/CIFS sistema de ficheiros montado em rede com o Samba |
sharing files via "Microsoft Windows Network", see
smb.conf (5) and The Official Samba 3.2.x HOWTO and
Reference Guide or the samba-doc package
|
NFS sistema de ficheiros montado em rede com o kernel do Linux. |
sharing files via "Unix/Linux Network", see exports (5)
and Linux NFS-HOWTO
|
serviço HTTP | partilhando ficheiros entre o servidor/cliente web |
serviço HTTPS | sharing file between the web server/client with encrypted Secure Sockets Layer (SSL) or Transport Layer Security (TLS) |
serviço FTP | partilhando ficheiros entre o servidor/cliente FTP |
Although these filesystems mounted over network and file transfer methods over network are quite convenient for sharing data, these may be insecure. Their network connection must be secured by the following.
Veja também Secção 6.10, “Outras aplicações de servidor de rede” e Secção 6.11, “Outros clientes de aplicação de rede”.
When choosing computer data storage media for important data archive, you should be careful about their limitations. For small personal data backup, I use CD-R and DVD-R by the brand name company and store in a cool, shaded, dry, clean environment. (Tape archive media seem to be popular for professional use.)
![]() |
Nota |
---|---|
A fire-resistant safe are meant for paper documents. Most of the computer data storage media have less temperature tolerance than paper. I usually rely on multiple secure encrypted copies stored in multiple secure locations. |
Optimistic storage life of archive media seen on the net (mostly from vendor info).
Estes não contam com falhas mecânicas devido a manuseamento e etc.
Optimistic write cycle of archive media seen on the net (mostly from vendor info).
![]() |
Cuidado |
---|---|
Figures of storage life and write cycle here should not be used for decisions on any critical data storage. Please consult the specific product information provided by the manufacture. |
![]() |
Dica |
---|---|
Since CD/DVD-R and paper have only 1 write cycle, they inherently prevent accidental data loss by overwriting. This is advantage! |
![]() |
Dica |
---|---|
If you need fast and frequent backup of large amount of data, a hard disk on a remote host linked by a fast network connection, may be the only realistic option. |
Aqui discutimos manipulações da imagem do disco. Veja também Secção 9.3, “Dicas de armazenamento de dados”.
O ficheiro de imagem de disco, "disco.img
", de um
dispositivo não montado, ex., a segunda drive SCSI
"/dev/sdb
", pode ser feito usando o
cp
(1) ou o dd
(1) com o seguinte.
# cp /dev/sdb disco.img # dd if=/dev/sdb of=disco.img
The disk image of the traditional PC's master boot record (MBR) (see Secção 9.3.1, “Configuração das partições do disco”) which reside on the first sector
on the primary IDE disk can be made by using dd
(1) by the
following.
# dd if=/dev/hda of=mbr.img bs=512 count=1 # dd if=/dev/hda of=mbr-nopart.img bs=446 count=1 # dd if=/dev/hda of=mbr-part.img skip=446 bs=1 count=66
mbr.img
": O MBR com a tabela de partições
mbr-nopart.img
": O MBR sem a tabela de partições
part.img
": A tabela de partições apenas do MBR
If you have a SCSI device (including the new serial ATA drive) as the boot
disk, substitute "/dev/hda
" with
"/dev/sda
".
If you are making an image of a disk partition of the original disk,
substitute "/dev/hda
" with "/dev/hda1
"
etc.
The disk image file, "disk.img
" can be written to an
unmounted device, e.g., the second SCSI drive "/dev/sdb
"
with matching size, by the following.
# dd if=disco.img of=/dev/sdb
Similarly, the disk partition image file, "partition.img
"
can be written to an unmounted partition, e.g., the first partition of the
second SCSI drive "/dev/sdb1
" with matching size, by the
following.
# dd if=partition.img of=/dev/sdb1
The disk image "partition.img
" containing a single
partition image can be mounted and unmounted by using the loop device as follows.
# losetup -v -f partition.img Loop device is /dev/loop0 # mkdir -p /mnt/loop0 # mount -t auto /dev/loop0 /mnt/loop0 ...hack...hack...hack # umount /dev/loop0 # losetup -d /dev/loop0
Isto pode ser simplificado como se segue.
# mkdir -p /mnt/loop0 # mount -t auto -o loop partition.img /mnt/loop0 ...hack...hack...hack # umount partition.img
Each partition of the disk image "disk.img
" containing
multiple partitions can be mounted by using the loop device. Since the loop device does not
manage partitions by default, we need to reset it as follows.
# modinfo -p loop # verify kernel capability max_part:Maximum number of partitions per loop device max_loop:Maximum number of loop devices # losetup -a # verify nothing using the loop device # rmmod loop # modprobe loop max_part=16
Agora, o dispositivo loop pode lidar com 16 partições (máximo).
# losetup -v -f disk.img Loop device is /dev/loop0 # fdisk -l /dev/loop0 Disk /dev/loop0: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x452b6464 Device Boot Start End Blocks Id System /dev/loop0p1 1 600 4819468+ 83 Linux /dev/loop0p2 601 652 417690 83 Linux # mkdir -p /mnt/loop0p1 # mount -t ext3 /dev/loop0p1 /mnt/loop0p1 # mkdir -p /mnt/loop0p2 # mount -t ext3 /dev/loop0p2 /mnt/loop0p2 ...hack...hack...hack # umount /dev/loop0p1 # umount /dev/loop0p2 # losetup -d /dev/loop0
Alternatively, similar effects can be done by using the device mapper devices created by
kpartx
(8) from the kpartx
package as
follows.
# kpartx -a -v disk.img ... # mkdir -p /mnt/loop0p2 # mount -t ext3 /dev/mapper/loop0p2 /mnt/loop0p2 ... ...hack...hack...hack # umount /dev/mapper/loop0p2 ... # kpartx -d /mnt/loop0
![]() |
Nota |
---|---|
You can mount a single partition of such disk image with loop device using offset to skip MBR etc., too. But this is more error prone. |
A disk image file, "disk.img
" can be cleaned of all
removed files into clean sparse image "new.img
" by the
following.
# mkdir old; mkdir new # mount -t auto -o loop disk.img old # dd bs=1 count=0 if=/dev/zero of=new.img seek=5G # mount -t auto -o loop new.img new # cd old # cp -a --sparse=always ./ ../new/ # cd .. # umount new.img # umount disk.img
Se o "disco.img
" está em ext2 ou ext3, você também pode
usar o zerofree
(8) do pacote zerofree
como se segue.
# losetup -f -v disco.img Loop device is /dev/loop3 # zerofree /dev/loop3 # cp --sparse=always disco.img novo.img
A imagem de disco vazia "disco.img
" que pode crescer até
aos 5GiB pode ser feita usando o dd
(1) como se segue.
$ dd bs=1 count=0 if=/dev/zero of=disco.img seek=5G
You can create an ext3 filesystem on this disk image
"disk.img
" using the loop
device as follows.
# losetup -f -v disco.img Loop device is /dev/loop1 # mkfs.ext3 /dev/loop1 ...hack...hack...hack # losetup -d /dev/loop1 $ du --apparent-size -h disco.img 5.0G disco.img $ du -h disco.img 83M disco.img
For "disk.img
", its file size is 5.0 GiB and its actual
disk usage is mere 83MiB. This discrepancy is possible since ext2fs can hold sparse
file.
![]() |
Dica |
---|---|
The actual disk usage of sparse file grows with data which are written to it. |
Using similar operation on devices created by the loop device or the device mapper devices as Secção 10.2.3, “Montar o ficheiro de imagem de disco”, you can partition this disk image
"disk.img
" using parted
(8) or
fdisk
(8), and can create filesystem on it using
mkfs.ext3
(8), mkswap
(8), etc.
The ISO9660 image file,
"cd.iso
", from the source directory tree at
"source_directory
" can be made using
genisoimage
(1) provided by cdrkit by the following.
# genisoimage -r -J -T -V volume_id -o cd.iso directório_fonte
Similarly, the bootable ISO9660 image file, "cdboot.iso
",
can be made from debian-installer
like directory tree at
"source_directory
" by the following.
# genisoimage -r -o cdboot.iso -V volume_id \ -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table source_directory
Here Isolinux boot loader (see Secção 3.3, “Estágio 2: o gestor de arranque”) is used for booting.
You can calculate the md5sum value and make the ISO9660 image directly from the CD-ROM device as follows.
$ isoinfo -d -i /dev/cdrom CD-ROM is in ISO 9660 format ... Logical block size is: 2048 Volume size is: 23150592 ... # dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror | md5sum # dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror > cd.iso
![]() |
Atenção |
---|---|
You must carefully avoid ISO9660 filesystem read ahead bug of Linux as above to get the right result. |
![]() |
Dica |
---|---|
Um DVD é apenas um CD grande para o |
Você pode procurar um dispositivo utilizável com o seguinte.
# wodim --devices
Then the blank CD-R is inserted to the CD drive, and the ISO9660 image file,
"cd.iso
" is written to this device, e.g.,
"/dev/hda
", using wodim
(1) by the
following.
# wodim -v -eject dev=/dev/hda cd.iso
Se for usado um CD-RW em vez de um CD-R, faça antes o seguinte.
# wodim -v -eject blank=fast dev=/dev/hda cd.iso
![]() |
Dica |
---|---|
Se o seu ambiente montar CDs automaticamente, desmonte-o com " |
If "cd.iso
" contains an ISO9660 image, then the following
manually mounts it to "/cdrom
".
# mount -t iso9660 -o ro,loop cd.iso /cdrom
![]() |
Dica |
---|---|
Modern desktop system mounts removable media automatically (see Secção 10.1.10, “Dispositivo de armazenamento amovível”). |
Here, we discuss direct manipulations of the binary data on storage media. See Secção 9.3, “Dicas de armazenamento de dados”, too.
The most basic viewing method of binary data is to use "od -t
x1
" command.
Tabela 10.7. Lista de pacote para ver e editar dados binários
pacote | popcon | tamanho | descrição |
---|---|---|---|
coreutils *
|
V:92, I:99 | 13828 |
basic package which has od (1) to dump files (HEX, ASCII,
OCTAL, …)
|
bsdmainutils *
|
V:81, I:99 | 768 |
utility package which has hd (1) to dump files (HEX,
ASCII, OCTAL, …)
|
hexedit *
|
V:0.3, I:1.9 | 108 | editor binário e visualizador (HEX, ASCII) |
bless
*
|
V:0.08, I:0.3 | 1232 | editor hexadecimal cheiro de funcionalidades (GNOME) |
okteta *
|
V:0.4, I:3 | 2528 | editor hexadecimal cheiro de funcionalidades (KDE4) |
ncurses-hexedit *
|
V:0.07, I:0.5 | 192 | editor binário e visualizador (HEX, ASCII, EBCDIC) |
lde
*
|
V:0.04, I:0.3 | 992 | Editor de Disco de Linux |
beav
*
|
V:0.03, I:0.3 | 164 | editor binário e visualizador (HEX, ASCII, EBCDIC, OCTAL, …) |
hex
*
|
V:0.01, I:0.09 | 84 | hexadecimal dumping tool (support Japanese 2 byte codes) |
![]() |
Dica |
---|---|
HEX is used as an acronym for hexadecimal format with radix 16. OCTAL is for octal format with radix 8. ASCII is for American Standard Code for Information Interchange, i.e., normal English text code. EBCDIC is for Extended Binary Coded Decimal Interchange Code used on IBM mainframe operating systems. |
Existem ferramentas para ler e escrever ficheiros sem montar o disco.
Software RAID systems offered by the Linux kernel provide data redundancy in the kernel filesystem level to achieve high levels of storage reliability.
There are tools to add data redundancy to files in application program level to achieve high levels of storage reliability, too.
Tabela 10.9. Lista de ferramentas para adicionar redundância de dados a ficheiros
pacote | popcon | tamanho | descrição |
---|---|---|---|
par2
*
|
V:0.5, I:1.7 | 272 | Parity Archive Volume Set, for checking and repair of files |
dvdisaster *
|
V:0.14, I:0.7 | 1388 | data loss/scratch/aging protection for CD/DVD media |
dvbackup *
|
V:0.01, I:0.09 | 544 |
ferramenta de backup que usa câmaras de filmar MiniDV (disponibilizando
rsbep (1))
|
vdmfec *
|
V:0.00, I:0.02 | 88 | recuperar blocos perdidos usando o Forward Error Correction |
Existem ferramentas para recuperação de ficheiros e dados e análise forense.
Tabela 10.10. Lista de pacotes para recuperação de ficheiros e dados e análise forense
pacote | popcon | tamanho | descrição |
---|---|---|---|
testdisk *
|
V:0.3, I:3 | 4620 | utilitários para sondagem de partições e recuperação de discos |
magicrescue *
|
V:0.07, I:0.5 | 344 | utilitário para recuperar ficheiros ao procurar por bytes mágicos |
scalpel *
|
V:0.03, I:0.2 | 124 | frugal, entalhador de ficheiros de alta performance |
myrescue *
|
V:0.02, I:0.18 | 84 | recuperar dados de discos rijos danificados |
recover *
|
V:0.07, I:0.6 | 104 | utilitários para recuperar ficheiros apagados no sistema de ficheiros ext2 |
e2undel *
|
V:0.07, I:0.5 | 244 | utilitários para recuperar ficheiros apagados no sistema de ficheiros ext2 |
ext3grep *
|
V:0.08, I:0.6 | 300 | ferramenta para ajudar a recuperar ficheiros apagados no sistema de ficheiros ext3 |
scrounge-ntfs *
|
V:0.03, I:0.4 | 80 | programa de recuperação de dados para sistemas de ficheiros NTFS |
gzrt
*
|
V:0.01, I:0.12 | 68 | conjunto de ferramentas de recuperação gzip |
sleuthkit *
|
V:0.13, I:0.7 | 540 | ferramentas para análise forense. (Sleuthkit) |
autopsy *
|
V:0.07, I:0.4 | 1372 | interface gráfica para o SleuthKit |
foremost *
|
V:0.11, I:0.8 | 140 | aplicação forense para recuperar dados |
guymager *
|
V:0.00, I:0.02 | 688 | ferramenta de imagem forense baseada em Qt |
tct
*
|
V:0.03, I:0.2 | 604 | utilitários relacionados com forenses |
dcfldd *
|
V:0.03, I:0.2 | 124 |
versão melhorada do dd para forenses e segurança
|
rdd
*
|
V:0.01, I:0.11 | 200 | programa de cópia forense |
When a data is too big to backup as a single file, you can backup its content after splitting it into, e.g. 2000MiB chunks and merge those chunks back into the original file later.
$ split -b 2000m ficheiro_grande $ cat x* >ficheiro_grande
![]() |
Cuidado |
---|---|
Por favor certifique-se que não tem nenhuns ficheiros que começam com
" |
In order to clear the contents of a file such as a log file, do not use
rm
(1) to delete the file and then create a new empty
file, because the file may still be accessed in the interval between
commands. The following is the safe way to clear the contents of the file.
$ :>ficheiro_a_ser_limpo
Os seguintes comandos criam ficheiros dummy ou vazios.
$ dd if=/dev/zero of=5kb.file bs=1k count=5 $ dd if=/dev/urandom of=7mb.file bs=1M count=7 $ touch zero.file $ : > alwayszero.file
Você deve encontrar os seguintes ficheiros.
5kb.file
" é 5KB de zeros.
7mb.file
" são 7MB de dados aleatórios.
zero.file
" pode ser um ficheiro de 0 bytes. Se existir,
o seu mtime
é actualizado enquanto o seu conteúdo e
tamanho são mantidos.
alwayszero.file
" é sempre um ficheiro de 0 bytes. Se
existir, o seu mtime
é actualizado e o seu conteúdo é
reposto.
Existem várias maneiras de apagar completamente os dados de um dispositivo
inteiro tipo disco rijo, ex., stick de memória USB em
"/dev/sda
".
![]() |
Cuidado |
---|---|
Check your USB memory stick location with |
Apagar todo o conteúdo do disco ao repor os dados a 0 com o seguinte.
# dd if=/dev/zero of=/dev/sda
Apagar tudo ao sobrescrever dados aleatórios com o seguinte.
# dd if=/dev/urandom of=/dev/sda
Apagar tudo ao sobrescrever dados aleatórios muito eficientemente com o seguinte.
# shred -v -n 1 /dev/sda
Since dd
(1) is available from the shell of many bootable
Linux CDs such as Debian installer CD, you can erase your installed system
completely by running an erase command from such media on the system hard
disk, e.g., "/dev/hda
", "/dev/sda
",
etc.
Unused area on an hard disk (or USB memory stick),
e.g. "/dev/sdb1
" may still contain erased data themselves
since they are only unlinked from the filesystem. These can be cleaned by
overwriting them.
# mount -t auto /dev/sdb1 /mnt/foo # cd /mnt/foo # dd if=/dev/zero of=junk dd: writing to `junk': No space left on device ... # sync # umount /dev/sdb1
![]() |
Atenção |
---|---|
Normalmente isto é suficientemente bom para o seu stick de memória USB. Mas não é perfeito. A maioria das partes dos nomes de ficheiros apagados e os seus atributos podem ficar escondidos e permanecerem no sistema de ficheiros. |
Mesmo que tenha acidentalmente apagado um ficheiro, desde que esse ficheiro esteja ainda a ser usado por alguma aplicação (em modo de leitura ou escrita), é possível recuperar tal ficheiro.
Por exemplo, tente o seguinte
$ echo foo > bar $ less bar $ ps aux | grep ' less[ ]' bozo 4775 0.0 0.0 92200 884 pts/8 S+ 00:18 0:00 less bar $ rm bar $ ls -l /proc/4775/fd | grep bar lr-x------ 1 bozo bozo 64 2008-05-09 00:19 4 -> /home/bozo/bar (apagado) $ cat /proc/4775/fd/4 >bar $ ls -l -rw-r--r-- 1 bozo bozo 4 2008-05-09 00:25 bar $ cat bar foo
Execute em outro terminal (quando tem o pacote lsof
instalado) o seguinte.
$ ls -li bar 2228329 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:02 bar $ lsof |grep bar|grep less less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar $ rm bar $ lsof |grep bar|grep less less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar (apagado) $ cat /proc/4775/fd/4 >bar $ ls -li bar 2228302 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:05 bar $ cat bar foo
Os ficheiros com hardlinks podem ser identificados com "ls
-li
".
$ ls -li total 0 2738405 -rw-r--r-- 1 root root 0 2008-09-15 20:21 bar 2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 baz 2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 foo
Ambos "baz
" e "foo
" têm contagens de
link de "2" (>1) mostrando que têm hardlinks. Os números de inode deles são comuns "2738404". Isto significa que
eles são o mesmo ficheiro em hardlink. Se você não encontrar todos os
ficheiros em hardlink por acaso, pode procurá-los pelo inode, ex., "2738404" com o seguinte.
# find /caminho/para/ponto/de/montagem -xdev -inum 2738404
The data security infrastructure is provided by the combination of data encryption tool, message digest tool, and signature tool.
Tabela 10.11. Lista de ferramentas de infraestrutura da segurança de dados
comando | pacote | popcon | tamanho | descrição |
---|---|---|---|---|
gpg (1)
|
gnupg
*
|
V:43, I:99 | 5288 | GNU Privacy Guard - OpenPGP encryption and signing tool |
N/D |
gnupg-doc *
|
I:1.1 | 4124 | GNU Privacy Guard documentation |
gpgv (1)
|
gpgv
*
|
V:59, I:99 | 436 | GNU Privacy Guard - signature verification tool |
paperkey (1)
|
paperkey *
|
V:0.01, I:0.10 | 88 | extract just the secret information out of OpenPGP secret keys |
cryptsetup (8), …
|
cryptsetup *
|
V:3, I:5 | 1172 | utilities for dm-crypto block device encryption supporting LUKS |
ecryptfs (7), …
|
ecryptfs-utils *
|
V:0.2, I:0.3 | 416 | utilities for ecryptfs stacked filesystem encryption |
md5sum (1)
|
coreutils *
|
V:92, I:99 | 13828 | computa e verifica o resumo da mensagem MD5 |
sha1sum (1)
|
coreutils *
|
V:92, I:99 | 13828 | computa e verifica o resumo da mensagem SHA1 |
openssl (1ssl)
|
openssl *
|
V:56, I:91 | 2380 |
computa o resumo da mensagem com "openssl dgst " (OpenSSL)
|
See Secção 9.4, “Dicas de encriptação de dados” on dm-crypto and ecryptfs which implement automatic data encryption infrastructure via Linux kernel modules.
Aqui estão comandos do GNU Privacy Guard para gestão de chaves básica.
Tabela 10.12. Lista de comandos do GNU Privacy Guard para gestão de chaves
comando | descrição |
---|---|
gpg --gen-key
|
gerar uma chave nova |
gpg --gen-revoke meu_ID_utilizador
|
gera chave de revogação para meu_ID_utilizador |
gpg --edit-key ID_utilizador
|
edita chave interactivamente, "help" para ajuda |
gpg -o ficheiro --exports
|
exporta todas as chaves para ficheiro |
gpg --imports ficheiro
|
importa todas as chaves de ficheiro |
gpg --send-keys ID_utilizador
|
envia chave de ID_utilizador para servidor de chaves |
gpg --recv-keys ID_utilizador
|
recupera chave de ID_utilizador do servidor de chaves |
gpg --list-keys ID_utilizador
|
lista chaves de ID_utilizador |
gpg --list-sigs ID_utilizador
|
lista assinaturas de ID_utilizador |
gpg --check-sigs ID_utilizador
|
verifica assinaturas de ID_utilizador |
gpg --fingerprint ID_utilizador
|
verifica a impressão digital de ID_utilizador |
gpg --refresh-keys
|
actualiza o chaveiro local |
Aqui está o significado do código de confiança
Tabela 10.13. Lista do significado do código de confiança
código | descrição de confiança |
---|---|
-
|
nenhuma confiança de dono atribuída / ainda não calculado |
e
|
falha no cálculo da confiança |
q
|
não existe informação suficiente para o cálculo |
n
|
nunca confiar nesta chave |
m
|
marginalmente confiável |
f
|
totalmente confiável |
u
|
de confiança absoluta |
The following uploads my key "1DD8D791
" to the popular
keyserver "hkp://keys.gnupg.net
".
$ gpg --keyserver hkp://keys.gnupg.net --send-keys 1DD8D791
A good default keyserver set up in "~/.gnupg/gpg.conf
"
(or old location "~/.gnupg/options
") contains the
following.
keyserver hkp://keys.gnupg.net
O seguinte obtém chaves desconhecidas do servidor de chaves.
$ gpg --list-sigs --with-colons | grep '^sig.*\[User ID not found\]' |\ cut -d ':' -f 5| sort | uniq | xargs gpg --recv-keys
There was a bug in OpenPGP Public Key
Server (pre version 0.9.6) which corrupted key with more than 2
sub-keys. The newer gnupg
(>1.2.1-2) package can
handle these corrupted subkeys. See gpg
(1) under
"--repair-pks-subkey-bug
" option.
Here are examples for using GNU Privacy Guard commands on files.
Tabela 10.14. List of GNU Privacy Guard commands on files
comando | descrição |
---|---|
gpg -a -s ficheiro
|
sign file into ASCII armored file.asc |
gpg --armor --sign ficheiro
|
, , |
gpg --clearsign ficheiro
|
clear-sign message |
gpg --clearsign file|mail foo@example.org
|
mail a clear-signed message to foo@example.org
|
gpg --clearsign --not-dash-escaped patchfile
|
clear-sign patchfile |
gpg --verify ficheiro
|
verify clear-signed file |
gpg -o ficheiro.sig -b ficheiro
|
create detached signature |
gpg -o ficheiro.sig --detach-sig ficheiro
|
, , |
gpg --verify ficheiro.sig ficheiro
|
verify file with file.sig |
gpg -o crypt_file.gpg -r name -e file
|
public-key encryption intended for name from file to binary crypt_file.gpg |
gpg -o crypt_file.gpg --recipient name --encrypt file
|
, , |
gpg -o crypt_file.asc -a -r name -e file
|
public-key encryption intended for name from file to ASCII armored crypt_file.asc |
gpg -o crypt_file.gpg -c file
|
symmetric encryption from file to crypt_file.gpg |
gpg -o crypt_file.gpg --symmetric file
|
, , |
gpg -o crypt_file.asc -a -c file
|
symmetric encryption intended for name from file to ASCII armored crypt_file.asc |
gpg -o file -d crypt_file.gpg -r name
|
desencriptação |
gpg -o file --decrypt crypt_file.gpg
|
, , |
Add the following to "~/.muttrc
" to keep a slow GnuPG
from automatically starting, while allowing it to be used by typing
"S
" at the index menu.
macro index S ":toggle pgp_verify_sig\n" set pgp_verify_sig=no
The gnupg
plugin let you run GnuPG transparently for
files with extension ".gpg
", ".asc
",
and ".ppg
".
# aptitude install vim-scripts vim-addon-manager $ vim-addons install gnupg
md5sum
(1) provides utility to make a digest file using
the method in rfc1321 and verifying each file
with it.
$ md5sum foo bar >baz.md5 $ cat baz.md5 d3b07384d113edec49eaa6238ad5ff00 foo c157a79031e1c40f85931829bc5fc552 bar $ md5sum -c baz.md5 foo: OK bar: OK
![]() |
Nota |
---|---|
The computation for the MD5 sum is less CPU intensive than the one for the cryptographic signature by GNU Privacy Guard (GnuPG). Usually, only the top level digest file is cryptographically signed to ensure data integrity. |
There are many merge tools for the source code. Following commands caught my eyes.
Tabela 10.15. Lista de ferramentas de fusão de código fonte
comando | pacote | popcon | tamanho | descrição |
---|---|---|---|---|
diff (1)
|
diff
*
|
V:68, I:85 | 36 | compara ficheiros linha a linha |
diff3 (1)
|
diff
*
|
V:68, I:85 | 36 | compara e funde três ficheiros linha a linha |
vimdiff (1)
|
vim
*
|
V:15, I:33 | 1792 | compara dois ficheiros lado a lado no vim |
patch (1)
|
patch
*
|
V:10, I:92 | 244 | aplica ficheiro diff a um original |
dpatch (1)
|
dpatch *
|
V:1.4, I:11 | 344 | gere séries de patches para pacote Debian |
diffstat (1)
|
diffstat *
|
V:2, I:15 | 92 | produz um histograma de alterações feitas pelo diff |
combinediff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | cria uma patch cumulativa de duas patches incrementais |
dehtmldiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | extrai um diff de uma página HTML |
filterdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | extrai ou executa diffs de um ficheiro diff |
fixcvsdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 |
corrige ficheiros diff criados pelo CVS que o patch (1)
interpreta mal
|
flipdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | troca a ordem de duas patches |
grepdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | mostra que ficheiros são modificados por uma patch que corresponde a um regex |
interdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | mostra as diferenças entre dois ficheiros diff unificados |
lsdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | mostra quais ficheiros são modificados por uma patch |
recountdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | recompute counts and offsets in unified context diffs |
rediff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | fix offsets and counts of a hand-edited diff |
splitdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | separa patches incrementais |
unwrapdiff (1)
|
patchutils *
|
V:1.8, I:14 | 292 | demangle patches that have been word-wrapped |
wiggle (1)
|
wiggle *
|
V:0.01, I:0.11 | 232 | aplica patches rejeitadas |
quilt (1)
|
quilt
*
|
V:1.5, I:9 | 872 | gere séries de patches |
meld (1)
|
meld
*
|
V:0.7, I:2 | 2576 | compara e funde ficheiros (GTK) |
xxdiff (1)
|
xxdiff *
|
V:0.2, I:1.3 | 1352 | compara e funde ficheiros (X simples) |
dirdiff (1)
|
dirdiff *
|
V:0.08, I:0.6 | 224 | mostra diferenças e funde alterações entre árvores de directórios |
docdiff (1)
|
docdiff *
|
V:0.01, I:0.14 | 688 | compara dois ficheiros palavra a palavra / caractere a caractere |
imediff2 (1)
|
imediff2 *
|
V:0.02, I:0.10 | 76 | ferramenta de fusão de 2 vias interactiva de écran completo |
makepatch (1)
|
makepatch *
|
V:0.01, I:0.17 | 148 | gera ficheiros de patch extensos |
applypatch (1)
|
makepatch *
|
V:0.01, I:0.17 | 148 | aplica ficheiros de patch extensos |
wdiff (1)
|
wdiff
*
|
V:1.6, I:14 | 1024 | mostra diferenças de palavras entre ficheiros de texto |
One of following procedures extract differences between two source files and
create unified diff files "file.patch0
" or
"file.patch1
" depending on the file location.
$ diff -u ficheiro.antigo ficheiro.novo > ficheiro.patch0 $ diff -u antigo/ficheiro novo/ficheiro > ficheiro.patch1
The diff file (alternatively called patch file) is used to send a program update. The receiving party applies this update to another file by the following.
$ patch -p0 ficheiro < ficheiro.patch0 $ patch -p1 ficheiro < ficheiro.patch1
Aqui está um sumário dos sistemas de controle de versão (VCS) no sistema Debian.
![]() |
Nota |
---|---|
Se você é novato nos sistemas VCS, deverá começar a aprender com o Git, o qual está a crescer rapidamente na popularidade. |
Tabela 10.16. lista de ferramentas de sistemas de controle de versão
pacote | popcon | tamanho | ferramenta | Tipo VCS | comentário |
---|---|---|---|---|---|
cssc
*
|
V:0.00, I:0.04 | 2240 | CSSC | local | clone do SCCS do Unix (descontinuado) |
rcs
*
|
V:1.3, I:7 | 772 | RCS | local | "SCCS do Unix bem feito" |
cvs
*
|
V:3, I:21 | 3660 | CVS | remoto | VCS remoto standard anterior |
subversion *
|
V:10, I:31 | 4288 | Subversion | remoto | "CVS bem feito", o novo VCS remoto standard "de facto" |
git
*
|
V:5, I:17 | 10632 | Git | distribuído | DVCS rápido em C (usado pelo kernel Linux e outros) |
mercurial *
|
V:1.8, I:6 | 368 | Mercurial | distribuído | DVCS em Python e algum C |
bzr
*
|
V:1.1, I:3 | 16220 | Bazaar | distribuído |
DVCS influenciado por tla escrito em Python (usado pelo
Ubuntu)
|
darcs
*
|
V:0.19, I:1.4 | 9504 | Darcs | distribuído | DVCS com algebra inteligente de patches (lento) |
tla
*
|
V:0.17, I:1.4 | 932 | GNU arch | distribuído | DVCS principalmente por Tom Lord (Histórico) |
monotone *
|
V:0.04, I:0.3 | 5272 | Monotone | distribuído | DVCS em C++ |
tkcvs
*
|
V:0.08, I:0.4 | 2476 | CVS, … | remoto | Mostrador GUI de árvores de repositório VCS (CVS, Subversion, RCS) |
gitk
*
|
V:0.8, I:4 | 900 | Git | distribuído | Mostrador GUI de árvores de repositório VCS (Git) |
VCS is sometimes known as revision control system (RCS), or software configuration management (SCM).
Distributed VCS such as Git is the tool of choice these days. CVS and Subversion may still be useful to join some existing open source program activities.
Debian provides free VCS services via Debian Alioth service. It supports practically all VCSs. Its documentation can be found at http://wiki.debian.org/Alioth .
![]() |
Cuidado |
---|---|
O pacote |
There are few basics for creating a shared access VCS archive.
umask 002
" (see Secção 1.2.4, “Control de permissões para ficheiros acabados de criar: umask”)
Here is an oversimplified comparison of native VCS commands to provide the big picture. The typical command sequence may require options and arguments.
Tabela 10.17. Comparação dos comandos VCS nativos
CVS | Subversion | Git | função |
---|---|---|---|
cvs init
|
svn create
|
git init
|
cria o repositório (local) |
cvs login
|
- | - | login ao repositório remoto |
cvs co
|
svn co
|
git clone
|
check out the remote repository as the working tree |
cvs up
|
svn up
|
git pull
|
update the working tree by merging the remote repository |
cvs add
|
svn add
|
git add .
|
adiciona ficheiro(s) na árvore de trabalho do VCS |
cvs rm
|
svn rm
|
git rm
|
remove ficheiro(s) na árvore de trabalho do VCS |
cvs ci
|
svn ci
|
- | comete alterações para o repositório remoto |
- | - |
git commit -a
|
comete alterações para o repositório local |
- | - |
git push
|
actualiza o repositório remoto pelo repositório local |
cvs status
|
svn status
|
git status
|
mostra o estado da árvore de trabalho do VCS |
cvs diff
|
svn diff
|
git diff
|
diff <reference_repository> <working_tree> |
- | - |
git repack -a -d; git prune
|
re-empacota o repositório local em um único pacote |
tkcvs
|
tkcvs
|
gitk
|
Mostrador GUI de árvore de repositório VCS |
![]() |
Cuidado |
---|---|
Invoking a |
![]() |
Dica |
---|---|
GUI tools such as |
![]() |
Dica |
---|---|
Git can work directly with different VCS repositories such as ones provided
by CVS and Subversion, and provides the local repository for local changes
with |
![]() |
Dica |
---|---|
Git has commands which have no equivalents in CVS and Subversion: "fetch", "rebase", "cherry-pick", … |
Veja o seguinte.
cvs
(1)
/usr/share/doc/cvs/html-cvsclient
"
/usr/share/doc/cvs/html-info
"
/usr/share/doc/cvsbook
"
info cvs
"
The following configuration allows commits to the CVS repository only by a
member of the "src
" group, and administration of CVS only
by a member of the "staff
" group, thus reducing the
chance of shooting oneself.
# cd /var/lib; umask 002; mkdir cvs # export CVSROOT=/srv/cvs/project # cd $CVSROOT # chown root:src . # chmod 2775 . # cvs -d $CVSROOT init # cd CVSROOT # chown -R root:staff . # chmod 2775 . # touch val-tags # chmod 664 history val-tags # chown root:src history val-tags
![]() |
Dica |
---|---|
You may restrict creation of new project by changing the owner of
" |
The default CVS repository is pointed by "$CVSROOT
". The
following sets up "$CVSROOT
" for the local access.
$ export CVSROOT=/srv/cvs/project
Many public CVS servers provide read-only remote access to them with account
name "anonymous
" via pserver service. For example,
Debian web site contents are maintained by webwml project via CVS at Debian alioth
service. The following sets up "$CVSROOT
" for the remote
access to this CVS repository.
$ export CVSROOT=:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/webwml $ cvs login
![]() |
Nota |
---|---|
Since pserver is prone to eavesdropping attack and insecure, write access is usually disable by server administrators. |
The following sets up "$CVS_RSH
" and
"$CVSROOT
" for the remote access to the CVS repository by
webwml project with SSH.
$ export CVS_RSH=ssh $ export CVSROOT=:ext:account@cvs.alioth.debian.org:/cvs/webwml
Você também pode usar autenticação de chave pública para SSH o que elimina o pedido remoto de palavra-passe.
Crie uma nova localização de árvore fonte local em
"~/caminho/para/module1
" com o seguinte.
$ mkdir -p ~/caminho/para/module1; cd ~/caminho/para/module1
Populate a new local source tree under
"~/path/to/module1
" with files.
Importe-o para o CVS com os seguintes parâmetros.
module1
"
Main-branch
" (etiqueta para o branch
completo)
Release-initial
" (etiqueta para um
lançamento específico)
$ cd ~/caminho/para/module1 $ cvs import -m "Start module1" module1 Main-branch Release-initial $ rm -Rf . # opcional
CVS does not overwrite the current repository file but replaces it with
another one. Thus, write permission to the repository directory is
critical. For every new module for "module1
" in
repository at "/srv/cvs/project
", run the following to
ensure this condition if needed.
# cd /srv/cvs/project # chown -R root:src module1 # chmod -R ug+rwX module1 # chmod 2775 module1
Aqui está um exemplo de um fluxo de trabalho típico usando CVS
Check all available modules from CVS project pointed by
"$CVSROOT
" by the following.
$ cvs rls CVSROOT module1 module2 ...
Checkout "module1
" to its default directory
"./module1
" by the following.
$ cd ~/caminho/para $ cvs co module1 $ cd module1
Faça as alterações necessárias ao conteúdo.
Check changes by making "diff -u [repository] [local]
"
equivalent by the following.
$ cvs diff -u
You find that you broke some file "file_to_undo
" severely
but other files are fine.
Overwrite "file_to_undo
" file with the clean copy from
CVS by the following.
$ cvs up -C file_to_undo
Save the updated local source tree to CVS by the following.
$ cvs ci -m "Describe change"
Create and add "file_to_add
" file to CVS by the
following.
$ vi file_to_add $ cvs add file_to_add $ cvs ci -m "Added file_to_add"
Merge the latest version from CVS by the following.
$ cvs up -d
Watch out for lines starting with "C filename
" which
indicates conflicting changes.
Look for unmodified code in ".#filename.version
".
Search for "<<<<<<<
" and
">>>>>>>
" in files for conflicting
changes.
Edit files to fix conflicts as needed.
Adicione uma etiqueta de lançamento "Release-1
" com o
seguinte.
$ cvs ci -m "last commit for Release-1" $ cvs tag Release-1
Continuar a editar.
Remova a etiqueta de lançamento "Release-1
" com o
seguinte.
$ cvs tag -d Release-1
Verifique as alterações no CVS com o seguinte.
$ cvs ci -m "real last commit for Release-1"
Re-add the release tag "Release-1
" to updated CVS HEAD of
main by the following.
$ cvs tag Release-1
Create a branch with a sticky branch tag
"Release-initial-bugfixes
" from the original version
pointed by the tag "Release-initial
" and check it out to
"~/path/to/old
" directory by the following.
$ cvs rtag -b -r Release-initial Release-initial-bugfixes module1 $ cd ~/path/to $ cvs co -r Release-initial-bugfixes -d old module1 $ cd old
![]() |
Dica |
---|---|
Use " |
Work on this local source tree having the sticky tag
"Release-initial-bugfixes
" which is based on the original
version.
Work on this branch by yourself … until someone else joins to this
"Release-initial-bugfixes
" branch.
Sync with files modified by others on this branch while creating new directories as needed by the following.
$ cvs up -d
Edit files to fix conflicts as needed.
Verifique as alterações no CVS com o seguinte.
$ cvs ci -m "checked into this branch"
Update the local tree by HEAD of main while removing sticky tag
("-A
") and without keyword expansion
("-kk
") by the following.
$ cvs up -d -kk -A
Update the local tree (content = HEAD of main) by merging from the
"Release-initial-bugfixes
" branch and without keyword
expansion by the following.
$ cvs up -d -kk -j Release-initial-bugfixes
Corrigir conflitos com o editor.
Verifique as alterações no CVS com o seguinte.
$ cvs ci -m "merged Release-initial-bugfixes"
Criar arquivo com o seguinte.
$ cd .. $ mv old old-module1-bugfixes $ tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes $ rm -rf old-module1-bugfixes
![]() |
Dica |
---|---|
" |
![]() |
Dica |
---|---|
You can checkout only a sub directory of " |
Tabela 10.18. Notable options for CVS commands (use as first argument(s) to
cvs
(1))
opção | significado |
---|---|
-n
|
dry run, no effect |
-t
|
display messages showing steps of cvs activity |
To get the latest files from CVS, use "tomorrow
" by the
following.
$ cvs ex -D tomorrow module_name
Add module alias "mx
" to a CVS project (local server) by
the following.
$ export CVSROOT=/srv/cvs/project $ cvs co CVSROOT/modules $ cd CVSROOT $ echo "mx -a module1" >>modules $ cvs ci -m "Now mx is an alias for module1" $ cvs release -d .
Now, you can check out "module1
" (alias:
"mx
") from CVS to "new
" directory by
the following.
$ cvs co -d new mx $ cd new
![]() |
Nota |
---|---|
In order to perform above procedure, you should have appropriate file permissions. |
When you checkout files from CVS, their execution permission bit is retained.
Whenever you see execution permission problems in a checked out file,
e.g. "filename
", change its permission in the
corresponding CVS repository by the following to fix it.
# chmod ugo-x nome_de_ficheiro
Subversion is a recent-generation version control system replacing older CVS. It has most of CVS's features except tags and branches.
You need to install subversion
,
libapache2-svn
and subversion-tools
packages to set up a Subversion server.
Currently, the subversion
package does not set up a
repository, so one must set it up manually. One possible location for a
repository is in "/srv/svn/project
".
Crie um directório com o seguinte.
# mkdir -p /srv/svn/project
Crie a base de dados do repositório com o seguinte.
# svnadmin create /srv/svn/project
If you only access Subversion repository via Apache2 server, you just need to make the repository only writable by the WWW server by the following.
# chown -R www-data:www-data /srv/svn/project
Add (or uncomment) the following in
"/etc/apache2/mods-available/dav_svn.conf
" to allow
access to the repository via user authentication.
<Location /project> DAV svn SVNPath /srv/svn/project AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/subversion/passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>
Crie um ficheiro de autenticação de utilizador com o comando com o seguinte.
# htpasswd2 -c /etc/subversion/passwd algum_nome_de_utilizador
Reiniciar o Apache2
Your new Subversion repository is accessible at URL
"http://localhost/project
" and
"http://example.com/project
" from
svn
(1) (assuming your URL of web server is
"http://example.com/
").
The following sets up Subversion repository for the local access by a group,
e.g. project
.
# chmod 2775 /srv/svn/project # chown -R root:src /srv/svn/project # chmod -R ug+rwX /srv/svn/project
Your new Subversion repository is group accessible at URL
"file:///localhost/srv/svn/project
" or
"file:///srv/svn/project
" from svn
(1)
for local users belonging to project
group. You must run
commands, such as svn
, svnserve
,
svnlook
, and svnadmin
under
"umask 002
" to ensure group access.
A group accessible Subversion repository is at URL
"example.com:/srv/svn/project
" for SSH, you can access it
from svn
(1) at URL
"svn+ssh://example.com:/srv/svn/project
".
Many projects uses directory tree similar to the following for Subversion to compensate its lack of branches and tags.
----- module1 | |-- branches | |-- tags | | |-- release-1.0 | | `-- release-2.0 | | | `-- trunk | |-- file1 | |-- file2 | `-- file3 | `-- module2
![]() |
Dica |
---|---|
You must use " |
Crie uma nova localização de árvore fonte local em
"~/caminho/para/module1
" com o seguinte.
$ mkdir -p ~/caminho/para/module1; cd ~/caminho/para/module1
Populate a new local source tree under
"~/path/to/module1
" with files.
Import it to Subversion with the following parameters.
module1
"
file:///srv/svn/project
"
module1/trunk
"
module1/tags/Release-initial
"
$ cd ~/path/to/module1 $ svn import file:///srv/svn/project/module1/trunk -m "Start module1" $ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-initial
Alternativamente, pelo seguinte.
$ svn import ~/path/to/module1 file:///srv/svn/project/module1/trunk -m "Start module1" $ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-initial
![]() |
Dica |
---|---|
You can replace URLs such as " |
Here is an example of typical work flow using Subversion with its native client.
![]() |
Dica |
---|---|
Client commands offered by the |
Check all available modules from Subversion project pointed by URL
"file:///srv/svn/project
" by the following.
$ svn list file:///srv/svn/project module1 module2 ...
Checkout "module1/trunk
" to a directory
"module1
" by the following.
$ cd ~/path/to $ svn co file:///srv/svn/project/module1/trunk module1 $ cd module1
Faça as alterações necessárias ao conteúdo.
Check changes by making "diff -u [repository] [local]
"
equivalent by the following.
$ svn diff
You find that you broke some file "file_to_undo
" severely
but other files are fine.
Overwrite "file_to_undo
" file with the clean copy from
Subversion by the following.
$ svn revert ficheiro_para_desfazer
Save the updated local source tree to Subversion by the following.
$ svn ci -m "Describe change"
Create and add "file_to_add
" file to Subversion by the
following.
$ vi file_to_add $ svn add file_to_add $ svn ci -m "Added file_to_add"
Merge the latest version from Subversion by the following.
$ svn up
Watch out for lines starting with "C filename
" which
indicates conflicting changes.
Look for unmodified code in, e.g., "filename.r6
",
"filename.r9
", and "filename.mine
".
Search for "<<<<<<<
" and
">>>>>>>
" in files for conflicting
changes.
Edit files to fix conflicts as needed.
Adicione uma etiqueta de lançamento "Release-1
" com o
seguinte.
$ svn ci -m "last commit for Release-1" $ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1
Continuar a editar.
Remova a etiqueta de lançamento "Release-1
" com o
seguinte.
$ svn rm file:///srv/svn/project/module1/tags/Release-1
Check in changes to Subversion by the following.
$ svn ci -m "real last commit for Release-1"
Re-add the release tag "Release-1
" from updated
Subversion HEAD of trunk by the following.
$ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1
Create a branch with a path
"module1/branches/Release-initial-bugfixes
" from the
original version pointed by the path
"module1/tags/Release-initial
" and check it out to
"~/path/to/old
" directory by the following.
$ svn cp file:///srv/svn/project/module1/tags/Release-initial file:///srv/svn/project/module1/branches/Release-initial-bugfixes $ cd ~/path/to $ svn co file:///srv/svn/project/module1/branches/Release-initial-bugfixes old $ cd old
![]() |
Dica |
---|---|
Use " |
Work on this local source tree pointing to branch
"Release-initial-bugfixes
" which is based on the original
version.
Work on this branch by yourself … until someone else joins to this
"Release-initial-bugfixes
" branch.
Sync with files modified by others on this branch by the following.
$ svn up
Edit files to fix conflicts as needed.
Check in changes to Subversion by the following.
$ svn ci -m "checked into this branch"
Update the local tree with HEAD of trunk by the following.
$ svn switch file:///srv/svn/project/module1/trunk
Update the local tree (content = HEAD of trunk) by merging from the
"Release-initial-bugfixes
" branch by the following.
$ svn merge file:///srv/svn/project/module1/branches/Release-initial-bugfixes
Corrigir conflitos com o editor.
Check in changes to Subversion by the following.
$ svn ci -m "merged Release-initial-bugfixes"
Criar arquivo com o seguinte.
$ cd .. $ mv old old-module1-bugfixes $ tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes $ rm -rf old-module1-bugfixes
![]() |
Dica |
---|---|
You can replace URLs such as " |
![]() |
Dica |
---|---|
You can checkout only a sub directory of " |
Tabela 10.19. Notable options for Subversion commands (use as first argument(s) to
svn
(1))
opção | significado |
---|---|
--dry-run
|
dry run, no effect |
-v
|
mostra mensagens detalhadas da actividade do svn |
Git can do everything for both local and remote source code management. This means that you can record the source code changes without needing network connectivity to the remote repository.
You may wish to set several global configuration in
"~/.gitconfig
" such as your name and email address used
by Git by the following.
$ git config --global user.name "Name Surname" $ git config --global user.email yourname@example.com
If you are too used to CVS or Subversion commands, you may wish to set several command aliases by the following.
$ git config --global alias.ci "commit -a" $ git config --global alias.co checkout
Você pode verificar a sua configuração global com o seguinte.
$ git config --global --list
Veja o seguinte.
/usr/share/doc/git-doc/git.html
)
/usr/share/doc/git-doc/user-manual.html
)
/usr/share/doc/git-doc/gittutorial.html
)
/usr/share/doc/git-doc/gittutorial-2.html
)
/usr/share/doc/git-doc/everyday.html
)
git for CVS users
(/usr/share/doc/git-doc/gitcvs-migration.html
)
Other git resources available on the web
/usr/share/doc/gitmagic/html/index.html
)
git-gui
(1) and gitk
(1) commands make
using Git very easy.
![]() |
Atenção |
---|---|
Do not use the tag string with spaces in it even if some tools such as
|
Even if your upstream uses different VCS, it may be good idea to use
git
(1) for local activity since you can manage your local
copy of source tree without the network connection to the upstream. Here
are some packages and commands used with git
(1).
Tabela 10.20. Lista de pacotes e comandos relacionados com o git
comando | pacote | popcon | tamanho | descrição |
---|---|---|---|---|
N/D |
git-doc *
|
I:3 | 7436 | documentação oficial para o Git |
N/D |
gitmagic *
|
I:0.3 | 920 | "Git Magic", easier to understand guide for Git |
git (7)
|
git
*
|
V:5, I:17 | 10632 | Git, the fast, scalable, distributed revision control system |
gitk (1)
|
gitk
*
|
V:0.8, I:4 | 900 | GUI Git repository browser with history |
git-gui (1)
|
git-gui *
|
V:0.3, I:2 | 1612 | GUI for Git (No history) |
git-svnimport (1)
|
git-svn *
|
V:0.5, I:3 | 552 | import the data out of Subversion into Git |
git-svn (1)
|
git-svn *
|
V:0.5, I:3 | 552 | provide bidirectional operation between the Subversion and Git |
git-cvsimport (1)
|
git-cvs *
|
V:0.17, I:1.6 | 676 | import the data out of CVS into Git |
git-cvsexportcommit (1)
|
git-cvs *
|
V:0.17, I:1.6 | 676 | export a commit to a CVS checkout from Git |
git-cvsserver (1)
|
git-cvs *
|
V:0.17, I:1.6 | 676 | CVS server emulator for Git |
git-send-email (1)
|
git-email *
|
V:0.12, I:1.7 | 404 | send a collection of patches as email from the Git |
stg (1)
|
stgit
*
|
V:0.07, I:0.7 | 1864 | quilt on top of git (Python) |
git-buildpackage (1)
|
git-buildpackage *
|
V:0.2, I:1.1 | 596 | automate the Debian packaging with the Git |
guilt (7)
|
guilt
*
|
V:0.01, I:0.11 | 336 | quilt on top of git (SH/AWK/SED/…) |
![]() |
Dica |
---|---|
With |
![]() |
Dica |
---|---|
When you want to go back to a clean working directory without loosing the
current state of the working directory, you can use " |
You can check out a Subversion repository at
"svn+ssh://svn.example.org/project/module/trunk
" to a
local Git repository at "./dest
" and commit back to the
Subversion repository. E.g.:
$ git svn clone -s -rHEAD svn+ssh://svn.example.org/project dest $ cd dest ... make changes $ git commit -a ... keep working locally with git $ git svn dcommit
![]() |
Dica |
---|---|
The use of " |
You can manually record chronological history of configuration using Git tools. Here is a simple example for your practice
to record "/etc/apt/
" contents.
$ cd /etc/apt/ $ sudo git init $ sudo chmod 700 .git $ sudo git add . $ sudo git commit -a
Cometer configuração com descrição
Fazer modificações nos ficheiros de configuração.
$ cd /etc/apt/ $ sudo git commit -a
Cometer a configuração com descrição e continuar com a sua vida.
$ cd /etc/apt/ $ sudo gitk --all
You have full configuration history with you.
![]() |
Nota |
---|---|
|
![]() |
Nota |
---|---|
The " |
![]() |
Dica |
---|---|
For more complete setup for recording configuration history, please look for
the |