Sie sind auf Seite 1von 28

 Cont...

Shell Commands
1. Root > user
• Switch to other user account 2. / > Partition
$echo Δ $PATH 3. /root > Folder
$su – Δ username

© Samantha Indika
switch the user
Password database
Switch environment
www.lastpast.com

$su Δ – Δ root Issues in Internet Cafe


Or Use FireFox portable version
Linux Live CD
$su Δ –
#exit
Password not required
Root Normal account or user

Password required

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 1
 Cont... Shell Commands
• File/Folder searching commands
GUI – Places > Search for files
$locate Δ –i Δ objectname ; in case sensitive name

© Samantha Indika
$locate Δ –i Δ splash.xpm.gz
$locate Δ –i Δ grub.conf Locate Database
This will get a snapshot of the entire
$locate Δ –i Δ splash hard disk when computer starts and
store in locate database.

Tab1 Tab2
$mkdir Δ ratmalana $su Δ - Δ root
$locate Δ –i Δ ratmalana Password ; 123456
No result #updatedb
$locate Δ –i Δ ratmalana
Output found

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 2
 Cont... Shell Commands
TAB2
#find Δ location Δ search parameter Δ object parameter

© Samantha Indika
Ex: entire root Ex: incase Ex: file’s name or part of the
partition sensitive name file’s name
/ -iname

Ex: specific folder By size Ex: size of the object


/etc -size
/boot
Home folder

~ can do as a normal user

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 3
 Cont... Shell Commands
Ex: splash.xpm.gz
#find / -iname splash.xpm.gz

© Samantha Indika
Ex: grub.conf
#find / -iname grub.conf

Ex: splash
#find Δ /Δ –iname Δ splash
#find Δ /Δ –iname Δ splash*
#find Δ /Δ –iname Δ *splash
#find Δ /Δ –iname Δ *splash*

#find Δ / Δ –iname Δ ratmalana


#find Δ ~ Δ –iname Δ ratmalana

$find Δ / Δ -iname Δ ratmalana


Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 4
 Cont... Shell Commands
• TAB2 (root)
Search for all objects larger than 15MB in ‘/’ partition
#find Δ / Δ -size Δ +15M

© Samantha Indika
More MB
than Reference Link
Tingyurl.com/findcmd

TAB1
To locate system objects
To locate sytem configuration files/system commands and their manuals.
Ex: fstab Ex : mkdir
#whereis Δ fstab #whereis Δ mkdir

Only root
To locate system commands
Ex: mkdir
#which Δ mkdir
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 5
 Cont... Shell Commands
Command Types

© Samantha Indika
Internal External
in-built to BASH
Ex: cd Ex; mkdir
#type Δ cd #type Δ mkdir

-To see all internal commands


#help

• Mounting commands (To access storage devices in command-line]


Only root
System > Administration > System Monitor> File System
/dev/sda2/

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 6
 Cont... Shell Commands
Tab2
#root
Create a mount point > An empty folder
Old system

© Samantha Indika
/mnt ;
#mkdir Δ /media/mymount
New system
Any name /media
#ls Δ /media
#ls Δ-l Δ /media/cd*
#ls Δ -l Δ /media/mymount

Mounting
Loading the data structure of a storage device into a mount point

Optical media (CD/DVD)


#mount Δ /dev/cdrom / Δ media/mymount

where is the media to mount point


mount (device to mount) /dev/cdrom > hda
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
/dev/cdrom /dev/cdrom > hdb
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 7
/dev/cdrecorder
 Cont... Shell Commands
#ls Δ /media/mymount

Umount

© Samantha Indika
• Before you takeout or unplug any mounted device be sure to un-mount it properly.
• You can’t be in the mount point.

#umount Δ /media/mymount

Mount point

#eject
#ls Δ –l Δ /media/mymount

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 8
 Cont... Shell Commands
Floppy
#mount Δ /dev/floppy / Δ media/mymount

© Samantha Indika
Device mount point

#ls Δ –l Δ /dev/fl*

Before you take out the floppy

#umount Δ /media/mymount

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 9
 Cont... Shell Commands
Mounting partitions in hard disk drive
(IDE, SATA, USB Pen drive, USB HDD)

© Samantha Indika
HDD

IDE SCSI USB

PATA SATA

had, hdb, hdc, hdd sda, sdb, sdc, sdd

IDE - Integrated development environment


SCSI - Small Computer System Interface
USB - Universal Serial Bus
SATA - Serial ATA
PATA – Parallel ATA Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 10
 Cont... Shell Commands
#fdisk Δ –l

list

© Samantha Indika
The following cannot be mounted
1. Swap partition
2. Extended partition but we can mount logical partitions with in the extended partitions
3. Linux LVM partition but we can mount logical volumes with in the LVM mounts
4. Software RAID partitions but we can mount RAID devices created combing the software
RAID partitions
5. Windows NTFS partitions : but later we can install windows drivers

-Linux (ext3)
-linux LVM
-raid
-HPFS (MS old name)/NTFS (Ms new Name)
-vfat (Extended W95 Extended, if it creates in Windows)

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 11
 Cont... Shell Commands
Mounting standard partitions
• Linux [ext3]
• vfat, [FAT16/FAT32]

© Samantha Indika
• hpfs/ntfs

#mount Δ /dev/hdaX Δ /media/mymount

partition number mount point


#ls Δ /media/mymount

Mounting LVM partitions (Linux LVM)


Verify logical volumes within LVM

#lvdisplay
#mount Δ /dev/VolGroup00/LogVol00 Δ /media/mymount

LV Name Mount point


Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP
#ls Δ /media/mymount 12
 Cont... Shell Commands
Mounting RAID partitions (Linux raid auto detect)

© Samantha Indika
RAID (Redundant Array of Independent Disks )
RAID is a technology that provides increased storage functions and reliability through
redundancy . This is achieved by combining multiple disk drive components into a logical unit,
where data is distributed across the drives in one of several ways called "RAID levels".

RAID is now used as an umbrella term for computer data storage schemes that can divide and
replicate data among multiple disk drives.

The various designs of RAID systems involve two key goals: increase data reliability and
increase input/output performance.

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 13
 Cont... Shell Commands
Standard levels

© Samantha Indika
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 14
 Cont... Shell Commands
Standard levels

© Samantha Indika
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 15
 Cont... Shell Commands
Verify raid devices
#cat Δ /proc/mdstat

© Samantha Indika
Ex :
Md0
md1
md2
md3

#mount Δ /dev/md0 Δ /media/mymount

RAID device

#ls Δ /media/mymount

If the hard drive is a portable drive be sure to unmounts the partitions before you unplug the
device.
IF it is a fixed hard drive you can either unmounts Prepared
partitions manually
by : Samantha Indika |or they
MCT, willCCNA,
ACS, CEH, be BCS
automatically uncounted when you shutdown the(Certificate),
system MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 16
 Cont... Shell Commands
Object capacity measuring commands
Full device capacity
The device must be mounted before measuring the capacity

© Samantha Indika
$df Δ –hT

Disk File Type of file


System human system
readable
$df Δ –hT Δ mount point

$df Δ –hT Δ /

$df Δ –hT Δ /media/mymount

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 17
 Cont... Shell Commands
File/Folder capacity
If the file is in the current directory just give the file name otherwise you have to give the file
path/file name.

© Samantha Indika
$du Δ –h Δ file path/file name

disk human
usage readable

$du Δ –h Δ /boot/grub/splash.xpm.gz

Folder
Current folder Different folder
$du Δ –hs $du Δ –hs Δ /etc

summery

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 18
 Cont... Shell Commands
System information commands
Root
#uname Δ - -help

© Samantha Indika
#uname Δ –s ; kernal name
#uname Δ –n ; node name
#uname Δ –r ; kernal-release
#uname Δ –v ; kernal-version
#uname Δ –m ; i686 > PII or higher
#uname Δ -p ; i686 > Multiple cores
#uname Δ –i ; i386 > 32bit OS
x86_64 > 64bit OS
#uname Δ –o ; Gnu/Linux > OS

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 19
 Cont... Shell Commands
System information commands
CPU information
#cat Δ /proc/cpuinfo

© Samantha Indika
RAM information
Full information
#cat Δ /proc/meminfo

Less information
#free
#free Δ -m

MB
PCI Configuration
#lspci
#lspci Δ –v Δ | Δ more

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


BIOS information (Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 20
#dmidecode Δ | Δ more
 Cont... Shell Commands
User and Group Management commands

User Types

© Samantha Indika
System Normal

• Automatically created by OS • Additional users created by


and Software root user
Eg : root • Non admin
• Only root user can login and
work
• For functioning system
servers properly

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 21
 Cont... Shell Commands
User Account DB
#cat Δ /etc/passwd Δ | Δ more

© Samantha Indika
UID (User ID)
0 - 499 = System
60,001 - and up = System
500 - 60,000 = Normal

#id Δ username
#id Δ user1
#id Δ root

Creating new user


User name (login name) is case sensitive
#useradd Δ username
#useradd Δ nimal
Or
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
#adduser Δ nimal (Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 22
#adduser Δ user2
#adduser Δ user3
 Cont... Shell Commands
Password
#passwd Δ username
#passwd Δ nimal

© Samantha Indika
New unix password:
If the password is BAD, it will give a warning
Retype the password:

Single seesion login


• One user can be logged in locally at a time.
• Current user must be logged out if a new user wants to login

#exit
Or
#logout
Or
Ctrl + D
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 23
 Cont... Shell Commands
Multi session login
• Multiple users can be logged in locally at a time.

© Samantha Indika
tty1 Ctrl + Alt + F1
tty2 Ctrl + Alt + F2
tty3 Ctrl + Alt + F3
tty4 Ctrl + Alt + F4
CLI
tty5 Ctrl + Alt + F5
tty6 Ctrl + Alt + F6
:0 Ctrl + Alt + F7 GUI
Pts/1 Terminal in GUI

All users logged in


#who

Which command session


Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
#tty (Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 24
 Cont... Shell Commands
How to change your own password as normal linux users
$passwd

© Samantha Indika
Current Password:
New Password :
If the Password is BAD
New Password :
If the password is Good
Retype new password :
New Password :

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 25
 Cont... Shell Commands
How to change the password properties of a user
Logging to root
Ctrl + F2

© Samantha Indika
User Name : root
Password : 123456

#chage Δ –l Δ username
#chage Δ –l Δ nimal

List
#chage Δ nimal

Minimum Password Age [0] : press Enter


Maximum Password Age [99999] : 30
Last Password Change (YYYY-MM-DD) [2011-03-14]:2011-03-14
Password Expiration Warning [7] : 7
Password inactive [-1] : 7 Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
Account Expiration date [YYYY-MM-DD] [1969-12-31] : 2011-03-14
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 26

Unix developed date


 Cont... Shell Commands
How to lock and unlock user accounts
To view user password

© Samantha Indika
#cat Δ /etc/shadow
nimal:$1$ …../ …………….

Encrypted Properties
Password
To lock
#passwd Δ –l Δ username
#passwd Δ –l Δ nimal

Lock

#cat Δ /etc/shadow
nimal:!!$1$ …../ …………….

Locked

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 27
 Cont... Shell Commands
To unlock
#passwd Δ –u Δ username
#passwd Δ –u Δ nimal

© Samantha Indika
Unlock

#cat Δ /etc/shadow
How to reset a user’s password as root
#passwd Δ username
#passwd Δ nimal

How to force a user to change his password


#chage Δ –d Δ 0 Δ username
#chage Δ –d Δ 0 Δ nimal

Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS


(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 28

Das könnte Ihnen auch gefallen