03 October 2009

Some Basic Linux Command

Searching and Installing packaages on Centos

yum search jdk

This will find out all available package with name jdk

yum install java-1.6.0-openjdk

This will install package java-1.6.0-openjdk

To See all running services

ps -Al

ps -a

This is like task manager of windows. It will show all proccess being running in console

Download file/folder from internet

lwp-download http://www.perl.com/CPAN/src/latest.tar.gz

and

wget http://www.perl.com/CPAN/src/latest.tar.gz

This will download latest.tar.gz from given url

Create and Edit file

vi filename

saving file

ESC + : +wq

Quit without saving

ESC + : q!

Creating folder

mkdir foldername

Deleting file

rm filename

rm file1 file2 ------ deleting multiple files at a time

Deleting folder

rm –rf foldername

Open File and See content

cat filename

Finding File

find -name ‘*.txt’

and

locate "*.c" -n 10 ---- -n 10 limit result to 10

Copy file to directory

cp file dir1/dir2

Copy folder to directory

cp –r folder dir1/dir2

Renaming file

mv filename1 filename2

Moving file to directory

mv file dir1/file2

Find all username who has currently login

who

Find username of me

whomi

Send message to other user

write username/ip

ctr+d to exit

Change permission on file

chmod 777 filename

Point Tables

R W X

4 2 1

Owner Group Other

Owner = rwx = 4+2+1=7

Group = rwx = 4+2+1=7

Other = rwx = 4+2+1=7

Text Editor Commads

vi filename

Save changes to buffer

ESC + :w

Save changes and quit vi

ESC +:wq

Save file to new file

ESC +:w filename

Quit without saving

ESC + :q!

Save lines to new file

ESC + :10,15w file

Restarting Server

reboot

start/stop/restart services

service httpd start

service httpd stop

service httpd restart

Stoping firewall

iptables stop