Linux Commands
Find Command
## To search for files in /target_directory and all its sub-directories, that have been modified in the last 60 minutes:
$ find /target_directory -type f -mmin -60
## To search for files in /target_directory and all its sub-directories, that have been modified in the last 2 days:
$ find /target_directory -type f -mtime -2
## To search for files in /target_directory and all its sub-directories no more than 3 levels deep, that have been modified in the last 2 days:
$ find /target_directory -type f -mtime -2 -depth -3
## You can also specify the range of update time. To search for files in /target_directory and all its sub-directories, that have been modified in the last 7 days, but not in the last 3 days:
$ find /target_directory -type f -mtime -7 ! -mtime -3
## To search for files in /target_directory (and all its sub-directories) that have been modified in the last 60 minutes, and print out their file attributes:
$ find /target_directory -type f -mmin -60 -exec ls -al {} \;
$ find /target_directory -type f -mmin -60 | xargs ls -l
##
Find all files in current directory and subdirectory, greater than some size
using find command in Unix:
find . -size +1000c
-exec ls -l {} \;
Always use a c after the number, and specify the size in bytes, otherwise you will get confuse because find -size list files based on size of disk block. To find files using a range of file sizes, a minus or plus sign can be specified before the number. The minus sign means "less than," and the plus sign means "greater than." Suppose if you want to find all the files within a range you can use find command as below.
## It return files which size is greater than 50M
find . -size +50000000c
-exec ls -lh {} \;
## It
return files which extension are .java and end with other character
find . -type f -name
"*.java*" -print
Change Shell by Cmd
##First, find out available shell list:
$ less /etc/shells
##Now change your shell name to /bin/tcsh:
$ chsh -s /bin/tcsh
##When promte for password, type your own password. If you just type chsh command, it will prompt for shell name interactively:
$ chsh
Owner Ship Cmd on File System
$chmod u+x
<filename>
$chmod uog+xwr <filename>
g : Group
o : Other
---------
r : Read : 4
w : Write : 2
x : Execute : 1
$chmod 660 <Filename> // owner group other
$chmod 751 tech
$chmod u=rwx, g=rx, o=x tech
<chown> change ownership of file system.
##As the owner, jim can use the chmod command to permit or deny other users access to program.c.
$chown jim program.c
##To change the owner and group of all files in the directory /tmp/src to owner john and group build:
$chown -R john:build /tmp/src
Linux Version Info
## see your current Linux kernel version:
$ uname -r
$ uname -mrs
## To print all information, enter:
$ uname -a
## see Linux version info:
$ cat /proc/version
## Here is another output from my Debian based serve
$ lsb_release -a
Process Command line Info
## Display a tree of processes
$ pstree
## Dynamic real-time view of a running system
$ top
## Display all running process:
$ ps aux | less
## Print a process tree using ps
$ ps -ejH
$ ps axjf
## Get info about threads
$ ps -eLf
## Get security info
$ ps -eo euser,ruser,suser,fuser,f,comm,label
$ ps axZ
$ ps -eM
## Save Process Snapshot to a file
$ top -b -n1 > /tmp/process.log
$ top -b -n1 | mail -s 'Process snapshot' you@example.com