0% found this document useful (0 votes)
119 views19 pages

Basic Linux Commands MS4

Linux is a free open source operating system. UNIX is a copyrighted piece of software that demands license fees when any part of its source code is used. Linux shares UNIX's command set and look-and-feel, so if you know either UNIX or Linux, you know the other, too. It is also compliant with the POSIX. Standard, so porting applications between Linux and UNIX systems is a snap.

Uploaded by

rockin_ravi_vit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views19 pages

Basic Linux Commands MS4

Linux is a free open source operating system. UNIX is a copyrighted piece of software that demands license fees when any part of its source code is used. Linux shares UNIX's command set and look-and-feel, so if you know either UNIX or Linux, you know the other, too. It is also compliant with the POSIX. Standard, so porting applications between Linux and UNIX systems is a snap.

Uploaded by

rockin_ravi_vit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Linux Basic Commands 1

LINUX BASIC COMMANDS

Linux is a free open source operating system. UNIX work-alike


designed for Intel processors on PC architecture machines. Linux
is not UNIX, as UNIX is a copyrighted piece of software that
demands license fees when any part of its source code is used.
Linux was written from scratch to avoid license fees entirely,
although the operation of the Linux operating system is based
entirely on UNIX. It shares UNIX's command set and look-and-feel,
so if you know either UNIX or Linux, you know the other, too.
Linux supports a wide range of software, from TeX (a text
formatting language) to X (a graphical user interface) to the GNU
C/C++ compilers to TCP/IP networking. Linux is also compliant with
the POSIX.1 standard, so porting applications between Linux and
UNIX systems is a snap.

LOGIN
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686
login: rkk
Password:
Last login: Mon Nov 21 [Link] from [Link]

CHANGE PASSWORD
[jau@VIT-LINUX jau]$ passwd // change password
Changing password for user jau.
Changing password for jau
(current) UNIX password:
New password:
BAD PASSWORD: it's WAY too short
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[jau@VIT-LINUX jau]$

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 2

PROCESS STATUS

PS command is used to find out what processes are currently running. PS


stands for ‘process ststus’.

[jau@VIT-LINUX jau]$ ps // processes status


PID TTY TIME CMD
341 pts/1 [Link] bash
424 pts/1 [Link] ps

[jau@VIT-LINUX jau]$ ps –u // processes status of the user


USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jau 341 0.0 0.1 4292 1376 pts/1 S 08:18 0:00 -bash
jau 425 0.0 0.0 2592 644 pts/1 R 08:19 0:00 ps -u

[jau@VIT-LINUX jau]$ ps –a //all processes status


PID TTY TIME CMD
433 pts/1 [Link] ps

[jau@VIT-LINUX jau]$ ps –au


USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jau 341 0.0 0.1 4292 1376 pts/1 S 08:18 0:00 -bash
jau 434 0.0 0.0 2596 648 pts/1 R 08:20 0:00 ps -au

[jau@VIT-LINUX jau]$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1452 341 339 0 75 0 - 1073 wait4 pts/1 [Link] bash
0 R 1452 435 341 0 75 0 - 775 - pts/1 [Link] ps

[jau@VIT-LINUX jau]$

PID Process ID
PPID Parent process ID
USER User name
%CPU % of CPU processing power user
%MEM %of memory being user for the
processes
STAT Status
S Sleep
R Running
START Start time
TIME Time taken to execute the command
CMD Command

[jau@VIT-LINUX jau]$ kill 1 // to kill the process 1-> process ID


-bash: kill: (1) - Operation not permitted

[jau@VIT-LINUX jau]$ pwd //present working directory


/home/jau

[rkk@VIT-LINUX rkk]$ echo how r u? // to display the text


how r u?

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 3

[rkk@VIT-LINUX rkk]$ banner anu


-bash: banner: command not found

[rkk@VIT-LINUX rkk]$ date // to display date


Mon Nov 21 [Link] IST 2005

[rkk@VIT-LINUX anu]$ cal 2005 //to display calendar for the given year
2005

January February March


Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3 4 5
2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12
9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19
16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26
23 24 25 26 27 28 29 27 28 27 28 29 30 31
30 31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 7 1 2 3 4
3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11
10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18
17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25
24 25 26 27 28 29 30 29 30 31 26 27 28 29 30

July August September


Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3
3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10
10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17
17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24
24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30
31

October November December


Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2 3
2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10
9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17
16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24
23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31
30 31

[rkk@VIT-LINUX rkk]$ clear // to clear the screen

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 4

CAT COMMAND

rkk@VIT-LINUX rkk]$ cat // to create files


colors
red
red
blue
blue
green
green
yellow
yellow
oange
oange
violet
//ctrl+d to get the prompt

[jau@VIT-LINUX jau]$ cat add.c //view file


#include <stdio.h>
void main()
{
int a,b;
printf("enter two integer values");
scanf("%d %d",&a,&b);
printf("sum of two numbers %d + %d = %d",a,b,a+b);
}

[rkk@VIT-LINUX anu]$ cat > newcolor // directed the text to file newcolor
violet
indigo
red
blue
green
yellow
orange

[rkk@VIT-LINUX anu]$ cat newcolor //displays file newcolor


violet
indigo
red
blue
green
yellow
orange

[rkk@VIT-LINUX anu]$ cat * //displays all files


#include <stdio.h>
#include<conio.h>
viod main()
{
int x,y;
printf("enter two numbers");
scanf("%d %d",&x,&y);
printf("sum of two numbers : %d",x+y);
getch();
}

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 5

yellow
red
blue
green
violet
indigo
red
blue
green
yellow
orange
[rkk@VIT-LINUX anu]$ cat n?color
cat: n?color: No such file or directory

[rkk@VIT-LINUX anu]$ cat ad?.c //displays the file that start with ad
#include <stdio.h>
#include<conio.h>
viod main()
{
int x,y;
printf("enter two numbers");
scanf("%d %d",&x,&y);
printf("sum of two numbers : %d",x+y);
getch();
}
[rkk@VIT-LINUX anu]$
[jau@VIT-LINUX anu]$ cat colors pric rainbow > xxx//concatination of files

[jau@VIT-LINUX anu]$ cat xxx //display of the result


red blue
green
yellow
orange
pink
purple
meganta
cyan
violet
indigo
black
white
yellow
orange
red

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 6

WORKING ON FILES AND DIRECTORIES

CREATION OF FILES USING VI EDITOR

A screen editor in LINUX allows you to see the portion of the file on the
screen and to modify characters under current cursor position.

[rkk@VIT-LINUX rkk]$vi [Link] // to open text editor


//content ...

#include <stdio.h>
#include<conio.h>
viod main()
{
int x,y;

printf("enter two numbers");


scanf("%d %d",&x,&y);
printf("sum of two numbers : %d",x+y);
getch();
}
~
~
~
~
~
"[Link]" [New] 10L, 171C written

MOVING CURSOR AROUND THE SCREEN


The basic cursor motion commands are h,j,k and l

H For moving left


J Moving down
K Moving up
L Moving right

H L

ESC + i Insert after cursor position

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 7

ESC + x Delete a character


ESC + dd Delete a line
ESC + u Undo previous command
ESC + o Create a blank line
^D and ^U Scroll half a screen down and half a screen up
ESC + w Moves the cursor to next word
ESC + e Moves the cursor to end of line
ESC + b Move the cursor backward a word
ESC + :3 Go to 3rd line
ESC + yyy Copies three lines
ESC + p Paste in the current cursor position

Control commands

:W – write in the same file


:wq – write and quit
:q – quit
:n – go to nth line

[rkk@VIT-LINUX rkk]$ mkdir anu // to create directory

[rkk@VIT-LINUX rkk]$ cd .. // to move one level up

[rkk@VIT-LINUX rkk]$ rmdir anu // to remove directory

[rkk@VIT-LINUX rkk]$ cd anu // change directory

[rkk@VIT-LINUX anu]$ cmp color newcolor //compare two files


color newcolor differ: byte 1, line 1

[rkk@VIT-LINUX anu]$ cmp newcolor color


newcolor color differ: byte 1, line 1

[jau@VIT-LINUX jau]$ mv [Link] add.c //rename file as add.c

[jau@VIT-LINUX anu]$ cp xxx allcolors //copy xxx to allcolors file

[jau@VIT-LINUX anu]$ rm allcolors //remove file(delete)

[jau@VIT-LINUX anu]$ cat allcolors


cat: allcolors: No such file or directory

SORTING FILES

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 8

[rkk@VIT-LINUX anu]$ sort newcolor //sort files in ascending order


blue
green
indigo
orange
red
violet
yellow

[rkk@VIT-LINUX anu]$ sort -r newcolor //sort files in reverse order


yellow
violet
red
orange
indigo
green
blue

LISTING OF FILES

[rkk@VIT-LINUX anu]$ ls // list files found that doesnot begin with a perod
add.c color newcolor

[jau@VIT-LINUX jau]$ ls -a // list all files that begin with the period also
. add.c .bash_logout .canna .gtkrc sample.c xxx
.. anu .bash_profile .emacs .kde .viminfo .zshrc
4sem .bash_history .bashrc folder one .xemacs
[jau@VIT-LINUX jau]$

[rkk@VIT-LINUX anu]$ ls -l // contains the detail describtion of the file


total 4
-rw-rw-r-- 1 rkk rkk 171 Nov 21 09:52 [Link] // list of
files in anu directory
-rw-rw-r -- indicates the file's type and permissions

1 -- indicates the number of links to the file

rkk -- user ID of the file's owner

rkk -- the group ID of the group that the owner belongs to


171 -- size of the file in bytes

Nov 21 09:52 -- the time stamp-the date and time when the file was last modified

[Link] -- the name of the file

[jau@VIT-LINUX jau]$ ls -t //sort files by date


4sem one folder anu xxx sample.c add.c

[jau@VIT-LINUX jau]$ ls -alt


total 96

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 9

-rw------- 1 jau jau 1946 Nov 23 11:13 .bash_history


drwx------ 8 jau jau 4096 Nov 23 10:42 .
-rw------- 1 jau jau 906 Nov 23 10:42 .viminfo
drwxr-xr-x 5 jau jau 4096 Nov 23 08:55 4sem
drwxrwxr-x 2 jau jau 4096 Nov 22 11:32 one
drwxrwxr-x 2 jau jau 4096 Nov 22 11:30 folder
drwxrwxr-x 2 jau jau 4096 Nov 22 11:23 anu
-rw-rw-r-- 1 jau jau 0 Nov 22 11:23 xxx
-rw-rw-r-- 1 jau jau 162 Nov 22 09:29 sample.c
-rw-rw-r-- 1 jau jau 162 Nov 22 09:28 add.c
drwxr-xr-x 1152 root root 20480 Nov 22 09:06 ..
drwxr-xr-x 2 jau jau 4096 Nov 19 2004 .xemacs

[jau@VIT-LINUX jau]$ ls –altr //sort files in reverse order


total 96
drwxr-xr-x 3 jau jau 4096 Aug 12 2002 .kde
-rw-r--r-- 1 jau jau 220 Nov 28 2002 .zshrc
-rw-r--r-- 1 jau jau 5531 Feb 4 2003 .canna
-rw-r--r-- 1 jau jau 124 Feb 11 2003 .bashrc
-rw-r--r-- 1 jau jau 191 Feb 11 2003 .bash_profile
-rw-r--r-- 1 jau jau 24 Feb 11 2003 .bash_logout
-rw-r--r-- 1 jau jau 847 Feb 20 2003 .emacs
-rw-r--r-- 1 jau jau 120 Feb 27 2003 .gtkrc
drwxr-xr-x 2 jau jau 4096 Nov 19 2004 .xemacs
drwxr-xr-x 1152 root root 20480 Nov 22 09:06 ..

[jau@VIT-LINUX jau]$ ls -l /bin | more // more- display page by page


total 5512
-rwxr-xr-x 1 root root 2644 Feb 25 2003 arch
-rwxr-xr-x 1 root root 92444 Feb 6 2003 ash
-rwxr-xr-x 1 root root 492968 Feb 6 2003 [Link]
-rwxr-xr-x 1 root root 10456 Jan 25 2003 aumix-minimal
-rwxrwxrwx 1 root root 4 Nov 19 2004 awk -> gawk
-rwxr-xr-x 1 root root 10848 Feb 18 2003 basename
-rwxr-xr-x 1 root root 626028 Feb 11 2003 bash
lrwxrwxrwx 1 root root 4 Nov 19 2004 bash2 -> bash
lrwxrwxrwx 1 root root 3 Nov 19 2004 bsh -> ash
-rwxr-xr-x 1 root root 14364 Feb 18 2003 cat
-rwxr-xr-x 1 root root 18076 Feb 18 2003 chgrp
-rwxr-xr-x 1 root root 18076 Feb 18 2003 chmod
-rwxr-xr-x 1 root root 19772 Feb 18 2003 chown
-rwxr-xr-x 1 root root 47732 Feb 18 2003 cp
[more]

[rkk@VIT-LINUX anu]$ ls -x color[12] // to idenfify executable files


ls: color[12]: No such file or directory

[rkk@VIT-LINUX rkk]$ ls -R //list files recursively

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 10

.:
1.c anu anucolor [Link] cdanu color colour [Link]
ls: ./anu/add.c: Permission denied
ls: ./anu/color: Permission denied
ls: ./anu/newcolor: Permission denied

[jau@VIT-LINUX jau]$ ls -f –x //list files and directories


executable files are indicated with *

. .. .kde .canna .bash_logout .bash_profile .bashrc


.emacs .gtkrc .xemacs .zshrc .bash_history sample.c add.c
anu xxx folder .viminfo 4sem .[Link]

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 11

FILTERS
Filter is done by looking for one or more patterns in one or more files.

GREP(GLOBAL REGULAR EXPRESSIONPRINTER)

Grep command scans for the occurrence of one or more patterns in one or
more files

[rkk@VIT-LINUX folder]$ grep '^we' * /list out files start with the pattern
[Link]:we r vitians
[Link]:we live , we grow

[rkk@VIT-LINUX folder]$ grep 'live' *


[Link]:we live , we grow

[rkk@VIT-LINUX folder]$ grep '[ab]*' * // list out files that starts with ab
citrus:lemon
citrus:grape fruit
citrus:orange
fruits:apple
fruits:orange
fruits:grape fruit
fruits:pine apple
fruits:papaya
fruits:rasberries
fruits:cherry
fruits:strawbery
fruits:bananas
fruits:lemon
fruits:
[Link]:^ hai folks!
[Link]:we r vitians
[Link]:we live , we grow

[rkk@VIT-LINUX folder]$ grep '[ab]*' fruits


apple
orange
grape fruit
pine apple
papaya
rasberries
[rkk@VIT-LINUX folder]$ grep -l 'lemon' * //list out files with word
citrus
fruits
[rkk@VIT-LINUX folder]$ grep -l 'lemon' citrus fruits
citrus
fruits
[rkk@VIT-LINUX folder]$ grep -v 'lemon' citrus fruits
// selects all except the pattern
citrus:grape fruit
citrus:orange
fruits:apple
fruits:orange
fruits:grape fruit
fruits:pine apple

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 12

fruits:papaya
fruits:rasberries
fruits:cherry
fruits:strawbery
fruits:bananas
fruits:
[rkk@VIT-LINUX folder]$ grep -n 'lemon' citrus fruits
// display line number that consist of the pattern
citrus:1:lemon
fruits:10:lemon
[rkk@VIT-LINUX folder]$ grep -c 'lemon' citrus fruits // number of occurrences
for the pattern
citrus:1
fruits:1

[jau@VIT-LINUX anu]$ egrep 'lemon|grapes' fruits citrus //search for more


than one pattern
fruits:lemon
fruits:grapes
fruits:grapes
citrus:lemon
citrus:grapes
[jau@VIT-LINUX anu]$

[jau@VIT-LINUX anu]$ egrep -v 'lemon|grapes' fruits citrus //searches other than


the pattern
fruits:banana
fruits:apple
fruits:rasberries
fruits:cherry
fruits:strawbery
fruits:pineapple
fruits:pomogranate
fruits:grape fruit
fruits:orange
fruits:papaya
citrus:grape fruit
citrus:orange
[rkk@VIT-LINUX anu]$

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 13

PRINTING FILES
Pr command prepares file for printing by adding header and footer and
blank lines.

[jau@VIT-LINUX anu]$ pr citrus // prints the file

2005-11-22 09:34 citrus Page 1

lemon
grape fruit
orange
grapes
[rkk@VIT-LINUX anu]$
[jau@VIT-LINUX anu]$ pr -4 fruits

2005-11-22 09:34 fruits Page 1

banana strawbery lemon grapes


apple pineapple grape fruit grapes
rasberries pomogranate orange papaya
cherry

[jau@VIT-LINUX anu]$ pr -1 50 fruits //leaves 5 blank lines at the header and


footer and prints 50 lines per page

2005-11-22 09:34 fruits Page 1

banana
apple
rasberries
cherry
strawbery
pineapple
pomogranate
lemon
grape fruit
orange
grapes
grapes
papaya

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 14

[jau@VIT-LINUX anu]$ pr -h "FRUITS" fruits //it fix the header as “fruits”

2005-11-22 09:34 FRUITS Page 1

banana
apple
rasberries
cherry
strawbery
pineapple
pomogranate
lemon
grape fruit
orange
grapes
grapes
papaya

-ln Set length of page to n line


s-wn Set width of the page to n characters
-h 'string' Set the header of every page to 'string'
-n Lines numbers in output
-d double spacing in output

[jau@VIT-LINUX anu]$ head -5 fruits //specified number of lines from the top
banana
apple
rasberries
cherry
strawbery

[jau@VIT-LINUX anu]$ cat fruits // list the original content of the file
banana
apple
rasberries
cherry
strawbery
pineapple
pomogranate
lemon
grape fruit
orange
grapes
grapes
papaya

[jau@VIT-LINUX anu]$ tail -5 fruits //specified number of lines from the bottom
grape fruit
orange
grapes
grapes

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 15

INPUT OUTPUT REDIRECTION

The commands redirect the input form the keyboard to file or output from
the screen to a file or from file to the command.

[jau@VIT-LINUX anu]$ sort < allfruits


apple
banana
cherry
grape fruit
grape fruit
grapes
grapes
grapes
lemon
lemon

[jau@VIT-LINUX anu]$ who > rkk

[jau@VIT-LINUX anu]$ who


root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
rkk pts/3 Nov 22 10:30 ([Link])

[jau@VIT-LINUX anu]$ cat rkk //result


root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])

[jau@VIT-LINUX anu]$ cat fruits citrus >allfruits //concatenates the two fine
and the result is saved in the file allfruits

[jau@VIT-LINUX anu]$ cat allfruits


banana
apple
rasberries
cherry
strawbery
pineapple
pomogranate
lemon
grape fruit
orange

[jau@VIT-LINUX anu]$ wc -l <allfruits // takes the input from the file all
fruits and performs the word count operation.
17

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 16

PIPE
[jau@VIT-LINUX anu]$ who
root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
[jau@VIT-LINUX anu]$ who | wc -l
5
[jau@VIT-LINUX anu]$ who | wc
5 28 244
[jau@VIT-LINUX anu]$ who | sort allfruits
apple
banana
cherry
grape fruit
grape fruit
grapes
grapes
grapes
lemon
lemon
orange
orange
papaya
pineapple
pomogranate
rasberries
strawbery

[jau@VIT-LINUX anu]$ who | sort


jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
rkk pts/3 Nov 22 10:36 ([Link])
root :0 Nov 21 08:59
root pts/0 Nov 21 08:59

[jau@VIT-LINUX anu]$ who | grep 'grape' allfruits | wc -l


5

[jau@VIT-LINUX anu]$ who | grep 'grape' allfruits


grape fruit
grapes
grapes
grape fruit
grapes

[jau@VIT-LINUX anu]$ who | tee occ


grape fruit
grapes
grapes
grape fruit
grapes

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 17

[jau@VIT-LINUX anu]$ cat occ


root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
rkk pts/3 Nov 22 10:36 ([Link])

[jau@VIT-LINUX anu]$ who | grep 'grape' allfruits


grape fruit
grapes
grapes
grape fruit
grapes

[jau@VIT-LINUX anu]$ who |tee owho


root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
rkk pts/3 Nov 22 10:36 ([Link])

[jau@VIT-LINUX anu]$ cat owho


root :0 Nov 21 08:59
root pts/0 Nov 21 08:59
jau pts/1 Nov 22 09:15 ([Link])
rkk pts/2 Nov 22 10:29 ([Link])
rkk pts/3 Nov 22 10:36 ([Link])
[jau@VIT-LINUX anu]$

[rkk@VIT-LINUX rkk]$ ls | wc //word count for all files


8 8 50
[rkk@VIT-LINUX rkk]$ wc [Link] //wc for given file
4 4 28 [Link]
(line) (word) (characters)

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 18

FILE PERMISSIONS
There are three categories of users of file. U Owner who creates the file,
g group tells to which project the owner belongs to, o others or common people.
The chmod command is used to set read, write and execute permission for the
file.

Every user(ugo) has three permission –r,w,x-


Owner group others
- rwx - rwx – rwx –
- 421 – 421 – 421 –
7(4+2+1) 7 7 (full permission)

4 – permission to read
2 – permission to write
1 – permission to execute
[jau@VIT-LINUX jau]$ chmod 0764 sample.c
[jau@VIT-LINUX jau]$ ls -l
total 20
drwxr-xr-x 5 jau jau 4096 Nov 23 08:55 4sem
-rw-rw-r-- 1 jau jau 162 Nov 22 09:28 add.c
drwxrwxr-x 2 jau jau 4096 Nov 22 11:23 anu
drwxrwxr-x 2 jau jau 4096 Nov 22 11:30 folder
-rwxrw-r-- 1 jau jau 162 Nov 22 09:29 sample.c
-rw-rw-r-- 1 jau jau 0 Nov 22 11:23 xxx
[jau@VIT-LINUX jau]$

[jau@VIT-LINUX jau]$ chmod go+w sample.c //grant write permission to g ,o user

[jau@VIT-LINUX jau]$ ls –l sample.c


-rwxrw-rw- 1 jau jau 162 Nov 22 09:29 sample.c

[jau@VIT-LINUX jau]$ chmod a+x sample.c // grant execute permission to all users

[jau@VIT-LINUX jau]$ ls -l sample.c


-rwxrwxrwx 1 jau jau 162 Nov 22 09:29 sample.c

[jau@VIT-LINUX jau]$ chmod ugo-x * //removes execute permission for all files

[jau@VIT-LINUX jau]$ ls -l
total 20
drw-r--r-- 5 jau jau 4096 Nov 23 08:55 4sem
-rw-rw-r-- 1 jau jau 162 Nov 22 09:28 add.c
drw-rw-r-- 2 jau jau 4096 Nov 22 11:23 anu
drw-rw-r-- 2 jau jau 4096 Nov 22 11:30 folder
-rw-rw-rw- 1 jau jau 162 Nov 22 09:29 sample.c
-rw-rw-r-- 1 jau jau 0 Nov 22 11:23 xxx
[jau@VIT-LINUX jau]$

J ANURADHA, LECTURER, VIT.


Linux Basic Commands 19

PROC FOLDER
Proc folder maintains all the details regarding the system, memory and
kernel. The following are the file maintained by the proc folder.

[rkk@VIT-LINUX folder]$ cd /proc

[rkk@VIT-LINUX proc]$ ls
1 14345 21535 605 758 869 8794 dma loadavg slabinfo
10 14346 21536 7 759 8706 8795 driver locks stat
1020 14347 21537 702 765 8749 8796 execdomains mdstat swaps
1029 14661 21538 711 77 8752 8797 fb meminfo sys
1033 182 21539 725 777 8755 8799 filesystems misc sysvipc
1051 183 21540 745 8 8757 880 fs modules tty
1064 184 21541 750 807 8775 8800 ide mounts uptime
1065 185 3 751 820 8781 8803 interrupts mpt version
1066 186 4 752 829 8782 9 iomem mtrr
1067 187 5 753 839 8784 943 ioports net
1068 19 556 754 848 8785 bus irq partitions
1069 2 560 755 859 8787 cmdline kcore pci
1070 21412 586 756 8632 8789 cpuinfo kmsg scsi
1119 21534 6 757 8642 8790 devices ksyms self
[rkk@VIT-LINUX proc]$

[jau@VIT-LINUX proc]$ cat version // details about kernal


Linux version 2.4.20-8 (bhcompile@[Link]) (gcc version 3.2.2 200
30222 (Red Hat Linux 3.2.2-5)) #1 Thu Mar 13 [Link] EST 2003
[jau@VIT-LINUX proc]$

[rkk@VIT-LINUX folder]$ df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 5036316 170388 4610096 4% /
/dev/sda1 295564 19149 261155 7% /boot
/dev/sda2 20161204 1981576 17155488 11% /home
/dev/sda6 2016016 32828 1880776 2% /opt
none 515432 0 515432 0% /dev/shm
/dev/sda7 2016016 33812 1879792 2% /tmp
/dev/sdb1 20161172 4653284 14483748 25% /usr
/dev/sdb3 2016044 500216 1413416 27% /var
/dev/sda5 2047968 0 2047968 0% /vitlin
[rkk@VIT-LINUX folder]$
[jau@VIT-LINUX jau]$

J ANURADHA, LECTURER, VIT.

You might also like