Often-used Solaris Commands
Really concise and usefulhttp://www.themis.com/supp/suppfaqs/faqs_solaris.htm#q36
Identifying System Configuration
IBM AIX
- prtconf Command : displays system configuration information.
View files in octal or hexadecimal format - od
You can view non ascii base files in hexadecimal format usingod
command.
% od -A d -x journal.log
For more about od
, refer the following.
- http://www.opengroup.org/onlinepubs/9699919799/utilities/od.html
- http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds4/od.htm
Find files with specified name and list them with full path
If you want to find files with extension of 'jar' and print them with full path, usefind
command with -exec
operator like the following.
% find . -name '*.jar' -exec ls -l {} \;
For more about find
command and -exec
operator including strange '{}' or '\;' in the above example, refer the followings.
- http://www.opengroup.org/onlinepubs/9699919799/utilities/find.html
- http://docstore.mik.ua/orelly/unix3/upt/ch09_01.htm
Find files containing the specified word
List files using find
command excluding files with 'Permission denined'
When executing find
command in simplest format, you may get lots of lines just saying that 'Permission denied'
. Most cases, those are not what you want, and lots of permission denied lines can disturb you identifying the wanted result.
You can use stderr
redirection to cut out permission denied files (or directories).
- How can I exclude all “permission denied”-messages from “find .”? (from stackoverflow)
- Redirection on Wikipedia
Sorting the file system usage result from the du
command
You can sort the output of du
command applying pipe to sort
command.
% du -m | sort -n
For more about du
and sort
, read the followings.
Finding large files
To find large files(not directories) under current directory and list them in pages, use the following command.
% find . -type f -exec du -k {} 2>/dev/null \; | sort -nr | more
To filter out small files, you can use size
option with find
command, or to filter out some subdirectories you can redirect the result to grep
command.
The following command will list files whose size are more than 1 mega-byte under current directory recursively except the subdirectories starting with 'svn' in order of their size.
% find . -type f -size +1000000c -exec du -k {} 2>/dev/null \; | sort -nr | grep -E "\./svn.*" -v
Identifying the shell of your current login
To identify what shell a user is set to use by default, you can check 'SHELL'
variable.
As the above example shows, SHELL
variable contains the login default shell type not the one currently in use.
Identifying the product of Linux installed
For Linux, /etc/issues
file contains more detailed information on what Linux product it is.
Identifying TCP/IP ports currently in use.
You can identify TCP/IP ports currently in use using netstat
command. The options of netstat
is slightly different among operating systems.
For UNIX,
For Linux,
You need root privilege to take effect of -p
option
For Windows,
For more about netstat
, refer topics in Wikipedia.
Inverse matching with grep
command
To find lines not matching the specified patterns in a file, you can use -v
option with grep
command.
You don't need to be bothered to find out how to use complex negative patterns with regex.
0 comments:
Post a Comment