Monday, 11 August 2014

LINUX BASICS

Linux is a 100% free operating system which is specially designed for multitasking, multi-user networks that is similar to Unix. -Linux was created by ×Linus Torvalds in 1991.

Linux Architecture
















Linux file system
A file system is the way how system contains and stores all your files like your documents, games, programs, music, videos etc.In Linux world, the same theory holds true you have directories and  folders in which you arrange your files.




Basic Linux commands



        COMMAND


         SYNTAX


     DESCRIPTION


  EXAMPLE


pwd
pwd

Identifying the current directory path
[student@localhost student]$ pwd
/home/student
mkdir
mkdir directory name
Creating a directory
mkdir directoryname
cd
cd directory name
Changing the current directory
cd  user/bin
rmdir
rmdir directory name
Removing a directory
rmdir filename
ls
ls
options are: -l,-a,-r
To display the names of files and subdirectories that are stored in a directory
ls /home/student
ps
ps
Display the shell
ps
who 
who
Display the information about users who are logged in
who
clear
clear
To clear the screen
clear
cat
Cat>filename
Create file
Cat>file1
content
cntrl+z
cat
cat  filename

To display the contents of a specified file.
cat file1

Cat File1 file2
To display the contents of more than one file
cat file1 file2
cp
cp [options] <source files> <destination files/directory>
To copy the contents of the source file into a target file.
cp file1 file2 
rm
rm [option] file/s
option are:
To delete files/directories.
rm file1
mv
mv [option] source destination

To move file or directory from one location to another
mv temp emp
Wildcard character
            *
*
Matches none or one character or string of characters.

cat c*
            ?
?
Displays all files that contains any characters before a period followed by exactly one character after a period.
ls *.?
head
head [option] [filename]
To display the specified number of lines from the beginning of a file.

head-3 file1
tail
tail [option] [filename]
To display the specified number of lines from the end  of a file.

tail -3 file1
find
find [path] [expression]

Options:
To locate in a specific directory and its subdirectories
find /home/student/


-name
To specifies the name of the files that you need to locate
find /home/student/                            -name “jan”


-type
To locate a specific type of file.
find /home/student/    
   -type f(search all the ordinary files)


-exec
To specify the operations that need to be to be performs on this that have been located by the find command

find -name temp -type 
f –exec rem {} \;

-ok 
Used with find command which prompt the user for a conformation before executing the command for each file.

find –name temp –type f –ok rm {} \;
touch 
touch filename
This command is used to creating empty file.
touch file3

Filters:

grep
grep regular_epr [filename]
Options: -a,-n,-c
Searches a file for a specified pattern of characters and displays all the lines that contain the pattern.

grep hai text
pipes
|
It helps to combine two or more commands
ls  | more
vi editor
Visual editor
Write a program , compile it and run it
At shell prompt
$vi programname.c
Press for Insert
Type the program code
Press 
esc 
 (colon)
 wq (write & quit)
Compile program
At prompt 
$ gcc programname.c
Execute program 
$./a.out program name

No comments:

Post a Comment