- copy, move, delete
- wildcards
- find files based on type, size & date
- tar, cpio, dd
- bzip2, gunzip
copy
- cp
- cp -R; -r; --recursive
example:
- cp 123.txt 234.txt
- cp -R folder1/ folder2/
move
- mv
example:
- mv folder1/ folder2/
- mv folder1/789.txt ./
delete / remove
- rm
- rm -f
- rm -rf
example:
- rm file.abc
- rm -i file.abc
- rm folder/
- rm -r; -R; --recursive
- rm -rf /
rename
– mv
example:
– mv file1 file2
touch
– creates an empty file
– updates timestamp
example:
– touch file
mkdir
– creates directory
example:
– mkdir folder
rmdir
– remove empty directory by default
file
–tells you information about files
example:
root@debian:~# file *
1.txt: ASCII text
2.txt: ASCII text
backup.mbr: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 15986688 sectors; partition 2: ID=0x5, starthead 96, startsector 15990782, 784386 sectors, code offset 0x63
blackbox: ASCII text
dayoff.zip: Zip archive data, at least v2.0 to extract
Desktop: directory
Documents: directory
Downloads: directory
hello2.txt: ASCII text
hello.txt: ASCII text
Music: directory
Pictures: directory
Public: directory
Templates: directory
Videos: directory
VMWARE: directory
wc: empty
root@debian:~#
wildcards (globbing)
• * - anything
• ? - any single character
• ! - not(stuff)
• [ac] – a,c
• [a-c] – a,b,c
root@debian:~/test# ls
bag.txt bat.txt cat.txt sat.txt
root@debian:~/test# ls *
bag.txt bat.txt cat.txt sat.txt
root@debian:~/test# ls ???.???
bag.txt bat.txt sat.txt
root@debian:~/test# ls *.???
bag.txt bat.txt sat.txt
root@debian:~/test# ls [ab]*
bag.txt bat.txt
root@debian:~/test# ls [bc]*
bag.txt bat.txt cat.txt
root@debian:~/test# ls [an]*
bag.txt bat.txt cat.txt
root@debian:~/test# ls [!an]*
sat.txt
root@debian:~/test#
find
- - type
- - timestamp
- - size
- - name
root@debian:~/test# ls l
total 6100
-rw-r--r-- 1 root root 0 Feb 25 15:07 file.txt
drwxr-xr-x 2 root root 4096 Feb 25 15:10 folder
-rw-r--r-- 1 root root 6228730 Feb 25 15:11 images.zip
lrwxrwxrwx 1 root root 8 Feb 25 15:07 symlink.lnk > file.txt
root@debian:~/test# find . name "fo*"
./folder
root@debian:~/test# find . name "[az]*.*"
./file.txt
./symlink.lnk
./images.zip
root@debian:~/test# find . size +5M
./images.zip
root@debian:~/test# find . size -5M
.
./file.txt
./symlink.lnk
./folder
root@debian:~/test# cp images.zip folder/otherimages.zip
root@debian:~/test# ls -l
total 6100
-rw-r--r-- 1 root root 0 Feb 25 15:07 file.txt
drwxr-xr-x 2 root root 4096 Feb 25 15:16 folder
-rw-r--r-- 1 root root 6228730 Feb 25 15:11 images.zip
lrwxrwxrwx 1 root root 8 Feb 25 15:07 symlink.lnk > file.txt
root@debian:~/test# ls folder/
otherimages.zip
root@debian:~/test# find . size +5M
./folder/otherimages.zip
./images.zip
root@debian:~/test# find . size +5M name "images.*"
./images.zip
root@debian:~/test#
Search items
- - block device
- - character
- - directory
- - named pipe
- - symbolic link
root@debian:~/test# find . type l
./symlink.lnk
root@debian:~/test# find . type f
./file.txt
./folder/otherimages.zip
./images.zip
root@debian:~/test# find . type d
.
./folder
root@debian:~/test# find . type f size +5M
./folder/otherimages.zip
./images.zip
root@debian:~/test#
find . atime +5 File was last accessed n*24 hours ago
find . ctime +5 File's status was last changed n*24 hours ago.
find . mtime +5 File's data was last modified n*24 hours ago
tar, cpiop, dd
- - tar ( uses gzip or bzip2 )
- - cpio ( uses gzip or bzip2 )
- - dd
- - gzip
- - bzip2
cpio
copy files to and from archives
cpio -o, --create
cpio -i, --extract
cpio -d
ls | cpio o > ../ls_archive.cpio
creates an archive one level up from the current directory based on the output from ls
dd
convert and copy a file
dd if=/dev/sdb of=keydrive.img
gzip
gzip nameoffile.xxx
– will erase original file
– adds gz extension
gunzip nameoffile.xxx.gz
bzip2
– erases original file
– adds bz
tar
– tar cvf archive.tar files/
– tar cvzf archive.tar.gz→ gzip
– tar cvjf → bzip2
– tar xjvf → extract bzip2, verbose, file
– tar -cxvf → gzip, extract, verbose, file
- -c create the file
- -v verbose
- -z use gzip compression
- -j use bzip2 compression
- -x extract
- -t list contents of archive
- -r append files to end of archive
No comments:
Post a Comment