Unix basic command (Solaris)

1. Directory and file operation
pwd		Print and view which directory is now.
cd dirname		Enter directory.
cd ..		Enter parant dir.
cd / 		Enter root dir.
cd wl*		Enter the only one wl*(Such as wlserver, wlss) dir
ls		List subdir and files in current dir.
ls -l		List detail of subdir and files.
ls -al		List hidden subdir and files.

mkdir dirname	Make a dir, means create a dir.
mv file1 file2	Move file1 into file2, means rename file1 to file2.
mv file1 dir1	Move file1 into dir1.
mv dir1 dir2	Move dir1 into dir2.
cp file1 dir1	Copy file1 into dir1.
cp -r dir1 dir2	Copy dir1 into dir2.
rm file1	Remove file1, means delete file1.
rm -r dir1	Remove dir1, means delete dir1.

find . -name file/dir	Find file or dir in current dir.

chown username file1 	Change the owner of the file1 to username
chown -R username dir1	Change the owner of the dir1(all of subdir and files) to username

chgrp groupname file1 	Change the group of the file1 to groupname
chgrp -R groupname dir1	Change the group of the dir1(all of subdir and files) to groupname

chmod +x file		Change file can be executed.
chmod +w file		Change file can be writed.
chmod +r file		Change file can be read.
chmod 777 file		Change file can be executed, writed and read.
chmod -R +x dir 	Change dir can be executed.
chmod -R +w dir		Change dir can be writed.
chmod -R +r dir		Change dir can be read.
chmod -R 777 dir	Change dir can be executed, writed and read.

./filename		Execute filename in csh, if the file can be executed.

2. vi editor

vi filename	Enter vi.(Defult is Command Mode.)

Under Command Mode:
-> KEY
<- KEY
UP KEY
DOWN KEY

i KEY		Enter insert edit mode.(Esc KEY to exit and enter command mode.)
a KEY		Enter append edit mode.(Esc KEY to exit and enter command mode.)
r KEY		Enter modify edit mode.(Esc KEY to exit and enter command mode.)
R KEY		Enter replace edit mode.(Esc KEY to exit and enter command mode.)
x KEY		Delete a character.
dd KEY		Delete a line.

:q		Qiut vi and not save.
:q!		Quit vi and not save in anytime.
:w		Write to file, means save file.
:wq		Write to file, and quit vi.

Under Edit Mode:
Esc KEY		Exit edit mode, and enter command mode.

3. Other

man commandname 	Manual of the command, it will enter the help view, space KEY to move and q KEY to exit.

su - username		Change to other username to login.
su - 			Change to root user to login.
whoami			Show user name.
passwd username		Change user password.
hostname		Show host name.

ping hostname/IP	Check whether the host is actived.
nslookup hostname/IP	Network info.
ps -ef			Process info.
df -k 			Disk info with KB.
vmstat 2		CPU and memory state info.
netstat -sP tcp		TCP network state info.
psrinfo			Number of processor(CPU) in machine.
psradm -f PID		Stop PID CPU.
psradm -n PID		Start PID CPU.

tar cvf file1 .		Compress(tar) all files in current dir into file1.
tar xvf file1.tar	Uncompress all files from file1.tar to current dir.
tar tvf file1.tar	Show all files in compressed file1.tar.

kill -9 PID		Kill process whoes id is PID. (Danger)
reboot			Reboot the computer. (Danger)
init 6			(Solaris)Reboot the computer. (Danger)
init 5			(Solaris)Shutdown the computer. (Danger)