0% found this document useful (0 votes)
12 views

linux commands (1)

Commands of Linux.

Uploaded by

suneelar397
Copyright
© © All Rights Reserved
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)
12 views

linux commands (1)

Commands of Linux.

Uploaded by

suneelar397
Copyright
© © All Rights Reserved
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/ 35

1. Explain about the Operating System Architecture?

2. What are the Features of Unix Operating System?

3. What are the Features of Linux Operating System?

4. What are the Differences between Linux and Windows Operating System?

5. Write Few Unix Family Operating Systems and Linux Distributions


Information?

6. What are the Types of File Present in Linux Operating System?

7. Explain the Categories of the Users and Permissions of Files in Linux


Operating System?

8. What are the Partitions required to Install an Linux Operating System


and What is the Order of Installation if System need both Windows and
Linux, explain?

9. Explain the Linux Hierarchical File System?

10. Explain the Linux Boot Procedure?

11. What is Run Level? What are the Run Levels present in Linux Operating
System?

12. What is Shell? What are the Various Shells Present in Linux Operating
System?
=======================================================================
Linux Basics

Privileged User(root)#
Unprivileged User$

shift + pgup/pgdn -> scroll the Screen

Basic Commands
1. uname : It is useful to know the Flavour of Operating System
uname -r : Display the Linux Kernel Version no
uname -a : Display the Complete Information about the Linux Machine

2. clear : Clear the Screen (Ctrl + l)

3. cat /proc/version :Distribution Infromation and Version No

4. dmidecode : Display the Complete Hardware Information


-t <type>: Display the Given type Hardware Information
1: BIOS Information
2: Mother Board
4: Processor Information
6: Memory Information
5. lsusb : List of Usb ports and Connected Devices Information

6. free : Display the Information of the RAM and Swap Memory


-m : Display Information in MBs
-g : Display Information in GBs

7. df : Display the Paritions Information using by Linux Oprating System


-h : Human Readable Format

8. fdisk -l : Display the Information of all the Secondary Storage


Devices

9. history : Display the List of Command Executed in the Terminals


history <no>: Display given no of commands from history
!<historyid> : Execute the Command with the Given id in History
up and down arrow we can navigate all the commands present in the
history
history -c : Clear all the Commands in the History

10. date : Display the Current System Date & Time


date -u : Universal Time Zone
+: Useful to provde the Format
Formats are
%D : Date
%T : Time
%d : date of the month
%m : month
%y : Year
%H : Hours
%M : Minutes
%S : Seconds
%s : Seconds from 1970 Jan 1 to Till System Date
monthday-EnglishMonth-4digityear
date +%d-%B-%Y

11. cal : Display Current Month Calendar


cal -3 : Display 3 Months Calendar (prev/cur/next)
cal -y : Current Year Calendar
cal <year> : Display the Given Year Calendar
cal <mm> <year> : Display the Given Month in the Given year Calendar
cal -j : Julian Calendar
cal -m : Display the Calendar Starting from Monday
cal 9 1752: 10 Days Eliminated from gregorian Reformation.

12. who : Display the Information about the Current Login Users and
Terminals
who -r : Display the Current Runlevel of the Linux OS

13. runlevel: Display the Current Runlevel of the Linux OS

14. who am i/who i am : Display the Information of the Current Terminal

15. whoami: Display Current Terminal User Information


16. logname: Display the Current Termical User Information

17. tty: Current Terminal File Information

18. w : Detailed Information about all the Login Users and Terminals

19. last : Current Login User Login and Logout Details Information along
with system boot Information
last <username>: Login and Logout Details of the given user

20. lastlog : Recent Login information of all the users.

21. id : Display the Login user ID and Group Information.


id <username>: Dispaly the Given user id and Group Information

22. finger : It display the who command output


finger <username> : Given user Credentials(username, home dir,
shell,last login)

23. dc : Desktop Calculator


12
23
+
p : Print the Output
q : Quit from Application

24. bc : Bench Calculator


12+23 press enter
quit : Close the Application

25. alias : Display the List of alis command present in the Current Shell
and also useful to create the alias commands
alias today='date +%d-%B-%Y'

26. unalias: Remove the Given Alias name


unalias <aliasname>

Process Related Information


---------------------------
27. ps : Display the application running in the Current Terminal
ps -A : Display the Applications/services running in the Linux
Machine
ps -l : Long List Information of the Services

28. top : Display the Dynamic view of all the running services
information
q : quit
k : Close/kill the Application

29. kill : Kill the Given Process id Process(Application)


Note: Owner or Privileged user can kill the processes.
Note: Bydefault kill command is using Signal no 15.
kill -l: get the list of signals
kill -SIGNALNO/SIGNALID <processid>
kill -9 5181 / kill -SIGKILL 5181

30. nice: Useful to start a process with the given priority


Nice Priority is from -20(Most) to 19(Least)
nice -n <priority> <processname>
nice -n -10 top

31. jobs: Display the List of background Jobs in the current terminal

32. bg : Display the Last Backgroung Jobs information

33. fg : Bring back the background process to Foreground


fg <backgroungjobid>

34. <processname> & : Start and Running the Process in the Background.
top &

35. nohup : Start the Process and Run in the Background


nohup <processname>
Note: The Process releasing output will be store in a file called
nohup.out

Keys:
ctrl + c -> Useful to terminate the Process
ctrl + z -> Useful to send the Running Process to Background
ctrl + d -> End of the File

Daemon: Service/application which is running in the Background.


Orphan Processes: A process whose parent process is closed.Orphan process
will be taking care by the init process(1)
Zombie: State of the child process which is waiting to give the
execution report to parent but parent is busy in execution.

Network Related Information:


-----------------------------
36. ping

37. traceroute

38. nslookup

39. dig

40. netstat

41. route

42. cat /etc/resolve.conf

43. ifconfig

Genral Commands
-------------------------------
44. hostname : Display the Linux Machine Name

45. init <runlevel>: Shift from Current Runlevel to Given Runlevel


init 0 : Shutdown
init 6 : Restart
Note: init command can execute only by the root user

46. reboot : Restart the Linux System

47. poweroff/halt: Shutdown the Linux System

48. shutdown : Shutdown the Linux System

49. exit : Close the Terminal

50. logout : Logout The user from the Session

51. script : Record the Current terminal Session


Note: We will Discuss later

52. lsof : Display List of open Files Information in the Linux System

53. which <commandname>: Display the Location of the Command

54. whereis <commandname>: Display the Location of the Command and the
Command Manual Information.

55. env : Display the List of Environment Variables provided to the


Shell.

56. echo/printf : Display the Given text on the Standard Output


echo "Welcome to Linux" -> Print Newline after the Statement
printf "Welcome to Linux" \n-newline \t-tabspace \b-backspace

By using printf and echo we can print the Environment Variable Values
and also command outputs. $variablename/$(command)
printf "$PATH"
echo "$HISTSIZE"
printf "My name is $(logname) and Today Date is $(date)\n"

Printf with Colors


-------------------
printf "\033[attribute;foreground;backgroundm text..";
printf "\033[1;32;43m Welcome to Clabs\n";
printf "\033[1;32;43m Welcome to Clabs \033[0m \n"
printf "\033[1;32m Welcome to Linux \033[0m"
color codes
colorvalues:
0 -> Black
1 -> red
2 -> Green
3 -> Yellow
4 -> Blue
5 -> Magenta
6 -> Cyan
7 -> White
Foreground Color
3<colorno>
Background Color
4<colono>
Attributes:
0 -> off
1 -> Bold
4 -> Underscore
5 -> Reverse Video
======================================================================
command -option : Every Character is One Option of the Command
command --option : Entrie Word is One Option

Help Commands: Useful to know the Purpose and the Subcommands information
1. <commandname> --help
Ex: date --help
Note: View is not much good

2. info <commandname>
Ex: info date
Note: info is a Help Application with the Chain of Commands.
u: Up p->Prev n->next q->quit
Note: View is not much good and information is not Elabirated.
3. whatis <commandname> : Know the Purpose of the Command
Ex: whatis date
Whatis having it's own database to store the commands
information.Whatis command everyday run the job to get update from the
manuals present in the linux machine.
makewhatis: Update the whatis database manually(root only)
4. man <commandname>:
Ex: man cal/man date

man look for the given command from 1 to 8 and it will display
the information from the chapater where it intially exist.

man <cno> <commandname>: To get the Information from the


Specific Chapter
Ex: man 3 printf

man -f <commandname> : Know the List of Chapter where given


command Exist
Help About the Man: man man

q-> Quit
/expression: Highlight the Given Expression
======================================================================
Absolute PATH:PATH Start from /. Every Directory Has the Absoulte path to
access the directory from any where in the File System.
/root/Classes/aug2014/Test
Relitive PATH:PATH Start from Current Working Directory. This PATH
changes from location to location.
From Classes: aug2014/Test
From root: Classes/aug2014/Test
Note: relitive PATH is useful to access the Sub Directory
Structure.

pwd: Display the Absolute PATH of the Current Working Directory.


======================================================================
List Commands
1. ls : Display the Lis of Files and Directories in the Current
working Directory

2. ls -l/ll: Display the Long List information of the File and


Directories

3. ls -a: Display all the File and Directories information


including Hidden files and Directories
Note:File or directory start with . get the Hidden Property

4. ls -s : Display the Size of File and Directories in Blocks.

5. ls -i : Inode Nos

6. ls <path of the directory>: Display the List of Files from the


Given Path.

7. ls -l <filename>: Get the Properties of the Given File

8. ls -l <directoryname> : Properties of All the Files and


Directories in the Given Directory

9. ls -l -d <file/directoryname> : Properties of given file or


Directory

10. ls -R/ls -l -R <Directoryname> : Display the Complete


Directory Structure from the given directory.

11. tree <directory> : Text Based Explorer Option to Display the


Complete Directory Structure
tree -d <directory> : Only Directory Structure with out
displaying the Files information

12. ls -Z : Context Permissions of the Files

13. ls -r : Display the Files in Filenames Desending order

14. ls -t : Display the Files in Modification Order(New->Old)

15. ls -t -r:Display the Files in Modification Order(Old->New)

16. stat <file/directoryname> : Detailed properties of the Given


file or Directory
Wildcard Characters
-------------------
1. list: Group of Files or directories can be seperate with space.
ls -l nohup.out offf.lst on.lst

2. * : Multiple Character set


Display the List of Files and Directories start with a
ls -l -d a*

Display the List of Files and Directories Start with D and end with
s
ls -l -d D*s

Display Only Directories


ls -l -d */ (Only Directories having PATH)

3. ? : Single Character set


Display the List of Files which are having 3rd character as c
ls -l -d ??c*

Display the List of file having Only 3 Characters in the name


ls -l -d ???

4. Range: [a-z] [A-Z] [0-9]


Display the List of File start with p ,q ,r,s,t
ls -l -d p* q* r* s* t*

ls -l -d [p-t]*

du: Display the Size of the Given Directory (Bytes)


du Desktop
du -h Directoryname: Display in Human Redable Format
du -h Desktop
du -s -h Directoryname: Display the Final Size of the Directory
du -s -h Desktop
======================================================================
Directory Commands:

1. mkdir : Create the Directory


a. mkdir <directoryname>: Create the Directory in the Current
Working Directory
b. mkdir dir1 dir2 dir3 : Create the Multiple Directories in the
Current working directory
Note:Directory name should be in the following way if it has
spaces. "directory name" or directory\ name
c. mkdir PATH/directoryname : Create the Directory in the given
PATH
d. mkdir PATH/{dir1,dir2,dir3,..} : Create Multiple Directories in
the Given PATH
e. mkdir -p PATH: It create the PATH from where it does not exist
with out distrubing the exitsing PATH

Create the Following Structure


2. Change the Current Working Directory
a.cd <PATH>: Move to the Given PATH
Note: using tab key we can get the List of Files and Directories
information in the given PATH
b.cd .. : Move to the Parent Directory of the Current Directory

c. cd - : Move to the Previous Working Directory

d. cd : Move to user login directory(User home Directory)

e. cd . : Keeps the Current Directory

3. Move or Rename a Directory


mv <src> <dest>
case 1: Destination Directory Does not Exist
Rename the Course Directory with Dest

case 2: Destination Directory Already Exist


Move the Src Directory into Dest Directory

mv <src1> <src2> <src3> ....<dest> : Move all the Src directories


to the Destination Directory

4. Copy the Directory


cp -r <src> <dest>
Note:Copy should have the -r Option to Directroy input
case 1: Destination Does not Exist
Create Another Copy of Src with the name Dest.

case 2: Destination Already Exist


Create Another Copy of Src in Dest.

cp -r <src1> <src2> <src3>.....<dest> : Create the Copy of all the


Sources in the Destination Directory

5. Remove the Directories


rmdir dir1 dir2 dir3.....
Note:rmdir can delete only empty directories

rm -r dir1 dir2 dir3 ...


Note: It can delete any type of directories

rm -r -f dir1 dir2 dir3...


It deletes all the directories with out any confirmation

Note: In the Place of Directory name we can use wild card


characters
rm -rf a*
rm -rf *
======================================================================
File Commands
1. Create the File and Write the data
cat>filename
cat>>filename
----
----
ctrl +d
> create the new file if does not exist otherwise overwrite
the Existing File
>> create the new file if does not exist otherwise append the
new content to the Existing File

2. Display the Data from the File


cat filename
cat -n filename: Display the Content with line nos
cat file1 file2 file3 ....filen : Display the Content from
all the given files

3. Create the Empty Files with the file size 0.


touch file1 file2 file3.....filen
Note; If the File Already exist having content, touch does
not distrub the file but the file modification time change to the touch
command execution time.

4. Move or Rename
mv <src> <dest>
Case1 : Destination Does not Exist
Rename the Source file with Destination Name

Case2 : Destination is a Directory


Move the Source file to Destination Directory

Case3: Destination is a File


??????????

mv file1 file2 file3......dest

5. Copy File
cp <src> <dest>
cp -p <src> <dest>: Preserve the Source file Properties to
the Destination File.
Case1: Destination Does not Exist
Create Another Copy of Source with Destination Name

Case2: Destination is a Directory


Create Another Copy of Source in Destination Directory

Case3: Destination is a File


????????????

cp file1 file2 file3 ....dest

5. Remove the File


rm file1 file2 file3....: It removes all the given file but
request the confirmation
rm -f file1 file2 file3....: It removes all the given file
with out request the confirmation.

Link Files
Linux has 2 Types of Link Files
1. Hard Links
Create an alias file to the existing file.Internally it
create a new file entry in the directory by copying the i-node no of the
exitsing file with out allocate any memory.

Syntax to create the Hardlink:


ln <srcfilename> <linkfilename>

Use: It is useful to create an access point to access the


data if any case file is deleted mistakely.

Note: We can not create the Hard Link of a Directory.


We can not create the harlink of one file in Different
Partition.

1071015
+------------------------------------------------------------------
---+
We are in the Class
and class is very boring but we are smiling
12
23
35
+------------------------------------------------------------------
----+
Test Directory
===================================================================
=====
1071006 .
1070881 ..
1071015 class
1071023 info
1071014 test1
1071015 boom

Index Node Table


===================================================================
======
1071006 drwxr-xr-x. 3 root root 4096 Sep 2 11:44
1070881 drwxr-xr-x. 4 root root 4096 Aug 30 09:47
1071015 -rw-r--r--. 2 root root 64 Sep 2 11:44
1071023 drwxr-xr-x. 2 root root 4096 Sep 2 11:44
1071014 -rw-r--r--. 1 root root 25 Sep 2 11:44

2. Soft Links or Symbolic Links


Softlink is the Original Link file which maintain the PATH of
the source file and it is shortcut file.
Note: Shortcut does not if source file is deleted.
Note: If The link of a file or directory created in Different
Directory or Parition, we have to provide the absoulte PATH of the Source
File.

Syntax to create the Softlink:


ln -s <srcfilename> <linkfilename>
ln -s class india

We can create the Softlink of a directory and we can create


the softlink of a file or dierctory in Different Partition.

1071024
+------------------------------------------------------------------
---+
class
+------------------------------------------------------------------
---+

1071015
+------------------------------------------------------------------
---+
We are in the Class
and class is very boring but we are smiling
12
23
35
+------------------------------------------------------------------
----+
Test Directory
===================================================================
=====
1071006 .
1070881 ..
#1071015 class
1071023 info
1071014 test1
1071024 india
Index Node Table
===================================================================
======
1071006 drwxr-xr-x. 3 root root 4096 Sep 2 11:44
1070881 drwxr-xr-x. 4 root root 4096 Aug 30 09:47
#1071015 -rw-r--r--. 2 root root 64 Sep 2 11:44
1071023 drwxr-xr-x. 2 root root 4096 Sep 2 11:44
1071014 -rw-r--r--. 1 root root 25 Sep 2 11:44
1071024 lrwxrwxrwx. 1 root root 5 Sep 2 11:44->class

=======================================================================
Compress Files and Directories
1. gzip <filename>: Compress the Given file and replace with the
new file named filename.gz
2. zcat <filename.gz>: It will diaplay the content in the
Compressed file with out Uncompress the file and the file is a Text file

3. gunzip <filename.gz>: Uncompress the given file and replace the


file with the new file named filename

Note: gzip command can not compress a directory.

Create a Single Archive File using Multiple Archives


c: create
f: file
v: Verbose: Display the Status of the Execution
x: Extract

1. Create the Single Archive File


tar -cf <dest.tar> <src1> <src2> <src3>......
tar -cvf <dest.tar> <src1> <src2> <src3>......
Note: Source can be a file or Directory
Note: we can compress the tar file using gzip command

//Create the Tar file with Compression


tar -zcvf <dest.tar.gz> <src1> <src2> <src3>......

2. Display the List of Files information present in Tar


tar -tf <dest.tar>
tar -tvf <dest.tar>

3. Extract the File and Directories from tar file


tar -xf <dest.tar>
tar -xvf <dest.tar>
======================================================================
ed: It is a Line Editor
VI/VIM Editor:
Vi Editor Modes
1. Command Mode: Vi Editor open the file in Command Mode and in
this mode every key stroke treated as command.
Command Mode -> i -> Insert Mode
Command Mode -> : -> Colon Mode

Note: The Below keys can work using no combination.

k(up)
j(down)
l(right)
h(left)
Note: Arrow key also working

x : Delete the Characters


X : Backspace Charcater
dw : Delete a Word
dd : Delete the Entire Line
Note: Vi editor having a buffer which stores last Deleted
Informtion using x or dw or dd

p : Paste the Data from Buffer to Editor


yy : Yanking -> Copy the Line in the Buffer Maintained by Delete.
u : Undo -> Recover the Last transaction
ctrl + r : -> Redo -> get back the Undo Transaction

2. Insert Mode: It is useful to Add,delete and Edit the Content


Insert Mode -> esc -> Command Mode

3. Colon Mode : It is useful to Perform Copy, Move and Other Vi


Editor Operations.
Colon Mode -> esc -> Command Mode

:nu -> Display the Cursor Line no


:set nu -> Display the Line nos for all the Lines
:set nonu -> Disable the Line Nos
:<lineno> -> Move Cursor to the Given Line no
Note: . Represents Current Cursor Line no
$ Represents End of the File Line no
:<srclineno> co <destlineno> : Copy the Src Line After Dest Line
Position
:<sline>,<eline> co <destline> : Copy All the Lines from Start to
end after Destination Line
:<srclineno> mo <destlineno> : Move the Src Line After Dest Line
Position
:<sline>,<eline> mo <destline> : Move All the Lines from Start to
end after Destination Line
:!<command> : Execute the Given command on the Terminal and Return
back to the Vi Editor
:w -> Save the File
:wq -> Save and Quit
:x -> Save and Quit
:w <filename> -> Save as given File
:q! -> Quit Forcefully
--------------------------------------------------------
File Recovery using Vi Editor
If any file opened using Vi Editor , internally editor opens a file
with the name .filename.swp to store all the Unsaved Information. If the
Editor get closed improperly the swp file remain same and next time file
open moves to File Recovery Mode

To Recover the Unsaved data


:recover or open the file vi -r <filename>
Note: After Recove delete the swp file manually
rm -f .filename.swp
-------------------------------------------------------
Vi Editor Settings File
Every User In Linux Can provide their Individual Setting for Vi
Editor which work when the User is Working in the Linux Machine.
~/.exrc
set nu
abbr macroname macrodefintion
set nu
abbr clabs Convergence Labs
abbr h1 #include<stdio.h>
abbr h2 #include<math.h>

~ represents the Login User Home Directory


----------------------------------------------------------
Split the Vi Editor Screen and Open Multiple Files
Note: Split Screen May not Work in Some Version of vi but vim
support.
Split the Vi Screen
ctrl+w Leave then
Press v -> Vertical
Press s -> Horizontal
Note: Both options open the same file in other screen also, to open
a new file in that screen, we have enter to colon mode and type vi
filename.
Press n -> Open the New file in Horizontal

ctrl+w Leave then


Press arrow Key to Move the Cursor Between Screens

wqa : Save and Quit all the Screens


======================================================================
FTP(File Transfer Protocol)->Download and Upload the Data from/to the
Server Machine
HTTP(Hyper Text Transfer Protocol)-> Get the HTML Script from the Server
machine to Run the Application in the Client Machine

Teamviewer: We can get the Desktop and Control of the Remote machine to
perform the Operation in the Remote Machine.

Remote Login Applications: it is useful to perform all the Computer


Opearations in a remote machine from another machine.

Note: Every Network Application Required Server and Client Program.

Linux Client Linux Server Windows Client


Telnet Telnet Telnet
SSH SSH Putty(Telnet,SSH,Rlogin)
Rlogin Rlogin -
Note: All Above Application provide the CUI Terminals
VNC Viewer VNC Server VNC Viewer
Rdesktop Rdesktop RDP

Linux Client Windows Server Windows Client


Telnet Telnet Telnet
Rdesktop RDP RDP
----------------------------------------------------------------------
How to Connect the Linux Machine using Telnet Protocol?
PortNo: 23

telnet <remotemachine ip Address>


Login:
Password:

Note: root user of the remote machine telnet login is diabled because of
telnet is not secured.(Plain text Authauntication)
---------------------------
How to Connect the Linux Machine using SSH Protocol?
Secured Shell, Port NO: 22

ssh <remotemachine ip address>


Enter localusername@ipaddress password:
(or)
ssh <username>@<remotemachine ip address>
Enter username@ipaddress password:

Note: Root user of the remote machine can login using ssh protocol
because of it is Secured with the RSA Algorithm for password
authauntication.

------------------------------
Assignment:
What is the RSA Algorithm and how it is provide the security to the
SSH Protocol?
What is RDP?What are Port Nos using by the RDP?
======================================================================
Scheduling Commands
useful to run a job/task automatically at the given time.job can be
a command or an application.

1. Login : At the time of user login (FG&BG)


2. Logout : At the time of user logout (FG&BG)
3. Corntab : At the Given Interval of time (BG)
4. At : At the Given Date & Time (BG)

Note: If any kind of Foregroung Job scheduled using Crontab or At,


the output will send to user through mail.

2 Types of Applications
1. Foreground Applications: Application which is required running
user terminal.
Ex: cal

2. Background Applications: Application which does not required


running user terminal.
Ex: wall Welcome
------------------------------------------------
1. Login Scheduling: Every User in Linux Has a file in the user home
directory with the name .bash_profile. add the job in the following file
with out distrubing the exitsing content.
vi ~/.bash_profile
cal
date
wall "Hai to EveryOne"

Note: Root user can scheduling a job to run very user login time
using the file /etc/bashrc
Running -> Jobs in /etc/bashrc then user Jobs present in
~/.bash_profile

2. Logout Scheduling: Every User in Linux has a file in the user home
directory with the name .bash_logout. add the job in the following file
with out distrubing the exitsing content.
vi ~/.bash_logout
wall " Have a Nice Day"
cal
sleep 3 #Suspend the Execution for given no of seconds

3. crontab : Run the Job automatically at the given Interval


crontab -l : View the List of Jobs Present in the Crontab
crontab -e : Edit the Crontab file

1. Minutes in a Hour: 0-59 Ex:15 or 15,25,35 or *


2. Hours in a a Day : 0-23 Ex: 10 or 10,14,19 or *
3. Date in a Month : 1-31 Ex: 1 or 1,15,30 or *
4. Month in a Year : 1-12 Ex: 1 or 3,6,9 or *
5. Day in a Week : 0/1(sun)-6(sat) Ex: 1 or 2,3,4 or *
1(SUN)-7(SAT)

Crontab Job should be in the following format


I1 I2 I3 I4 I5 job

#24 17 10 9 * wall "Plase come for the Meeting"


#24 17 10 * * wall "Please come for the Meeting"
#24 11,17 * * * wall "Please take the break"
#* * * * * wall "HeeeeHeee"
30 10 1 * * wall "Send your monthly Report"
30 17 * * 7 wall "Happy Weekend"
0 0 1 1 * wall "Happy New Year"
30 12 8,9,10,11,12,13,14 * 7 wall "Happy Second Saturday"
30 12 8,9,10,11,12,13,14 * 7 cal

4. at : It is useful to run the job at a given date & time


at <date&time>
at mmddyyyy -> It will take the Current System Time
at 10302014
at -t yyyymmddhhmm -> In the Given Date and Time
at -t 201410300930
at> ----
at>ctrl +d -> Close the Task

atq -> View the List of Pending Jobs


atrm <jobid> -> Remove the Given Jobs

at noon/teatime(4PM)/midnight
======================================================================
Change the Date & Time
date mmddhhmmyyyy
date 091017152014
Control the Crontab Service
service crond restart
======================================================================
Redirection Commands/Characters
1. >(Overwrite) and >>(Append)
command>filename
command>>filename
Redirect the Left Side Command output to the Right side File.

2. | (PIPE)
command1|command2
Redirect the Left Side Command Output as Right side CommandInput.
cal|wc
Note: Some time command can not take the inputs Supplied by |
character, in this cased better to use xargs command.
xargs command will take the inputs getting from | and excute the
given command by supplying that inputs.
command1 | xargs command2
echo "9 1752" | xargs cal
======================================================================
Filter / Database Commands
wc : Display the No of Lines, Words and Characters in the given file.
wc file1 file2 ...filen
-l : Lines -w : Words -c : Character

Paste:Combine the Lines as Columns from the given files and Display and
by default delimiter is tab space.
paste file1 file2 file3 ... filen
paste -d "character" file1 file2 file3 ... filen
paste -d "$" file1 file2 file3 ... filen

head filename: Display the Top 10 Lines from the given file.
head filename
head -lineno filename: Display the top given no of Lines
head -n lineno filename: Display the top given no of Lines

tail filename: Display the Last 10 Lines from the given file.
tail filename
tail -lineno filename: Display the last given no of Lines
tail -n lineno filename: Display the last given no of lines
tail -n +lineno filename: Display from the given line no to end of
the file.

Display 6 to 13th Lines content from info file.


head -13 info | tail -n +6

grep: Useful to search the given expression in the given file


grep "expression" filename1 filename2
Note: Above Syntax follow the case.
-i : Ignore Case sensitive
-n : Display the Line nos
-c : Count of Lines
-w : Search for the Word
-x : Expression should be in the Entire Line
-v : Invert Match
-r : Search all the files in the given directory
egrep/fgrep : Work like grep Command

tr : Replace The Expression in the Given Input and Display the Output
Note: tr command required the data using |
input | tr
tr "exist chars set" "new chars set"
cat info | tr "aeiou" "PQRST"
cat info | tr "aeiou" "PQR"
Note: The extra characters replace with last character in the
charcater set
cat info | tr [a-z] [A-Z]
tr -d "characterset"->Remove all the Given characters.
tr -s "characterset"->Squeeze the Given Characters
cat empdata | tr -s ":"

cut: Get the data using Positions from the file


cut -c<cpos> filename
cut -c3 einfo
cut -c<cposx>,<cposy>,<cposz> filename
cut -c3,9,15,19 einfo
cut -c<cposx>-<cposy> filename
cut -c3-9 einfo

Cut the data at the given delimiter


cut -d 'char' -f<f1> filename
cut -d ':' -f2 einfo
cut -d 'char' -f<f1,f3> filename
cut -d ':' -f2,3 einfo
cut -d 'char' -f<f1-f3> filename

Change : as Tab Space and store the Output in a File


cat einfo| tr ":" "\t" > mydata

Note: Cut bydefault take the delimiter as tab space


cut -f2 mydata

sort: Display the Sorted data getting input from the file
sort filename (Asending) Character
sort -n filename Character and Numerical Sorting
-r : Desending

Sort the Data based on the given field in the file


sort -t "delimiter" -k<fieldno> <filename>
sort -n -t ":" -k3 einfo
uniq: Squeeze the Lines(If the Same Line is Repeated , Make it Unique)
uniq <filename>
uniq info

cmp: Compare 2 Files and Given the Location where files having the
Difference.
cmp file1 file2

diff: Compare 2 Files data line by line and Display all the differences
present in Both the files
diff file1 file2

comm: Display the data in the following way from the Sorted Files
uniqinfile1 uniqinfile2 commoninbothfiles
comm f1 f2
-1,-2,-3 : Suppress the given no column
comm f1 f2 --output-delimiter='$'

split: Split the Given file Content in Multiple Files


split -lineno filename
split -5 filename
Bydefault filenames are xaa,xab....(Overwrite if files exist)
split -lineno filename prefixname
split -5 filename clabs -> prefixname will be use instead of x
split -b <bytes> filename
split -d <filename> : Use the Suffix as Digits instead of using
apphabet combination (x00,x01,x01,...)

csplit: Csplit have more Extra Features than split. We can split the file
at the given expression also.

locate <filename>: Search for the Given file in All the locations in the
file system.

find: Search the file with the given conditions


find <path> -option <optioninput>
find /root -name mydata : Search for the mydata file
* can use as wild card character Ex: mydata*
+n -> for greater than n
-n -> for less than n
n -> for n
time +5 min -> 5 Mintures before any time
-5 min -> With in 5 Minutes
5 min -> Exactly at 5 Minutes
-amin n: File was last accessed n minutes ago.
Ex: Search the List of Files Acessed with in 2 Minutes
-cmin n: File’s status was last changed n minutes ago.
======================================================================
Change File Permissions
chmod ugo+/-/=rwx file/dir1 file/dir2 file/dir3....
Note: Owner or Administrator
+: Add the Given Permissions without distrub the exitsing one
-: Remove the Given Permissions without delete the other
permissions
=: Exactly Assign given Permissions
chmod ugo+x abc
chmod go-w abc
chmod ugo=rx abc

Add the Following Permissions to abc file


---x--x--x. 1 root root 26 Sep 12 12:17 abc
User -> rwx 4+2+1 ->7
Group -> rx 4+1 ->5
Others -> x 1 ->1
chmod u=rwx,g=rx,o=x abc
We can use numerical values for the permissions
Read - r - 4
Write - w - 2
Execute - x - 1
UGO
chmod 751 abc

chmod permissions directory: It will change the permissions of the


directory but not change all the files and sub directory structure inside
the directory, so we have to -R option along with chmod.
chmod -R permissions directory
======================================================================
umask: Useful to get and change the default file permissions of the User.
umask: Display the default File Permissions of the User.
777
0022
----
755 rwxr-xr-x
----
Note: Linux Does not assign execute(x) permission on file for the
security puporse for not allow to run the scripts directly.

Change the Umask permissions


rwxrwx--x
7 7 1 777-771=>006
umask 0006: Excute to change the Permissions
Note: The changing permissions only effect on the current session
and next time you will get the default umask value. To make permannat add
umask command in ~/.bash_profile
======================================================================
Linux Administration

Change the File/Directory Owner and Group Owner

Change the File Owner


chown newusername file/dir1 file2/dir2 file3/dir3 ....
Note: User should be exist in the Linux System
(lastlog or cat /etc/passwd)
chown tomcat abc
chown -R tomcat Test

Change the File group Owner


chgrp newgroupname file/dir1 file2/dir2....
Note: Group should be exist in the Linux System
(cat /etc/group)
chgrp info abc
chgrp -R info Test

Note: chown command can change the file owner and group owner at a time
chown owner:groupowner file/dir1 file/dir2....

Note: -R option is required To change all the Files and Sub Directory
structure of the Directory for chown and chgrp
======================================================================
User Group:
1. Primary Group (User Must Have one Group as Primary Group and
it should be only one)
2. Secondary Groups (User May be using some groups as secondary
groups to perform some operations)

Linux Bydefault reserve the Userids and Group Ids from 0 to 499 for the
system Accounts.

User Database File: /etc/passwd Backup File: /etc/passwd-


username:x:userid:primarygroupid:Comment:homedirectory:shell
root:x:0:0:root:/root:/bin/bash
u1:x:500:500:user1:/home/u1:/bin/bash
u2:x:777:500:user2:/home/jamesbond:/bin/csh
u6:x:502:500:user6:/home/user6:/bin/bash
u3:x:888:501:user3:/home/user3:/bin/ksh
u4:x:999:501:user4:/home/user4:/bin/ksh
u9:x:567:578:user9:/home/user9:/bin/bash
u10:x:568:578:user10:/home/user10:/bin/bash
suman:x:555:800:suman:/home/suman:/bin/bash

User Password File: /etc/shadow Backup File: /etc/shadow-


username:!userpassword with md5 Encryption!:

Group Database File: /etc/group Backup File: /etc/group-


groupname:x:groupid:list of users using group as secondary group
root:x:0:u1,u10
tpd:x:500:
awc:x:501:
tpt:x:578:
linux:x:800:u1,u2,u10

Group Password File: /etc/gshadow Backup File: /etc/gshadow-


groupname:!group password with md5 encryption!:

User Management
======================================================================
useradd <username>
username:givename
userid:1 increment to previous id
groupid:create a group with the same username and add the user
comment:blank
homedir:/home/username
shell:/bin/bash

useradd -u <userid> -g <primarygroupid/name> -G <seondarygroupid/name


with ,> -c >comment> -d <hoemdir> -s <shell> <username>

useradd -u 555 -g 514 -G root,bin,clabs -c "He is Tech" -d /home/jeeva -s


/bin/csh jeevan

Create the Password for the user: passwd <username>


passwd command useful to change login user password
passwd -d <username>: Delete the user password
The user can directly login with out any password.
-------------------------------------------------------------
usermod -u <userid> -g <primarygroupid/name> -G <seondarygroupid/name
with ,> -c >comment> -d <hoemdir> -s <shell> <username>
Note: We have to use -a along with -G option to add more groups as
secondary groups with out removing from existing groups
usermod -G info,raju jeevan
usermod -a -G info,raju jeevan

Change the User Name: usermod -l <newusername> <existingusername>


Lock the User :usermod -L <username>
UnLock the User :usermod -U <username>
Change to Nologin Shell: usermod -s /sbin/nologin <username>
Note: We change the userid to another existing userid
usermod -o -u 999 jeevan
This is user to provide the same privilege to Multiple users, for example
i want to create a user with the root privilege , we can add the user id
as 0.

--------------------------------------------
Delete the User
userdel <username> : It delete the user but leave the user home
directory
userdel -r <username>: Delete the user along with homedir

Note: Linux copy the data present in /etc/skel directory to user home
directory after create the user.So if any files want to copy in the user
home directories at the time of create the user , copy in skel directory.
======================================================================
Group Management
Create the Group : groupadd <groupname>
groupadd aug2014
groupadd -g <groupid> <groupname>
groupadd -g 999 holiday

Modify the Group Parameters: groupmod -g <newgroupid> <groupname>


groupmod -g 520 aug2014

Delete the Group: groupdel <groupname>


groupdel aug2014
Note:We can not delete the group if it is using as primary
group
More Information About the Group
Add the Group Password
gpasswd <groupname>: Request the password and add the password for
the group.
======================================================================
Every Process in Linux Has owner and Group owner.
Bydefault owner is login user and group owner is promary group of the
user.
ps axo stat,uname,group,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
-------------------------
Create the New session with different username in the same
terminal(Switch User)
su : Default username is root
su <username>
password:
Note:Session create with tyhe given user and his primary group

Close the session: exit


--------------------------
Create the Session with same owner and with Different Group Owner
newgrp <groupname>
Note: Group should be added as user primary or secondary group
otherwise it request the group password.
-------------------------
More About Group Administration
It is very difficult for root to control every User&Group Administration
Operations.So To manage the user groups, we can create the Administrators
for different groups called group administrator.Group Administrator can
add/delete the users in the group.
gpasswd -A <username> <groupname> : Add the user as group
administrator
gpasswd -A venkat holiday
gpasswd -r <groupname>: Delete the Group Password

gpasswd -a <username> <groupname>: Add the user in the Group


-> This can excute by the group admin
gpasswd -d <username> <groupname>: Delete the user from the
Group -> This can excute by the group admin
gpasswd -a kalyan holiday
=======================================================================
Basic Structure
groupadd [root@classroom ~]# groupadd tpd
[root@classroom ~]# groupadd tpt
[root@classroom ~]# groupadd awc
[root@classroom ~]# useradd -g tpd u1
[root@classroom ~]# useradd -g tpd u2
[root@classroom ~]# useradd -g tpd u3
[root@classroom ~]# useradd -g tpt u4
[root@classroom ~]# useradd -g tpt u5
[root@classroom ~]# useradd -g tpt u6
[root@classroom ~]# useradd -g awc u7
[root@classroom ~]# useradd -g awc u8
[root@classroom ~]# useradd -g awc u9
Note: Create the password for all the users using passwd command
------------------------------------
Creating a Shared Directory which allow to Access Specific Users
1. Create the Directory to share the Data among selected users
Note: Shared Directory should be in the Location where every user
can access(ex: /, /home,/var...)
mkdir /aainfo

2. Create a Group to Logically Combine the Selected User


groupadd aadhar

3. Add the This Group as secondary group to Selected Users


groupmod -a -G aadhar u1
groupmod -a -G aadhar u4
groupmod -a -G aadhar u8

4. Change the Shared Directory Group Owner as Secondary Group of


the Selected User
chgrp -R aadhar /aainfo

5. Allow Only Owner and Group Owner to Perfrom all the Operations
in the Directory and Block Others
chmod -R 770 /aainfo

6. Add Toggle bit on the Directory to Secure the Ownership of the


Files/Directory.(No one can delete other than owner)
chmod -R +t /aainfo

7. Add Sticky bit on the Directory to make all newely creating


files group owner as the directory group owner.
chmod -R +s /aainfo
=======================================================================
[root@classroom ~]# groupadd aadhar
[root@classroom ~]# usermod -a -G aadhar u1
[root@classroom ~]# usermod -a -G aadhar u4
[root@classroom ~]# usermod -a -G aadhar u8
[root@classroom ~]# chgrp -R aadhar /aainfo
[root@classroom ~]# chmod -R 770 /aainfo
[root@classroom ~]# chmod -R +t /aainfo
[root@classroom ~]# chmod -R +s /aainfo
======================================================================
What are the Feature a Linux User Can Access?
User
----
Login/Remote Login -> User Required a Shell
FTP
MAIL
Other Server Services
Note: If the user get locked , he can not access any of the services
present in the user linux machine.
Linux Administration

Recover root user password:


start->post->bios->boot device->MBR->grub->By default Linux Select the
Run Level from /etc/inittab file if the runlevel not supplied at the grub
options.

Recover the Root User Password


1. Start the Linux Machine
2. Select the Linux in grub menu and append the run level 1(Press a
->space->1)
3. System boot to Run Level 1(Single User Maintainance Mode with
out any authentications)
4. Change or Delete the Password of the root
passwd or passwd -d root
6. Reboot the System
7. Boot to Linux Machine with the new password or with out password

Note: User can not edit or append the Information at grub menu if grub
has the password.

----------------------------

How to add the Grub Password


1. generate the password using grub-md5-crypt command
2. Copy the Password and Add the Following entry with the encrypted
password in /boot/grub/grub.conf file.
Copy after "hiddenmenu" option in the file
password --md5 <encryptedpassword>
Ex: password --md5 $1$INsru1$mugQf5FsIQibQupOlAKne.

---------------------------
Remove the Grub Password if we lost both grub and root password
1. Boot from Liux DVD and Select the Rescue Installed System Mode
2. Select the Shell prompt and Enter to root mode using chroot
/mnt/sysimage
3. Open the Grub file(/boot/grub/grub.conf) and remove the Grub
password.
4. Go back to Menu using exit command and select reboot option to
restart the machine
Note: This operation is possible only if we can access the machine
directly(physically).
---------------------------
Mouting and Unmounting
Mounting: Create the Logical Directory structure of a storage
partition or shared directory to perfrom File Opeations.
Unmounting: Detach the Storage Patition with the Logical Directory
for not perfrom the File operations.

Note: Linux has automatic and manual mouting and unmounting


options, bydefault linux mount all the extrnal storage device paritions
in /media directory by create the new directory for every connected
device and also it delete the created directory if the device is
disconnected from the system.
File Systems are
ext2
etx3
ext4
fat(vfat)
ntfs
Note: Bydefault Linux can mount only ext2,ext3,ext4,vfat file
systems and required install a package for mounting the ntfs file system.

Mounting the paritions Externally


===================================
mount partitionid mountpoint
mount -t filesystemtype partitionid mountpoint
Ex:mount /dev/sdb1 Desktop/mydata

Umount the Paritions


================================
umount paritionid or mountpoint
umount /dev/sdb1

Why mounting is required even Linux is Mouting Automatically?


Manual mouting is required to access the Directories shared using
NFS Server
Ex: mount -t nfs ipaddress:/PATH/directory mountpoint
mount -t nfs 192.168.1.25:/softwares Desktop/mydata

Linux Can mount the ISO file in a Directory to Access the data.
mount -o loop Desktop/rhel6.0.iso Desktop/test

Note: Linux provided an empty directory named /mnt for user mounts

How linux Automatically mouting the /,boot and swap partitions?


Linux Automatically mount the devices at the time of booting
present in /etc/fstab file.
192.168.1.25:/softwares /mnt nfs defaults 0 0

mount -a : It is useful to refresh all the mounts present in


/etc/fstab file.
=========================================================================
=====================================
Linux Packages Installation
Most of the Packages in Linux available in .rpm extension(resource/redhat
package manager)

1.rpm -ivh PATH/packagefilename.rpm : Install the Packages


i: install
v: verbose
h: hashing

2.rpm -q packagename : Display packages is instralled or not


rpm -qa : Display all the List of Installed Packages
3.rpm -e packageinfo : Delete the Given Package

Note: Sometimes packages are required the installations of Other


Packages called dependencies.

-------------------------------
Linux has a tool named yum(Yellowdog Updater Modified) for packages
installation
Note: yum can not be directly install the packages,yum shpuld be
configured with the repository information. repository can be present in
Local System or In remote system(Share through nfs,ftp,http...)

Repository: A Directory with Collection of Packages along with the


information about the Packages.
Note: Bydefault Linux DVD act as a Repository.

How to Configure YUM with the Repository


----------------------------------------
1. Enter to /etc/yum.repos.d directory
cd /etc/yum.repos.d

2. create a file with anyname but should with .repo extension and
add the Repository Information in the Following way
[title]
baseurl=ftp://ipaddressorurl/path
baseurl=http://ipaddressorurl/path
baseurl=file://absolutepath
enabled=1
gpgcheck=0 (Gnu Privacy Gaurd)

[convergencelabs]
baseurl=file:///mnt/rhel6
enabled=1
gpgcheck=0

3. Execute the Following Command to Refersh the yum


yum clean all

4. Update the Information of the Packages available in the New


Repositories configured in YUM
yum update

How to Install the Packages using YUM


-------------------------------------
1. yum list all : Get the List of all Avialable Packages
yum list name : Informaiton of the Packages with the given
name

2. yum install package: To install the Given Package

3. yum remove package: Remove the Given Package

----------------------------------------------
How to Create the Repository?
1. Create the Directory
mkdir /mypack

2. Copy all the Packages in the Directory

3. create the repository using the Following command


createrepo PATH/directory
createrepo PATH/directory --update : Update the Existing
Repository
createrepo /mypack
Note: We have to install createrepo package to get the
createrepo command
rpm -ivh /mypack/deltarpm-3.5-0.5.20090913git.el6.i686.rpm
rpm -ivh /mypack/python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
rpm -ivh /mypack/createrepo-0.9.8-4.el6.noarch.rpm
=========================================================================
=====================================
Disk Management
1. Select the Disk/Device for the Disk Management using fdisk
command
fdisk deviceid
fdisk /dev/sda
Command(m for help):
m ->Display the List of Available Commands
n ->Add/Create the New partition
Disk can have Maximum 4 Paritions with the combination of
Primary and extended.
Parition no,Starting Cylendar,Ending Cylinder or Size

Note:Linux bydefault create the partition with the parition id 83


which is support to format with ext2/ext3/ext4 filesystems. to format
with fat(b), ntfs(7) or swap(82) we have to change the partition id.
t -> Change the Parition ID
L -> Display the List of Parition IDs

p ->Print the Parition Table


w ->Save the Changes
Note: We have to update the Changes in Linux Kernal using partprobe
command or eboot the system.
q ->Quit from fdisk with out save the changes
d ->Delete the Parition

2. Newely Created Partitions should be format with the File System


mkfs -t filesystem paritionid
mkfs -t ext4 /dev/sda3
mkfs -t vfat /dev/sda5
Note: e2label command to add the Label to
aParition(ext2,ext3,etx4)

Note: mkfs can not format parition with swap file system.
mkswap paritionid
mkswap -L label partitionid
3.We have to use Following Method to Mount the
ext2/etx3/ext4/vfat/ntfs file systems
[root@newserver ~]# mount /dev/sda3 Desktop/l1
[root@newserver ~]# mount /dev/sda5 Desktop/w1
To make this moutings permanant add in /etc/fstab file
/dev/sda3 /root/Desktop/l1 ext4 defaults 0 0

/dev/sda5 /root/Desktop/w1 vfat defaults 0 0

4. We have to use following Method to Attach the swappartition to


Linux Machine
swapon <paritionid> / swapoff <apritionid>
swapon /dev/sda6 / swapoff /dev/sda6
To make this moutings permanant add in /etc/fstab file
/dev/sda6 swap swap defaults 0 0

swapon -a : Attach all the Swap paritions present in


/etc/fstab file to Linux
swapoff -a : Detach all the Swap paritions present in
/etc/fstab file from Linux
=========================================================================
=====================================
Network Cards Management and Configure IP Addresses

1. ifconfig: View and Change the IP Address of the Linux Machine


eth0, eth1,......
lo : Loop Backup Adapter(127.0.0.1 - Self pinging) -> To Access the
Network Based Application Running in the Same machine.

ifconfig -a : Display all the INterfaces information irrespective of


their state(Active or Inactive)

ifconfig <interfaceid> ipaddress netmask <netmaskvalue> up/down

ifconfig <interfaceid> ipaddress netmask <netmaskvalue>


ifconfig eth0 192.168.1.4 netmask 255.255.255.0
Note: This is not permanent.

2. Using setup Dialog Tool


setup->network configurations->Device Configuration->Select the
Ethernet Device->Add the IP -> Save&Quit
Note: After Configure the IP Address we have to Restart the Network
Service or Re Instiate the Interface Connect
service network status/start/stop/restart ifup/ifdwon <ethernatid>
ifup eth0

3. Using the Network Configuration File


/etc/sysconfig/network-scripts/ifcfg-eth<no>
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
Configuration using DHCP Protocol
BOOTPROTO=dhcp

Configuration using Static IP ADdress


BOOTPROTO=none/static
IPADDR=192.168.1.8
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1

Note: After Configure the IP Address we have to Restart the Network


Service or Re Instiate the Interface Connect
service network status/start/stop/restart ifup/ifdwon <ethernatid>
ifup eth0

4. Using GUI
System -> Preferences -> Network Connections (Commandline: nm-
connection-editor)
After add/Change the IP Address we have to Reconnect the Inetrface
===================================
How to View/Change the DNS Server Information?
cat /etc/resolve.conf
Note: We can Edit this file and change the DNS Server Information
nameserver <dnsipaddress>
nameserver 192.168.1.1
nameserver 8.8.8.8
===================================
How to Create Psuedo Ethernet Cards and Assign the IP Addresses?
Q: Why Psuedo etherenet cards are required in the machine?
A: It is useful to Configure a Linux machine with Multiple IP
Addresses to run Several network applications on the same port no with
out having multiple ethernet inteface cards.
Network Application Socket Binds IPADDRESS:PORTNO -> This
combination should be unique
192.168.1.20:30
192.168.1.25:30

Note: Real Ethernet card can be Configure with DHCP and Static but
Psuedo Ethernet Card should have the static IP Address.

1. Move to /etc/sysconfig/network-scripts Directory


cd /etc/sysconfig/network-scripts

2. Create new copy for the Physical Ethernet Card with the
Following Filenames
ifcfg-eth<no> -> ifcfg-eth<no>:0 , ifcfg-eth<no>:1 ,.....
ifcfg-eth0 -> ifcfg-eth0:0, ifcfg-eth0:1, ifcfg-eth0:2,...

3. Edit the Psuedo Ethernet Card File and Change the Following
Information
DEVICE=eth0:1
IPADDR=192.168.1.17
NAME="System eth0:2"
4. Activate all the Interfaces
Reboot or use ifup <interfaceid>
-------------------------------------------------------------------------
------------------------------------
Services
View the List of Services running in the Linux System
1. setup->System Services
2. ntsysv

Enable/Disable the Service Boot time Startup


1. setup->System Service / ntsysv -> Add *(Enable)/Remove
*(Disable)
2. chkconfig <servicename> on/off
chkconfig crond on

Control the Services after Booting


service <servicename> status/start/stop/restart
service crond status/start/stop/restart
-------------------------------------------------------------------------
-------------------------------------
Note: After Linux Installation Enable the Following Network Devices and
Protocols in the FIrewall to use the Network Resources
setup->Firewall Configuration->Customize->
Trusted Interfaces
Masquerading
-------------------------------------------------------------------------
-------------------------------------
Remote Login: Login to a machine available in the network to perform the
various options/Configurations in the Remote System.
Remote Login Server
Telnet
ssh
rlogin

-------------------------------------------------------------------------
-------------------------------------
How to Connect to FTP server from Linux for Download and Upload the
files?
1. Every Internet browser can work as FTP Client.
2. Linux has a cli tool named ftp.
rpm -ivh ftp-versionno.rpm
yum install ftp*

Working with ftp Client


ftp <url/ipaddress>
Login: ftp/username
Password: Blank/userpassword
ftp>ls -> Display the List of files
ftp>cd <directory> : Change the Directory in FTP
ftp>get <filename> : Download the Files
ftp>put <filename> : Upload the files
ftp>pass : Enable/Disable the Passive mode
ftp>quit/bye : Close the ftp Connection
ftp>help : List of Vailable Commands
ftp>help command : Use of the given command

FTP Connectivity and Data Transfer in 2 Modes


1. Active Mode:
1. FTP Client Send Request/Commands to FTP server on 21 Port
Number
2. FTP Client Send/Receive Data to server on 20 Port Number

2. Passive Mode:
1. FTP Client Send Request/Commands to FTP server on 21 Port
Number then Server Randomly Pick a Port number and send to client for
Data Transfer
2. FTP Client Send/Receive Data to server on the Port No send
by the server

How to Connect to FTP server from Windows for Download and Upload the
files?
1. Every Internet browser can work as FTP Client.
2. Lot of Third Party Tools are
available(Filezilla,DownloadAccelator)

FTP Server ftp port nos(20-Data,21-Command)


1. Install the FTP server Package
rpm -ivh vsftpd-version.rpm
yum install vsftpd*

2. Enable FTP in the Linux Firewall


setup->firewall configuration->customize->FTP

3. Enable the FTP Server for Bottime Startup


chkconfig vsftpd on/off
setup->System Services->Select the vsftpd service

4. Control the FTP Service


service vsftpd status/start/stop/restart
--------------------------------------------------
5. FTP Server Configurations (/etc/vsftpd/vsftpd.conf)
2 Types
1. Anonymous/Public ftp
It is useful to connect the ftp server with out any
authauntication to upload/download the data in a Common Directory.
(/var/ftp)
Note: Bydefault ftp server configure with anonymous ftp for
download the data.
Note: Anonymous Login Directory should not have writable
permission for security reasons, so anonymous ftp login directory has
another directory with the name pub with write permissions for upload and
download the data.
Configurations to Upload the data in Anonymous ftp
--------------------------------------------------
1. Open the FTP Configuration FILE. -
/etc/vsftpd/vsftpd.conf
2. Enable the Following Options
anon_upload_enable=YES
anon_mkdir_write_enable=YES

3. Add the Write Permissions on pub directory


chmod -R 777 /var/ftp/pub

4. Add the Writable Context Permissions on Pub


dirtectory
ls -ldZ /var/ftp/pub
drwxrwxrwx. root root
system_u:object_r:public_content_t:s0 /var/ftp/pub
chcon -R -t public_content_rw_t /var/ftp/pub

5. Enable Anonymous upload in SELinux Boolean Option

getsebool -a -> Display all the boolean options


getsebool -a | grep "ftp"
setsebool -P allow_ftpd_anon_write=on/1

6. Restart the ftp service


service vsftpd restart

Change the Anonymous Root Directory


-------------------------------------
1. Add the Following Option in FTP Confiuration File
anon_root=/PATH anon_root=/store

2. Add the Public Context Permission on new ftp root


directory
//chcon -R -t public_content_rw_t /store
chcon -R /store --reference=/var/ftp
3. If the New anon directory has any directory need to
allow uploads must be do the following changes
a. Add the Write permission to sub directory
chmod -R 777 /store/uploads
b. Add the Context permision for writing
chcon -R -t public_content_rw_t /store/uploads

2. Unanonymous/Private ftp
It is useful to connect the ftp server with the username
and password of the Linux system to upload/download the data from the
login user home directory.
1.Bydefault FTP enable the ftp login for the local users
with the following option.
local_enable=YES
2. Enable the user login in SELinux Boolean options
setsebool -P ftp_home_dir=on
--------------------------------------------------------
------------
User Management in FTP Server
FTP server has a file with the name user_list in
/etc/vsftpd directory.
The file can use to specify the user list as allwoing or
denying list with the following options
1. Open the Configuration file
/etc/vsftp[d/vsftpd.conf
2. Enable for User List file Authentication
userlist_enable=YES
3. Specify the purpose of userlist by adding the
following line
userlist_deny=NO, only allow users in this file
userlist_deny=YES, only deny users in this file

Note: FTP server bydefault disable the root to login ftp


irrespective of the user_list file option.
FTP server does not allow the users present in the file
name ftpusers present in /etc/vsftpd directory.

You might also like