A free Basic UNIX-training with muLinux
Notes: This Text is roughly translated (German to English) by a translating program. Sorry, but I have not time for the translation. Maybe you can do this?
In order to store this exercise on our work diskette, we put these into the
floppy disk drive, mounten the drive after /a and change into the
directory /a .
/ # mount /dev/fd0 /a
/ # cd /a
/ a #
Searching and Finding of Files - with find and to Prove the Filetypes with file
Unix possesses an extensive directory system. The search for certain files
resembles sometimes the search for the needle in heap of hay. For this search
Unix provides the instruction find for the order. This instruction
searches a start directory and all sublists contained there for files, which
meet certain criteria. To these files a find-specific instruction is then
applied. The general syntax is:
/# find directory options
Unfortunately orders muLinux version of find do not lengthen over
all possibilities like the standard version. It is however nevertheless amazing,
as much university X-commands fit on a diskette.
The indicated directory is the start directory for the search. This
directory and all sublists are searched. Usually unfavorable the general
statement is to be indicated /, since the search lasts every now and then
for a very long time.
Options
The options define the search conditions and the internal messages which are connected with it.
-name filename
The option -name causes a search for files or directories with the Dateienamen indicated here.
Unfortunately accepts the muLinux version of findhere no Wildcard characters, e.g. the asterisk * .
-user username
With -user can files or directories of a user be looked up.
-print
The option -print is an internal message.
This outputs the found Dateienamen.
Strictly speaking is the specification of -print with the muLinux version of find not necessarily.
The standard version of find still different internal message versions, e.g. executing programs contains with certain conditions.
Examples
/# find / -name passwd -print
It becomes, beginning from the general statement / , looked up for
all files with " the names " passwd. These become through - print on
the display output. In addition, error messages appear, there sublists of /
proc not to be searched can. Who does not want to see these error messages,
she sends simply into the garbage pail:
/# find / -name passwd -print 2> /dev/null
We modify this instruction (command retry also Cursor key up ), over after all files with the name LS to look up:
/# find / -name ls -print 2> /dev/null
This instruction finds also files, in which the letter sequence "ls" is.
/# find / -user craxi -print 2> /dev/null > /a/found.txt
All names of files users "craxi" are stored in " the file "found.txt" on the diskette. Error messages are ignored.
/# find -h
The option -h lists all options of find.
Who has the possibility to a "right" Unix to operate, should
itself absolutely the instruction find look at with all its options.
Additionally there is there also the faster search instruction locate.
Find programs with which
The program which outputs the path of an instruction.
/# which ls
/bin/ls
The program ls is thus in the directory /bin.
/# which find
/usr/bin/find
The program find is in the directory /usr/bin.
File type determine with file
With the multiplicity of files it can occur that one do not point, which hides itself in a file.
Here the instruction helps file:
file filename(s)
The instruction tries to find out due to the initial data in the file, which contents it concerns with the indicated file or the files.
Examples
/# file /etc
/etc: directory
/etc is thus a directory.
/# file /etc/passwd
/etc/passwd: ASCII text or DATA
The file passwd is a ASCII file.
/# file /etc/ * | grep "link"
Here all everything becomes left in the directory /etc displayed.
/# file /bin/cat
/bin/cat: ELF executable
/bin/cat is an executable program.
Around this exercise to terminate we lift those mount - allocation of
our work diskette up.
/ a # CD /
/ # umount / a
/ #
Robert.Warnke@giso.de (copyleft) Robert Warnke, Berlin (Germany) - You can write me in English. | http://rowa.giso.de
|