LPIC 103-3 Perform basic file management

Содержание:

cp — copies files and directories;

cp -rp folder1 folder2;

find — searches for files in a directory hierarchy;

find /home -name "*.txt" find all *.txt files in home directory;

find /home -size +5M find all files in home directory larger than 5MB;

find /home -type d find all dirs in home directory;

find /home -atime +5 find all files in home directory with access time larger than 5 day;

find /home -ctime +5 find all files in home directory with change time larger than 5 day;

file — determine file type;

mkdir — makes directories;

mv — moves (renames) files;

ls — lists directory contents;

rm — removes files or directories;

rm -rf file or folder;

rmdir — remove empty directories;

touch — changes file timestamps;

tar — tar archiving utility;

tar cvf folder1.tar folder1 — archives folder1 (create, verbose, file);

tar xvf folder1.tar — extract archive folder1.tar (extract, verbose, file);

tar cvfz folder1.tar.gz folder1 — archives folder1 with gzip (create, verbose, file, gzip);

tar xvfz folder1.tar.gz folder1 — extract archive folder1.tar.gz with gzip (extract, verbose, file, gzip);

cpio — copies files to and from archives;

ls | cpio -o > ../archive.cpio — archives all files from current dir to ../archive.cpio;

cpio -id < ../archive.cpio — extracts all files from archive.cpio to current dir;

dd — convert and copy a file;

dd if=/dev/sdb of=/var/backups/drive.sdb.img — backup /dev/sdb block device;

gzip — compress files;

gzip drive.sdb.img — compress to drive.sdb.img.gz;

gunzip — expands files;

gunzip drive.sdb.img.gz — extracts to drive.sdb.img;

bzip2 — a block-sorting file compressor;

bzip2 drive.sdb.img — compress to drive.sdb.img.bz2;

bunzip2 — a block-sorting file extractor;

bunzip2 drive.sdb.img.bz2 — extracts to drive.sdb.img;

xz — compress .xz and .lzma files;

xz drive.sdb.img — compress to drive.sdb.img.xz;

unxz — decompress .xz and .lzma files;

unxz drive.sdb.img.xz — extracts to drive.sdb.img;

file globbing — Unix style pathname pattern expansion, see wildcards;

wildcards:

  • * — all symbol(s);
  • ? — one symbol;
  • ! — not;
  • [ac] — a or c;
  • [a-c] — a, b, c.