CH9: Working with file Flashcards
(22 cards)
all files are case sensitive (T/F)
True
winter.txt !== Winter.txt
everything is a file (T/F)
True
A directory is a special kind of file, but it is still a (case sensitive!) file.
Define DIrectory
A directory is a special kind of file, but it is still a (case sensitive!) file.
file
The file utility determines the file type. Linux does not use extensions to determine the file type
~$ file pic33.png
pic33.png: PNG image data, 3840 x 1200, 8-bit/color RGBA, non-interlaced
how linux recognize file types ?
The file command uses a magic file that contains patterns to recognise file types. The magic file is located in /usr/share/file/magic
file -s
for special files
like:
/ prod
/ dev
touch
create an empty file
touch -t
set some properties while creating empty files
rm
remove forever
Linux have a trash bin to recover removed files (T/F)
the command line in general does not have a waste bin or trash can to recover files
rm -i
o prevent yourself from accidentally removing a file
rm -rf
O will not remove none empty directories
O The rm -rf statement is famous because it will erase anything
You can literally erase your entire file system by accident.
cp
To copy a file, use cp with a source and a target argument.
how to copy file
cp file42 file42.copy
Copy file to another directory
paul@debian7:~$ mkdir dir42 paul@debian7:~$ cp SinkoDeMayo dir42
cp -i
To prevent cp from overwriting existing files
aul@debian7:~$ cp -i SinkoDeMayo file42 cp: overwrite `file42’? n paul@debian7:~$
mv
to rename a file or to move the file to another directory
Rename files
ls
file33
mv file33 file34
ls
file34
also can used to rename directories
mv -i
to prevent for accidently rename file
mv is more popular than rename
use mv whenever you need to rename only a couple of files.
the rename command on linux use regular expressions
rename ‘s/.txt/.png/’ *.txt
what this code do
switches all occurrences of txt to png for all file names ending in .txt.
$ rename ‘s/file/document/’ *.png
switches all (first) occurrences of file into document for all file names ending in .png.
RHEL short for
Red Hat Enterprise Linux