About Me

hyderabad, A.P, India

Blog Archive

Friday, 11 January 2013

linux commands



                                                                                LINUX COMMANDS
Ø  Date: To print the system date and time

Syntax:  $ date
Mon Dec 3 10:25:23 EDT 2012

Ø  Who: this command is used to get information about all users who are currently loged onto the system

Syntax: $ who

hari Hy 19 may 19 12:34
Raj Hy 19 may 19 12:45
Ramu Hy 19 may 19 12:56

$ who am i: - Prints information about yourself.

Raj Hy 19 may 19 12:34

Ø  Echo: it displays on the screen whatever is typed after the command.

Syntax: $ echo hello,Linux

O/P:- hello,Linux

Ø  Clear: clear the screen

Syntax: $ clear

Ø  PWD: (Present Working Directories)
It displays present working directory

$ pwd
/root

Ø  Mkdir: for creating new director

Sntax:

$ mkdir dirname

$mkdir user-> it creates directory with name user.


Ø  Rmdir: it is used to remove the directory. Before using this command the directory must be empty.

$rmdir user-> it deletes user directory


Ø  Man: it provides the manual or help for the command


$man rmdir-> it gives the manual for rmdir


Ø  Cd: it is used to change the directory


$ cd user


Ø  Ls: this command lists the files  or  directory ’s


$ls

Ls-l: it gives long listing files

It gives the following data

·         Permissions of a file
·         No.of links
·         Owner
·         Group
·         Size of file
·         Date
·         Time
·         Filename
Ø  Cat : This commands is used to create a file.

Syntax :  $ cat  > filename
Ex: $cat  >hello

Hi
Every body
This is first linux file
Jsdjkd
Adj

Press ctrl + d
Save & terminate the cursor

Again we want see the content of a file we are using cat command

Syntax: $cat filename

$cat hello à display the content of hello file

How to run ‘c’ program in linux
Steps are: 
7)  
 Syntax:-  $ vi first.c
Press ‘I’ key on keyboard
Type the program like
#include<stdio.h>
main()
{
printf(“welcome to linux”);
}
Then press ‘Esc’ key on keyboard
Hold ‘shift’ key and press ‘:’ key on keyboard
Enter wq and press enter key
Now u r program is save and exit
Now compile the program using
$cc (or) gcc first.c
If any errors then back to u r program using vi first.c
And modify program and follow above same steps.
After compile run the program using this command
./a.out,
get output of the program
welcome to linux

Ø  rm : this command is used to delete the file.
$rm filename
$rm hello

Ø  cp(copy): it copies the contents of one file to another file
Syntax:$cp filename1 filename2

Ø  mv : move the filename1 to filename2(rename)
Syntax:$mv filename1 filename2

Ø  sort: this command is used to sorts and merge files

Before executing the sort command, first we need to create two files using cat command
$cat  > cmr1
Hfj hfjk hjksf
Sfj jf  fjs sjk

$cat  >cmr2
Njk dfj kdjf kfj
Dnfjk hjkf f
Dfn

Syntax: $sort file1 file2  >file3
The contents of file1 and file2 are merged, sorted and stored into file3.
          Example : $cat cmr1 cmr2  > cmr3




No comments:

Post a Comment