Introduction To Linux Concepts: Iva Umar Huchipalli
Introduction To Linux Concepts: Iva Umar Huchipalli
Introduction To Linux Concepts: Iva Umar Huchipalli
Data files
LFS Directory Structure (Contd…)
/bin System binaries, including the command shell
/boot Boot-up routines
/dev Device files for all your peripherals
/etc System configuration files
/home User directories
/lib Shared libraries and modules
/lost+found Lost-cluster files, recovered from a disk-check
/mnt Mounted file-systems
/opt Optional software
/proc Kernel-processes pseudo file-system
/root Administrator’s home directory
/sbin System administration binaries
/usr User-oriented software
/var Various other files: mail, spooling and logging
Shell
Command Line Interpreter
Bridge between kernel and the user
Types
SH – Simple Shell
BASH – Bourne Again Shell
KSH – Korne Shell
CSH – C Shell
Bash is the default Shell Type
Linux Command Basics
To execute a command, type its name and arguments at
the command line
ls -l /etc
Finds the occurance of abc in hello.txt and displays the line in the screen
grep –i abc hello.txt – Ignores case. Will find Abc, ABC, aBc, aBC etc
grep –c abc hello.txt – Displays the count of matches
grep –n abc hello.txt – Displays the matching lines along with line number
grep –v abc hello.txt – Displays the lines that donot have the pattern abc
^a – Starts with a
a$ - Ends with a
a* - a followed by any number of characters
a..b – a separated by 2 characters and then followed by b
Shell Scripting
Open a file with extension .sh using any editor
We can type any number of commands
Save the file
Execute the file
• sh file.sh
• ./file.sh
For Loop
for (( i=0; i<5; i++ ))
do
Body of the loop
done
If else condition
if [ condn ]
then
elif [ condn ]
then
else
fi
Shell Scripting
These are the contents of a shell script called display:
cat display
# This script displays the date, time, username and
# current directory.
echo "Date and time is:"
date
echo
echo "Your username is: `whoami` \\n"
echo "Your current directory is: \\c"
pwd