Skip to content

Command List for Windows and Unix

February 17, 2011

Important UNIX and Windows commands for use.

Quite an old collection and some commands can be irrelevant now and for some commands expecting MKS tool kit or Cygwin on Windows.

1) To know the Ethernet and other Ip address details:
> ipconfig /all —- for Windows Desktop
> ifconfig -a —- for Solaris and Linux Desktop

2)To check the protocol and N/W statistics
> netstat -rn

3) To know whether a system is alive and know its ip-address:
> ping -s host-name for Solari/Linux workstations
> ping hostname  for Windows workstations

4) Find a file/directory in command line
> find (./dir-name) -name “hello.java”
> find (./dir-name) -name “hello.java” -print
> find (./dir-name) -type d –> This will list the fully qualified directory name inside dir-name name.

5)Remote login to a machine
> rlogin hostname/ipaddress in Win/Solaris/Linux

6)Telnet into a machine(Windows)
> telnet hostname/ipaddress

7) Information of Threads for a particular Process
ps -LP “process-id”

8)To mount a file system in Linux
U shd be at the point of sqindia/export
$ for i in 1 2 3 4 5 6 7 8 9
> do
> mkdir disk0$i
> mount sqindia.india.sun.com:/export/disk0$i disk0$i
>done

9)Find the disk space in Solaris
df -k will show total space mounted
du -k shows the space used

10)To create a Symbolic link
ln -s oldfilename(from what) slinkname(to here)

11)To Set CLASSPATH variable in Solaris and Linux
ksh> set CLASSPATH=classpath1:classpath2:classpath3:.
ksh> export CLASSPATH
ksh> export CLASSPATH=classpath1:classpath2:classpath3:.
In Windows:-
ksh> set CLASSPATH=classpath1;classpath2;.

12) To set the Path variable
ksh / sh > setenv PATH path1:path2:path3:$path:. ****In Solaris and Linux
> export PATH

> setenv PATH=path1;path2;path3;%path%;. ****In Windows

13)To find the processor configuration
> psrinfo -v ——- In Solaris
> prtconf
> prtconf -v
> eeprom

14)Find the system diagnostic info to find the error log
> dmesg — In Solaris

15)Find the patches that have been installed
showrev -p — In Solaris

16)To find the audio and videocards
$ sndconfig —-In Solaris for Sound cards
else check this file etc/modules.conf

17) Command to find whether a system supports which bit kernel
$ getconf HW_CPU_SUPP_BITS /// In Solaris and Linux
$ getconf KERNEL_BITS or: $ file /stand/vmunix

18) Command to find whether running 32 bit or 64 bit processor
$ isainfo

19) Command to recursively change the permissions of a directory
$ chmod -Rf  722 dir-name

20) Again few more points on system configuration
/usr/sbin/psrinfo
/usr/sbin/prtconf
RAM: prtconf | grep -i mem
CPU: mpstat
or
/usr/platform/`uname -m`/sbin/prtdiag
Try /usr/platform/`uname -m`/sbin/prtdiag. This will give you the amount of memory installed and speed and number of processors.

The command “prtconf” does it. If you want more and better details get sysinfo off the network.

dmesg | egrep ‘cpu|mem’

21) Get CPU, RAM and other etc info in Solaris and Linux
cat /proc/cpuinfo

22) ipcs – report inter-process communication facilities status

23) vmstat – reports virtual memory statistics regarding kernel thread, virtual memory, disk, trap, and CPU activity.

24) prstat – report active process statistics

25) /etc/logindevperm file help to set the drivers of the devices in the solaris environment.

26) mdb – modular debugger: The mdb utility is an extensible utility for low-level debugging and editing of the live operating system, operating system crash dumps, user processes, user process core dumps, and object files. For a more detailed description of mdb features, refer to the manual, Solaris Modular Debugger Guide.

27) kstat – disply kernel statistics: The kstat utility examines the available kernel statistics, or kstats, on the system and reports those statistics which match the criteria specified on the command line. Each matching statistic is printed with its module, instance, and name fields, as well as its actual value.

28) ptree – help to print the process in a tree hierarchical format.

29) mpstat – report per-processor or per-processor-set statistics

30) umask – get or set the file mode creation mask

31) rctladm – display or modify global state of system resource controls

32) arp – address resolution display and control

33) fmdump – fault management log viewer: The fmdump utility can be used to display the contents of any of the log files associated with the Solaris Fault Manager, fmd(1M). The Fault Manager runs in the background on each Solaris system. It receives telemetry information relating to problems detected by the system software, diagnoses these problems, and initiates proactive self-healing activities such as disabling faulty components.

34) dbx usage manual and commands :

%> dbx /java/jdk/latest/binaries/solaris/bin/java
(dbx) dbxenv rtc_inherit on # command needed for the leak checking to follow the fork/exec of child processes, which java does.
….
….
(dbx) check -leaks
….
….
(dbx) run -version
….
….
(dbx) cont

35) awk – pattern scanning and processing language
ls -l | awk ‘{print $2}’

36) sed – stream editor

>cat file
I have three dogs and two cats
>sed -e ‘s/dog/elephant/g’ -e ‘s/cat/tiger/g’ file
I have three elephants and two tigers

37) dump – dump selected parts of an object file
The dump utility dumps selected parts of each of its object file arguments.

The dump utility is best suited for use in shell scripts, whereas the elfdump(1) command is recommended for more human-readable output.

38) elfdump – dump selected parts of an object file
The elfdump utility symbolically dumps selected parts of the specified object file(s). The options allow specific portions of the file to be displayed.

The elfdump utility is similar in function to the dump(1) utility, which offers an older and less user-friendly interface than elfdump, although dump may be more appropriate for certain uses such as in shell scripts.

Archive files, produced by ar(1), can also be inspected with elfdump. In this case each object within the archive is processed using the options supplied.

39) ypcat hosts

ypcat helps to print all the hosts with its ipaddress in the local domain.

ypcat hosts | grep timetone

Prints the ipaddress and hostname of the timetone server.

40) /usr/ucb/ps -auxwww | grep java

This command should get you the whole command line for the running JVM including the memory settings.

41) ldd – list dynamic dependencies of executable files or shared objects
ldd /usr/lib/libc.so
libm.so.2 => /lib/libm.so.2
/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1

42) nm – print name list of an object file

ldd /usr/lib/libc.so
libm.so.2 => /lib/libm.so.2
/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1

nm /platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1 | grep memset

43) logname – command on Windows
Which gets you the current user-name.

$logname
Administrator

44) Remove tailing CTRL M characters from each line
In vi, do a :%s/^M//g
linux/solaris: dos2unix

Advertisements

From → tech, unix

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: