Pages

Friday, December 28, 2012

man find

Man page for the find command


find

find [pathnames] [conditions]
An extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. The default pathname is the current directory. The most useful conditions include -name and -type (for general use), -exec and -size (for advanced use), and -mtime and -user(for administrators).
Conditions may be grouped by enclosing them in \( \) (escaped parentheses), negated with !, given as alternatives by separating them with -o, or repeated (adding restrictions to the match; usually only for -name-type, or -perm). Note that "modification" refers to editing of a file's contents, whereas "change" means a modification, or permission or ownership changes. In other words, -ctime is more inclusive than -atime or -mtime.

Conditions and actions

-amin +n| -n| n
Find files last accessed more than n (+n), less than n (-n), or exactly n minutes ago.
-anewer file
Find files that were accessed after file was last modified. Affected by -follow when after -follow on the command line.
-atime +n| -n| n
Find files that were last accessed more than n (+n), less than n (-n), or exactly n days ago. Note that find changes the access time of directories supplied as pathnames.
-cmin +n| -n| n
Find files last changed more than n (+n), less than n (-n), or exactly n minutes ago.
-cnewer file
Find files that were changed after they were last modified. Affected by -follow when after -follow on the command line.
-ctime +n| -n| n
Find files that were changed more than n (+n), less than n (-n), or exactly n days ago. A change is anything that changes the directory entry for the file, such as a chmod.
-daystart
Calculate times from the start of the day today, not 24 hours ago.
-depth
Descend the directory tree, skipping directories and working on actual files first, and then the parent directories. Useful when files reside in unwritable directories (e.g., when usingfind with cpio).
-empty
Continue if file is empty. Applies to regular files and directories.
-exec command{ } \ ;
Run the Linux command, from the starting directory on each file matched by find (providedcommand executes successfully on that file—i.e., returns a 0 exit status). When commandruns, the argument { } substitutes the current file. Follow the entire sequence with an escaped semicolon (\;). In some shells, the braces may need to be escaped as well.
-false
Return false value for each file encountered.
-follow
Follow symbolic links and track the directories visited (don't use with -type l).
-fstype type
Match files only on type filesystems. Acceptable types include minixextext2xiamsdos,umsdosvfatprocnfsiso9660hpfssysvsmb, and ncpfs.
-gid num
Find files with numeric group ID of num.
-group gname
Find files belonging to group gnamegname can be a group name or a group ID number.
-ilname pattern
A case-insensitive version of -lname.
-iname pattern
A case-insensitive version of -name.
-inum n
Find files whose inode number is n.
-ipath pattern
A case-insensitive version of -path.
-iregex pattern
A case-insensitive version of -regex.
-links n
Find files having n links.
-lname pattern
Search for files that are symbolic links, pointing to files named patternpattern can include shell metacharacters and does not treat / or . specially. The match is case-insensitive.
-maxdepth num
Do not descend more than num levels of directories.
-mindepth num
Begin applying tests and actions only at levels deeper than num levels.
-mmin +n| -n| n
Find files last modified more than n (+n), less than n (-n), or exactly n minutes ago.
-mount, -xdev
Search only for files that reside on the same filesystem as pathname.
-mtime +n| -n| n
Find files that were last modified more than n (+n), less than n (-n), or exactly n days ago. A modification is a change to a file's data.
-name pattern
Find files whose names match pattern. Filename metacharacters may be used but should be escaped or quoted.
-newer file
Find files that were modified more recently than file; similar to -mtime. Affected by -followonly if it occurs after -follow on the command line.
-nogroup
The file's group ID does not correspond to any group.
-noleaf
Normally, find assumes that each directory has at least two hard links that should be ignored (a hard link for its name and one for "."--i.e., two fewer "real" directories than its hard link count indicates). -noleaf turns off this assumption, a useful practice when findruns on non-Unix-style filesystems. This forces find to examine all entries, assuming that some might prove to be directories into which it must descend (a time-waster on Unix).
-nouser
The file's user ID does not correspond to any user.
-ok command { }\;
Same as -exec, but prompts user to respond with y before command is executed.
-path pattern
Find files whose names match pattern. Expect full pathnames relative to the starting pathname (i.e., do not treat / or . specially).
-perm nnn
Find files whose permission flags (e.g., rwx) match octal number nnn exactly (e.g., 664 matches -rw-rw-r--). Use a minus sign before nnn to make a "wildcard" match of any unspecified octal digit (e.g., -perm -600 matches -rw-******, where * can be any mode).
-print
Print the matching files and directories, using their full pathnames. Return true. This is the default behavior.
-regex pattern
Like -path, but uses grep-style regular expressions instead of the shell-like globbing used in -name and -path.
-size n[c]
Find files containing n blocks, or if c is specified, n characters long.
-type c
Find files whose type is cc can be b (block special file), c (character special file), d(directory), p (fifo or named pipe), l (symbolic link), s (socket), or f (plain file).
-user user
Find files belonging to user (name or ID).

Examples

List all files (and subdirectories) in your home directory:
find $HOME -print
List all files named chapter1 in the /work directory:
find /work -name chapter1
List all files beginning with memo owned by ann:
find /work -name 'memo*' -user ann -print
Search the filesystem (begin at root) for manpage directories:
find / -type d -name 'man*' -print
Search the current directory, look for filenames that don't begin with a capital letter, and send them to the printer:
find . \! -name '[A-Z] *' -exec lpr { }\;
Find and compress files whose names don't end with .gz:
gzip `find . \! -name '*.gz' -print`
Remove all empty files on the system (prompting first):
find / -size 0 -ok rm { } \;
Search the system for files that were modified within the last two days (good candidates for backing up):
find / -mtime -2 -print
Recursively grep for a pattern down a directory tree:
find /book -print | xargs grep '[Nn] utshell'
If the files kt1 and kt2 exist in the current directory, their names can be printed with the command:
find . -name 'kt[0-9] ' ./kt1 ./kt2
Since the command prints these names with an initial ./ path, you need to specify the ./ when using the-path option:
find . -path './kt[0-9] ' ./kt1 ./kt2
The -regex option uses a complete pathname, like -path, but treats the following argument as a regular expression rather than a glob pattern (although in this case the result is the same):
find . -regex './kt[0-9] ' ./kt1 ./kt2

Source: http://www.oreillynet.com/linux/cmd/cmd.csp?path=f/find

How to Exit vi

Press escape to get into command mode if you re not already in command mode (i.e. if you are in insert/edit mode) .. Even if you are not in the edit mode press escape any way, it s OK. 

So, press esc, then

type one of these:

:q to quit and dont save
:q! to quit with out saving changes or prompts (if you have made changes)
:w to save
:wq to save and quit 


:x to save and quit 


emacs - ^X^S to save, ^X^C to quit
esc shift^ZZ to save and exit.


Notes:

Adding an exclamation mark at the end of the command means "do it!" - as in  :q!

When you will press escape the "insert" mode will be disabled, then you need to type : After that you can provide q! or w or wq and hit enter.

What Version of SUSE Linux?

How Do I find out the version / distribution info on my SUSE Linux system?



Most distributions include a small text file in /etc that will tell you what version of the distribution you're using. I believe this is called /etc/SuSE-release on SuSE

To find out what version of Linux you are using open your terminal and type:

cat /proc/version
or type:
cat /etc/issue

Search & Find files on SuSe

If you installed the package "locate", you'll be able to search an indexed list of all files on your computer to find where they are.

locate [filename]

The slow method is "find"...as in:


find / -type f -name [filename]


find / | grep [filename]

Note: these commands are executed in a Terminal.    

SUSE Manuals, Documentation and Support

SUSE man pages or manuals and PDF books or documentation might be a bit hard to find for a newbie.
New to SUSE Linux?  Learning SUSE?  Looking for SUSE help and tutorials?  Searching for SUSE books? 

Here are some useful resources  ((plz submit any useful links in the comment section below))

~~~~~~~~
From suse.com

SUSE Linux Enterprise Server 11 SP2 documentation 
SUSE Cloud 1.0 
SUSE Linux Enterprise Server 11 
SUSE Linux Enterprise Server 10 
SUSE Linux Enterprise Server 9 
SUSE Linux Enterprise Desktop 11 
SUSE Linux Enterprise Desktop 10 
SUSE Linux Enterprise Point of Service 11 
SUSE Linux Enterprise Point of Service 10 
Novell Linux Point of Service 9 
SUSE Linux Enterprise for SAP Applications 11 SP2  
SUSE Linux Enterprise Real Time Extension 11 
SUSE Linux Enterprise Real Time Extension 10 
SUSE Linux Enterprise High Availability Extension 11 
SUSE Manager 1.7 
SUSE Lifecycle Management Server 1.2 
SUSE Studio Onsite 1.2 
Subscription Management Tool for SUSE Linux Enterprise 11 
Subscription Management Tool for SUSE Linux Enterprise 10 
WebYaST  
openSUSE Official Documentation 

~~~~~~~~

From Novell:

Getting Started view size last update
openSUSE 11.0 Start-Up  pdf  3 MB 06/19/2008
openSUSE 11.0 KDE Quick Start  pdf  3 MB 06/19/2008
openSUSE 11.0 GNOME Quick Start  pdf  4 MB 06/19/2008

User Guides view size last update
openSUSE 11.0 KDE3 User Guide  pdf  9 MB 06/19/2008

Administration view size last update
openSUSE 11.0 Reference  pdf  7 MB 06/19/2008
AppArmor 2.1 Quick Start  pdf  1 MB 10/01/2007
AppArmor 2.3 Administration Guide  pdf  2 MB 06/19/2008

~~~~~~~~

From doc.opensuse.org for  openSUSE 12.2
Startup HTML single HTML PDF EPUB sources
Reference HTML single HTML PDF EPUB
Security Guide HTML single HTML PDF EPUB
Virtualization with KVM HTML single HTML PDF EPUB
System Analysis and Tuning HTML single HTML PDF EPUB
YaST
Zypp
Libyui
~~~~~~~~
MAN pages at die.net
http://linux.die.net/man/


~~~~~~~~

SuSE Linux Administration Guide by SuSE Linux AG  (PDF)
ftp://ftp-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.0/SuSE-Linux-Adminguide-9.0.0.0x86.pdf

~~~~~~~~

Forums 

~~~~~~~~

Useful Websites:


~~~~~~~~



Other Support:

Can ask questions on USENET or on any of the many mailing lists available.

I've never had a problem I couldn't find a solution to, by either searching on http://www.dejanews.com/, or Google, or by asking in one of the comp.os.linux.* newsgroups. 

Friday, December 21, 2012

The Caps

Those of you moving from Windows to Linux also need to know about "capitalization"

In Linux, capital letters are "not" the same as lower case letter. In other words, Linux is case-sensitive.

Windows is (largely) case insensitive; Windows doesn't care if you type cmd or Cmd, ping or Ping, or if you name your folder Folder or folder, all these are the same.  The exception is with passwords, passwords are case sensitive.

Linux was created differently and intentionally encodes letters in ASCI text .. So, every letter in Linux has a different ASCI encoding.

In ASCI, an upper case letter is a differet character than a lower case letter.

Let me rephrase, with Linux an "R" is not the same as an "r"
In Linux, you can create a directory and call it "Music" and then create another and call it "music" and the system wont complain because these words are not the same.  In Windows you will get an error.

In summary,
Linux letters are encoded differently than Windows, and Linux is case-sensitive.


finis


The "Root" of Everything

Let's talk "root"

The concept of root is essential for any Linux beginner and those moving from Windows to Linux


Root Defined:
Root = The highest level of anything.


Different uses of the concept of root:
Root in the Linux world is used in three different ways:


~ ~ ~



1- The "root user"

"root user" is the user with the highest level of rights on the computer.  In other words, the root user is "the system admin".   This is similar to the Windows admin user, or an administrators group.

People often say "log in as root" this literally mean to log in on your Linux box with the user name "root".

For instance when you log into your email you might type bob@hotmail.com then type your password and log in. Here bob@hotmail.com is your log-in user

Summary:
"root user" = The highest level a user can have on the computer.
"log in as root" = log in with the user name root



~ ~ ~


2- Root of the Operating System (OS)

"root of the OS" is the highest level in the folder structure on the hard drive.  For example "C:/".

In Windows 7 you can get to the root (C:/) by clicking on "Computer" then
root of the OS is the "Default (C:)" under "Hard Disk Drives."


In Windows XP this was called "My Computer"


Summary
"root of the OS" = "C:/"



~ ~ ~


3- The root of the user

"root of the user" is the home folder for that user. This has application settings, photos, docs, etc.
the "root" for any user is the "home" directory or folder for that user

Summary:
"root of the user" = the home folder



finis