Anda di halaman 1dari 37

INTRODUCTION TO LINUX

UNIX

1960 UNIX was originally developed at Bell Laboratories

1969 Ken Thompson from AT&TS Bell Telephone Labs wrote first version of UNIX
Operating System.

1973 Development of UNIX was rewriting of the kernel in C, by Ritchie & Thompson.

1975 First distribution of UNIX software was made by Berkeley groupknownas BSD.

1978 Seventh edition of operating system was released with support of many different
hardware architectures.

PRINCIPLES OF UNIX

EVERTHING IS FILE INCLUDING THE HARDWARE.

CONFIGRATION DATA IS STORED IN SIMPLE TEXT FILE.

SMALL & SINGLE PURPOSE PROGRAMMS

ABILITY TO CHAIN THE PROGRAM

IT IS OPEN SYSTEM. MEANS,


-

RUN FOR ANY REASON

REDISTRIBUTE TO THE NEIGHBORS

FREEDOM TO IMPROVE

MULTI-USER, MULTI-TASKING

NOTHING IS AUTO-EXCUTABLE

SYSTEM SECURITY.

Red Hat Enterprise Linux


Bhushan

More

HOW ACTUALLY OPERATING WORKS?


As you know each operating system has minimum three parts which are hardware, Kernel &
shell.

HARDWARE: - All the peripherals which are present inside your system (Processor,
Motherboard, RAM, etc) all are comes under the hardware.
KERNEL: - UNIX kernel is the heart of the Operating system. It is the master program
which controls the computers resources, allots them to users and to different task.
SHELL: -UNIX shell is the command interpreter for the commands input by the user. Each
user has its own shell; multiple users may not be having the same shell.
FUNCTIONS OF SHELL
It acts as the command interpreter between the user & hardware (Kernel).
It expands the various meta characters used in file operations
It is responsible for the redirection output of one command as the input for the other.
It is responsible for executing the shell scripts which uses the programming language.
(Commands)
It is responsible to setting the environment for the user.
2

Red Hat Enterprise Linux


Bhushan

More

TYPES OF SHELL

sh
-

Bourne shell

Original UNIX shell

Writtem by Steven Bourne

csh
-

C shell

Added features such as command completion, history and job control

Written by Bill Joy

ksh
-

Korn Shell

Written By David Korn

Command completion & history

tcsh
-

The Enhanced C Shell

More features like command-line editing and more sophisticated completion

bash
-

Bourne Again Shell

Features
Command completion
Command line editing
Use of various meta characters
History

Red Hat Enterprise Linux


Bhushan

More

LINUX

THE FIRST KERNEL OF LINUX WAS FINNISHED BY COLLEGE


STUDENT.

STUDENT NAME WAS LINUS TORVALDS

LINUX WAS PUBLISHED BY NEWSGROUP IN AUG, 1991.

FEATURES OF LINUX

1. IT IS AN UNIX LIKE OPERATING SYSTEM


2. IT HAS WIDE HARDWARE SUPPORT
3. IT HAS SUPPORT FOR SMALL AS WELL AS LARGE APPLICATION
4. IT SUPPORTS MANY NETWORKING PROTOCOLS & CONFIGRATIONS
5. IT HAS SIX VIRTUAL CONSOLE (ALT+F(1-6)) & ONE GRAPHICAL
CONSOLE ON (ALT+F7)

Red Hat Enterprise Linux


Bhushan

More

RED HAT ENTERPRISE LINUX 6.0

Red Hat Enterprise Linux 6 is the next generation of Red Hat's comprehensive suite of operating
systems, designed for mission-critical enterprise computing and certified by top enterprise
software and hardware vendors.
This release is available as a single kit on the following architectures:
o I386
o AMD64/Intel64
o System z
o IBM Power (64-bit)
In this release, Red Hat brings together improvements across the server, systems and the overall
Red Hat open source experience.

Local logins:

Text-mode at virtual console

Graphical login

Virtual Consoles

Multiple Non-GUI logins are possible through the use of Virtual Consoles

There are 6 by default available virtual consoles

Available through CTRL ALT F[1 6]

If X is running, it is available at CTRL ALT F7

Red Hat Enterprise Linux


Bhushan

More

LINUX GRAPHICAL ENVIRONMENTS

Xfree86

GNOME

KDE

X Window System

Standard X Window System

Provides foundation for the graphical component linux

Blue curve theme


Easy navigation and configuration
Artistically designed look

GNOME

Graphical Network Object Model Environment

Desktop environment based on the GTK+ toolkit

Default desktop & Consistent, easy to use desktop

GNOME Office productivity applications


abiword
gnumeric
Games
Mozilla Firefox

KDE

K Desktop Environment

Desktop environment based on the Qt toolkit

KDE Office productivity applications


konsole graphical terminal
konqueror file manager and web browser

Red Hat Enterprise Linux


Bhushan

More

kmail email client


GEBERAL PURPOSE COMMANDS: 1. ls - to see the list of the files & directories in that directory
Syntax: - ls

<options>

<directory>

-l

long listing

-a

all files including hidden files

-h

human readable (1MB=1024bytes)

-i

list with inode number

2. wc to count the lines, words & letters of the file


Syntax: - wc <filename with full path>
3. mkdir - to create a new directory
Syntax: mkdir <new directory name>
4. cd - to change the directory
Syntax: cd <directory name>
Syntax: cd . . <enter> to go to the parent directory
Syntax: cd

<enter>

to go to home directory from anywhere

5. cp to copy the files & directories


Syntax:cp <options> <destination full path> <source full path>
-r

recursively

-f

forcefully

6. mv - to move the files & directories


Syntax: mv <source> <destination>
Syntax: mv <old name> <new name> to rename the file.

7. date to see & modify the current date & time


Syntax: date to see
7

Red Hat Enterprise Linux


Bhushan

More

Syntax: date <MMDDHMINYY> -to change the date & time

8. cal to see the current months calendar


Syntax: cal to see current month
Syntax: cal <month> <year> to see particuar month
Syntax: cal <year> to see whole year calendar

9. pwd to see the present working directory


Syntax: pwd

10. find to search the files and directories


Syntax: find <location> -name <filename>

11. who to see the information about the users logon to local machine
Syntax: who

12. who i am to see the information about yourself


Syntax: who i am

13. rmdir to remove an empty directory


Syntax: rmdir <directory name>

14. rm to remove a regular file


Syntax: rm <filename>

15. rm rf -to remove the directory with its content


Syntax: rm rf <directory name>

16. touch to modify date & time of file (creates empty file)
Syntax: touch

17. cat to create ,append & read file content


Syntax: cat > <filename> to create & write into new file
Syntax: cat >> <filename> to append existing file
Syntax: cat <filename> to read file content
8

Red Hat Enterprise Linux


Bhushan

More

18. head to read first 10 lines of file content


Syntax: head

19. tail to read last 10 lines of file content


Syntax: tail

20. more to read file content in pagewise manner( One directional)


Syntax: more

21. less to read file content in pagewise manner( Both directional)


Syntax: less

22. logout
Syntax: logout

23. poweroff
Syntax: poweroff

24. reboot
Syntax: reboot

HELP COMMANDS

1. man <command>
2. info <command>
3. <command> --help
4. whatis <command>

Red Hat Enterprise Linux


Bhushan

More

10

Red Hat Enterprise Linux


Bhushan

More

BROWSING THE FILESYSTEM


The Red Hat Enterprise Linux has the hierarchy structure for the file system.
In the RHEL each and every files address start from only the /.(slash )
/

: - Begins the filesystem structure called root

/boot

: - Kernel & booting related files

/bin

: - Binary files related to user

/dev

: - Device related files

/etc

: - Configuration files

/home

: - home directory for all the users

/lib

: - Library files

/media

: - By default mount point for the removable storage when you mount
from GUI mode

/misc

: - Miscellaneous files

/mnt, /opt : - Mount point for the removable storage


/proc

: - System information (Hardware)

/root

: - Home directory of user root (Administrator)

/sbin

: - Binary files related to system

/selinux : - Selinux related (Security enhanced Linux like firewall)


/srv

: - Data for services provided by this system

/tmp

: - Application & user buffer

/usr/bin : - User related binary files


/usr/sbin : - System related binary files
/usr/share : -Sample configuration files
/var

: -Variable files

/var/log : -Contains log files for most of the services


11

Red Hat Enterprise Linux


Bhushan

More

As you all know in Red Hat we do our maximum work on the console (command
prompt) so we do not have the icons and pictures from where we will know which one is file
or directory. For that we use the command ls l which gives us the output like,

drwxr-xr-x 2 root root 4096 Oct 14 00:26 directory

-rw-r--r--

1 root root

40 Oct 14 00:50 file

In the above case you will some different characters at the starting, from where you will the
kind of file.

12

-stand for ordinary file

-stand for directory file

-stand for link file

-stand for character file

-stand for block special file

Red Hat Enterprise Linux


Bhushan

More

STANDERED I/O & PIPES


One of the most important features of Linux is the streaming nature of data known as
standard input, standard output & standard error. This allows the input from program to come
from any source and the output to go to any source.
Linux provides three I/O channels to processes
Standard input

: keyboard is default

Standard output : terminal window is default


Standard error

: terminal window is default

Common redirection operators: > Command

>

file

Directs standard output of command to file

>> Command

>

file

Appends standard output of command to file

< Command

<

file

Command receives the input from file

2> Command

2>

file

Error messages from command are directed

2>>

file

to file
2>>

Command

Error messages from command are

appended to file

PIPES: Two of the basic tenets of UNIX philosophy are make small programs that do thing well
and expect the output of every program to become the input to another.
Pipes (|) let you redirect output from one command to become input to another command.
Syntax

<Command1>

| < Command2>

Any command that writes to standard output can be used on left-hand side of a pipe.
Any command thats read from standard input can be used on the right-hand side.
Multiple commands can be chained together with pipes.
13

Red Hat Enterprise Linux


Bhushan

More

VI editor: The vi is standard editor under Linux & Unix systems. And the newer vim editor is improved
editor, standard Red Hat editor.
To start vi,
vim <filename> If the filename exists, the file is opened the content are displayed, If file does
not exist it creates the file when the edits are saved for first time.

VI editor work in three modes,

1. Insert mode
2. Command mode
3. Ex mode

In Insert mode, your keystrokes are actually data entered into your document rather than
commands.
In command mode you will get to do the actions like cursor movement, change, delete,
yank(copy), put & search.
In final ex mode, you will going to do configuring, exiting, saving, search and replace.
Entering Insert Mode
a

append after the cursor

insert before the cursor

opens a new line below

append to end of line

Insert at beginning of line

opens a new line above

Leaving Insert mode :<esc>


14

Red Hat Enterprise Linux


Bhushan

More

Command mode

Change

Delete Yank(copy)

Line

cc

dd

yy

Letter

cl

dl

yl

Word

cw

dw

yw

Use p or P to put (paste) copied or deleted data


p puts line data below the cursor
P puts line data above the cursor

ndd deletes the n number of lines, Any number can be precede any of the change, delete, and
yank or put commands.

Undoing changes
u

undoes most recent change

<ctrl-r>

redo last undone change

EX MODE: -

:w

to save the changes

:q

to quite without saving

:wq

to save & then quiet

:w!

to save changes forcefully

:wq!

to save & then quiet forcefully

15

Red Hat Enterprise Linux


Bhushan

More

ADVANCE USES OF VI EDITOR

Multiple documents can be viewed in a single vim screen.


-

Ctrl+w, s

splits the screen horizontally

Ctrl+w, v

splits the screen vertically

Ctrl+w, arrow

moves between windows

Ctrl+w, +

Ctrl+w, -

:e

to change the file being edited in window

:qa

to quit all windows without saving

:set number

to see the line numbers

:set all

to see available other options

:set nonu to

unset the line numbers

:help

help topic

to increase the size


to decrease the size

To learn more about vim just go through command vimtutor.

16

Red Hat Enterprise Linux


Bhushan

More

USER MANAGEMENT: -

User: -The application or service or resource which controls the system in efficient manner
with some authentication process is user. There are three types of user,
Administrator (root)

(UID=0)

Super

(UID 1 to 499)

Normal

(UID=500+)

Group: -If we want give the same permissions or rights to multiple user, we create a group of
that users, to decrease the administrator load.
There are two types of group
-

Primary

Secondary

useradd: -to create a new user


Syntax:

17

useradd

<options>

-d

home directory

-c

comment

-s

shell

-g

gid or primary group

-G

secondary group

-u

uid

<username>

Red Hat Enterprise Linux


Bhushan

More

usermod: - to modify an existing user


Syntax:

usermod

<options>

-d

home directory

-c

comment

-s

shell

-g

gid or primary group

-G

secondary group

-u

uid

-l

login name

<exist username>

passwd: - to change the user password


Syntax:

passwd <username>

Syntax:

passwd

--only for the user root

cat /etc/passwd: -to see the total information about all the system users. The entry will be,
root:x:0:0:root:/root:/bin/bash
Where root is username, x stand for the link to shadow file, 0 is stand for UID, 0 is stand
for GID, root is stand for the comment, /root is the home directory, /bin/bash is the shell of
that user.
cat /etc/shadow: - to see the encrypted password for the entire user.
root :< encrypted password>
Where root is username, after colon (:) everything is encrypted password.
userdel: -to delete a particular user.

18

Syntax:

userdel

Syntax:

userdel

<username>
-r

<username>

to delete the user with its home directory.

Red Hat Enterprise Linux


Bhushan

More

groupadd: - to add a new group.


Syntax:

groupadd <group name>

groupmod: -to modify the existing group


Syntax:

groupmod

<options>

<existing group name>

-g gid
-n to change the group name
groupdel: -to delete the group.
Syntax:

groupdel

<exist group name>

cat /etc/group: - to see the list of all groups on that local machine with all the members.
group: x:503:usera, userb

Where group is group name, x is the link to the shadow file, 503 is gid and
usera & userb are the members of that group.

19

Red Hat Enterprise Linux


Bhushan

More

Users, groups & permissions

As all you know is, Linux has one of the most powerful features as secure operating system.
So to keep that, we need to implement some permission on files & directories. There are
three modes of file accessing,
Read only
Write
Execute

And there are three categories to divide the permissions,


User or owner
Group owner
Other

You can see the permissions of files with the help of command ls -l
You will get output like,
drwxr-xr-x 2 root root 4096 Oct 14 00:26 directory
-rw-r--r--

1 root root

40 Oct 14 00:50 file

By default permission for any file or directory in Linux is,


File rw-rw-rw & for directory drwxrwxrwx.
But as you know Linux is secured operating system so you have to give permissions as per
requirement & as per the security concern. So in Linux, by default we need to remove
permissions from file & directory. For that we set user mask to assign by default permission,

umask is the command with you can see the user mask of particular user & also you can set
the user mask.
20

Red Hat Enterprise Linux


Bhushan

More

By default umask of user root is 0022 & for normal user it is 0002.
So now default permission for any file or directory will be,
Default permissions

- umask.

1. ls l : - to see the permissions for file.


drwxr-xr-x 2 root root 4096 Oct 14 00:26 directory
rw-r--r--

1 root root

40 Oct 14 00:50 file

In this example you are getting 10 permissions which you have to divide in 4 categories
which will be like follows
d

rwx

special

owner

r-x
group

r-x
other

chmod: - to change the permissions


Syntax :
path>

chmod <permissions which you have to assign in nos>

<filename with full

there are two methods to change the permission,


1. Numerical

In numeric methods permissions are assigned with help of nos.


Read=4
Write=2
Execute=1
Special permissions=0

EX. chmod
21

0777 /home/user1/test/

Red Hat Enterprise Linux


Bhushan

More

2. Symbolic

In symbolic method you have to assign the permissions with the help of characters.
User or owner =u

Read=r

Group owner=g

Write=w

Other=o

Execute=x

To change the permission we require giving the command in the following syntax
EX. chmod u+w,g+w,o+r

/home/user1/test

is used to add the permission

is used to remove the permission

is used to assign the permission

chown: - to change owner of file or directory.


Syntax:

chown <new owner name> <filename with full path>

chgrp: - to change the group owner of file or directory.


Syntax:

22

chgrp <new group owner name> <filename with full path>

Red Hat Enterprise Linux


Bhushan

More

* IMPORTANT NOTE
1. EACH USERS HOME DIRECTORY HAS PERMISSION 0700.(EXCEPT root)
2. IF YOU WANT TO DO SOME WORK ON ANY DIRECTORY YOU
SHOULD HAV MINIMUM READ & EXECUTE PERMISSION.
3. BYDEFAULT WHENER YOU CREATE A FILE OR DIRECTORY ITS
GROUPOWNER IS PRIMARY GROUP OF THAT OWNER.

FOR PRACTICE: -

groupadd group

useradd -G group user1

useradd -G group user2

useradd user3

passwd user1

passwd user2

passwd user3

login with users user1,user2 & user3 on different console


(F1=root, F2=user1, F3=user2, F4=user3)
On F1,
-

mkdir /share

chmod 0777 /share

On F2

23

mkdir /share/user1

ls l /share

chgrp group /share/user1

ls l /share

cat

> /share/user1/file

Red Hat Enterprise Linux


Bhushan

More

ls -l /share/user1/file

chgrp

ls l /share/user1/

group /share/user1/file

On F3
-

cat /share/user1/file

cat >>

/share/user1/file

(READ)
(WRITE)

On F4
-

cat /share/user1/file

(READ)

cat >>

(Permission Denied)

/share/user1/file

On F2
-

chmod 0646

ls l /share/user1/

/share/user1/file

On F3
-

cat /share/user1/test

cat >>

/share/user1/file

(READ)
(Permission Denied)

On F4

24

cat /share/user1/file

cat >>

/share/user1/file

(READ)
(WRITE)

Red Hat Enterprise Linux


Bhushan

More

LINUX FILESYSTEM IN-DEPTH

Disk drives are divided into partitions


Partitions are formatted with filesystems, allowing users to store there data
Default filesystem ext4 (Fourth Extended Linux Filesystem)
Other
o ext3
o ext2
o iso9660 (CD)
o msdos

INODES: -

ext2 & ext3 file systems keep a list of the files they contain in a table called an inode
table.

An in individual entry in inode table is inode.

An inode table contains a list of all files in an ext2 & ext3 filesystems

An inode table contains information about file (the metadata): -

file type, permissions, UID & GID

link count (count of path names pointing to this file)

the file size with modification date & time

pointers to the files data blocks on disk

other data about the file

DIRECTORIES: - We commonly think of a directory as a container for files & other


directories, in fact directories is a mapping between the file names that humans use to
reference files and inode numbers
25

Red Hat Enterprise Linux


Bhushan

More

cp & inode
Allocates a free inode number, placing a new entry in a inode table
Copies data into a new file
EXAMPLE: -

cat > /root/file1

ls il /root/file1

cp /root/file1 /

ls il /file1

Inode no will different from the original file.


mv & inode
Creates a new entry with a new file name
Deletes the old entry with old fil name
EXAMPLE: -

cat > /root/file2

ls il /root/file2

mv /root/file2 /

ls il /file2

ls il /root

Inode no will same, and original fill will not present.

rm & inode
26

Red Hat Enterprise Linux


Bhushan

More

Decrements the link count, thus freeing the inode number to be reused

EXAMPLE
-

cd /root

touch filea fileb filec

ls il /root

rm rf filea fileb filec

ls il

touch file1 file2 file3

ls il

Inode no of files file1, file2 & file3 will be same as the inode no of filea, fileb & filec.

Hard link & inode


One physical file on the filesystem. Each link references the files inode.
Cannot span drives or artitions
Syntax:

ln <filename> <linkname>

EXAMPLE: -

cat > /root/file

mkdir /root/dir

ln /root/file /root/dir/file

ls il /root

ls il /root/dir

Inode no will same for both files, because they are hard linked to each other.
Soft link & inode
27

Red Hat Enterprise Linux


Bhushan

More

A soft link points to another file.


Syntax:

ln s

<filenmae>

<linkname>

EXAMPLE: -

cat > /root/file1

mkdir /root/dir1

ln s /root/file1 /root/dir1/file1

ls il /root

ls il /root/dir1

Checking Free Space


df

Reports disk space usage


Syntax:

df

<options>

human readable

print file system type

<filesystem>

Mounting Removable media


-

Floopy
mount /dev/fd0

/mnt

CD
mount /dev/cdrom

/opt

USB
fdisk

-l

mount /dev/sda1

/opt

Formatting a Floppy
mkfs.vfat

28

/dev/fd0

Red Hat Enterprise Linux


Bhushan

More

Archiving files: Archiving files is the process of incorporating a copy of those files into a single archive file.
These makes easier to back up, store & transfer.

The tar command is used to archive.

Synatx:

tar <options>

<filename to create>

-c

create

-f

filename

-v

verbose

-x

extract

<filenames to archive>

Example: -

29

cd /root

vi a

vi b

vi c

tar cvf

ls

rm rf a b

ls

tar -xvf backup.tar

(Insert some data)


(Insert some data)
(Insert some data)
backup.tar

a b c

Red Hat Enterprise Linux


Bhushan

More

Compressing file: Compression is used to make the file size less, and used save the hard-disk size.The gzip
& bzip2 commands are used to compress.

Syntax:

gzip

<filename to compress>

Syntax:

bzip2

<option>

-k

<filename to compress>

to keep original file unchanged

Example: -

30

cd /root

vi test

ls l

gzip test

ls l

gunzip test.gz

bzip2

ls l

bunzip2

ls l

bzip2

ls l

(Add some large data)

test

test.bz2

-k

test

Red Hat Enterprise Linux


Bhushan

More

INTRODUCTION TO STRING PROCESSING


1

head

-n <x=no of lines to see>

<filename>

To see first x no lines of file.

2. tail

-n <x=no of lines to see>

<filename>

To see last x no of lines of file.

3. wc

to count no of lines, words & letter

If we want to see individually we have options,


-l

for no of lines

-w

for no of words

-c

for no of letters or characters

4. sort

<options>

<filename>

-r

reverse

-n

numeric

-f

ignores case

to sort in order.

5. uniq

reports & omits the duplicate line

6. cut

remove section from each line of files

Example

31

1. cut f7 -d:

/etc/passwd

2. cut -f7 -d:

/etc/passwd | uniq

3. cut -f7 -d:

/etc/passwd | uniq | sort

4. cut -f7 -d:

/etc/passwd | uniq | sort r

Red Hat Enterprise Linux


Bhushan

More

7. aspell -c <filename> to check the spelling mistakes in a particular


file
8. grep

<options>

print lines matching a pattern

-n shows no of line
-v not containing pattern

9. locate <filename>

10. find

to search a file with filename

<location> <string> <matching pattern>


-name
-size
-user

To find files in GUI mode, you will get tab in start/system/Search for

32

Red Hat Enterprise Linux


Bhushan

files

More

INVESTING & MANAGING PROCESSES

1. ps

<options>

report a snapshot of the current processes

-a

all process status

-u

process status with username

-x

processes from all terminals

A process can be in one of the many states

R Runnable

S Sleeping

T Stopped

D Uninterruptable

In the output you will get the information like,


USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

2. kill -9 <PID>

3. pstree

to kill the particular process

to see the process tree of all processes

4.top

displays Linux tasks

5. jobs

Displays all processes running in background

6. fg

Suspended jobs brought back to the foreground

Scheduling the task


33

Red Hat Enterprise Linux


Bhushan

More

1. at:

Scheduling a Process To execute Later


Syntax:

at <time>
<command> ctrl+z

atq

displays scheduled jobs

atrm <jobId>

removes scheduled job

2. cron To schedule a particular task for the user, we have make the entry of that task in
file which is opens after the command crontab e. The entry in crontab is not removed
after the execution of command that entry has to be removed by the user itself.
crontab e

: to edit the scheduler task file, Entry should be

Min
(0-59)

hours

<command>

DOM Month DOW

(0-11) (0-30) (0-11) (0-6)


0=Sunday

crontab l to see the scheduled task for that user

34

Red Hat Enterprise Linux


Bhushan

More

BASH SHELL
As you know the role of shell in system, you also know that every user has its own shell.
There are many shells present in your system like,
/bin/bash, /bin/ksh, /bin/csh, /sbin/nologin, etc.
But the most of the work is done on the Bash shell & it is also the by default shell.
Features of Bash shell
1. Command completion
2. Command line editing
3. Use of various meta characters
4. History
Configuring the bash shell: To configure bash shell we have some variables through which we can
configure our shell. There are two types of variables: -

Local : Used only by the shell

Environmental: Passed onto other commands

Some common LOCAL variables: 1. HISTFILESIZE: Determines how many commands to be saved in the history file on
logout.
2. COLUMNS: Sets the width of the terminal
3. LINES: Sets the height of the terminal
4. PS1: Sets the prompt
To configure the prompt we have the command: -PS1= []
PS1=
\h hostname
\u username
\d date
35

Red Hat Enterprise Linux


Bhushan

More

\t time
\w working directory
\! No of history commands

Example
To look your bash shell like follows;
[root@server~]

you should give command;

PS1=[\u@\h\w]
To make changes permanent save the upper line in file ~/.bash_profile

5. Aliases: Aliases let you assign single letters to commands.


alias command is used to see the set aliases.
alias c=clear
After this command you does not require to type whole command to clear the screen just say
c.
To make the aliases permanent we have to make the entry of aliases into file ~/.bashrc which
is present in users home directory.

Some common ENVIRONMENT variables: 1. HOME: Path to users home directory


2. PWD: Users current home directory
3. EDITOR: For text editing
4. TERM: Set terminal type
5. PATH: Colon separated list of locations where commands can be found
6. which: Shows path of executable

36

Red Hat Enterprise Linux


Bhushan

More

Startup Scripts: Order of Execution

Login Shells

/etc/profile

/etc/profile.d

~/.bash_profile

~/.bashrc

/etc/bashrc

Non-login Shells

~/.bashrc

/etc/bashrc

/etc/profile.d

/etc/profile
-

System wide startup scipt

Parsed by all users with shells like bash & sh

Usually sets default PATH variable, user limits

/etc/profile.d
-

Some application-specific startup scripts in this directory

Scripts set up variables and run initialization procedures

~/.bash_profile and ~/.bashrc

37

For user-specific settings

Aliases

Red Hat Enterprise Linux


Bhushan

More

Anda mungkin juga menyukai