Linux commands

Linux /unix

Client machine:

Windows operations systems
Windows msDos
Windows 95
Winodows 98
Windows xp
Windows vista
Windows 7
Windows 8
Windows10

Server editions:

Windows 2000 server
Windows 2003 server
Windows 2008 server

Linux Operating systems:

Redhat linux
Redhat enter prise linux (Rhel)
Cent os
Suse
Ubuntu
Fedora
Oracle enterprise linux (O.E.L)

Unix operating systems:

Sun/solaries

Ibm/Aix

Hp/Unix

Mac os

Why use linux /unix:

User friendly

Security

Virus free

Remote accesses

Linux/unix is very very case sensitive

Root # Administrator :

$

root @host~]# super user

[rama@cuelex ~]$ normal user

# super user root

$ normal user

/ on linux Ex: /home/rama

\ windows c:\winodws\system32

Basic commands:

$ touch :- user for create empty file

Syn:- touch filename

Ex: touch rama

$ls list of files and directories

$ ls –l Long listing

File type, permissions, link files, user(or)owner name, group name, file size, time stamp, file or dir name.

– regular (or) normal file

d directory

l link file

ls –a : show the all (including hidden files)

Hidden files and directories start with . (dot)

Help commands:

man :-gives the description of commonds

ex:$man ls

Press q for quit from manual page

Cat commands:

cat :- Displays the data

Syn:- cat filename

Ex:- cat rama

cat Insert data

Syn:- cat >filename

Ex:- cat >rama(Press enter)

Hi this is kumar

Hi this is rakesh

Hi this is sarala

Hi this is raju

Press enter ^d (control+d) save file

cat update data

Syn:- cat >>filename

Ex:- cat >>rama

(Press enter)

Hi this is pavan

HI this is RAMU

Hi this is Krishna

^d(control+d) save file

Cd commands:

cd :- change directory and it’s go to users home dir

ex:- cd direname it is enter to directory

or give cd press enter it’s go to users home dir

/home users home dir

Users home

syn:-/home/username

Ex: I logged in rama user

What is users home dir

/home/rama

pwd:- print/presently/currently working directory

cd – it’s go to previously executed directory

cd .. it’s go to previous directory.(two directorys less)

Ex: /home/rama/rakesh/user/mani/kumar/

cd ../.. change the two directories

file – determine file type

mkdir : make directory

syn:- mkdir dir name

ex: – mkdir rama

whoami : command use for which user I am using

^l :- ctrl+l clear the window

Switch user :

Syn:- su – username

Ex :- su – ramesh

Copy, rename , replace or move (cut and paste):

cp : cp command use for copy the files and directories

syn:- cp <source path> <Destination path>

[rama@cuelex ~]$ pwd

/home/rama

ex: cp hai jaga

copy the directories

cp –rf <source path> <Destination path>

Ex:- [rama@cuelex ~]$ cp -rf pavanr raj

Rename:

mv command :- use for rename,replace

in the same location use this command rename files directories.

use this command move files and directories another place.

Syn:- mv oldname newname

Ex:- mv asw rajita

Syn:- mv <source> <Destination>

Ex:- [rama@cuelex ~]$ mv rajitha rajita

Permissions:

Permissions are two types

1.symbolic permissions

2.numerical permissions

1.symbolic permissions

u = user (owner)

g = group

o = others

a = all

– = remove

+ = add

r = read

w = write

x = execute

– = null

Ex:- drwxrwxr-x 3 rama rama 4096 Nov 3 12:56 abc

rwx rwx r-x

user(owner) Group Others

chmod : – This command user for changing permissions.

Syn:- chmod permissions and dir or file name

Ex:- chmod g-w dirname (rama) I t ‘ s changing permissions for group

2.Numerical permissions

Read = 4

Write = 2

Execute = 1

Null = 0

Directory default permissions 755

File default permissions 644

Directory full permissions 777

File full permissions 666

Vi editor:

vim – Vi IMproved, a programmers text editor

Modes are 4 Types

1. Insert mode i, a, I, A, o,O

2.Command mode

3.execute mode

4.visual mode

When open the vi file it will the command mode.

To edit the file when go to the insert mode. When return to command mode use Esc key.

1.Insert mode:

i:- begins insert mode at the cursor

many other options exist.

A:- Append to end of line.

I:- Insert a beginning of line

o :- insert new a line (Below)

O:- insert new a line (Above)

a:- Cursor go to next letter

gg Go to beginning of the line

2.Command mode

Copy

Paste

Delete (or) Cut

Copy lines

copy paste Delete

yy p(Below) dd

P(Above the cursor)

3.Execute mode:

Esc: go to command mode from insert mode.

Esc :w save &enter

Esc :q quit

Esc:wq save& exit

Esc :q quit with out saving

Esc:q! quit with out saving forcefully

Esc :w! save with force fully

Esc :wq! Save and exit with force fully

Esc:x save

Esc:X Asking password (giving password also remove).

Esc:20 go to line of 20

Esc:se nu set numbers

Esc: se nonu unset numbers

Syn: for find and replace

Esc:%s/oldname/newname/g

Esc:%s/rama/we/g find and replace

Filter commands

More: view pages by page

Head : To display first ten lines. If we want to Display 20 lines give number with below command .

Syn: head filename

Ex: head hari

Ex: head -n 20 hari

Tail: To display last ten lines. If we want Display 30 lines give number with below command.

Syn: tail file name

Ex: tail hari

Ex: tail -n 30 hari

Grep : grep is the command to search for word in the file display that lines.

Syn: grep word from file file name

Ex: grep ramamadhu

Ex: grep –color rama madhu

echo – display a line of text

ex:[rama@cuelex ~]$ echo “rama madhu”

Out put rama madhu

expr – evaluate expressions

ex: a=10

b=20

[ramesh@cuelex ~]$ echo $a

o/p:10

[ramesh@cuelex ~]$ echo $b

o/p:20

expr $a + $b

o/p:30

cal – displays a calendar

cal command displays present month .

cal 5 1991

ex:[ramesh@cuelex ~]$ cal 5 1991 ( Displays year and month (There is 5 that is may 1991)

May 1991

Su Mo Tu We Th Fr Sa

1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30 31

[ramesh@cuelex ~]$ cal Displays present month.

November 2014

Su Mo Tu We Th Fr Sa

1

2 3 4 5 6 7 8

9 10 11 12 13 14 15

16 17 18 19 20 21 22

23 24 25 26 27 28 2930

[ramesh@cuelex ~]$ cal 2014

It ‘s Display the total year.

cut – remove sections from each line of files

pipe – Postfix delivery to external command.

First command is output second command input

| This symbol are pipe just press wi

[ramesh@cuelex ~]$ cat rama1

ramesh:rakesh:sachin

kumar :harih :rakesh

sundar:ganesh:sehwag

gambir:gangul:ram

legend:bala :krish

ntr :mahesh:krish

fields are dividing from columns (:)

[ramesh@cuelex ~]$ cut -d : -f1 rama1

ramesh

kumar

sundar

gambir

legend

ntr

[ramesh@cuelex ~]$ cut -c 1 rama1

r

k

s

g

l

n

[ramesh@cuelex ~]$ cut -c 1-5 rama1

rames

kumar

sunda

gambi

legen

ntr

[ramesh@cuelex ~]$ cut -c 1-5 rama1|head -n1

rames

[ramesh@cuelex ~]$ cut -c 1 rama1|head -n1

R

cut -d: -f1 rama1\:|head -n 1 -c 2

ftp : file transfer protocol

copy files one place to another place.

Ex: server to windows. Windows to server

Just go to i.e (internet explorer) give the below url:-

ftp://cuelex.it.com

When it will open there is on file called pub.

Just right click on white space there on dialogue box is coming.

Select loginas

Give user name devappl

Password devappl

it is asking username and password

find commond:-

find – search for files in a directory hierarchy

syn:find / -name file(or)directory name

ex: find / -name rama

uname: it shows ths the operating system

date Displays date

Ex: [rama@cuelex ~]$ date

Wed Nov 5 11:55:17 IST 2014

mail – mail command use for sending and receiving mails.

Syn: mail –s “subject” user@host&domainname

Ex: mail –s “ hai” rama@info.com

Hi this is ramesh

How ru

Ctrl +d

Automatically sent.

Ln ln – make links between files

  • normal or regular file

d directory

l link file

s socket file

c character file

Creating soft(sim) link

Note: once we delete for move original file it will not work.

Syn: ln –s oldfile name newfile name

Ex: ln -s bhaskar ram

[ramesh@cuelex ~]$ du -sh naidu

8.0K naidu

[ramesh@cuelex ~]$ df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda5 18G 7.0G 9.5G 43% /

/dev/sda2 337G 225G 96G 71% /Dev

/dev/sda7 210G 149G 51G 75% /Stage

/dev/sda3 337G 252G 68G 79% /Test

/dev/sda1 99M 18M 77M 19% /boot

none 16G 3.6M 16G 1% /dev/shm

How to find ip address?

Windows

Go to run

Cmd

Ipconfig

It is show the this system ip address

2nd way

Go to start

Network connections

Go to support

It will display ip address.

What is this ip address 192.168.0.18.

Linux

/sbin/ifconfig

Ex:

[ramesh@cuelex ~]$ /sbin/ifconfig

eth0 Link encap:Ethernet HWaddr 00:E0:1C:3C:34:06

inet addr:192.168.0.222 Bcast:192.168.0.255 Mask:255.255.255.0

inet6 addr: fe80::2e0:1cff:fe3c:3406/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:256674 errors:0 dropped:0 overruns:0 frame:0

TX packets:290956 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:48471508 (46.2 MiB) TX bytes:225570907 (215.1 MiB)

Interrupt:169 Base address:0xe000

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:2147971 errors:0 dropped:0 overruns:0 frame:0

TX packets:2147971 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:859444464 (819.6 MiB) TX bytes:859444464 (819.6 MiB)

Ping : packet internet groper

Syn: ping ip address

Ip internert protocol

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools
%d bloggers like this: