Hi everyone, in this tutorial i will share you Solaris usefull commands. Also you can use some commands different linux distros.
Before this article, you should look previously.
Let’s start display the size of file,
ls [-lh] [-s]
- Displays a list of files and directories in long format, showing the sizes in bytes. (See the example that follows.)
- Scales file sizes and directory sizes into Kbytes, Mbytes, Gbytes, or Tbytes when the file or directory size is larger than 1024 bytes. This option also modifies the output displayed by the -o, -n, -@, and -g options to display file or directory sizes in the new format.
- Displays a list of the files and directories, showing the sizes in blocks.
How to Find Large Files
ls -l | sort +4rn | more
Note that this command sorts files in a list by the character that is in the fourth field, starting from the left.
If the characters or columns for the files are the same, use the following command to sort a list of files by block size, from largest to smallest.
ls -s | sort -nr | more
How to Find Files That Exceed a Specified Size Limit
find directory -size +nnn
- Identifies the directory that you want to search.
- -size +nnn
- Is a number of 512-byte blocks. Files that exceed this size are listed.
find . -size +400 -print
How to Display the Size of Directories, Subdirectories, and Files
du [-as] [directory …]
Displays the size of each directory that you specify, including each subdirectory beneath it.
Displays the size of each file and subdirectory, and the total number of blocks that are contained in the specified directory.
Displays the total number of blocks that are contained in the specified directory.
Displays the size of each directory in 1024–byte blocks.
Displays the size of each directory in 1000–byte blocks.
The following example shows the sizes of two directories
du -s /var/adm /var/spool/cups
The following example shows the sizes of two directories and includes the sizes of all the subdirectories and files that are contained within each directory. The total number of blocks that are contained in each directory is also displayed.
du /var/adm /var/spool/cups The following example shows directory sizes in 1024–byte blocks.
du -h /usr/lib
How to Find and Remove Old or Inactive Files
find directory -type f[-atime +nnn] [-mtime +nnn] -print > filename &
- Identifies the directory you want to search. Directories below this directory are also searched.
- -atime +nnn
- Finds files that have not been accessed within the number of days (nnn) that you specify.
- -mtime +nnn
- Finds files that have not been modified within the number of days (nnn) that you specify.
- Identifies the file that contains the list of inactive files.
find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles & more /var/tmp/deadfiles
rm `cat /var/tmp/deadfiles`
208 views last month, 2 views today